Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/IR/DebugInfoMetadata.h
Line
Count
Source (jump to first uncovered line)
1
//===- llvm/IR/DebugInfoMetadata.h - Debug info metadata --------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// Declarations for metadata specific to debug info.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_IR_DEBUGINFOMETADATA_H
14
#define LLVM_IR_DEBUGINFOMETADATA_H
15
16
#include "llvm/ADT/ArrayRef.h"
17
#include "llvm/ADT/BitmaskEnum.h"
18
#include "llvm/ADT/None.h"
19
#include "llvm/ADT/Optional.h"
20
#include "llvm/ADT/PointerUnion.h"
21
#include "llvm/ADT/STLExtras.h"
22
#include "llvm/ADT/SmallVector.h"
23
#include "llvm/ADT/StringRef.h"
24
#include "llvm/ADT/iterator_range.h"
25
#include "llvm/BinaryFormat/Dwarf.h"
26
#include "llvm/IR/Constants.h"
27
#include "llvm/IR/Metadata.h"
28
#include "llvm/Support/Casting.h"
29
#include <cassert>
30
#include <climits>
31
#include <cstddef>
32
#include <cstdint>
33
#include <iterator>
34
#include <type_traits>
35
#include <vector>
36
37
// Helper macros for defining get() overrides.
38
9.44M
#define DEFINE_MDNODE_GET_UNPACK_IMPL(...) __VA_ARGS__
39
9.44M
#define DEFINE_MDNODE_GET_UNPACK(ARGS) DEFINE_MDNODE_GET_UNPACK_IMPL ARGS
40
#define DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS)              \
41
  static CLASS *getDistinct(LLVMContext &Context,                              \
42
741k
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
741k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
741k
  }                                                                            \
Unexecuted instantiation: llvm::GenericDINode::getDistinct(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::ArrayRef<llvm::Metadata*>)
llvm::GenericDINode::getDistinct(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::ArrayRef<llvm::Metadata*>)
Line
Count
Source
42
11
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
11
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
11
  }                                                                            \
Unexecuted instantiation: llvm::DISubrange::getDistinct(llvm::LLVMContext&, long long, long long)
Unexecuted instantiation: llvm::DISubrange::getDistinct(llvm::LLVMContext&, llvm::Metadata*, long long)
Unexecuted instantiation: llvm::DIEnumerator::getDistinct(llvm::LLVMContext&, long long, bool, llvm::StringRef)
Unexecuted instantiation: llvm::DIEnumerator::getDistinct(llvm::LLVMContext&, long long, bool, llvm::MDString*)
Unexecuted instantiation: llvm::DIFile::getDistinct(llvm::LLVMContext&, llvm::MDString*, llvm::MDString*, llvm::Optional<llvm::DIFile::ChecksumInfo<llvm::MDString*> >, llvm::Optional<llvm::MDString*>)
Unexecuted instantiation: llvm::DIBasicType::getDistinct(llvm::LLVMContext&, unsigned int, llvm::StringRef)
Unexecuted instantiation: llvm::DIBasicType::getDistinct(llvm::LLVMContext&, unsigned int, llvm::StringRef, unsigned long long, unsigned int, unsigned int, llvm::DINode::DIFlags)
Unexecuted instantiation: llvm::DIBasicType::getDistinct(llvm::LLVMContext&, unsigned int, llvm::MDString*, unsigned long long, unsigned int, unsigned int, llvm::DINode::DIFlags)
Unexecuted instantiation: llvm::DIDerivedType::getDistinct(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, unsigned long long, unsigned int, unsigned long long, llvm::Optional<unsigned int>, llvm::DINode::DIFlags, llvm::Metadata*)
llvm::DICompositeType::getDistinct(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, unsigned long long, unsigned int, unsigned long long, llvm::DINode::DIFlags, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, llvm::MDString*, llvm::Metadata*)
Line
Count
Source
42
656
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
656
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
656
  }                                                                            \
Unexecuted instantiation: llvm::DISubroutineType::getDistinct(llvm::LLVMContext&, llvm::DINode::DIFlags, unsigned char, llvm::DITypeRefArray)
llvm::DISubroutineType::getDistinct(llvm::LLVMContext&, llvm::DINode::DIFlags, unsigned char, llvm::Metadata*)
Line
Count
Source
42
3
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
3
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
3
  }                                                                            \
llvm::DICompileUnit::getDistinct(llvm::LLVMContext&, unsigned int, llvm::DIFile*, llvm::StringRef, bool, llvm::StringRef, unsigned int, llvm::StringRef, llvm::DICompileUnit::DebugEmissionKind, llvm::MDTupleTypedArrayWrapper<llvm::DICompositeType>, llvm::MDTupleTypedArrayWrapper<llvm::DIScope>, llvm::MDTupleTypedArrayWrapper<llvm::DIGlobalVariableExpression>, llvm::MDTupleTypedArrayWrapper<llvm::DIImportedEntity>, llvm::MDTupleTypedArrayWrapper<llvm::DIMacroNode>, unsigned long long, bool, bool, llvm::DICompileUnit::DebugNameTableKind, bool)
Line
Count
Source
42
3.65k
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
3.65k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
3.65k
  }                                                                            \
llvm::DICompileUnit::getDistinct(llvm::LLVMContext&, unsigned int, llvm::Metadata*, llvm::MDString*, bool, llvm::MDString*, unsigned int, llvm::MDString*, unsigned int, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, unsigned long long, bool, bool, unsigned int, bool)
Line
Count
Source
42
2.85k
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
2.85k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
2.85k
  }                                                                            \
llvm::DILocation::getDistinct(llvm::LLVMContext&, unsigned int, unsigned int, llvm::Metadata*, llvm::Metadata*, bool)
Line
Count
Source
42
185
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
185
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
185
  }                                                                            \
llvm::DILocation::getDistinct(llvm::LLVMContext&, unsigned int, unsigned int, llvm::DILocalScope*, llvm::DILocation*, bool)
Line
Count
Source
42
608k
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
608k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
608k
  }                                                                            \
llvm::DISubprogram::getDistinct(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DISubroutineType*, unsigned int, llvm::DIType*, unsigned int, int, llvm::DINode::DIFlags, llvm::DISubprogram::DISPFlags, llvm::DICompileUnit*, llvm::MDTupleTypedArrayWrapper<llvm::DITemplateParameter>, llvm::DISubprogram*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>, llvm::MDTupleTypedArrayWrapper<llvm::DIType>)
Line
Count
Source
42
118k
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
118k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
118k
  }                                                                            \
llvm::DISubprogram::getDistinct(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, int, llvm::DINode::DIFlags, llvm::DISubprogram::DISPFlags, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*)
Line
Count
Source
42
3.39k
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
3.39k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
3.39k
  }                                                                            \
Unexecuted instantiation: llvm::DILexicalBlock::getDistinct(llvm::LLVMContext&, llvm::DILocalScope*, llvm::DIFile*, unsigned int, unsigned int)
llvm::DILexicalBlock::getDistinct(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, unsigned int, unsigned int)
Line
Count
Source
42
2.13k
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
2.13k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
2.13k
  }                                                                            \
Unexecuted instantiation: llvm::DILexicalBlockFile::getDistinct(llvm::LLVMContext&, llvm::DILocalScope*, llvm::DIFile*, unsigned int)
Unexecuted instantiation: llvm::DILexicalBlockFile::getDistinct(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, unsigned int)
Unexecuted instantiation: llvm::DINamespace::getDistinct(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, bool)
Unexecuted instantiation: llvm::DINamespace::getDistinct(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, bool)
Unexecuted instantiation: llvm::DIModule::getDistinct(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::StringRef)
Unexecuted instantiation: llvm::DIModule::getDistinct(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::MDString*, llvm::MDString*)
Unexecuted instantiation: llvm::DITemplateTypeParameter::getDistinct(llvm::LLVMContext&, llvm::StringRef, llvm::DIType*)
Unexecuted instantiation: llvm::DITemplateTypeParameter::getDistinct(llvm::LLVMContext&, llvm::MDString*, llvm::Metadata*)
Unexecuted instantiation: llvm::DITemplateValueParameter::getDistinct(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::DIType*, llvm::Metadata*)
Unexecuted instantiation: llvm::DITemplateValueParameter::getDistinct(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, llvm::Metadata*)
Unexecuted instantiation: llvm::DIExpression::getDistinct(llvm::LLVMContext&, llvm::ArrayRef<unsigned long long>)
llvm::DIGlobalVariable::getDistinct(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIType*, bool, bool, llvm::DIDerivedType*, llvm::MDTuple*, unsigned int)
Line
Count
Source
42
614
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
614
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
614
  }                                                                            \
llvm::DIGlobalVariable::getDistinct(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, bool, bool, llvm::Metadata*, llvm::Metadata*, unsigned int)
Line
Count
Source
42
753
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
753
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
753
  }                                                                            \
Unexecuted instantiation: llvm::DICommonBlock::getDistinct(llvm::LLVMContext&, llvm::DIScope*, llvm::DIGlobalVariable*, llvm::StringRef, llvm::DIFile*, unsigned int)
Unexecuted instantiation: llvm::DICommonBlock::getDistinct(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int)
Unexecuted instantiation: llvm::DILocalVariable::getDistinct(llvm::LLVMContext&, llvm::DILocalScope*, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIType*, unsigned int, llvm::DINode::DIFlags, unsigned int)
Unexecuted instantiation: llvm::DILocalVariable::getDistinct(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, llvm::DINode::DIFlags, unsigned int)
Unexecuted instantiation: llvm::DILabel::getDistinct(llvm::LLVMContext&, llvm::DILocalScope*, llvm::StringRef, llvm::DIFile*, unsigned int)
Unexecuted instantiation: llvm::DILabel::getDistinct(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int)
Unexecuted instantiation: llvm::DIObjCProperty::getDistinct(llvm::LLVMContext&, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::StringRef, llvm::StringRef, unsigned int, llvm::DIType*)
Unexecuted instantiation: llvm::DIObjCProperty::getDistinct(llvm::LLVMContext&, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::MDString*, llvm::MDString*, unsigned int, llvm::Metadata*)
Unexecuted instantiation: llvm::DIImportedEntity::getDistinct(llvm::LLVMContext&, unsigned int, llvm::DIScope*, llvm::DINode*, llvm::DIFile*, unsigned int, llvm::StringRef)
Unexecuted instantiation: llvm::DIImportedEntity::getDistinct(llvm::LLVMContext&, unsigned int, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, unsigned int, llvm::MDString*)
llvm::DIGlobalVariableExpression::getDistinct(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*)
Line
Count
Source
42
122
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
43
122
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct);         \
44
122
  }                                                                            \
Unexecuted instantiation: llvm::DIMacro::getDistinct(llvm::LLVMContext&, unsigned int, unsigned int, llvm::StringRef, llvm::StringRef)
Unexecuted instantiation: llvm::DIMacro::getDistinct(llvm::LLVMContext&, unsigned int, unsigned int, llvm::MDString*, llvm::MDString*)
Unexecuted instantiation: llvm::DIMacroFile::getDistinct(llvm::LLVMContext&, unsigned int, unsigned int, llvm::DIFile*, llvm::MDTupleTypedArrayWrapper<llvm::DIMacroNode>)
Unexecuted instantiation: llvm::DIMacroFile::getDistinct(llvm::LLVMContext&, unsigned int, unsigned int, llvm::Metadata*, llvm::Metadata*)
45
  static Temp##CLASS getTemporary(LLVMContext &Context,                        \
46
4.08k
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
4.08k
    return Temp##CLASS(                                                        \
48
4.08k
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
4.08k
  }
llvm::GenericDINode::getTemporary(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::ArrayRef<llvm::Metadata*>)
Line
Count
Source
46
1
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1
    return Temp##CLASS(                                                        \
48
1
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1
  }
Unexecuted instantiation: llvm::GenericDINode::getTemporary(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::ArrayRef<llvm::Metadata*>)
Unexecuted instantiation: llvm::DISubrange::getTemporary(llvm::LLVMContext&, long long, long long)
llvm::DISubrange::getTemporary(llvm::LLVMContext&, llvm::Metadata*, long long)
Line
Count
Source
46
1
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1
    return Temp##CLASS(                                                        \
48
1
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1
  }
llvm::DIEnumerator::getTemporary(llvm::LLVMContext&, long long, bool, llvm::StringRef)
Line
Count
Source
46
1
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1
    return Temp##CLASS(                                                        \
48
1
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1
  }
Unexecuted instantiation: llvm::DIEnumerator::getTemporary(llvm::LLVMContext&, long long, bool, llvm::MDString*)
llvm::DIFile::getTemporary(llvm::LLVMContext&, llvm::StringRef, llvm::StringRef, llvm::Optional<llvm::DIFile::ChecksumInfo<llvm::StringRef> >, llvm::Optional<llvm::StringRef>)
Line
Count
Source
46
1
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1
    return Temp##CLASS(                                                        \
48
1
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1
  }
Unexecuted instantiation: llvm::DIFile::getTemporary(llvm::LLVMContext&, llvm::MDString*, llvm::MDString*, llvm::Optional<llvm::DIFile::ChecksumInfo<llvm::MDString*> >, llvm::Optional<llvm::MDString*>)
Unexecuted instantiation: llvm::DIBasicType::getTemporary(llvm::LLVMContext&, unsigned int, llvm::StringRef)
llvm::DIBasicType::getTemporary(llvm::LLVMContext&, unsigned int, llvm::StringRef, unsigned long long, unsigned int, unsigned int, llvm::DINode::DIFlags)
Line
Count
Source
46
2
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
2
    return Temp##CLASS(                                                        \
48
2
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
2
  }
Unexecuted instantiation: llvm::DIBasicType::getTemporary(llvm::LLVMContext&, unsigned int, llvm::MDString*, unsigned long long, unsigned int, unsigned int, llvm::DINode::DIFlags)
Unexecuted instantiation: llvm::DIDerivedType::getTemporary(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, unsigned long long, unsigned int, unsigned long long, llvm::Optional<unsigned int>, llvm::DINode::DIFlags, llvm::Metadata*)
llvm::DIDerivedType::getTemporary(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIScope*, llvm::DIType*, unsigned long long, unsigned int, unsigned long long, llvm::Optional<unsigned int>, llvm::DINode::DIFlags, llvm::Metadata*)
Line
Count
Source
46
2.15k
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
2.15k
    return Temp##CLASS(                                                        \
48
2.15k
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
2.15k
  }
llvm::DICompositeType::getTemporary(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIScope*, llvm::DIType*, unsigned long long, unsigned int, unsigned long long, llvm::DINode::DIFlags, llvm::MDTupleTypedArrayWrapper<llvm::DINode>, unsigned int, llvm::DIType*, llvm::MDTupleTypedArrayWrapper<llvm::DITemplateParameter>, llvm::StringRef, llvm::DIDerivedType*)
Line
Count
Source
46
1.46k
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1.46k
    return Temp##CLASS(                                                        \
48
1.46k
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1.46k
  }
Unexecuted instantiation: llvm::DICompositeType::getTemporary(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, unsigned long long, unsigned int, unsigned long long, llvm::DINode::DIFlags, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, llvm::MDString*, llvm::Metadata*)
llvm::DISubroutineType::getTemporary(llvm::LLVMContext&, llvm::DINode::DIFlags, unsigned char, llvm::DITypeRefArray)
Line
Count
Source
46
5
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
5
    return Temp##CLASS(                                                        \
48
5
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
5
  }
llvm::DICompileUnit::getTemporary(llvm::LLVMContext&, unsigned int, llvm::DIFile*, llvm::StringRef, bool, llvm::StringRef, unsigned int, llvm::StringRef, llvm::DICompileUnit::DebugEmissionKind, llvm::MDTupleTypedArrayWrapper<llvm::DICompositeType>, llvm::MDTupleTypedArrayWrapper<llvm::DIScope>, llvm::MDTupleTypedArrayWrapper<llvm::DIGlobalVariableExpression>, llvm::MDTupleTypedArrayWrapper<llvm::DIImportedEntity>, llvm::MDTupleTypedArrayWrapper<llvm::DIMacroNode>, unsigned long long, bool, bool, llvm::DICompileUnit::DebugNameTableKind, bool)
Line
Count
Source
46
133
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
133
    return Temp##CLASS(                                                        \
48
133
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
133
  }
Unexecuted instantiation: llvm::DICompileUnit::getTemporary(llvm::LLVMContext&, unsigned int, llvm::Metadata*, llvm::MDString*, bool, llvm::MDString*, unsigned int, llvm::MDString*, unsigned int, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, unsigned long long, bool, bool, unsigned int, bool)
llvm::DILocation::getTemporary(llvm::LLVMContext&, unsigned int, unsigned int, llvm::Metadata*, llvm::Metadata*, bool)
Line
Count
Source
46
198
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
198
    return Temp##CLASS(                                                        \
48
198
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
198
  }
Unexecuted instantiation: llvm::DILocation::getTemporary(llvm::LLVMContext&, unsigned int, unsigned int, llvm::DILocalScope*, llvm::DILocation*, bool)
llvm::DISubprogram::getTemporary(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DISubroutineType*, unsigned int, llvm::DIType*, unsigned int, int, llvm::DINode::DIFlags, llvm::DISubprogram::DISPFlags, llvm::DICompileUnit*, llvm::MDTupleTypedArrayWrapper<llvm::DITemplateParameter>, llvm::DISubprogram*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>, llvm::MDTupleTypedArrayWrapper<llvm::DIType>)
Line
Count
Source
46
39
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
39
    return Temp##CLASS(                                                        \
48
39
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
39
  }
Unexecuted instantiation: llvm::DISubprogram::getTemporary(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, int, llvm::DINode::DIFlags, llvm::DISubprogram::DISPFlags, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*)
llvm::DILexicalBlock::getTemporary(llvm::LLVMContext&, llvm::DILocalScope*, llvm::DIFile*, unsigned int, unsigned int)
Line
Count
Source
46
26
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
26
    return Temp##CLASS(                                                        \
48
26
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
26
  }
Unexecuted instantiation: llvm::DILexicalBlock::getTemporary(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, unsigned int, unsigned int)
llvm::DILexicalBlockFile::getTemporary(llvm::LLVMContext&, llvm::DILocalScope*, llvm::DIFile*, unsigned int)
Line
Count
Source
46
1
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1
    return Temp##CLASS(                                                        \
48
1
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1
  }
Unexecuted instantiation: llvm::DILexicalBlockFile::getTemporary(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, unsigned int)
llvm::DINamespace::getTemporary(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, bool)
Line
Count
Source
46
1
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1
    return Temp##CLASS(                                                        \
48
1
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1
  }
Unexecuted instantiation: llvm::DINamespace::getTemporary(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, bool)
llvm::DIModule::getTemporary(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::StringRef)
Line
Count
Source
46
1
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1
    return Temp##CLASS(                                                        \
48
1
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1
  }
Unexecuted instantiation: llvm::DIModule::getTemporary(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::MDString*, llvm::MDString*)
llvm::DITemplateTypeParameter::getTemporary(llvm::LLVMContext&, llvm::StringRef, llvm::DIType*)
Line
Count
Source
46
2
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
2
    return Temp##CLASS(                                                        \
48
2
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
2
  }
Unexecuted instantiation: llvm::DITemplateTypeParameter::getTemporary(llvm::LLVMContext&, llvm::MDString*, llvm::Metadata*)
llvm::DITemplateValueParameter::getTemporary(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::DIType*, llvm::Metadata*)
Line
Count
Source
46
3
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
3
    return Temp##CLASS(                                                        \
48
3
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
3
  }
Unexecuted instantiation: llvm::DITemplateValueParameter::getTemporary(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, llvm::Metadata*)
llvm::DIExpression::getTemporary(llvm::LLVMContext&, llvm::ArrayRef<unsigned long long>)
Line
Count
Source
46
1
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1
    return Temp##CLASS(                                                        \
48
1
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1
  }
llvm::DIGlobalVariable::getTemporary(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIType*, bool, bool, llvm::DIDerivedType*, llvm::MDTuple*, unsigned int)
Line
Count
Source
46
6
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
6
    return Temp##CLASS(                                                        \
48
6
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
6
  }
Unexecuted instantiation: llvm::DIGlobalVariable::getTemporary(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, bool, bool, llvm::Metadata*, llvm::Metadata*, unsigned int)
Unexecuted instantiation: llvm::DICommonBlock::getTemporary(llvm::LLVMContext&, llvm::DIScope*, llvm::DIGlobalVariable*, llvm::StringRef, llvm::DIFile*, unsigned int)
Unexecuted instantiation: llvm::DICommonBlock::getTemporary(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int)
llvm::DILocalVariable::getTemporary(llvm::LLVMContext&, llvm::DILocalScope*, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIType*, unsigned int, llvm::DINode::DIFlags, unsigned int)
Line
Count
Source
46
24
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
24
    return Temp##CLASS(                                                        \
48
24
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
24
  }
Unexecuted instantiation: llvm::DILocalVariable::getTemporary(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, llvm::DINode::DIFlags, unsigned int)
Unexecuted instantiation: llvm::DILabel::getTemporary(llvm::LLVMContext&, llvm::DILocalScope*, llvm::StringRef, llvm::DIFile*, unsigned int)
Unexecuted instantiation: llvm::DILabel::getTemporary(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int)
llvm::DIObjCProperty::getTemporary(llvm::LLVMContext&, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::StringRef, llvm::StringRef, unsigned int, llvm::DIType*)
Line
Count
Source
46
1
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1
    return Temp##CLASS(                                                        \
48
1
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1
  }
Unexecuted instantiation: llvm::DIObjCProperty::getTemporary(llvm::LLVMContext&, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::MDString*, llvm::MDString*, unsigned int, llvm::Metadata*)
llvm::DIImportedEntity::getTemporary(llvm::LLVMContext&, unsigned int, llvm::DIScope*, llvm::DINode*, llvm::DIFile*, unsigned int, llvm::StringRef)
Line
Count
Source
46
1
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
1
    return Temp##CLASS(                                                        \
48
1
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
1
  }
Unexecuted instantiation: llvm::DIImportedEntity::getTemporary(llvm::LLVMContext&, unsigned int, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, unsigned int, llvm::MDString*)
llvm::DIGlobalVariableExpression::getTemporary(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*)
Line
Count
Source
46
2
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
2
    return Temp##CLASS(                                                        \
48
2
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
2
  }
Unexecuted instantiation: llvm::DIMacro::getTemporary(llvm::LLVMContext&, unsigned int, unsigned int, llvm::StringRef, llvm::StringRef)
Unexecuted instantiation: llvm::DIMacro::getTemporary(llvm::LLVMContext&, unsigned int, unsigned int, llvm::MDString*, llvm::MDString*)
llvm::DIMacroFile::getTemporary(llvm::LLVMContext&, unsigned int, unsigned int, llvm::DIFile*, llvm::MDTupleTypedArrayWrapper<llvm::DIMacroNode>)
Line
Count
Source
46
22
                                  DEFINE_MDNODE_GET_UNPACK(FORMAL)) {          \
47
22
    return Temp##CLASS(                                                        \
48
22
        getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary));          \
49
22
  }
Unexecuted instantiation: llvm::DIMacroFile::getTemporary(llvm::LLVMContext&, unsigned int, unsigned int, llvm::Metadata*, llvm::Metadata*)
50
#define DEFINE_MDNODE_GET(CLASS, FORMAL, ARGS)                                 \
51
8.70M
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
8.70M
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
8.70M
  }                                                                            \
llvm::GenericDINode::get(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::ArrayRef<llvm::Metadata*>)
Line
Count
Source
51
44
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
44
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
44
  }                                                                            \
llvm::DISubrange::get(llvm::LLVMContext&, long long, long long)
Line
Count
Source
51
458
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
458
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
458
  }                                                                            \
llvm::DISubrange::get(llvm::LLVMContext&, llvm::Metadata*, long long)
Line
Count
Source
51
80
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
80
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
80
  }                                                                            \
llvm::DIEnumerator::get(llvm::LLVMContext&, long long, bool, llvm::StringRef)
Line
Count
Source
51
84
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
84
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
84
  }                                                                            \
llvm::DIEnumerator::get(llvm::LLVMContext&, long long, bool, llvm::MDString*)
Line
Count
Source
51
11.9k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
11.9k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
11.9k
  }                                                                            \
llvm::DIFile::get(llvm::LLVMContext&, llvm::StringRef, llvm::StringRef, llvm::Optional<llvm::DIFile::ChecksumInfo<llvm::StringRef> >, llvm::Optional<llvm::StringRef>)
Line
Count
Source
51
13.8k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
13.8k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
13.8k
  }                                                                            \
llvm::DIFile::get(llvm::LLVMContext&, llvm::MDString*, llvm::MDString*, llvm::Optional<llvm::DIFile::ChecksumInfo<llvm::MDString*> >, llvm::Optional<llvm::MDString*>)
Line
Count
Source
51
3.61k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
3.61k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
3.61k
  }                                                                            \
llvm::DIBasicType::get(llvm::LLVMContext&, unsigned int, llvm::StringRef)
Line
Count
Source
51
39
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
39
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
39
  }                                                                            \
llvm::DIBasicType::get(llvm::LLVMContext&, unsigned int, llvm::StringRef, unsigned long long, unsigned int, unsigned int, llvm::DINode::DIFlags)
Line
Count
Source
51
1.25k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
1.25k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
1.25k
  }                                                                            \
llvm::DIBasicType::get(llvm::LLVMContext&, unsigned int, llvm::MDString*, unsigned long long, unsigned int, unsigned int, llvm::DINode::DIFlags)
Line
Count
Source
51
2.17k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
2.17k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
2.17k
  }                                                                            \
llvm::DIDerivedType::get(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, unsigned long long, unsigned int, unsigned long long, llvm::Optional<unsigned int>, llvm::DINode::DIFlags, llvm::Metadata*)
Line
Count
Source
51
3.00k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
3.00k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
3.00k
  }                                                                            \
llvm::DIDerivedType::get(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIScope*, llvm::DIType*, unsigned long long, unsigned int, unsigned long long, llvm::Optional<unsigned int>, llvm::DINode::DIFlags, llvm::Metadata*)
Line
Count
Source
51
4.18k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
4.18k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
4.18k
  }                                                                            \
llvm::DICompositeType::get(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIScope*, llvm::DIType*, unsigned long long, unsigned int, unsigned long long, llvm::DINode::DIFlags, llvm::MDTupleTypedArrayWrapper<llvm::DINode>, unsigned int, llvm::DIType*, llvm::MDTupleTypedArrayWrapper<llvm::DITemplateParameter>, llvm::StringRef, llvm::DIDerivedType*)
Line
Count
Source
51
690
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
690
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
690
  }                                                                            \
llvm::DICompositeType::get(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, unsigned long long, unsigned int, unsigned long long, llvm::DINode::DIFlags, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, llvm::MDString*, llvm::Metadata*)
Line
Count
Source
51
855
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
855
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
855
  }                                                                            \
llvm::DISubroutineType::get(llvm::LLVMContext&, llvm::DINode::DIFlags, unsigned char, llvm::DITypeRefArray)
Line
Count
Source
51
119k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
119k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
119k
  }                                                                            \
llvm::DISubroutineType::get(llvm::LLVMContext&, llvm::DINode::DIFlags, unsigned char, llvm::Metadata*)
Line
Count
Source
51
2.74k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
2.74k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
2.74k
  }                                                                            \
llvm::DILocation::get(llvm::LLVMContext&, unsigned int, unsigned int, llvm::Metadata*, llvm::Metadata*, bool)
Line
Count
Source
51
8.49M
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
8.49M
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
8.49M
  }                                                                            \
llvm::DILocation::get(llvm::LLVMContext&, unsigned int, unsigned int, llvm::DILocalScope*, llvm::DILocation*, bool)
Line
Count
Source
51
3.94k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
3.94k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
3.94k
  }                                                                            \
llvm::DISubprogram::get(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DISubroutineType*, unsigned int, llvm::DIType*, unsigned int, int, llvm::DINode::DIFlags, llvm::DISubprogram::DISPFlags, llvm::DICompileUnit*, llvm::MDTupleTypedArrayWrapper<llvm::DITemplateParameter>, llvm::DISubprogram*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>, llvm::MDTupleTypedArrayWrapper<llvm::DIType>)
Line
Count
Source
51
1.18k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
1.18k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
1.18k
  }                                                                            \
llvm::DISubprogram::get(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, int, llvm::DINode::DIFlags, llvm::DISubprogram::DISPFlags, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*)
Line
Count
Source
51
825
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
825
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
825
  }                                                                            \
llvm::DILexicalBlock::get(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, unsigned int, unsigned int)
Line
Count
Source
51
34
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
34
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
34
  }                                                                            \
llvm::DILexicalBlockFile::get(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, unsigned int)
Line
Count
Source
51
1.63k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
1.63k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
1.63k
  }                                                                            \
llvm::DINamespace::get(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, bool)
Line
Count
Source
51
169
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
169
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
169
  }                                                                            \
llvm::DINamespace::get(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, bool)
Line
Count
Source
51
149
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
149
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
149
  }                                                                            \
llvm::DIModule::get(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::StringRef)
Line
Count
Source
51
65
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
65
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
65
  }                                                                            \
llvm::DIModule::get(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::MDString*, llvm::MDString*)
Line
Count
Source
51
35
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
35
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
35
  }                                                                            \
llvm::DITemplateTypeParameter::get(llvm::LLVMContext&, llvm::StringRef, llvm::DIType*)
Line
Count
Source
51
380
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
380
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
380
  }                                                                            \
llvm::DITemplateTypeParameter::get(llvm::LLVMContext&, llvm::MDString*, llvm::Metadata*)
Line
Count
Source
51
101
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
101
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
101
  }                                                                            \
llvm::DITemplateValueParameter::get(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::DIType*, llvm::Metadata*)
Line
Count
Source
51
430
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
430
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
430
  }                                                                            \
llvm::DITemplateValueParameter::get(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, llvm::Metadata*)
Line
Count
Source
51
90
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
90
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
90
  }                                                                            \
llvm::DIExpression::get(llvm::LLVMContext&, llvm::ArrayRef<unsigned long long>)
Line
Count
Source
51
15.5k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
15.5k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
15.5k
  }                                                                            \
llvm::DIGlobalVariable::get(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, bool, bool, llvm::Metadata*, llvm::Metadata*, unsigned int)
Line
Count
Source
51
579
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
579
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
579
  }                                                                            \
Unexecuted instantiation: llvm::DICommonBlock::get(llvm::LLVMContext&, llvm::DIScope*, llvm::DIGlobalVariable*, llvm::StringRef, llvm::DIFile*, unsigned int)
llvm::DICommonBlock::get(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int)
Line
Count
Source
51
5
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
5
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
5
  }                                                                            \
llvm::DILocalVariable::get(llvm::LLVMContext&, llvm::DILocalScope*, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIType*, unsigned int, llvm::DINode::DIFlags, unsigned int)
Line
Count
Source
51
6.10k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
6.10k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
6.10k
  }                                                                            \
llvm::DILocalVariable::get(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, llvm::DINode::DIFlags, unsigned int)
Line
Count
Source
51
3.11k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
3.11k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
3.11k
  }                                                                            \
llvm::DILabel::get(llvm::LLVMContext&, llvm::DILocalScope*, llvm::StringRef, llvm::DIFile*, unsigned int)
Line
Count
Source
51
7
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
7
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
7
  }                                                                            \
llvm::DILabel::get(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int)
Line
Count
Source
51
38
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
38
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
38
  }                                                                            \
llvm::DIObjCProperty::get(llvm::LLVMContext&, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::StringRef, llvm::StringRef, unsigned int, llvm::DIType*)
Line
Count
Source
51
83
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
83
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
83
  }                                                                            \
llvm::DIObjCProperty::get(llvm::LLVMContext&, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::MDString*, llvm::MDString*, unsigned int, llvm::Metadata*)
Line
Count
Source
51
39
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
39
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
39
  }                                                                            \
llvm::DIImportedEntity::get(llvm::LLVMContext&, unsigned int, llvm::DIScope*, llvm::DINode*, llvm::DIFile*, unsigned int, llvm::StringRef)
Line
Count
Source
51
68
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
68
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
68
  }                                                                            \
llvm::DIImportedEntity::get(llvm::LLVMContext&, unsigned int, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, unsigned int, llvm::MDString*)
Line
Count
Source
51
293
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
293
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
293
  }                                                                            \
llvm::DIGlobalVariableExpression::get(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*)
Line
Count
Source
51
1.81k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
1.81k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
1.81k
  }                                                                            \
llvm::DIMacro::get(llvm::LLVMContext&, unsigned int, unsigned int, llvm::StringRef, llvm::StringRef)
Line
Count
Source
51
1.41k
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
1.41k
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
1.41k
  }                                                                            \
llvm::DIMacro::get(llvm::LLVMContext&, unsigned int, unsigned int, llvm::MDString*, llvm::MDString*)
Line
Count
Source
51
34
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
34
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
34
  }                                                                            \
llvm::DIMacroFile::get(llvm::LLVMContext&, unsigned int, unsigned int, llvm::DIFile*, llvm::MDTupleTypedArrayWrapper<llvm::DIMacroNode>)
Line
Count
Source
51
24
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
24
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
24
  }                                                                            \
llvm::DIMacroFile::get(llvm::LLVMContext&, unsigned int, unsigned int, llvm::Metadata*, llvm::Metadata*)
Line
Count
Source
51
46
  static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) {  \
52
46
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued);          \
53
46
  }                                                                            \
54
  static CLASS *getIfExists(LLVMContext &Context,                              \
55
0
                            DEFINE_MDNODE_GET_UNPACK(FORMAL)) {                \
56
0
    return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued,           \
57
0
                   /* ShouldCreate */ false);                                  \
58
0
  }                                                                            \
Unexecuted instantiation: llvm::GenericDINode::getIfExists(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::ArrayRef<llvm::Metadata*>)
Unexecuted instantiation: llvm::GenericDINode::getIfExists(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::ArrayRef<llvm::Metadata*>)
Unexecuted instantiation: llvm::DISubrange::getIfExists(llvm::LLVMContext&, long long, long long)
Unexecuted instantiation: llvm::DISubrange::getIfExists(llvm::LLVMContext&, llvm::Metadata*, long long)
Unexecuted instantiation: llvm::DIEnumerator::getIfExists(llvm::LLVMContext&, long long, bool, llvm::StringRef)
Unexecuted instantiation: llvm::DIEnumerator::getIfExists(llvm::LLVMContext&, long long, bool, llvm::MDString*)
Unexecuted instantiation: llvm::DIFile::getIfExists(llvm::LLVMContext&, llvm::StringRef, llvm::StringRef, llvm::Optional<llvm::DIFile::ChecksumInfo<llvm::StringRef> >, llvm::Optional<llvm::StringRef>)
Unexecuted instantiation: llvm::DIFile::getIfExists(llvm::LLVMContext&, llvm::MDString*, llvm::MDString*, llvm::Optional<llvm::DIFile::ChecksumInfo<llvm::MDString*> >, llvm::Optional<llvm::MDString*>)
Unexecuted instantiation: llvm::DIBasicType::getIfExists(llvm::LLVMContext&, unsigned int, llvm::StringRef)
Unexecuted instantiation: llvm::DIBasicType::getIfExists(llvm::LLVMContext&, unsigned int, llvm::StringRef, unsigned long long, unsigned int, unsigned int, llvm::DINode::DIFlags)
Unexecuted instantiation: llvm::DIBasicType::getIfExists(llvm::LLVMContext&, unsigned int, llvm::MDString*, unsigned long long, unsigned int, unsigned int, llvm::DINode::DIFlags)
Unexecuted instantiation: llvm::DIDerivedType::getIfExists(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, unsigned long long, unsigned int, unsigned long long, llvm::Optional<unsigned int>, llvm::DINode::DIFlags, llvm::Metadata*)
Unexecuted instantiation: llvm::DIDerivedType::getIfExists(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIScope*, llvm::DIType*, unsigned long long, unsigned int, unsigned long long, llvm::Optional<unsigned int>, llvm::DINode::DIFlags, llvm::Metadata*)
Unexecuted instantiation: llvm::DICompositeType::getIfExists(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIScope*, llvm::DIType*, unsigned long long, unsigned int, unsigned long long, llvm::DINode::DIFlags, llvm::MDTupleTypedArrayWrapper<llvm::DINode>, unsigned int, llvm::DIType*, llvm::MDTupleTypedArrayWrapper<llvm::DITemplateParameter>, llvm::StringRef, llvm::DIDerivedType*)
Unexecuted instantiation: llvm::DICompositeType::getIfExists(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, unsigned long long, unsigned int, unsigned long long, llvm::DINode::DIFlags, llvm::Metadata*, unsigned int, llvm::Metadata*, llvm::Metadata*, llvm::MDString*, llvm::Metadata*)
Unexecuted instantiation: llvm::DISubroutineType::getIfExists(llvm::LLVMContext&, llvm::DINode::DIFlags, unsigned char, llvm::DITypeRefArray)
Unexecuted instantiation: llvm::DISubroutineType::getIfExists(llvm::LLVMContext&, llvm::DINode::DIFlags, unsigned char, llvm::Metadata*)
Unexecuted instantiation: llvm::DILocation::getIfExists(llvm::LLVMContext&, unsigned int, unsigned int, llvm::Metadata*, llvm::Metadata*, bool)
Unexecuted instantiation: llvm::DILocation::getIfExists(llvm::LLVMContext&, unsigned int, unsigned int, llvm::DILocalScope*, llvm::DILocation*, bool)
Unexecuted instantiation: llvm::DISubprogram::getIfExists(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DISubroutineType*, unsigned int, llvm::DIType*, unsigned int, int, llvm::DINode::DIFlags, llvm::DISubprogram::DISPFlags, llvm::DICompileUnit*, llvm::MDTupleTypedArrayWrapper<llvm::DITemplateParameter>, llvm::DISubprogram*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>, llvm::MDTupleTypedArrayWrapper<llvm::DIType>)
Unexecuted instantiation: llvm::DISubprogram::getIfExists(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, int, llvm::DINode::DIFlags, llvm::DISubprogram::DISPFlags, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*)
Unexecuted instantiation: llvm::DILexicalBlock::getIfExists(llvm::LLVMContext&, llvm::DILocalScope*, llvm::DIFile*, unsigned int, unsigned int)
Unexecuted instantiation: llvm::DILexicalBlock::getIfExists(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, unsigned int, unsigned int)
Unexecuted instantiation: llvm::DILexicalBlockFile::getIfExists(llvm::LLVMContext&, llvm::DILocalScope*, llvm::DIFile*, unsigned int)
Unexecuted instantiation: llvm::DILexicalBlockFile::getIfExists(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, unsigned int)
Unexecuted instantiation: llvm::DINamespace::getIfExists(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, bool)
Unexecuted instantiation: llvm::DINamespace::getIfExists(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, bool)
Unexecuted instantiation: llvm::DIModule::getIfExists(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::StringRef)
Unexecuted instantiation: llvm::DIModule::getIfExists(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::MDString*, llvm::MDString*)
Unexecuted instantiation: llvm::DITemplateTypeParameter::getIfExists(llvm::LLVMContext&, llvm::StringRef, llvm::DIType*)
Unexecuted instantiation: llvm::DITemplateTypeParameter::getIfExists(llvm::LLVMContext&, llvm::MDString*, llvm::Metadata*)
Unexecuted instantiation: llvm::DITemplateValueParameter::getIfExists(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::DIType*, llvm::Metadata*)
Unexecuted instantiation: llvm::DITemplateValueParameter::getIfExists(llvm::LLVMContext&, unsigned int, llvm::MDString*, llvm::Metadata*, llvm::Metadata*)
Unexecuted instantiation: llvm::DIExpression::getIfExists(llvm::LLVMContext&, llvm::ArrayRef<unsigned long long>)
Unexecuted instantiation: llvm::DIGlobalVariable::getIfExists(llvm::LLVMContext&, llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIType*, bool, bool, llvm::DIDerivedType*, llvm::MDTuple*, unsigned int)
Unexecuted instantiation: llvm::DIGlobalVariable::getIfExists(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, bool, bool, llvm::Metadata*, llvm::Metadata*, unsigned int)
Unexecuted instantiation: llvm::DICommonBlock::getIfExists(llvm::LLVMContext&, llvm::DIScope*, llvm::DIGlobalVariable*, llvm::StringRef, llvm::DIFile*, unsigned int)
Unexecuted instantiation: llvm::DICommonBlock::getIfExists(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int)
Unexecuted instantiation: llvm::DILocalVariable::getIfExists(llvm::LLVMContext&, llvm::DILocalScope*, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DIType*, unsigned int, llvm::DINode::DIFlags, unsigned int)
Unexecuted instantiation: llvm::DILocalVariable::getIfExists(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::Metadata*, unsigned int, llvm::DINode::DIFlags, unsigned int)
Unexecuted instantiation: llvm::DILabel::getIfExists(llvm::LLVMContext&, llvm::DILocalScope*, llvm::StringRef, llvm::DIFile*, unsigned int)
Unexecuted instantiation: llvm::DILabel::getIfExists(llvm::LLVMContext&, llvm::Metadata*, llvm::MDString*, llvm::Metadata*, unsigned int)
Unexecuted instantiation: llvm::DIObjCProperty::getIfExists(llvm::LLVMContext&, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::StringRef, llvm::StringRef, unsigned int, llvm::DIType*)
Unexecuted instantiation: llvm::DIObjCProperty::getIfExists(llvm::LLVMContext&, llvm::MDString*, llvm::Metadata*, unsigned int, llvm::MDString*, llvm::MDString*, unsigned int, llvm::Metadata*)
Unexecuted instantiation: llvm::DIImportedEntity::getIfExists(llvm::LLVMContext&, unsigned int, llvm::DIScope*, llvm::DINode*, llvm::DIFile*, unsigned int, llvm::StringRef)
Unexecuted instantiation: llvm::DIImportedEntity::getIfExists(llvm::LLVMContext&, unsigned int, llvm::Metadata*, llvm::Metadata*, llvm::Metadata*, unsigned int, llvm::MDString*)
Unexecuted instantiation: llvm::DIGlobalVariableExpression::getIfExists(llvm::LLVMContext&, llvm::Metadata*, llvm::Metadata*)
Unexecuted instantiation: llvm::DIMacro::getIfExists(llvm::LLVMContext&, unsigned int, unsigned int, llvm::StringRef, llvm::StringRef)
Unexecuted instantiation: llvm::DIMacro::getIfExists(llvm::LLVMContext&, unsigned int, unsigned int, llvm::MDString*, llvm::MDString*)
Unexecuted instantiation: llvm::DIMacroFile::getIfExists(llvm::LLVMContext&, unsigned int, unsigned int, llvm::DIFile*, llvm::MDTupleTypedArrayWrapper<llvm::DIMacroNode>)
Unexecuted instantiation: llvm::DIMacroFile::getIfExists(llvm::LLVMContext&, unsigned int, unsigned int, llvm::Metadata*, llvm::Metadata*)
59
  DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS)
60
61
namespace llvm {
62
63
class DITypeRefArray {
64
  const MDTuple *N = nullptr;
65
66
public:
67
1.44k
  DITypeRefArray() = default;
68
170k
  DITypeRefArray(const MDTuple *N) : N(N) {}
69
70
446
  explicit operator bool() const { return get(); }
71
0
  explicit operator MDTuple *() const { return get(); }
72
73
130k
  MDTuple *get() const { return const_cast<MDTuple *>(N); }
74
10.6k
  MDTuple *operator->() const { return get(); }
75
0
  MDTuple &operator*() const { return *get(); }
76
77
  // FIXME: Fix callers and remove condition on N.
78
40.9k
  unsigned size() const { return N ? N->getNumOperands() : 
0u0
; }
79
5.76k
  DIType *operator[](unsigned I) const {
80
5.76k
    return cast_or_null<DIType>(N->getOperand(I));
81
5.76k
  }
82
83
  class iterator : std::iterator<std::input_iterator_tag, DIType *,
84
                                 std::ptrdiff_t, void, DIType *> {
85
    MDNode::op_iterator I = nullptr;
86
87
  public:
88
0
    iterator() = default;
89
818
    explicit iterator(MDNode::op_iterator I) : I(I) {}
90
91
621
    DIType *operator*() const { return cast_or_null<DIType>(*I); }
92
93
621
    iterator &operator++() {
94
621
      ++I;
95
621
      return *this;
96
621
    }
97
98
0
    iterator operator++(int) {
99
0
      iterator Temp(*this);
100
0
      ++I;
101
0
      return Temp;
102
0
    }
103
104
0
    bool operator==(const iterator &X) const { return I == X.I; }
105
1.03k
    bool operator!=(const iterator &X) const { return I != X.I; }
106
  };
107
108
  // FIXME: Fix callers and remove condition on N.
109
409
  iterator begin() const { return N ? iterator(N->op_begin()) : 
iterator()0
; }
110
409
  iterator end() const { return N ? iterator(N->op_end()) : 
iterator()0
; }
111
};
112
113
/// Tagged DWARF-like metadata node.
114
///
115
/// A metadata node with a DWARF tag (i.e., a constant named \c DW_TAG_*,
116
/// defined in llvm/BinaryFormat/Dwarf.h).  Called \a DINode because it's
117
/// potentially used for non-DWARF output.
118
class DINode : public MDNode {
119
  friend class LLVMContextImpl;
120
  friend class MDNode;
121
122
protected:
123
  DINode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
124
         ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None)
125
196k
      : MDNode(C, ID, Storage, Ops1, Ops2) {
126
196k
    assert(Tag < 1u << 16);
127
196k
    SubclassData16 = Tag;
128
196k
  }
129
65.0k
  ~DINode() = default;
130
131
5.27M
  template <class Ty> Ty *getOperandAs(unsigned I) const {
132
5.27M
    return cast_or_null<Ty>(getOperand(I));
133
5.27M
  }
llvm::MDString* llvm::DINode::getOperandAs<llvm::MDString>(unsigned int) const
Line
Count
Source
131
5.27M
  template <class Ty> Ty *getOperandAs(unsigned I) const {
132
5.27M
    return cast_or_null<Ty>(getOperand(I));
133
5.27M
  }
llvm::DIDerivedType* llvm::DINode::getOperandAs<llvm::DIDerivedType>(unsigned int) const
Line
Count
Source
131
355
  template <class Ty> Ty *getOperandAs(unsigned I) const {
132
355
    return cast_or_null<Ty>(getOperand(I));
133
355
  }
llvm::Metadata* llvm::DINode::getOperandAs<llvm::Metadata>(unsigned int) const
Line
Count
Source
131
5.17k
  template <class Ty> Ty *getOperandAs(unsigned I) const {
132
5.17k
    return cast_or_null<Ty>(getOperand(I));
133
5.17k
  }
llvm::MDTuple* llvm::DINode::getOperandAs<llvm::MDTuple>(unsigned int) const
Line
Count
Source
131
1.08k
  template <class Ty> Ty *getOperandAs(unsigned I) const {
132
1.08k
    return cast_or_null<Ty>(getOperand(I));
133
1.08k
  }
134
135
5.11M
  StringRef getStringOperand(unsigned I) const {
136
5.11M
    if (auto *S = getOperandAs<MDString>(I))
137
4.77M
      return S->getString();
138
340k
    return StringRef();
139
340k
  }
140
141
299k
  static MDString *getCanonicalMDString(LLVMContext &Context, StringRef S) {
142
299k
    if (S.empty())
143
131k
      return nullptr;
144
167k
    return MDString::get(Context, S);
145
167k
  }
146
147
  /// Allow subclasses to mutate the tag.
148
5
  void setTag(unsigned Tag) { SubclassData16 = Tag; }
149
150
public:
151
346k
  unsigned getTag() const { return SubclassData16; }
152
153
  /// Debug info flags.
154
  ///
155
  /// The three accessibility flags are mutually exclusive and rolled together
156
  /// in the first two bits.
157
  enum DIFlags : uint32_t {
158
#define HANDLE_DI_FLAG(ID, NAME) Flag##NAME = ID,
159
#define DI_FLAG_LARGEST_NEEDED
160
#include "llvm/IR/DebugInfoFlags.def"
161
    FlagAccessibility = FlagPrivate | FlagProtected | FlagPublic,
162
    FlagPtrToMemberRep = FlagSingleInheritance | FlagMultipleInheritance |
163
                         FlagVirtualInheritance,
164
    LLVM_MARK_AS_BITMASK_ENUM(FlagLargest)
165
  };
166
167
  static DIFlags getFlag(StringRef Flag);
168
  static StringRef getFlagString(DIFlags Flag);
169
170
  /// Split up a flags bitfield.
171
  ///
172
  /// Split \c Flags into \c SplitFlags, a vector of its components.  Returns
173
  /// any remaining (unrecognized) bits.
174
  static DIFlags splitFlags(DIFlags Flags,
175
                            SmallVectorImpl<DIFlags> &SplitFlags);
176
177
1.11k
  static bool classof(const Metadata *MD) {
178
1.11k
    switch (MD->getMetadataID()) {
179
1.11k
    default:
180
31
      return false;
181
1.11k
    case GenericDINodeKind:
182
1.08k
    case DISubrangeKind:
183
1.08k
    case DIEnumeratorKind:
184
1.08k
    case DIBasicTypeKind:
185
1.08k
    case DIDerivedTypeKind:
186
1.08k
    case DICompositeTypeKind:
187
1.08k
    case DISubroutineTypeKind:
188
1.08k
    case DIFileKind:
189
1.08k
    case DICompileUnitKind:
190
1.08k
    case DISubprogramKind:
191
1.08k
    case DILexicalBlockKind:
192
1.08k
    case DILexicalBlockFileKind:
193
1.08k
    case DINamespaceKind:
194
1.08k
    case DICommonBlockKind:
195
1.08k
    case DITemplateTypeParameterKind:
196
1.08k
    case DITemplateValueParameterKind:
197
1.08k
    case DIGlobalVariableKind:
198
1.08k
    case DILocalVariableKind:
199
1.08k
    case DILabelKind:
200
1.08k
    case DIObjCPropertyKind:
201
1.08k
    case DIImportedEntityKind:
202
1.08k
    case DIModuleKind:
203
1.08k
      return true;
204
1.11k
    }
205
1.11k
  }
206
};
207
208
/// Generic tagged DWARF-like metadata node.
209
///
210
/// An un-specialized DWARF-like metadata node.  The first operand is a
211
/// (possibly empty) null-separated \a MDString header that contains arbitrary
212
/// fields.  The remaining operands are \a dwarf_operands(), and are pointers
213
/// to other metadata.
214
class GenericDINode : public DINode {
215
  friend class LLVMContextImpl;
216
  friend class MDNode;
217
218
  GenericDINode(LLVMContext &C, StorageType Storage, unsigned Hash,
219
                unsigned Tag, ArrayRef<Metadata *> Ops1,
220
                ArrayRef<Metadata *> Ops2)
221
48
      : DINode(C, GenericDINodeKind, Storage, Tag, Ops1, Ops2) {
222
48
    setHash(Hash);
223
48
  }
224
48
  ~GenericDINode() { dropAllReferences(); }
225
226
74
  void setHash(unsigned Hash) { SubclassData32 = Hash; }
227
  void recalculateHash();
228
229
  static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag,
230
                                StringRef Header, ArrayRef<Metadata *> DwarfOps,
231
6
                                StorageType Storage, bool ShouldCreate = true) {
232
6
    return getImpl(Context, Tag, getCanonicalMDString(Context, Header),
233
6
                   DwarfOps, Storage, ShouldCreate);
234
6
  }
235
236
  static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag,
237
                                MDString *Header, ArrayRef<Metadata *> DwarfOps,
238
                                StorageType Storage, bool ShouldCreate = true);
239
240
1
  TempGenericDINode cloneImpl() const {
241
1
    return getTemporary(
242
1
        getContext(), getTag(), getHeader(),
243
1
        SmallVector<Metadata *, 4>(dwarf_op_begin(), dwarf_op_end()));
244
1
  }
245
246
public:
247
93
  unsigned getHash() const { return SubclassData32; }
248
249
  DEFINE_MDNODE_GET(GenericDINode, (unsigned Tag, StringRef Header,
250
                                    ArrayRef<Metadata *> DwarfOps),
251
                    (Tag, Header, DwarfOps))
252
  DEFINE_MDNODE_GET(GenericDINode, (unsigned Tag, MDString *Header,
253
                                    ArrayRef<Metadata *> DwarfOps),
254
                    (Tag, Header, DwarfOps))
255
256
  /// Return a (temporary) clone of this.
257
  TempGenericDINode clone() const { return cloneImpl(); }
258
259
169
  unsigned getTag() const { return SubclassData16; }
260
25
  StringRef getHeader() const { return getStringOperand(0); }
261
93
  MDString *getRawHeader() const { return getOperandAs<MDString>(0); }
262
263
6
  op_iterator dwarf_op_begin() const { return op_begin() + 1; }
264
6
  op_iterator dwarf_op_end() const { return op_end(); }
265
5
  op_range dwarf_operands() const {
266
5
    return op_range(dwarf_op_begin(), dwarf_op_end());
267
5
  }
268
269
21
  unsigned getNumDwarfOperands() const { return getNumOperands() - 1; }
270
  const MDOperand &getDwarfOperand(unsigned I) const {
271
    return getOperand(I + 1);
272
  }
273
  void replaceDwarfOperandWith(unsigned I, Metadata *New) {
274
    replaceOperandWith(I + 1, New);
275
  }
276
277
0
  static bool classof(const Metadata *MD) {
278
0
    return MD->getMetadataID() == GenericDINodeKind;
279
0
  }
280
};
281
282
/// Array subrange.
283
///
284
/// TODO: Merge into node for DW_TAG_array_type, which should have a custom
285
/// type.
286
class DISubrange : public DINode {
287
  friend class LLVMContextImpl;
288
  friend class MDNode;
289
290
  int64_t LowerBound;
291
292
  DISubrange(LLVMContext &C, StorageType Storage, Metadata *Node,
293
             int64_t LowerBound, ArrayRef<Metadata *> Ops)
294
      : DINode(C, DISubrangeKind, Storage, dwarf::DW_TAG_subrange_type, Ops),
295
502
        LowerBound(LowerBound) {}
296
297
490
  ~DISubrange() = default;
298
299
  static DISubrange *getImpl(LLVMContext &Context, int64_t Count,
300
                             int64_t LowerBound, StorageType Storage,
301
                             bool ShouldCreate = true);
302
303
  static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode,
304
                             int64_t LowerBound, StorageType Storage,
305
                             bool ShouldCreate = true);
306
307
1
  TempDISubrange cloneImpl() const {
308
1
    return getTemporary(getContext(), getRawCountNode(), getLowerBound());
309
1
  }
310
311
public:
312
  DEFINE_MDNODE_GET(DISubrange, (int64_t Count, int64_t LowerBound = 0),
313
                    (Count, LowerBound))
314
315
  DEFINE_MDNODE_GET(DISubrange, (Metadata *CountNode, int64_t LowerBound = 0),
316
                    (CountNode, LowerBound))
317
318
  TempDISubrange clone() const { return cloneImpl(); }
319
320
1.27k
  int64_t getLowerBound() const { return LowerBound; }
321
322
2.74k
  Metadata *getRawCountNode() const {
323
2.74k
    return getOperand(0).get();
324
2.74k
  }
325
326
  typedef PointerUnion<ConstantInt*, DIVariable*> CountType;
327
328
1.76k
  CountType getCount() const {
329
1.76k
    if (auto *MD = dyn_cast<ConstantAsMetadata>(getRawCountNode()))
330
1.59k
      return CountType(cast<ConstantInt>(MD->getValue()));
331
173
332
173
    if (auto *DV = dyn_cast<DIVariable>(getRawCountNode()))
333
170
      return CountType(DV);
334
3
335
3
    return CountType();
336
3
  }
337
338
34
  static bool classof(const Metadata *MD) {
339
34
    return MD->getMetadataID() == DISubrangeKind;
340
34
  }
341
};
342
343
/// Enumeration value.
344
///
345
/// TODO: Add a pointer to the context (DW_TAG_enumeration_type) once that no
346
/// longer creates a type cycle.
347
class DIEnumerator : public DINode {
348
  friend class LLVMContextImpl;
349
  friend class MDNode;
350
351
  int64_t Value;
352
  DIEnumerator(LLVMContext &C, StorageType Storage, int64_t Value,
353
               bool IsUnsigned, ArrayRef<Metadata *> Ops)
354
      : DINode(C, DIEnumeratorKind, Storage, dwarf::DW_TAG_enumerator, Ops),
355
12.0k
        Value(Value) {
356
12.0k
    SubclassData32 = IsUnsigned;
357
12.0k
  }
358
11.9k
  ~DIEnumerator() = default;
359
360
  static DIEnumerator *getImpl(LLVMContext &Context, int64_t Value,
361
                               bool IsUnsigned, StringRef Name,
362
85
                               StorageType Storage, bool ShouldCreate = true) {
363
85
    return getImpl(Context, Value, IsUnsigned,
364
85
                   getCanonicalMDString(Context, Name), Storage, ShouldCreate);
365
85
  }
366
  static DIEnumerator *getImpl(LLVMContext &Context, int64_t Value,
367
                               bool IsUnsigned, MDString *Name,
368
                               StorageType Storage, bool ShouldCreate = true);
369
370
1
  TempDIEnumerator cloneImpl() const {
371
1
    return getTemporary(getContext(), getValue(), isUnsigned(), getName());
372
1
  }
373
374
public:
375
  DEFINE_MDNODE_GET(DIEnumerator, (int64_t Value, bool IsUnsigned, StringRef Name),
376
                    (Value, IsUnsigned, Name))
377
  DEFINE_MDNODE_GET(DIEnumerator, (int64_t Value, bool IsUnsigned, MDString *Name),
378
                    (Value, IsUnsigned, Name))
379
380
  TempDIEnumerator clone() const { return cloneImpl(); }
381
382
55.5k
  int64_t getValue() const { return Value; }
383
24.7k
  bool isUnsigned() const { return SubclassData32; }
384
11.9k
  StringRef getName() const { return getStringOperand(0); }
385
386
24.6k
  MDString *getRawName() const { return getOperandAs<MDString>(0); }
387
388
11.8k
  static bool classof(const Metadata *MD) {
389
11.8k
    return MD->getMetadataID() == DIEnumeratorKind;
390
11.8k
  }
391
};
392
393
/// Base class for scope-like contexts.
394
///
395
/// Base class for lexical scopes and types (which are also declaration
396
/// contexts).
397
///
398
/// TODO: Separate the concepts of declaration contexts and lexical scopes.
399
class DIScope : public DINode {
400
protected:
401
  DIScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
402
          ArrayRef<Metadata *> Ops)
403
172k
      : DINode(C, ID, Storage, Tag, Ops) {}
404
40.6k
  ~DIScope() = default;
405
406
public:
407
8.66M
  DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
408
409
  inline StringRef getFilename() const;
410
  inline StringRef getDirectory() const;
411
  inline Optional<StringRef> getSource() const;
412
413
  StringRef getName() const;
414
  DIScope *getScope() const;
415
416
  /// Return the raw underlying file.
417
  ///
418
  /// A \a DIFile is a \a DIScope, but it doesn't point at a separate file (it
419
  /// \em is the file).  If \c this is an \a DIFile, we need to return \c this.
420
  /// Otherwise, return the first operand, which is where all other subclasses
421
  /// store their file pointer.
422
8.76M
  Metadata *getRawFile() const {
423
8.76M
    return isa<DIFile>(this) ? 
const_cast<DIScope *>(this)1
424
8.76M
                             : 
static_cast<Metadata *>(getOperand(0))8.76M
;
425
8.76M
  }
426
427
53.5k
  static bool classof(const Metadata *MD) {
428
53.5k
    switch (MD->getMetadataID()) {
429
53.5k
    default:
430
0
      return false;
431
53.5k
    case DIBasicTypeKind:
432
53.5k
    case DIDerivedTypeKind:
433
53.5k
    case DICompositeTypeKind:
434
53.5k
    case DISubroutineTypeKind:
435
53.5k
    case DIFileKind:
436
53.5k
    case DICompileUnitKind:
437
53.5k
    case DISubprogramKind:
438
53.5k
    case DILexicalBlockKind:
439
53.5k
    case DILexicalBlockFileKind:
440
53.5k
    case DINamespaceKind:
441
53.5k
    case DICommonBlockKind:
442
53.5k
    case DIModuleKind:
443
53.5k
      return true;
444
53.5k
    }
445
53.5k
  }
446
};
447
448
/// File.
449
///
450
/// TODO: Merge with directory/file node (including users).
451
/// TODO: Canonicalize paths on creation.
452
class DIFile : public DIScope {
453
  friend class LLVMContextImpl;
454
  friend class MDNode;
455
456
public:
457
  /// Which algorithm (e.g. MD5) a checksum was generated with.
458
  ///
459
  /// The encoding is explicit because it is used directly in Bitcode. The
460
  /// value 0 is reserved to indicate the absence of a checksum in Bitcode.
461
  enum ChecksumKind {
462
    // The first variant was originally CSK_None, encoded as 0. The new
463
    // internal representation removes the need for this by wrapping the
464
    // ChecksumInfo in an Optional, but to preserve Bitcode compatibility the 0
465
    // encoding is reserved.
466
    CSK_MD5 = 1,
467
    CSK_SHA1 = 2,
468
    CSK_Last = CSK_SHA1 // Should be last enumeration.
469
  };
470
471
  /// A single checksum, represented by a \a Kind and a \a Value (a string).
472
  template <typename T>
473
  struct ChecksumInfo {
474
    /// The kind of checksum which \a Value encodes.
475
    ChecksumKind Kind;
476
    /// The string value of the checksum.
477
    T Value;
478
479
2.04k
    ChecksumInfo(ChecksumKind Kind, T Value) : Kind(Kind), Value(Value) { }
llvm::DIFile::ChecksumInfo<llvm::StringRef>::ChecksumInfo(llvm::DIFile::ChecksumKind, llvm::StringRef)
Line
Count
Source
479
1.71k
    ChecksumInfo(ChecksumKind Kind, T Value) : Kind(Kind), Value(Value) { }
llvm::DIFile::ChecksumInfo<llvm::MDString*>::ChecksumInfo(llvm::DIFile::ChecksumKind, llvm::MDString*)
Line
Count
Source
479
332
    ChecksumInfo(ChecksumKind Kind, T Value) : Kind(Kind), Value(Value) { }
480
    ~ChecksumInfo() = default;
481
3
    bool operator==(const ChecksumInfo<T> &X) const {
482
3
      return Kind == X.Kind && Value == X.Value;
483
3
    }
484
    bool operator!=(const ChecksumInfo<T> &X) const { return !(*this == X); }
485
103
    StringRef getKindAsString() const { return getChecksumKindAsString(Kind); }
486
  };
487
488
private:
489
  Optional<ChecksumInfo<MDString *>> Checksum;
490
  Optional<MDString *> Source;
491
492
  DIFile(LLVMContext &C, StorageType Storage,
493
         Optional<ChecksumInfo<MDString *>> CS, Optional<MDString *> Src,
494
         ArrayRef<Metadata *> Ops)
495
      : DIScope(C, DIFileKind, Storage, dwarf::DW_TAG_file_type, Ops),
496
16.3k
        Checksum(CS), Source(Src) {}
497
4.53k
  ~DIFile() = default;
498
499
  static DIFile *getImpl(LLVMContext &Context, StringRef Filename,
500
                         StringRef Directory,
501
                         Optional<ChecksumInfo<StringRef>> CS,
502
                         Optional<StringRef> Source,
503
13.9k
                         StorageType Storage, bool ShouldCreate = true) {
504
13.9k
    Optional<ChecksumInfo<MDString *>> MDChecksum;
505
13.9k
    if (CS)
506
81
      MDChecksum.emplace(CS->Kind, getCanonicalMDString(Context, CS->Value));
507
13.9k
    return getImpl(Context, getCanonicalMDString(Context, Filename),
508
13.9k
                   getCanonicalMDString(Context, Directory), MDChecksum,
509
13.9k
                   Source ? 
Optional<MDString *>(getCanonicalMDString(Context, *Source))8
:
None13.9k
,
510
13.9k
                   Storage, ShouldCreate);
511
13.9k
  }
512
  static DIFile *getImpl(LLVMContext &Context, MDString *Filename,
513
                         MDString *Directory,
514
                         Optional<ChecksumInfo<MDString *>> CS,
515
                         Optional<MDString *> Source, StorageType Storage,
516
                         bool ShouldCreate = true);
517
518
1
  TempDIFile cloneImpl() const {
519
1
    return getTemporary(getContext(), getFilename(), getDirectory(),
520
1
                        getChecksum(), getSource());
521
1
  }
522
523
public:
524
  DEFINE_MDNODE_GET(DIFile, (StringRef Filename, StringRef Directory,
525
                             Optional<ChecksumInfo<StringRef>> CS = None,
526
                             Optional<StringRef> Source = None),
527
                    (Filename, Directory, CS, Source))
528
  DEFINE_MDNODE_GET(DIFile, (MDString * Filename, MDString *Directory,
529
                             Optional<ChecksumInfo<MDString *>> CS = None,
530
                             Optional<MDString *> Source = None),
531
                    (Filename, Directory, CS, Source))
532
533
  TempDIFile clone() const { return cloneImpl(); }
534
535
2.24M
  StringRef getFilename() const { return getStringOperand(0); }
536
1.25M
  StringRef getDirectory() const { return getStringOperand(1); }
537
13.9k
  Optional<ChecksumInfo<StringRef>> getChecksum() const {
538
13.9k
    Optional<ChecksumInfo<StringRef>> StringRefChecksum;
539
13.9k
    if (Checksum)
540
1.64k
      StringRefChecksum.emplace(Checksum->Kind, Checksum->Value->getString());
541
13.9k
    return StringRefChecksum;
542
13.9k
  }
543
1.28M
  Optional<StringRef> getSource() const {
544
1.28M
    return Source ? 
Optional<StringRef>((*Source)->getString())215
:
None1.28M
;
545
1.28M
  }
546
547
20.0k
  MDString *getRawFilename() const { return getOperandAs<MDString>(0); }
548
18.4k
  MDString *getRawDirectory() const { return getOperandAs<MDString>(1); }
549
18.5k
  Optional<ChecksumInfo<MDString *>> getRawChecksum() const { return Checksum; }
550
18.4k
  Optional<MDString *> getRawSource() const { return Source; }
551
552
  static StringRef getChecksumKindAsString(ChecksumKind CSKind);
553
  static Optional<ChecksumKind> getChecksumKind(StringRef CSKindStr);
554
555
8.76M
  static bool classof(const Metadata *MD) {
556
8.76M
    return MD->getMetadataID() == DIFileKind;
557
8.76M
  }
558
};
559
560
979k
StringRef DIScope::getFilename() const {
561
979k
  if (auto *F = getFile())
562
979k
    return F->getFilename();
563
32
  return "";
564
32
}
565
566
2.82k
StringRef DIScope::getDirectory() const {
567
2.82k
  if (auto *F = getFile())
568
2.81k
    return F->getDirectory();
569
4
  return "";
570
4
}
571
572
2.67k
Optional<StringRef> DIScope::getSource() const {
573
2.67k
  if (auto *F = getFile())
574
2.67k
    return F->getSource();
575
0
  return None;
576
0
}
577
578
/// Base class for types.
579
///
580
/// TODO: Remove the hardcoded name and context, since many types don't use
581
/// them.
582
/// TODO: Split up flags.
583
class DIType : public DIScope {
584
  unsigned Line;
585
  DIFlags Flags;
586
  uint64_t SizeInBits;
587
  uint64_t OffsetInBits;
588
  uint32_t AlignInBits;
589
590
protected:
591
  DIType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
592
         unsigned Line, uint64_t SizeInBits, uint32_t AlignInBits,
593
         uint64_t OffsetInBits, DIFlags Flags, ArrayRef<Metadata *> Ops)
594
21.7k
      : DIScope(C, ID, Storage, Tag, Ops) {
595
21.7k
    init(Line, SizeInBits, AlignInBits, OffsetInBits, Flags);
596
21.7k
  }
597
19.7k
  ~DIType() = default;
598
599
  void init(unsigned Line, uint64_t SizeInBits, uint32_t AlignInBits,
600
21.7k
            uint64_t OffsetInBits, DIFlags Flags) {
601
21.7k
    this->Line = Line;
602
21.7k
    this->Flags = Flags;
603
21.7k
    this->SizeInBits = SizeInBits;
604
21.7k
    this->AlignInBits = AlignInBits;
605
21.7k
    this->OffsetInBits = OffsetInBits;
606
21.7k
  }
607
608
  /// Change fields in place.
609
  void mutate(unsigned Tag, unsigned Line, uint64_t SizeInBits,
610
5
              uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags) {
611
5
    assert(isDistinct() && "Only distinct nodes can mutate");
612
5
    setTag(Tag);
613
5
    init(Line, SizeInBits, AlignInBits, OffsetInBits, Flags);
614
5
  }
615
616
public:
617
2.15k
  TempDIType clone() const {
618
2.15k
    return TempDIType(cast<DIType>(MDNode::clone().release()));
619
2.15k
  }
620
621
35.9k
  unsigned getLine() const { return Line; }
622
44.4k
  uint64_t getSizeInBits() const { return SizeInBits; }
623
38.4k
  uint32_t getAlignInBits() const { return AlignInBits; }
624
1.39k
  uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
625
32.9k
  uint64_t getOffsetInBits() const { return OffsetInBits; }
626
261k
  DIFlags getFlags() const { return Flags; }
627
628
10.9k
  DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
629
21.4k
  StringRef getName() const { return getStringOperand(2); }
630
631
632
65.9k
  Metadata *getRawScope() const { return getOperand(1); }
633
33.2k
  MDString *getRawName() const { return getOperandAs<MDString>(2); }
634
635
  /// Returns a new temporary DIType with updated Flags
636
2.15k
  TempDIType cloneWithFlags(DIFlags NewFlags) const {
637
2.15k
    auto NewTy = clone();
638
2.15k
    NewTy->Flags = NewFlags;
639
2.15k
    return NewTy;
640
2.15k
  }
641
642
657
  bool isPrivate() const {
643
657
    return (getFlags() & FlagAccessibility) == FlagPrivate;
644
657
  }
645
678
  bool isProtected() const {
646
678
    return (getFlags() & FlagAccessibility) == FlagProtected;
647
678
  }
648
625
  bool isPublic() const {
649
625
    return (getFlags() & FlagAccessibility) == FlagPublic;
650
625
  }
651
6.14k
  bool isForwardDecl() const { return getFlags() & FlagFwdDecl; }
652
634
  bool isAppleBlockExtension() const { return getFlags() & FlagAppleBlock; }
653
36.5k
  bool isBlockByrefStruct() const { return getFlags() & FlagBlockByrefStruct; }
654
671
  bool isVirtual() const { return getFlags() & FlagVirtual; }
655
2.42k
  bool isArtificial() const { return getFlags() & FlagArtificial; }
656
3.50k
  bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
657
681
  bool isObjcClassComplete() const {
658
681
    return getFlags() & FlagObjcClassComplete;
659
681
  }
660
6.86k
  bool isVector() const { return getFlags() & FlagVector; }
661
273
  bool isBitField() const { return getFlags() & FlagBitField; }
662
894
  bool isStaticMember() const { return getFlags() & FlagStaticMember; }
663
60
  bool isLValueReference() const { return getFlags() & FlagLValueReference; }
664
60
  bool isRValueReference() const { return getFlags() & FlagRValueReference; }
665
634
  bool isTypePassByValue() const { return getFlags() & FlagTypePassByValue; }
666
569
  bool isTypePassByReference() const {
667
569
    return getFlags() & FlagTypePassByReference;
668
569
  }
669
8.69k
  bool isBigEndian() const { return getFlags() & FlagBigEndian; }
670
1.01k
  bool isLittleEndian() const { return getFlags() & FlagLittleEndian; }
671
672
1.18M
  static bool classof(const Metadata *MD) {
673
1.18M
    switch (MD->getMetadataID()) {
674
1.18M
    default:
675
1.04M
      return false;
676
1.18M
    case DIBasicTypeKind:
677
140k
    case DIDerivedTypeKind:
678
140k
    case DICompositeTypeKind:
679
140k
    case DISubroutineTypeKind:
680
140k
      return true;
681
1.18M
    }
682
1.18M
  }
683
};
684
685
/// Basic type, like 'int' or 'float'.
686
///
687
/// TODO: Split out DW_TAG_unspecified_type.
688
/// TODO: Drop unused accessors.
689
class DIBasicType : public DIType {
690
  friend class LLVMContextImpl;
691
  friend class MDNode;
692
693
  unsigned Encoding;
694
695
  DIBasicType(LLVMContext &C, StorageType Storage, unsigned Tag,
696
              uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding,
697
              DIFlags Flags, ArrayRef<Metadata *> Ops)
698
      : DIType(C, DIBasicTypeKind, Storage, Tag, 0, SizeInBits, AlignInBits, 0,
699
               Flags, Ops),
700
3.06k
        Encoding(Encoding) {}
701
2.96k
  ~DIBasicType() = default;
702
703
  static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
704
                              StringRef Name, uint64_t SizeInBits,
705
                              uint32_t AlignInBits, unsigned Encoding,
706
                              DIFlags Flags, StorageType Storage,
707
1.29k
                              bool ShouldCreate = true) {
708
1.29k
    return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
709
1.29k
                   SizeInBits, AlignInBits, Encoding, Flags, Storage,
710
1.29k
                   ShouldCreate);
711
1.29k
  }
712
  static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
713
                              MDString *Name, uint64_t SizeInBits,
714
                              uint32_t AlignInBits, unsigned Encoding,
715
                              DIFlags Flags, StorageType Storage,
716
                              bool ShouldCreate = true);
717
718
2
  TempDIBasicType cloneImpl() const {
719
2
    return getTemporary(getContext(), getTag(), getName(), getSizeInBits(),
720
2
                        getAlignInBits(), getEncoding(), getFlags());
721
2
  }
722
723
public:
724
  DEFINE_MDNODE_GET(DIBasicType, (unsigned Tag, StringRef Name),
725
                    (Tag, Name, 0, 0, 0, FlagZero))
726
  DEFINE_MDNODE_GET(DIBasicType,
727
                    (unsigned Tag, StringRef Name, uint64_t SizeInBits,
728
                     uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
729
                    (Tag, Name, SizeInBits, AlignInBits, Encoding, Flags))
730
  DEFINE_MDNODE_GET(DIBasicType,
731
                    (unsigned Tag, MDString *Name, uint64_t SizeInBits,
732
                     uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
733
                    (Tag, Name, SizeInBits, AlignInBits, Encoding, Flags))
734
735
  TempDIBasicType clone() const { return cloneImpl(); }
736
737
7.22k
  unsigned getEncoding() const { return Encoding; }
738
739
  enum class Signedness { Signed, Unsigned };
740
741
  /// Return the signedness of this type, or None if this type is neither
742
  /// signed nor unsigned.
743
  Optional<Signedness> getSignedness() const;
744
745
3.96k
  static bool classof(const Metadata *MD) {
746
3.96k
    return MD->getMetadataID() == DIBasicTypeKind;
747
3.96k
  }
748
};
749
750
/// Derived types.
751
///
752
/// This includes qualified types, pointers, references, friends, typedefs, and
753
/// class members.
754
///
755
/// TODO: Split out members (inheritance, fields, methods, etc.).
756
class DIDerivedType : public DIType {
757
  friend class LLVMContextImpl;
758
  friend class MDNode;
759
760
  /// The DWARF address space of the memory pointed to or referenced by a
761
  /// pointer or reference type respectively.
762
  Optional<unsigned> DWARFAddressSpace;
763
764
  DIDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag,
765
                unsigned Line, uint64_t SizeInBits, uint32_t AlignInBits,
766
                uint64_t OffsetInBits, Optional<unsigned> DWARFAddressSpace,
767
                DIFlags Flags, ArrayRef<Metadata *> Ops)
768
      : DIType(C, DIDerivedTypeKind, Storage, Tag, Line, SizeInBits,
769
               AlignInBits, OffsetInBits, Flags, Ops),
770
8.77k
        DWARFAddressSpace(DWARFAddressSpace) {}
771
8.49k
  ~DIDerivedType() = default;
772
773
  static DIDerivedType *
774
  getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, DIFile *File,
775
          unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
776
          uint32_t AlignInBits, uint64_t OffsetInBits,
777
          Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
778
6.35k
          Metadata *ExtraData, StorageType Storage, bool ShouldCreate = true) {
779
6.35k
    return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
780
6.35k
                   Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
781
6.35k
                   DWARFAddressSpace, Flags, ExtraData, Storage, ShouldCreate);
782
6.35k
  }
783
  static DIDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
784
                                MDString *Name, Metadata *File, unsigned Line,
785
                                Metadata *Scope, Metadata *BaseType,
786
                                uint64_t SizeInBits, uint32_t AlignInBits,
787
                                uint64_t OffsetInBits,
788
                                Optional<unsigned> DWARFAddressSpace,
789
                                DIFlags Flags, Metadata *ExtraData,
790
                                StorageType Storage, bool ShouldCreate = true);
791
792
2.15k
  TempDIDerivedType cloneImpl() const {
793
2.15k
    return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
794
2.15k
                        getScope(), getBaseType(), getSizeInBits(),
795
2.15k
                        getAlignInBits(), getOffsetInBits(),
796
2.15k
                        getDWARFAddressSpace(), getFlags(), getExtraData());
797
2.15k
  }
798
799
public:
800
  DEFINE_MDNODE_GET(DIDerivedType,
801
                    (unsigned Tag, MDString *Name, Metadata *File,
802
                     unsigned Line, Metadata *Scope, Metadata *BaseType,
803
                     uint64_t SizeInBits, uint32_t AlignInBits,
804
                     uint64_t OffsetInBits,
805
                     Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
806
                     Metadata *ExtraData = nullptr),
807
                    (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
808
                     AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
809
                     ExtraData))
810
  DEFINE_MDNODE_GET(DIDerivedType,
811
                    (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
812
                     DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
813
                     uint32_t AlignInBits, uint64_t OffsetInBits,
814
                     Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
815
                     Metadata *ExtraData = nullptr),
816
                    (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
817
                     AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
818
                     ExtraData))
819
820
  TempDIDerivedType clone() const { return cloneImpl(); }
821
822
  /// Get the base type this is derived from.
823
6.14k
  DIType *getBaseType() const { return cast_or_null<DIType>(getRawBaseType()); }
824
44.0k
  Metadata *getRawBaseType() const { return getOperand(3); }
825
826
  /// \returns The DWARF address space of the memory pointed to or referenced by
827
  /// a pointer or reference type respectively.
828
39.9k
  Optional<unsigned> getDWARFAddressSpace() const { return DWARFAddressSpace; }
829
830
  /// Get extra data associated with this derived type.
831
  ///
832
  /// Class type for pointer-to-members, objective-c property node for ivars,
833
  /// global constant wrapper for static members, or virtual base pointer offset
834
  /// for inheritance.
835
  ///
836
  /// TODO: Separate out types that need this extra operand: pointer-to-member
837
  /// types and member fields (static members and ivars).
838
3.23k
  Metadata *getExtraData() const { return getRawExtraData(); }
839
25.3k
  Metadata *getRawExtraData() const { return getOperand(4); }
840
841
  /// Get casted version of extra data.
842
  /// @{
843
70
  DIType *getClassType() const {
844
70
    assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
845
70
    return cast_or_null<DIType>(getExtraData());
846
70
  }
847
848
648
  DIObjCProperty *getObjCProperty() const {
849
648
    return dyn_cast_or_null<DIObjCProperty>(getExtraData());
850
648
  }
851
852
15
  uint32_t getVBPtrOffset() const {
853
15
    assert(getTag() == dwarf::DW_TAG_inheritance);
854
15
    if (auto *CM = cast_or_null<ConstantAsMetadata>(getExtraData()))
855
6
      if (auto *CI = dyn_cast_or_null<ConstantInt>(CM->getValue()))
856
6
        return static_cast<uint32_t>(CI->getZExtValue());
857
9
    return 0;
858
9
  }
859
860
8
  Constant *getStorageOffsetInBits() const {
861
8
    assert(getTag() == dwarf::DW_TAG_member && isBitField());
862
8
    if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
863
8
      return C->getValue();
864
0
    return nullptr;
865
0
  }
866
867
60
  Constant *getConstant() const {
868
60
    assert(getTag() == dwarf::DW_TAG_member && isStaticMember());
869
60
    if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
870
18
      return C->getValue();
871
42
    return nullptr;
872
42
  }
873
3
  Constant *getDiscriminantValue() const {
874
3
    assert(getTag() == dwarf::DW_TAG_member && !isStaticMember());
875
3
    if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
876
1
      return C->getValue();
877
2
    return nullptr;
878
2
  }
879
  /// @}
880
881
3.17k
  static bool classof(const Metadata *MD) {
882
3.17k
    return MD->getMetadataID() == DIDerivedTypeKind;
883
3.17k
  }
884
};
885
886
/// Composite types.
887
///
888
/// TODO: Detach from DerivedTypeBase (split out MDEnumType?).
889
/// TODO: Create a custom, unrelated node for DW_TAG_array_type.
890
class DICompositeType : public DIType {
891
  friend class LLVMContextImpl;
892
  friend class MDNode;
893
894
  unsigned RuntimeLang;
895
896
  DICompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
897
                  unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits,
898
                  uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
899
                  ArrayRef<Metadata *> Ops)
900
      : DIType(C, DICompositeTypeKind, Storage, Tag, Line, SizeInBits,
901
               AlignInBits, OffsetInBits, Flags, Ops),
902
3.65k
        RuntimeLang(RuntimeLang) {}
903
3.54k
  ~DICompositeType() = default;
904
905
  /// Change fields in place.
906
  void mutate(unsigned Tag, unsigned Line, unsigned RuntimeLang,
907
              uint64_t SizeInBits, uint32_t AlignInBits,
908
5
              uint64_t OffsetInBits, DIFlags Flags) {
909
5
    assert(isDistinct() && "Only distinct nodes can mutate");
910
5
    assert(getRawIdentifier() && "Only ODR-uniqued nodes should mutate");
911
5
    this->RuntimeLang = RuntimeLang;
912
5
    DIType::mutate(Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags);
913
5
  }
914
915
  static DICompositeType *
916
  getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
917
          unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
918
          uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
919
          DINodeArray Elements, unsigned RuntimeLang, DIType *VTableHolder,
920
          DITemplateParameterArray TemplateParams, StringRef Identifier,
921
          DIDerivedType *Discriminator, StorageType Storage,
922
2.16k
          bool ShouldCreate = true) {
923
2.16k
    return getImpl(
924
2.16k
        Context, Tag, getCanonicalMDString(Context, Name), File, Line, Scope,
925
2.16k
        BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements.get(),
926
2.16k
        RuntimeLang, VTableHolder, TemplateParams.get(),
927
2.16k
        getCanonicalMDString(Context, Identifier), Discriminator, Storage, ShouldCreate);
928
2.16k
  }
929
  static DICompositeType *
930
  getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
931
          unsigned Line, Metadata *Scope, Metadata *BaseType,
932
          uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
933
          DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
934
          Metadata *VTableHolder, Metadata *TemplateParams,
935
          MDString *Identifier, Metadata *Discriminator,
936
          StorageType Storage, bool ShouldCreate = true);
937
938
3
  TempDICompositeType cloneImpl() const {
939
3
    return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
940
3
                        getScope(), getBaseType(), getSizeInBits(),
941
3
                        getAlignInBits(), getOffsetInBits(), getFlags(),
942
3
                        getElements(), getRuntimeLang(), getVTableHolder(),
943
3
                        getTemplateParams(), getIdentifier(), getDiscriminator());
944
3
  }
945
946
public:
947
  DEFINE_MDNODE_GET(DICompositeType,
948
                    (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
949
                     DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
950
                     uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
951
                     DINodeArray Elements, unsigned RuntimeLang,
952
                     DIType *VTableHolder,
953
                     DITemplateParameterArray TemplateParams = nullptr,
954
                     StringRef Identifier = "",
955
                     DIDerivedType *Discriminator = nullptr),
956
                    (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
957
                     AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
958
                     VTableHolder, TemplateParams, Identifier, Discriminator))
959
  DEFINE_MDNODE_GET(DICompositeType,
960
                    (unsigned Tag, MDString *Name, Metadata *File,
961
                     unsigned Line, Metadata *Scope, Metadata *BaseType,
962
                     uint64_t SizeInBits, uint32_t AlignInBits,
963
                     uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
964
                     unsigned RuntimeLang, Metadata *VTableHolder,
965
                     Metadata *TemplateParams = nullptr,
966
                     MDString *Identifier = nullptr,
967
                     Metadata *Discriminator = nullptr),
968
                    (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
969
                     AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
970
                     VTableHolder, TemplateParams, Identifier, Discriminator))
971
972
  TempDICompositeType clone() const { return cloneImpl(); }
973
974
  /// Get a DICompositeType with the given ODR identifier.
975
  ///
976
  /// If \a LLVMContext::isODRUniquingDebugTypes(), gets the mapped
977
  /// DICompositeType for the given ODR \c Identifier.  If none exists, creates
978
  /// a new node.
979
  ///
980
  /// Else, returns \c nullptr.
981
  static DICompositeType *
982
  getODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag,
983
             MDString *Name, Metadata *File, unsigned Line, Metadata *Scope,
984
             Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits,
985
             uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
986
             unsigned RuntimeLang, Metadata *VTableHolder,
987
             Metadata *TemplateParams, Metadata *Discriminator);
988
  static DICompositeType *getODRTypeIfExists(LLVMContext &Context,
989
                                             MDString &Identifier);
990
991
  /// Build a DICompositeType with the given ODR identifier.
992
  ///
993
  /// Looks up the mapped DICompositeType for the given ODR \c Identifier.  If
994
  /// it doesn't exist, creates a new one.  If it does exist and \a
995
  /// isForwardDecl(), and the new arguments would be a definition, mutates the
996
  /// the type in place.  In either case, returns the type.
997
  ///
998
  /// If not \a LLVMContext::isODRUniquingDebugTypes(), this function returns
999
  /// nullptr.
1000
  static DICompositeType *
1001
  buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag,
1002
               MDString *Name, Metadata *File, unsigned Line, Metadata *Scope,
1003
               Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits,
1004
               uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
1005
               unsigned RuntimeLang, Metadata *VTableHolder,
1006
               Metadata *TemplateParams, Metadata *Discriminator);
1007
1008
622
  DIType *getBaseType() const { return cast_or_null<DIType>(getRawBaseType()); }
1009
1.77k
  DINodeArray getElements() const {
1010
1.77k
    return cast_or_null<MDTuple>(getRawElements());
1011
1.77k
  }
1012
991
  DIType *getVTableHolder() const {
1013
991
    return cast_or_null<DIType>(getRawVTableHolder());
1014
991
  }
1015
988
  DITemplateParameterArray getTemplateParams() const {
1016
988
    return cast_or_null<MDTuple>(getRawTemplateParams());
1017
988
  }
1018
2.75k
  StringRef getIdentifier() const { return getStringOperand(7); }
1019
8.68k
  unsigned getRuntimeLang() const { return RuntimeLang; }
1020
1021
14.5k
  Metadata *getRawBaseType() const { return getOperand(3); }
1022
21.2k
  Metadata *getRawElements() const { return getOperand(4); }
1023
14.7k
  Metadata *getRawVTableHolder() const { return getOperand(5); }
1024
14.7k
  Metadata *getRawTemplateParams() const { return getOperand(6); }
1025
15.3k
  MDString *getRawIdentifier() const { return getOperandAs<MDString>(7); }
1026
13.7k
  Metadata *getRawDiscriminator() const { return getOperand(8); }
1027
355
  DIDerivedType *getDiscriminator() const { return getOperandAs<DIDerivedType>(8); }
1028
1029
  /// Replace operands.
1030
  ///
1031
  /// If this \a isUniqued() and not \a isResolved(), on a uniquing collision
1032
  /// this will be RAUW'ed and deleted.  Use a \a TrackingMDRef to keep track
1033
  /// of its movement if necessary.
1034
  /// @{
1035
1.13k
  void replaceElements(DINodeArray Elements) {
1036
#ifndef NDEBUG
1037
    for (DINode *Op : getElements())
1038
      assert(is_contained(Elements->operands(), Op) &&
1039
             "Lost a member during member list replacement");
1040
#endif
1041
    replaceOperandWith(4, Elements.get());
1042
1.13k
  }
1043
1044
845
  void replaceVTableHolder(DIType *VTableHolder) {
1045
845
    replaceOperandWith(5, VTableHolder);
1046
845
  }
1047
1048
317
  void replaceTemplateParams(DITemplateParameterArray TemplateParams) {
1049
317
    replaceOperandWith(6, TemplateParams.get());
1050
317
  }
1051
  /// @}
1052
1053
5.54k
  static bool classof(const Metadata *MD) {
1054
5.54k
    return MD->getMetadataID() == DICompositeTypeKind;
1055
5.54k
  }
1056
};
1057
1058
/// Type array for a subprogram.
1059
///
1060
/// TODO: Fold the array of types in directly as operands.
1061
class DISubroutineType : public DIType {
1062
  friend class LLVMContextImpl;
1063
  friend class MDNode;
1064
1065
  /// The calling convention used with DW_AT_calling_convention. Actually of
1066
  /// type dwarf::CallingConvention.
1067
  uint8_t CC;
1068
1069
  DISubroutineType(LLVMContext &C, StorageType Storage, DIFlags Flags,
1070
                   uint8_t CC, ArrayRef<Metadata *> Ops)
1071
      : DIType(C, DISubroutineTypeKind, Storage, dwarf::DW_TAG_subroutine_type,
1072
               0, 0, 0, 0, Flags, Ops),
1073
6.29k
        CC(CC) {}
1074
4.76k
  ~DISubroutineType() = default;
1075
1076
  static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags,
1077
                                   uint8_t CC, DITypeRefArray TypeArray,
1078
                                   StorageType Storage,
1079
119k
                                   bool ShouldCreate = true) {
1080
119k
    return getImpl(Context, Flags, CC, TypeArray.get(), Storage, ShouldCreate);
1081
119k
  }
1082
  static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags,
1083
                                   uint8_t CC, Metadata *TypeArray,
1084
                                   StorageType Storage,
1085
                                   bool ShouldCreate = true);
1086
1087
5
  TempDISubroutineType cloneImpl() const {
1088
5
    return getTemporary(getContext(), getFlags(), getCC(), getTypeArray());
1089
5
  }
1090
1091
public:
1092
  DEFINE_MDNODE_GET(DISubroutineType,
1093
                    (DIFlags Flags, uint8_t CC, DITypeRefArray TypeArray),
1094
                    (Flags, CC, TypeArray))
1095
  DEFINE_MDNODE_GET(DISubroutineType,
1096
                    (DIFlags Flags, uint8_t CC, Metadata *TypeArray),
1097
                    (Flags, CC, TypeArray))
1098
1099
  TempDISubroutineType clone() const { return cloneImpl(); }
1100
1101
133k
  uint8_t getCC() const { return CC; }
1102
1103
50.8k
  DITypeRefArray getTypeArray() const {
1104
50.8k
    return cast_or_null<MDTuple>(getRawTypeArray());
1105
50.8k
  }
1106
1107
193k
  Metadata *getRawTypeArray() const { return getOperand(3); }
1108
1109
17.4k
  static bool classof(const Metadata *MD) {
1110
17.4k
    return MD->getMetadataID() == DISubroutineTypeKind;
1111
17.4k
  }
1112
};
1113
1114
/// Compile unit.
1115
class DICompileUnit : public DIScope {
1116
  friend class LLVMContextImpl;
1117
  friend class MDNode;
1118
1119
public:
1120
  enum DebugEmissionKind : unsigned {
1121
    NoDebug = 0,
1122
    FullDebug,
1123
    LineTablesOnly,
1124
    DebugDirectivesOnly,
1125
    LastEmissionKind = DebugDirectivesOnly
1126
  };
1127
1128
  enum class DebugNameTableKind : unsigned {
1129
    Default = 0,
1130
    GNU = 1,
1131
    None = 2,
1132
    LastDebugNameTableKind = None
1133
  };
1134
1135
  static Optional<DebugEmissionKind> getEmissionKind(StringRef Str);
1136
  static const char *emissionKindString(DebugEmissionKind EK);
1137
  static Optional<DebugNameTableKind> getNameTableKind(StringRef Str);
1138
  static const char *nameTableKindString(DebugNameTableKind PK);
1139
1140
private:
1141
  unsigned SourceLanguage;
1142
  bool IsOptimized;
1143
  unsigned RuntimeVersion;
1144
  unsigned EmissionKind;
1145
  uint64_t DWOId;
1146
  bool SplitDebugInlining;
1147
  bool DebugInfoForProfiling;
1148
  unsigned NameTableKind;
1149
  bool RangesBaseAddress;
1150
1151
  DICompileUnit(LLVMContext &C, StorageType Storage, unsigned SourceLanguage,
1152
                bool IsOptimized, unsigned RuntimeVersion,
1153
                unsigned EmissionKind, uint64_t DWOId, bool SplitDebugInlining,
1154
                bool DebugInfoForProfiling, unsigned NameTableKind,
1155
                bool RangesBaseAddress, ArrayRef<Metadata *> Ops)
1156
      : DIScope(C, DICompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
1157
        SourceLanguage(SourceLanguage), IsOptimized(IsOptimized),
1158
        RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind),
1159
        DWOId(DWOId), SplitDebugInlining(SplitDebugInlining),
1160
        DebugInfoForProfiling(DebugInfoForProfiling),
1161
6.64k
        NameTableKind(NameTableKind), RangesBaseAddress(RangesBaseAddress) {
1162
6.64k
    assert(Storage != Uniqued);
1163
6.64k
  }
1164
4.36k
  ~DICompileUnit() = default;
1165
1166
  static DICompileUnit *
1167
  getImpl(LLVMContext &Context, unsigned SourceLanguage, DIFile *File,
1168
          StringRef Producer, bool IsOptimized, StringRef Flags,
1169
          unsigned RuntimeVersion, StringRef SplitDebugFilename,
1170
          unsigned EmissionKind, DICompositeTypeArray EnumTypes,
1171
          DIScopeArray RetainedTypes,
1172
          DIGlobalVariableExpressionArray GlobalVariables,
1173
          DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
1174
          uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
1175
          unsigned NameTableKind, bool RangesBaseAddress, StorageType Storage,
1176
3.79k
          bool ShouldCreate = true) {
1177
3.79k
    return getImpl(Context, SourceLanguage, File,
1178
3.79k
                   getCanonicalMDString(Context, Producer), IsOptimized,
1179
3.79k
                   getCanonicalMDString(Context, Flags), RuntimeVersion,
1180
3.79k
                   getCanonicalMDString(Context, SplitDebugFilename),
1181
3.79k
                   EmissionKind, EnumTypes.get(), RetainedTypes.get(),
1182
3.79k
                   GlobalVariables.get(), ImportedEntities.get(), Macros.get(),
1183
3.79k
                   DWOId, SplitDebugInlining, DebugInfoForProfiling,
1184
3.79k
                   NameTableKind, RangesBaseAddress, Storage, ShouldCreate);
1185
3.79k
  }
1186
  static DICompileUnit *
1187
  getImpl(LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
1188
          MDString *Producer, bool IsOptimized, MDString *Flags,
1189
          unsigned RuntimeVersion, MDString *SplitDebugFilename,
1190
          unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
1191
          Metadata *GlobalVariables, Metadata *ImportedEntities,
1192
          Metadata *Macros, uint64_t DWOId, bool SplitDebugInlining,
1193
          bool DebugInfoForProfiling, unsigned NameTableKind,
1194
          bool RangesBaseAddress, StorageType Storage, bool ShouldCreate = true);
1195
1196
133
  TempDICompileUnit cloneImpl() const {
1197
133
    return getTemporary(
1198
133
        getContext(), getSourceLanguage(), getFile(), getProducer(),
1199
133
        isOptimized(), getFlags(), getRuntimeVersion(), getSplitDebugFilename(),
1200
133
        getEmissionKind(), getEnumTypes(), getRetainedTypes(),
1201
133
        getGlobalVariables(), getImportedEntities(), getMacros(), DWOId,
1202
133
        getSplitDebugInlining(), getDebugInfoForProfiling(), getNameTableKind(),
1203
133
        getRangesBaseAddress());
1204
133
  }
1205
1206
public:
1207
  static void get() = delete;
1208
  static void getIfExists() = delete;
1209
1210
  DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(
1211
      DICompileUnit,
1212
      (unsigned SourceLanguage, DIFile *File, StringRef Producer,
1213
       bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,
1214
       StringRef SplitDebugFilename, DebugEmissionKind EmissionKind,
1215
       DICompositeTypeArray EnumTypes, DIScopeArray RetainedTypes,
1216
       DIGlobalVariableExpressionArray GlobalVariables,
1217
       DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
1218
       uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
1219
       DebugNameTableKind NameTableKind, bool RangesBaseAddress),
1220
      (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
1221
       SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
1222
       GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,
1223
       DebugInfoForProfiling, (unsigned)NameTableKind, RangesBaseAddress))
1224
  DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(
1225
      DICompileUnit,
1226
      (unsigned SourceLanguage, Metadata *File, MDString *Producer,
1227
       bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
1228
       MDString *SplitDebugFilename, unsigned EmissionKind, Metadata *EnumTypes,
1229
       Metadata *RetainedTypes, Metadata *GlobalVariables,
1230
       Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId,
1231
       bool SplitDebugInlining, bool DebugInfoForProfiling,
1232
       unsigned NameTableKind, bool RangesBaseAddress),
1233
      (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
1234
       SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
1235
       GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,
1236
       DebugInfoForProfiling, NameTableKind, RangesBaseAddress))
1237
1238
  TempDICompileUnit clone() const { return cloneImpl(); }
1239
1240
97.6k
  unsigned getSourceLanguage() const { return SourceLanguage; }
1241
4.48k
  bool isOptimized() const { return IsOptimized; }
1242
4.48k
  unsigned getRuntimeVersion() const { return RuntimeVersion; }
1243
5.85M
  DebugEmissionKind getEmissionKind() const {
1244
5.85M
    return (DebugEmissionKind)EmissionKind;
1245
5.85M
  }
1246
157k
  bool isDebugDirectivesOnly() const {
1247
157k
    return EmissionKind == DebugDirectivesOnly;
1248
157k
  }
1249
137k
  bool getDebugInfoForProfiling() const { return DebugInfoForProfiling; }
1250
104k
  DebugNameTableKind getNameTableKind() const {
1251
104k
    return (DebugNameTableKind)NameTableKind;
1252
104k
  }
1253
10.3k
  bool getRangesBaseAddress() const {
1254
10.3k
    return RangesBaseAddress; }
1255
4.37k
  StringRef getProducer() const {
1256
4.37k
    return getStringOperand(1); }
1257
6.35k
  StringRef getFlags() const {
1258
6.35k
    return getStringOperand(2); }
1259
1.52k
  StringRef getSplitDebugFilename() const {
1260
1.52k
    return getStringOperand(3); }
1261
13.7k
  DICompositeTypeArray getEnumTypes() const {
1262
13.7k
    return cast_or_null<MDTuple>(getRawEnumTypes());
1263
13.7k
  }
1264
11.1k
  DIScopeArray getRetainedTypes() const {
1265
11.1k
    return cast_or_null<MDTuple>(getRawRetainedTypes());
1266
11.1k
  }
1267
11.0k
  DIGlobalVariableExpressionArray getGlobalVariables() const {
1268
11.0k
    return cast_or_null<MDTuple>(getRawGlobalVariables());
1269
11.0k
  }
1270
10.1k
  DIImportedEntityArray getImportedEntities() const {
1271
10.1k
    return cast_or_null<MDTuple>(getRawImportedEntities());
1272
10.1k
  }
1273
9.14k
  DIMacroNodeArray getMacros() const {
1274
9.14k
    return cast_or_null<MDTuple>(getRawMacros());
1275
9.14k
  }
1276
8.47k
  uint64_t getDWOId() const { return DWOId; }
1277
23
  void setDWOId(uint64_t DwoId) { DWOId = DwoId; }
1278
2.35k
  bool getSplitDebugInlining() const { return SplitDebugInlining; }
1279
0
  void setSplitDebugInlining(bool SplitDebugInlining) {
1280
0
    this->SplitDebugInlining = SplitDebugInlining;
1281
0
  }
1282
1283
794
  MDString *getRawProducer() const { return getOperandAs<MDString>(1); }
1284
796
  MDString *getRawFlags() const { return getOperandAs<MDString>(2); }
1285
796
  MDString *getRawSplitDebugFilename() const {
1286
796
    return getOperandAs<MDString>(3);
1287
796
  }
1288
25.2k
  Metadata *getRawEnumTypes() const { return getOperand(4); }
1289
22.6k
  Metadata *getRawRetainedTypes() const { return getOperand(5); }
1290
22.5k
  Metadata *getRawGlobalVariables() const { return getOperand(6); }
1291
21.6k
  Metadata *getRawImportedEntities() const { return getOperand(7); }
1292
20.6k
  Metadata *getRawMacros() const { return getOperand(8); }
1293
1294
  /// Replace arrays.
1295
  ///
1296
  /// If this \a isUniqued() and not \a isResolved(), it will be RAUW'ed and
1297
  /// deleted on a uniquing collision.  In practice, uniquing collisions on \a
1298
  /// DICompileUnit should be fairly rare.
1299
  /// @{
1300
3.64k
  void replaceEnumTypes(DICompositeTypeArray N) {
1301
3.64k
    replaceOperandWith(4, N.get());
1302
3.64k
  }
1303
118
  void replaceRetainedTypes(DITypeArray N) {
1304
118
    replaceOperandWith(5, N.get());
1305
118
  }
1306
187
  void replaceGlobalVariables(DIGlobalVariableExpressionArray N) {
1307
187
    replaceOperandWith(6, N.get());
1308
187
  }
1309
18
  void replaceImportedEntities(DIImportedEntityArray N) {
1310
18
    replaceOperandWith(7, N.get());
1311
18
  }
1312
8
  void replaceMacros(DIMacroNodeArray N) { replaceOperandWith(8, N.get()); }
1313
  /// @}
1314
1315
228k
  static bool classof(const Metadata *MD) {
1316
228k
    return MD->getMetadataID() == DICompileUnitKind;
1317
228k
  }
1318
};
1319
1320
/// A scope for locals.
1321
///
1322
/// A legal scope for lexical blocks, local variables, and debug info
1323
/// locations.  Subclasses are \a DISubprogram, \a DILexicalBlock, and \a
1324
/// DILexicalBlockFile.
1325
class DILocalScope : public DIScope {
1326
protected:
1327
  DILocalScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
1328
               ArrayRef<Metadata *> Ops)
1329
126k
      : DIScope(C, ID, Storage, Tag, Ops) {}
1330
11.5k
  ~DILocalScope() = default;
1331
1332
public:
1333
  /// Get the subprogram for this scope.
1334
  ///
1335
  /// Return this if it's an \a DISubprogram; otherwise, look up the scope
1336
  /// chain.
1337
  DISubprogram *getSubprogram() const;
1338
1339
  /// Get the first non DILexicalBlockFile scope of this scope.
1340
  ///
1341
  /// Return this if it's not a \a DILexicalBlockFIle; otherwise, look up the
1342
  /// scope chain.
1343
  DILocalScope *getNonLexicalBlockFileScope() const;
1344
1345
548k
  static bool classof(const Metadata *MD) {
1346
548k
    return MD->getMetadataID() == DISubprogramKind ||
1347
548k
           
MD->getMetadataID() == DILexicalBlockKind38.0k
||
1348
548k
           
MD->getMetadataID() == DILexicalBlockFileKind14.9k
;
1349
548k
  }
1350
};
1351
1352
/// Debug location.
1353
///
1354
/// A debug location in source code, used for debug info and otherwise.
1355
class DILocation : public MDNode {
1356
  friend class LLVMContextImpl;
1357
  friend class MDNode;
1358
1359
  DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
1360
             unsigned Column, ArrayRef<Metadata *> MDs, bool ImplicitCode);
1361
29.4k
  ~DILocation() { dropAllReferences(); }
1362
1363
  static DILocation *getImpl(LLVMContext &Context, unsigned Line,
1364
                             unsigned Column, Metadata *Scope,
1365
                             Metadata *InlinedAt, bool ImplicitCode,
1366
                             StorageType Storage, bool ShouldCreate = true);
1367
  static DILocation *getImpl(LLVMContext &Context, unsigned Line,
1368
                             unsigned Column, DILocalScope *Scope,
1369
                             DILocation *InlinedAt, bool ImplicitCode,
1370
612k
                             StorageType Storage, bool ShouldCreate = true) {
1371
612k
    return getImpl(Context, Line, Column, static_cast<Metadata *>(Scope),
1372
612k
                   static_cast<Metadata *>(InlinedAt), ImplicitCode, Storage,
1373
612k
                   ShouldCreate);
1374
612k
  }
1375
1376
  /// With a given unsigned int \p U, use up to 13 bits to represent it.
1377
  /// old_bit 1~5  --> new_bit 1~5
1378
  /// old_bit 6~12 --> new_bit 7~13
1379
  /// new_bit_6 is 0 if higher bits (7~13) are all 0
1380
385
  static unsigned getPrefixEncodingFromUnsigned(unsigned U) {
1381
385
    U &= 0xfff;
1382
385
    return U > 0x1f ? 
(((U & 0xfe0) << 1) | (U & 0x1f) | 0x20)77
:
U308
;
1383
385
  }
1384
1385
  /// Reverse transformation as getPrefixEncodingFromUnsigned.
1386
3.64k
  static unsigned getUnsignedFromPrefixEncoding(unsigned U) {
1387
3.64k
    if (U & 1)
1388
186
      return 0;
1389
3.45k
    U >>= 1;
1390
3.45k
    return (U & 0x20) ? 
(((U >> 1) & 0xfe0) | (U & 0x1f))80
:
(U & 0x1f)3.37k
;
1391
3.45k
  }
1392
1393
  /// Returns the next component stored in discriminator.
1394
2.13k
  static unsigned getNextComponentInDiscriminator(unsigned D) {
1395
2.13k
    if ((D & 1) == 0)
1396
1.77k
      return D >> ((D & 0x40) ? 
1484
:
71.69k
);
1397
352
    else
1398
352
      return D >> 1;
1399
2.13k
  }
1400
1401
196
  TempDILocation cloneImpl() const {
1402
196
    // Get the raw scope/inlinedAt since it is possible to invoke this on
1403
196
    // a DILocation containing temporary metadata.
1404
196
    return getTemporary(getContext(), getLine(), getColumn(), getRawScope(),
1405
196
                        getRawInlinedAt(), isImplicitCode());
1406
196
  }
1407
1408
505
  static unsigned encodeComponent(unsigned C) {
1409
505
    return (C == 0) ? 
1U120
:
(getPrefixEncodingFromUnsigned(C) << 1)385
;
1410
505
  }
1411
1412
505
  static unsigned encodingBits(unsigned C) {
1413
505
    return (C == 0) ? 
1120
:
(C > 0x1f 385
?
1483
:
7302
);
1414
505
  }
1415
1416
public:
1417
  // Disallow replacing operands.
1418
  void replaceOperandWith(unsigned I, Metadata *New) = delete;
1419
1420
  DEFINE_MDNODE_GET(DILocation,
1421
                    (unsigned Line, unsigned Column, Metadata *Scope,
1422
                     Metadata *InlinedAt = nullptr, bool ImplicitCode = false),
1423
                    (Line, Column, Scope, InlinedAt, ImplicitCode))
1424
  DEFINE_MDNODE_GET(DILocation,
1425
                    (unsigned Line, unsigned Column, DILocalScope *Scope,
1426
                     DILocation *InlinedAt = nullptr,
1427
                     bool ImplicitCode = false),
1428
                    (Line, Column, Scope, InlinedAt, ImplicitCode))
1429
1430
  /// Return a (temporary) clone of this.
1431
  TempDILocation clone() const { return cloneImpl(); }
1432
1433
34.2M
  unsigned getLine() const { return SubclassData32; }
1434
17.2M
  unsigned getColumn() const { return SubclassData16; }
1435
10.4M
  DILocalScope *getScope() const { return cast<DILocalScope>(getRawScope()); }
1436
1437
17.2M
  DILocation *getInlinedAt() const {
1438
17.2M
    return cast_or_null<DILocation>(getRawInlinedAt());
1439
17.2M
  }
1440
1441
  /// Check if the location corresponds to an implicit code.
1442
  /// When the ImplicitCode flag is true, it means that the Instruction
1443
  /// with this DILocation has been added by the front-end but it hasn't been
1444
  /// written explicitly by the user (e.g. cleanup stuff in C++ put on a closing
1445
  /// bracket). It's useful for code coverage to not show a counter on "empty"
1446
  /// lines.
1447
13.1M
  bool isImplicitCode() const { return ImplicitCode; }
1448
3.80M
  void setImplicitCode(bool ImplicitCode) { this->ImplicitCode = ImplicitCode; }
1449
1450
309k
  DIFile *getFile() const { return getScope()->getFile(); }
1451
1.83k
  StringRef getFilename() const { return getScope()->getFilename(); }
1452
0
  StringRef getDirectory() const { return getScope()->getDirectory(); }
1453
0
  Optional<StringRef> getSource() const { return getScope()->getSource(); }
1454
1455
  /// Get the scope where this is inlined.
1456
  ///
1457
  /// Walk through \a getInlinedAt() and return \a getScope() from the deepest
1458
  /// location.
1459
97.0k
  DILocalScope *getInlinedAtScope() const {
1460
97.0k
    if (auto *IA = getInlinedAt())
1461
15.9k
      return IA->getInlinedAtScope();
1462
81.0k
    return getScope();
1463
81.0k
  }
1464
1465
  /// Get the DWARF discriminator.
1466
  ///
1467
  /// DWARF discriminators distinguish identical file locations between
1468
  /// instructions that are on different basic blocks.
1469
  ///
1470
  /// There are 3 components stored in discriminator, from lower bits:
1471
  ///
1472
  /// Base discriminator: assigned by AddDiscriminators pass to identify IRs
1473
  ///                     that are defined by the same source line, but
1474
  ///                     different basic blocks.
1475
  /// Duplication factor: assigned by optimizations that will scale down
1476
  ///                     the execution frequency of the original IR.
1477
  /// Copy Identifier: assigned by optimizations that clones the IR.
1478
  ///                  Each copy of the IR will be assigned an identifier.
1479
  ///
1480
  /// Encoding:
1481
  ///
1482
  /// The above 3 components are encoded into a 32bit unsigned integer in
1483
  /// order. If the lowest bit is 1, the current component is empty, and the
1484
  /// next component will start in the next bit. Otherwise, the current
1485
  /// component is non-empty, and its content starts in the next bit. The
1486
  /// value of each components is either 5 bit or 12 bit: if the 7th bit
1487
  /// is 0, the bit 2~6 (5 bits) are used to represent the component; if the
1488
  /// 7th bit is 1, the bit 2~6 (5 bits) and 8~14 (7 bits) are combined to
1489
  /// represent the component. Thus, the number of bits used for a component
1490
  /// is either 0 (if it and all the next components are empty); 1 - if it is
1491
  /// empty; 7 - if its value is up to and including 0x1f (lsb and msb are both
1492
  /// 0); or 14, if its value is up to and including 0x1ff. Note that the last
1493
  /// component is also capped at 0x1ff, even in the case when both first
1494
  /// components are 0, and we'd technically have 29 bits available.
1495
  ///
1496
  /// For precise control over the data being encoded in the discriminator,
1497
  /// use encodeDiscriminator/decodeDiscriminator.
1498
1499
  inline unsigned getDiscriminator() const;
1500
1501
  /// Returns a new DILocation with updated \p Discriminator.
1502
  inline const DILocation *cloneWithDiscriminator(unsigned Discriminator) const;
1503
1504
  /// Returns a new DILocation with updated base discriminator \p BD. Only the
1505
  /// base discriminator is set in the new DILocation, the other encoded values
1506
  /// are elided.
1507
  /// If the discriminator cannot be encoded, the function returns None.
1508
  inline Optional<const DILocation *> cloneWithBaseDiscriminator(unsigned BD) const;
1509
1510
  /// Returns the duplication factor stored in the discriminator, or 1 if no
1511
  /// duplication factor (or 0) is encoded.
1512
  inline unsigned getDuplicationFactor() const;
1513
1514
  /// Returns the copy identifier stored in the discriminator.
1515
  inline unsigned getCopyIdentifier() const;
1516
1517
  /// Returns the base discriminator stored in the discriminator.
1518
  inline unsigned getBaseDiscriminator() const;
1519
1520
  /// Returns a new DILocation with duplication factor \p DF * current
1521
  /// duplication factor encoded in the discriminator. The current duplication
1522
  /// factor is as defined by getDuplicationFactor().
1523
  /// Returns None if encoding failed.
1524
  inline Optional<const DILocation *> cloneByMultiplyingDuplicationFactor(unsigned DF) const;
1525
1526
  /// When two instructions are combined into a single instruction we also
1527
  /// need to combine the original locations into a single location.
1528
  ///
1529
  /// When the locations are the same we can use either location. When they
1530
  /// differ, we need a third location which is distinct from either. If they
1531
  /// have the same file/line but have a different discriminator we could
1532
  /// create a location with a new discriminator. If they are from different
1533
  /// files/lines the location is ambiguous and can't be represented in a line
1534
  /// entry. In this case, if \p GenerateLocation is true, we will set the
1535
  /// merged debug location as line 0 of the nearest common scope where the two
1536
  /// locations are inlined from.
1537
  ///
1538
  /// \p GenerateLocation: Whether the merged location can be generated when
1539
  /// \p LocA and \p LocB differ.
1540
  static const DILocation *getMergedLocation(const DILocation *LocA,
1541
                                             const DILocation *LocB);
1542
1543
  /// Returns the base discriminator for a given encoded discriminator \p D.
1544
1.62k
  static unsigned getBaseDiscriminatorFromDiscriminator(unsigned D) {
1545
1.62k
    return getUnsignedFromPrefixEncoding(D);
1546
1.62k
  }
1547
1548
  /// Raw encoding of the discriminator. APIs such as cloneWithDuplicationFactor
1549
  /// have certain special case behavior (e.g. treating empty duplication factor
1550
  /// as the value '1').
1551
  /// This API, in conjunction with cloneWithDiscriminator, may be used to encode
1552
  /// the raw values provided. \p BD: base discriminator \p DF: duplication factor
1553
  /// \p CI: copy index
1554
  /// The return is None if the values cannot be encoded in 32 bits - for
1555
  /// example, values for BD or DF larger than 12 bits. Otherwise, the return
1556
  /// is the encoded value.
1557
  static Optional<unsigned> encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI);
1558
1559
  /// Raw decoder for values in an encoded discriminator D.
1560
  static void decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF,
1561
                                  unsigned &CI);
1562
1563
  /// Returns the duplication factor for a given encoded discriminator \p D, or
1564
  /// 1 if no value or 0 is encoded.
1565
124
  static unsigned getDuplicationFactorFromDiscriminator(unsigned D) {
1566
124
    D = getNextComponentInDiscriminator(D);
1567
124
    unsigned Ret = getUnsignedFromPrefixEncoding(D);
1568
124
    if (Ret == 0)
1569
60
      return 1;
1570
64
    return Ret;
1571
64
  }
1572
1573
  /// Returns the copy identifier for a given encoded discriminator \p D.
1574
114
  static unsigned getCopyIdentifierFromDiscriminator(unsigned D) {
1575
114
    return getUnsignedFromPrefixEncoding(getNextComponentInDiscriminator(
1576
114
        getNextComponentInDiscriminator(D)));
1577
114
  }
1578
1579
1580
23.8M
  Metadata *getRawScope() const { return getOperand(0); }
1581
30.4M
  Metadata *getRawInlinedAt() const {
1582
30.4M
    if (getNumOperands() == 2)
1583
7.97M
      return getOperand(1);
1584
22.4M
    return nullptr;
1585
22.4M
  }
1586
1587
281k
  static bool classof(const Metadata *MD) {
1588
281k
    return MD->getMetadataID() == DILocationKind;
1589
281k
  }
1590
};
1591
1592
/// Subprogram description.
1593
class DISubprogram : public DILocalScope {
1594
  friend class LLVMContextImpl;
1595
  friend class MDNode;
1596
1597
  unsigned Line;
1598
  unsigned ScopeLine;
1599
  unsigned VirtualIndex;
1600
1601
  /// In the MS ABI, the implicit 'this' parameter is adjusted in the prologue
1602
  /// of method overrides from secondary bases by this amount. It may be
1603
  /// negative.
1604
  int ThisAdjustment;
1605
1606
public:
1607
  /// Debug info subprogram flags.
1608
  enum DISPFlags : uint32_t {
1609
#define HANDLE_DISP_FLAG(ID, NAME) SPFlag##NAME = ID,
1610
#define DISP_FLAG_LARGEST_NEEDED
1611
#include "llvm/IR/DebugInfoFlags.def"
1612
    SPFlagNonvirtual = SPFlagZero,
1613
    SPFlagVirtuality = SPFlagVirtual | SPFlagPureVirtual,
1614
    LLVM_MARK_AS_BITMASK_ENUM(SPFlagLargest)
1615
  };
1616
1617
  static DISPFlags getFlag(StringRef Flag);
1618
  static StringRef getFlagString(DISPFlags Flag);
1619
1620
  /// Split up a flags bitfield for easier printing.
1621
  ///
1622
  /// Split \c Flags into \c SplitFlags, a vector of its components.  Returns
1623
  /// any remaining (unrecognized) bits.
1624
  static DISPFlags splitFlags(DISPFlags Flags,
1625
                              SmallVectorImpl<DISPFlags> &SplitFlags);
1626
1627
  // Helper for converting old bitfields to new flags word.
1628
  static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition,
1629
                             bool IsOptimized,
1630
                             unsigned Virtuality = SPFlagNonvirtual,
1631
3.37k
                             bool IsMainSubprogram = false) {
1632
3.37k
    // We're assuming virtuality is the low-order field.
1633
3.37k
    static_assert(
1634
3.37k
        int(SPFlagVirtual) == int(dwarf::DW_VIRTUALITY_virtual) &&
1635
3.37k
            int(SPFlagPureVirtual) == int(dwarf::DW_VIRTUALITY_pure_virtual),
1636
3.37k
        "Virtuality constant mismatch");
1637
3.37k
    return static_cast<DISPFlags>(
1638
3.37k
        (Virtuality & SPFlagVirtuality) |
1639
3.37k
        (IsLocalToUnit ? 
SPFlagLocalToUnit296
:
SPFlagZero3.08k
) |
1640
3.37k
        (IsDefinition ? 
SPFlagDefinition2.67k
:
SPFlagZero700
) |
1641
3.37k
        (IsOptimized ? 
SPFlagOptimized1.45k
:
SPFlagZero1.92k
) |
1642
3.37k
        (IsMainSubprogram ? 
SPFlagMainSubprogram0
: SPFlagZero));
1643
3.37k
  }
1644
1645
private:
1646
  DIFlags Flags;
1647
  DISPFlags SPFlags;
1648
1649
  DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
1650
               unsigned ScopeLine, unsigned VirtualIndex, int ThisAdjustment,
1651
               DIFlags Flags, DISPFlags SPFlags, ArrayRef<Metadata *> Ops)
1652
      : DILocalScope(C, DISubprogramKind, Storage, dwarf::DW_TAG_subprogram,
1653
                     Ops),
1654
        Line(Line), ScopeLine(ScopeLine), VirtualIndex(VirtualIndex),
1655
123k
        ThisAdjustment(ThisAdjustment), Flags(Flags), SPFlags(SPFlags) {
1656
123k
    static_assert(dwarf::DW_VIRTUALITY_max < 4, "Virtuality out of range");
1657
123k
  }
1658
8.92k
  ~DISubprogram() = default;
1659
1660
  static DISubprogram *
1661
  getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
1662
          StringRef LinkageName, DIFile *File, unsigned Line,
1663
          DISubroutineType *Type, unsigned ScopeLine, DIType *ContainingType,
1664
          unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
1665
          DISPFlags SPFlags, DICompileUnit *Unit,
1666
          DITemplateParameterArray TemplateParams, DISubprogram *Declaration,
1667
          DINodeArray RetainedNodes, DITypeArray ThrownTypes,
1668
119k
          StorageType Storage, bool ShouldCreate = true) {
1669
119k
    return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
1670
119k
                   getCanonicalMDString(Context, LinkageName), File, Line, Type,
1671
119k
                   ScopeLine, ContainingType, VirtualIndex, ThisAdjustment,
1672
119k
                   Flags, SPFlags, Unit, TemplateParams.get(), Declaration,
1673
119k
                   RetainedNodes.get(), ThrownTypes.get(), Storage,
1674
119k
                   ShouldCreate);
1675
119k
  }
1676
  static DISubprogram *getImpl(LLVMContext &Context, Metadata *Scope,
1677
                               MDString *Name, MDString *LinkageName,
1678
                               Metadata *File, unsigned Line, Metadata *Type,
1679
                               unsigned ScopeLine, Metadata *ContainingType,
1680
                               unsigned VirtualIndex, int ThisAdjustment,
1681
                               DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
1682
                               Metadata *TemplateParams, Metadata *Declaration,
1683
                               Metadata *RetainedNodes, Metadata *ThrownTypes,
1684
                               StorageType Storage, bool ShouldCreate = true);
1685
1686
35
  TempDISubprogram cloneImpl() const {
1687
35
    return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
1688
35
                        getFile(), getLine(), getType(), getScopeLine(),
1689
35
                        getContainingType(), getVirtualIndex(),
1690
35
                        getThisAdjustment(), getFlags(), getSPFlags(),
1691
35
                        getUnit(), getTemplateParams(), getDeclaration(),
1692
35
                        getRetainedNodes(), getThrownTypes());
1693
35
  }
1694
1695
public:
1696
  DEFINE_MDNODE_GET(
1697
      DISubprogram,
1698
      (DIScope * Scope, StringRef Name, StringRef LinkageName, DIFile *File,
1699
       unsigned Line, DISubroutineType *Type, unsigned ScopeLine,
1700
       DIType *ContainingType, unsigned VirtualIndex, int ThisAdjustment,
1701
       DIFlags Flags, DISPFlags SPFlags, DICompileUnit *Unit,
1702
       DITemplateParameterArray TemplateParams = nullptr,
1703
       DISubprogram *Declaration = nullptr, DINodeArray RetainedNodes = nullptr,
1704
       DITypeArray ThrownTypes = nullptr),
1705
      (Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType,
1706
       VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams,
1707
       Declaration, RetainedNodes, ThrownTypes))
1708
1709
  DEFINE_MDNODE_GET(
1710
      DISubprogram,
1711
      (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
1712
       unsigned Line, Metadata *Type, unsigned ScopeLine,
1713
       Metadata *ContainingType, unsigned VirtualIndex, int ThisAdjustment,
1714
       DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
1715
       Metadata *TemplateParams = nullptr, Metadata *Declaration = nullptr,
1716
       Metadata *RetainedNodes = nullptr, Metadata *ThrownTypes = nullptr),
1717
      (Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType,
1718
       VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams,
1719
       Declaration, RetainedNodes, ThrownTypes))
1720
1721
4
  TempDISubprogram clone() const { return cloneImpl(); }
1722
1723
  /// Returns a new temporary DISubprogram with updated Flags
1724
1
  TempDISubprogram cloneWithFlags(DIFlags NewFlags) const {
1725
1
    auto NewSP = clone();
1726
1
    NewSP->Flags = NewFlags;
1727
1
    return NewSP;
1728
1
  }
1729
1730
public:
1731
14.6k
  unsigned getLine() const { return Line; }
1732
6.58k
  unsigned getVirtuality() const { return getSPFlags() & SPFlagVirtuality; }
1733
10.5k
  unsigned getVirtualIndex() const { return VirtualIndex; }
1734
10.4k
  int getThisAdjustment() const { return ThisAdjustment; }
1735
82.2k
  unsigned getScopeLine() const { return ScopeLine; }
1736
2.34M
  DIFlags getFlags() const { return Flags; }
1737
545k
  DISPFlags getSPFlags() const { return SPFlags; }
1738
1.44k
  bool isLocalToUnit() const { return getSPFlags() & SPFlagLocalToUnit; }
1739
520k
  bool isDefinition() const { return getSPFlags() & SPFlagDefinition; }
1740
654
  bool isOptimized() const { return getSPFlags() & SPFlagOptimized; }
1741
1.44k
  bool isMainSubprogram() const { return getSPFlags() & SPFlagMainSubprogram; }
1742
1743
1.59k
  bool isArtificial() const { return getFlags() & FlagArtificial; }
1744
1.44k
  bool isPrivate() const {
1745
1.44k
    return (getFlags() & FlagAccessibility) == FlagPrivate;
1746
1.44k
  }
1747
1.44k
  bool isProtected() const {
1748
1.44k
    return (getFlags() & FlagAccessibility) == FlagProtected;
1749
1.44k
  }
1750
1.42k
  bool isPublic() const {
1751
1.42k
    return (getFlags() & FlagAccessibility) == FlagPublic;
1752
1.42k
  }
1753
1.44k
  bool isExplicit() const { return getFlags() & FlagExplicit; }
1754
1.44k
  bool isPrototyped() const { return getFlags() & FlagPrototyped; }
1755
2.30M
  bool areAllCallsDescribed() const {
1756
2.30M
    return getFlags() & FlagAllCallsDescribed;
1757
2.30M
  }
1758
1.44k
  bool isPure() const { return getSPFlags() & SPFlagPure; }
1759
1.44k
  bool isElemental() const { return getSPFlags() & SPFlagElemental; }
1760
1.44k
  bool isRecursive() const { return getSPFlags() & SPFlagRecursive; }
1761
1762
  /// Check if this is reference-qualified.
1763
  ///
1764
  /// Return true if this subprogram is a C++11 reference-qualified non-static
1765
  /// member function (void foo() &).
1766
1.44k
  bool isLValueReference() const { return getFlags() & FlagLValueReference; }
1767
1768
  /// Check if this is rvalue-reference-qualified.
1769
  ///
1770
  /// Return true if this subprogram is a C++11 rvalue-reference-qualified
1771
  /// non-static member function (void foo() &&).
1772
1.44k
  bool isRValueReference() const { return getFlags() & FlagRValueReference; }
1773
1774
  /// Check if this is marked as noreturn.
1775
  ///
1776
  /// Return true if this subprogram is C++11 noreturn or C11 _Noreturn
1777
1.44k
  bool isNoReturn() const { return getFlags() & FlagNoReturn; }
1778
1779
  // Check if this routine is a compiler-generated thunk.
1780
  //
1781
  // Returns true if this subprogram is a thunk generated by the compiler.
1782
370
  bool isThunk() const { return getFlags() & FlagThunk; }
1783
1784
461k
  DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
1785
1786
1.22M
  StringRef getName() const { return getStringOperand(2); }
1787
323k
  StringRef getLinkageName() const { return getStringOperand(3); }
1788
1789
38.4k
  DISubroutineType *getType() const {
1790
38.4k
    return cast_or_null<DISubroutineType>(getRawType());
1791
38.4k
  }
1792
761
  DIType *getContainingType() const {
1793
761
    return cast_or_null<DIType>(getRawContainingType());
1794
761
  }
1795
1796
5.47M
  DICompileUnit *getUnit() const {
1797
5.47M
    return cast_or_null<DICompileUnit>(getRawUnit());
1798
5.47M
  }
1799
21
  void replaceUnit(DICompileUnit *CU) { replaceOperandWith(5, CU); }
1800
2.39k
  DITemplateParameterArray getTemplateParams() const {
1801
2.39k
    return cast_or_null<MDTuple>(getRawTemplateParams());
1802
2.39k
  }
1803
128k
  DISubprogram *getDeclaration() const {
1804
128k
    return cast_or_null<DISubprogram>(getRawDeclaration());
1805
128k
  }
1806
438k
  DINodeArray getRetainedNodes() const {
1807
438k
    return cast_or_null<MDTuple>(getRawRetainedNodes());
1808
438k
  }
1809
2.17k
  DITypeArray getThrownTypes() const {
1810
2.17k
    return cast_or_null<MDTuple>(getRawThrownTypes());
1811
2.17k
  }
1812
1813
491k
  Metadata *getRawScope() const { return getOperand(1); }
1814
6.00k
  MDString *getRawName() const { return getOperandAs<MDString>(2); }
1815
6.88k
  MDString *getRawLinkageName() const { return getOperandAs<MDString>(3); }
1816
65.2k
  Metadata *getRawType() const { return getOperand(4); }
1817
5.49M
  Metadata *getRawUnit() const { return getOperand(5); }
1818
154k
  Metadata *getRawDeclaration() const { return getOperand(6); }
1819
465k
  Metadata *getRawRetainedNodes() const { return getOperand(7); }
1820
27.5k
  Metadata *getRawContainingType() const {
1821
27.5k
    return getNumOperands() > 8 ? 
getOperandAs<Metadata>(8)3.42k
:
nullptr24.0k
;
1822
27.5k
  }
1823
30.6k
  Metadata *getRawTemplateParams() const {
1824
30.6k
    return getNumOperands() > 9 ? 
getOperandAs<Metadata>(9)1.68k
:
nullptr28.9k
;
1825
30.6k
  }
1826
28.8k
  Metadata *getRawThrownTypes() const {
1827
28.8k
    return getNumOperands() > 10 ? 
getOperandAs<Metadata>(10)72
:
nullptr28.7k
;
1828
28.8k
  }
1829
1830
  /// Check if this subprogram describes the given function.
1831
  ///
1832
  /// FIXME: Should this be looking through bitcasts?
1833
  bool describes(const Function *F) const;
1834
1835
2.31M
  static bool classof(const Metadata *MD) {
1836
2.31M
    return MD->getMetadataID() == DISubprogramKind;
1837
2.31M
  }
1838
};
1839
1840
class DILexicalBlockBase : public DILocalScope {
1841
protected:
1842
  DILexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage,
1843
                     ArrayRef<Metadata *> Ops)
1844
3.18k
      : DILocalScope(C, ID, Storage, dwarf::DW_TAG_lexical_block, Ops) {}
1845
2.64k
  ~DILexicalBlockBase() = default;
1846
1847
public:
1848
266k
  DILocalScope *getScope() const { return cast<DILocalScope>(getRawScope()); }
1849
1850
293k
  Metadata *getRawScope() const { return getOperand(1); }
1851
1852
4.65M
  static bool classof(const Metadata *MD) {
1853
4.65M
    return MD->getMetadataID() == DILexicalBlockKind ||
1854
4.65M
           
MD->getMetadataID() == DILexicalBlockFileKind4.64M
;
1855
4.65M
  }
1856
};
1857
1858
class DILexicalBlock : public DILexicalBlockBase {
1859
  friend class LLVMContextImpl;
1860
  friend class MDNode;
1861
1862
  unsigned Line;
1863
  uint16_t Column;
1864
1865
  DILexicalBlock(LLVMContext &C, StorageType Storage, unsigned Line,
1866
                 unsigned Column, ArrayRef<Metadata *> Ops)
1867
      : DILexicalBlockBase(C, DILexicalBlockKind, Storage, Ops), Line(Line),
1868
2.19k
        Column(Column) {
1869
2.19k
    assert(Column < (1u << 16) && "Expected 16-bit column");
1870
2.19k
  }
1871
2.17k
  ~DILexicalBlock() = default;
1872
1873
  static DILexicalBlock *getImpl(LLVMContext &Context, DILocalScope *Scope,
1874
                                 DIFile *File, unsigned Line, unsigned Column,
1875
                                 StorageType Storage,
1876
37
                                 bool ShouldCreate = true) {
1877
37
    return getImpl(Context, static_cast<Metadata *>(Scope),
1878
37
                   static_cast<Metadata *>(File), Line, Column, Storage,
1879
37
                   ShouldCreate);
1880
37
  }
1881
1882
  static DILexicalBlock *getImpl(LLVMContext &Context, Metadata *Scope,
1883
                                 Metadata *File, unsigned Line, unsigned Column,
1884
                                 StorageType Storage, bool ShouldCreate = true);
1885
1886
26
  TempDILexicalBlock cloneImpl() const {
1887
26
    return getTemporary(getContext(), getScope(), getFile(), getLine(),
1888
26
                        getColumn());
1889
26
  }
1890
1891
public:
1892
  DEFINE_MDNODE_GET(DILexicalBlock, (DILocalScope * Scope, DIFile *File,
1893
                                     unsigned Line, unsigned Column),
1894
                    (Scope, File, Line, Column))
1895
  DEFINE_MDNODE_GET(DILexicalBlock, (Metadata * Scope, Metadata *File,
1896
                                     unsigned Line, unsigned Column),
1897
                    (Scope, File, Line, Column))
1898
1899
  TempDILexicalBlock clone() const { return cloneImpl(); }
1900
1901
5.64k
  unsigned getLine() const { return Line; }
1902
1.14k
  unsigned getColumn() const { return Column; }
1903
1904
873
  static bool classof(const Metadata *MD) {
1905
873
    return MD->getMetadataID() == DILexicalBlockKind;
1906
873
  }
1907
};
1908
1909
class DILexicalBlockFile : public DILexicalBlockBase {
1910
  friend class LLVMContextImpl;
1911
  friend class MDNode;
1912
1913
  unsigned Discriminator;
1914
1915
  DILexicalBlockFile(LLVMContext &C, StorageType Storage,
1916
                     unsigned Discriminator, ArrayRef<Metadata *> Ops)
1917
      : DILexicalBlockBase(C, DILexicalBlockFileKind, Storage, Ops),
1918
986
        Discriminator(Discriminator) {}
1919
464
  ~DILexicalBlockFile() = default;
1920
1921
  static DILexicalBlockFile *getImpl(LLVMContext &Context, DILocalScope *Scope,
1922
                                     DIFile *File, unsigned Discriminator,
1923
                                     StorageType Storage,
1924
6
                                     bool ShouldCreate = true) {
1925
6
    return getImpl(Context, static_cast<Metadata *>(Scope),
1926
6
                   static_cast<Metadata *>(File), Discriminator, Storage,
1927
6
                   ShouldCreate);
1928
6
  }
1929
1930
  static DILexicalBlockFile *getImpl(LLVMContext &Context, Metadata *Scope,
1931
                                     Metadata *File, unsigned Discriminator,
1932
                                     StorageType Storage,
1933
                                     bool ShouldCreate = true);
1934
1935
1
  TempDILexicalBlockFile cloneImpl() const {
1936
1
    return getTemporary(getContext(), getScope(), getFile(),
1937
1
                        getDiscriminator());
1938
1
  }
1939
1940
public:
1941
  DEFINE_MDNODE_GET(DILexicalBlockFile, (DILocalScope * Scope, DIFile *File,
1942
                                         unsigned Discriminator),
1943
                    (Scope, File, Discriminator))
1944
  DEFINE_MDNODE_GET(DILexicalBlockFile,
1945
                    (Metadata * Scope, Metadata *File, unsigned Discriminator),
1946
                    (Scope, File, Discriminator))
1947
1948
  TempDILexicalBlockFile clone() const { return cloneImpl(); }
1949
1950
  // TODO: Remove these once they're gone from DILexicalBlockBase.
1951
  unsigned getLine() const = delete;
1952
  unsigned getColumn() const = delete;
1953
1954
14.8k
  unsigned getDiscriminator() const { return Discriminator; }
1955
1956
6.43M
  static bool classof(const Metadata *MD) {
1957
6.43M
    return MD->getMetadataID() == DILexicalBlockFileKind;
1958
6.43M
  }
1959
};
1960
1961
281k
unsigned DILocation::getDiscriminator() const {
1962
281k
  if (auto *F = dyn_cast<DILexicalBlockFile>(getScope()))
1963
12.5k
    return F->getDiscriminator();
1964
268k
  return 0;
1965
268k
}
1966
1967
const DILocation *
1968
340
DILocation::cloneWithDiscriminator(unsigned Discriminator) const {
1969
340
  DIScope *Scope = getScope();
1970
340
  // Skip all parent DILexicalBlockFile that already have a discriminator
1971
340
  // assigned. We do not want to have nested DILexicalBlockFiles that have
1972
340
  // mutliple discriminators because only the leaf DILexicalBlockFile's
1973
340
  // dominator will be used.
1974
340
  for (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope);
1975
402
       LBF && 
LBF->getDiscriminator() != 062
;
1976
340
       
LBF = dyn_cast<DILexicalBlockFile>(Scope)62
)
1977
62
    Scope = LBF->getScope();
1978
340
  DILexicalBlockFile *NewScope =
1979
340
      DILexicalBlockFile::get(getContext(), Scope, getFile(), Discriminator);
1980
340
  return DILocation::get(getContext(), getLine(), getColumn(), NewScope,
1981
340
                         getInlinedAt());
1982
340
}
1983
1984
1.62k
unsigned DILocation::getBaseDiscriminator() const {
1985
1.62k
  return getBaseDiscriminatorFromDiscriminator(getDiscriminator());
1986
1.62k
}
1987
1988
124
unsigned DILocation::getDuplicationFactor() const {
1989
124
  return getDuplicationFactorFromDiscriminator(getDiscriminator());
1990
124
}
1991
1992
114
unsigned DILocation::getCopyIdentifier() const {
1993
114
  return getCopyIdentifierFromDiscriminator(getDiscriminator());
1994
114
}
1995
1996
221
Optional<const DILocation *> DILocation::cloneWithBaseDiscriminator(unsigned D) const {
1997
221
  unsigned BD, DF, CI;
1998
221
  decodeDiscriminator(getDiscriminator(), BD, DF, CI);
1999
221
  if (D == BD)
2000
2
    return this;
2001
219
  if (Optional<unsigned> Encoded = encodeDiscriminator(D, DF, CI))
2002
218
    return cloneWithDiscriminator(*Encoded);
2003
1
  return None;
2004
1
}
2005
2006
117
Optional<const DILocation *> DILocation::cloneByMultiplyingDuplicationFactor(unsigned DF) const {
2007
117
  DF *= getDuplicationFactor();
2008
117
  if (DF <= 1)
2009
3
    return this;
2010
114
2011
114
  unsigned BD = getBaseDiscriminator();
2012
114
  unsigned CI = getCopyIdentifier();
2013
114
  if (Optional<unsigned> D = encodeDiscriminator(BD, DF, CI))
2014
113
    return cloneWithDiscriminator(*D);
2015
1
  return None;
2016
1
}
2017
2018
class DINamespace : public DIScope {
2019
  friend class LLVMContextImpl;
2020
  friend class MDNode;
2021
2022
  unsigned ExportSymbols : 1;
2023
2024
  DINamespace(LLVMContext &Context, StorageType Storage, bool ExportSymbols,
2025
              ArrayRef<Metadata *> Ops)
2026
      : DIScope(Context, DINamespaceKind, Storage, dwarf::DW_TAG_namespace,
2027
                Ops),
2028
297
        ExportSymbols(ExportSymbols) {}
2029
289
  ~DINamespace() = default;
2030
2031
  static DINamespace *getImpl(LLVMContext &Context, DIScope *Scope,
2032
                              StringRef Name, bool ExportSymbols,
2033
170
                              StorageType Storage, bool ShouldCreate = true) {
2034
170
    return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
2035
170
                   ExportSymbols, Storage, ShouldCreate);
2036
170
  }
2037
  static DINamespace *getImpl(LLVMContext &Context, Metadata *Scope,
2038
                              MDString *Name, bool ExportSymbols,
2039
                              StorageType Storage, bool ShouldCreate = true);
2040
2041
1
  TempDINamespace cloneImpl() const {
2042
1
    return getTemporary(getContext(), getScope(), getName(),
2043
1
                        getExportSymbols());
2044
1
  }
2045
2046
public:
2047
  DEFINE_MDNODE_GET(DINamespace,
2048
                    (DIScope *Scope, StringRef Name, bool ExportSymbols),
2049
                    (Scope, Name, ExportSymbols))
2050
  DEFINE_MDNODE_GET(DINamespace,
2051
                    (Metadata *Scope, MDString *Name, bool ExportSymbols),
2052
                    (Scope, Name, ExportSymbols))
2053
2054
  TempDINamespace clone() const { return cloneImpl(); }
2055
2056
624
  bool getExportSymbols() const { return ExportSymbols; }
2057
687
  DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
2058
422
  StringRef getName() const { return getStringOperand(2); }
2059
2060
1.74k
  Metadata *getRawScope() const { return getOperand(1); }
2061
406
  MDString *getRawName() const { return getOperandAs<MDString>(2); }
2062
2063
636k
  static bool classof(const Metadata *MD) {
2064
636k
    return MD->getMetadataID() == DINamespaceKind;
2065
636k
  }
2066
};
2067
2068
/// A (clang) module that has been imported by the compile unit.
2069
///
2070
class DIModule : public DIScope {
2071
  friend class LLVMContextImpl;
2072
  friend class MDNode;
2073
2074
  DIModule(LLVMContext &Context, StorageType Storage, ArrayRef<Metadata *> Ops)
2075
94
      : DIScope(Context, DIModuleKind, Storage, dwarf::DW_TAG_module, Ops) {}
2076
92
  ~DIModule() = default;
2077
2078
  static DIModule *getImpl(LLVMContext &Context, DIScope *Scope,
2079
                           StringRef Name, StringRef ConfigurationMacros,
2080
                           StringRef IncludePath, StringRef ISysRoot,
2081
66
                           StorageType Storage, bool ShouldCreate = true) {
2082
66
    return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
2083
66
                   getCanonicalMDString(Context, ConfigurationMacros),
2084
66
                   getCanonicalMDString(Context, IncludePath),
2085
66
                   getCanonicalMDString(Context, ISysRoot),
2086
66
                   Storage, ShouldCreate);
2087
66
  }
2088
  static DIModule *getImpl(LLVMContext &Context, Metadata *Scope,
2089
                           MDString *Name, MDString *ConfigurationMacros,
2090
                           MDString *IncludePath, MDString *ISysRoot,
2091
                           StorageType Storage, bool ShouldCreate = true);
2092
2093
1
  TempDIModule cloneImpl() const {
2094
1
    return getTemporary(getContext(), getScope(), getName(),
2095
1
                        getConfigurationMacros(), getIncludePath(),
2096
1
                        getISysRoot());
2097
1
  }
2098
2099
public:
2100
  DEFINE_MDNODE_GET(DIModule, (DIScope *Scope, StringRef Name,
2101
                               StringRef ConfigurationMacros, StringRef IncludePath,
2102
                               StringRef ISysRoot),
2103
                    (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot))
2104
  DEFINE_MDNODE_GET(DIModule,
2105
                    (Metadata *Scope, MDString *Name, MDString *ConfigurationMacros,
2106
                     MDString *IncludePath, MDString *ISysRoot),
2107
                    (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot))
2108
2109
  TempDIModule clone() const { return cloneImpl(); }
2110
2111
371
  DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
2112
323
  StringRef getName() const { return getStringOperand(1); }
2113
89
  StringRef getConfigurationMacros() const { return getStringOperand(2); }
2114
103
  StringRef getIncludePath() const { return getStringOperand(3); }
2115
113
  StringRef getISysRoot() const { return getStringOperand(4); }
2116
2117
515
  Metadata *getRawScope() const { return getOperand(0); }
2118
103
  MDString *getRawName() const { return getOperandAs<MDString>(1); }
2119
102
  MDString *getRawConfigurationMacros() const { return getOperandAs<MDString>(2); }
2120
102
  MDString *getRawIncludePath() const { return getOperandAs<MDString>(3); }
2121
102
  MDString *getRawISysRoot() const { return getOperandAs<MDString>(4); }
2122
2123
547k
  static bool classof(const Metadata *MD) {
2124
547k
    return MD->getMetadataID() == DIModuleKind;
2125
547k
  }
2126
};
2127
2128
/// Base class for template parameters.
2129
class DITemplateParameter : public DINode {
2130
protected:
2131
  DITemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage,
2132
                      unsigned Tag, ArrayRef<Metadata *> Ops)
2133
743
      : DINode(Context, ID, Storage, Tag, Ops) {}
2134
714
  ~DITemplateParameter() = default;
2135
2136
public:
2137
617
  StringRef getName() const { return getStringOperand(0); }
2138
206
  DIType *getType() const { return cast_or_null<DIType>(getRawType()); }
2139
2140
1.92k
  MDString *getRawName() const { return getOperandAs<MDString>(0); }
2141
3.24k
  Metadata *getRawType() const { return getOperand(1); }
2142
2143
1.12k
  static bool classof(const Metadata *MD) {
2144
1.12k
    return MD->getMetadataID() == DITemplateTypeParameterKind ||
2145
1.12k
           
MD->getMetadataID() == DITemplateValueParameterKind550
;
2146
1.12k
  }
2147
};
2148
2149
class DITemplateTypeParameter : public DITemplateParameter {
2150
  friend class LLVMContextImpl;
2151
  friend class MDNode;
2152
2153
  DITemplateTypeParameter(LLVMContext &Context, StorageType Storage,
2154
                          ArrayRef<Metadata *> Ops)
2155
      : DITemplateParameter(Context, DITemplateTypeParameterKind, Storage,
2156
369
                            dwarf::DW_TAG_template_type_parameter, Ops) {}
2157
359
  ~DITemplateTypeParameter() = default;
2158
2159
  static DITemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
2160
                                          DIType *Type, StorageType Storage,
2161
382
                                          bool ShouldCreate = true) {
2162
382
    return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage,
2163
382
                   ShouldCreate);
2164
382
  }
2165
  static DITemplateTypeParameter *getImpl(LLVMContext &Context, MDString *Name,
2166
                                          Metadata *Type, StorageType Storage,
2167
                                          bool ShouldCreate = true);
2168
2169
2
  TempDITemplateTypeParameter cloneImpl() const {
2170
2
    return getTemporary(getContext(), getName(), getType());
2171
2
  }
2172
2173
public:
2174
  DEFINE_MDNODE_GET(DITemplateTypeParameter, (StringRef Name, DIType *Type),
2175
                    (Name, Type))
2176
  DEFINE_MDNODE_GET(DITemplateTypeParameter, (MDString * Name, Metadata *Type),
2177
                    (Name, Type))
2178
2179
  TempDITemplateTypeParameter clone() const { return cloneImpl(); }
2180
2181
83
  static bool classof(const Metadata *MD) {
2182
83
    return MD->getMetadataID() == DITemplateTypeParameterKind;
2183
83
  }
2184
};
2185
2186
class DITemplateValueParameter : public DITemplateParameter {
2187
  friend class LLVMContextImpl;
2188
  friend class MDNode;
2189
2190
  DITemplateValueParameter(LLVMContext &Context, StorageType Storage,
2191
                           unsigned Tag, ArrayRef<Metadata *> Ops)
2192
      : DITemplateParameter(Context, DITemplateValueParameterKind, Storage, Tag,
2193
374
                            Ops) {}
2194
355
  ~DITemplateValueParameter() = default;
2195
2196
  static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
2197
                                           StringRef Name, DIType *Type,
2198
                                           Metadata *Value, StorageType Storage,
2199
433
                                           bool ShouldCreate = true) {
2200
433
    return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
2201
433
                   Value, Storage, ShouldCreate);
2202
433
  }
2203
  static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
2204
                                           MDString *Name, Metadata *Type,
2205
                                           Metadata *Value, StorageType Storage,
2206
                                           bool ShouldCreate = true);
2207
2208
3
  TempDITemplateValueParameter cloneImpl() const {
2209
3
    return getTemporary(getContext(), getTag(), getName(), getType(),
2210
3
                        getValue());
2211
3
  }
2212
2213
public:
2214
  DEFINE_MDNODE_GET(DITemplateValueParameter,
2215
                    (unsigned Tag, StringRef Name, DIType *Type,
2216
                     Metadata *Value),
2217
                    (Tag, Name, Type, Value))
2218
  DEFINE_MDNODE_GET(DITemplateValueParameter, (unsigned Tag, MDString *Name,
2219
                                               Metadata *Type, Metadata *Value),
2220
                    (Tag, Name, Type, Value))
2221
2222
  TempDITemplateValueParameter clone() const { return cloneImpl(); }
2223
2224
1.48k
  Metadata *getValue() const { return getOperand(2); }
2225
2226
40
  static bool classof(const Metadata *MD) {
2227
40
    return MD->getMetadataID() == DITemplateValueParameterKind;
2228
40
  }
2229
};
2230
2231
/// Base class for variables.
2232
class DIVariable : public DINode {
2233
  unsigned Line;
2234
  uint32_t AlignInBits;
2235
2236
protected:
2237
  DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Line,
2238
             ArrayRef<Metadata *> Ops, uint32_t AlignInBits = 0)
2239
      : DINode(C, ID, Storage, dwarf::DW_TAG_variable, Ops), Line(Line),
2240
11.0k
        AlignInBits(AlignInBits) {}
2241
10.7k
  ~DIVariable() = default;
2242
2243
public:
2244
29.4k
  unsigned getLine() const { return Line; }
2245
4.92k
  DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
2246
14.3k
  StringRef getName() const { return getStringOperand(1); }
2247
2.54k
  DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
2248
37.1k
  DIType *getType() const { return cast_or_null<DIType>(getRawType()); }
2249
27.8k
  uint32_t getAlignInBits() const { return AlignInBits; }
2250
2.13k
  uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
2251
  /// Determines the size of the variable's type.
2252
  Optional<uint64_t> getSizeInBits() const;
2253
2254
  /// Return the signedness of this variable's type, or None if this type is
2255
  /// neither signed nor unsigned.
2256
596
  Optional<DIBasicType::Signedness> getSignedness() const {
2257
596
    if (auto *BT = dyn_cast<DIBasicType>(getType()))
2258
596
      return BT->getSignedness();
2259
0
    return None;
2260
0
  }
2261
2262
2
  StringRef getFilename() const {
2263
2
    if (auto *F = getFile())
2264
2
      return F->getFilename();
2265
0
    return "";
2266
0
  }
2267
2268
2
  StringRef getDirectory() const {
2269
2
    if (auto *F = getFile())
2270
2
      return F->getDirectory();
2271
0
    return "";
2272
0
  }
2273
2274
0
  Optional<StringRef> getSource() const {
2275
0
    if (auto *F = getFile())
2276
0
      return F->getSource();
2277
0
    return None;
2278
0
  }
2279
2280
128k
  Metadata *getRawScope() const { return getOperand(0); }
2281
20.3k
  MDString *getRawName() const { return getOperandAs<MDString>(1); }
2282
58.1k
  Metadata *getRawFile() const { return getOperand(2); }
2283
159k
  Metadata *getRawType() const { return getOperand(3); }
2284
2285
174
  static bool classof(const Metadata *MD) {
2286
174
    return MD->getMetadataID() == DILocalVariableKind ||
2287
174
           
MD->getMetadataID() == DIGlobalVariableKind10
;
2288
174
  }
2289
};
2290
2291
/// DWARF expression.
2292
///
2293
/// This is (almost) a DWARF expression that modifies the location of a
2294
/// variable, or the location of a single piece of a variable, or (when using
2295
/// DW_OP_stack_value) is the constant variable value.
2296
///
2297
/// TODO: Co-allocate the expression elements.
2298
/// TODO: Separate from MDNode, or otherwise drop Distinct and Temporary
2299
/// storage types.
2300
class DIExpression : public MDNode {
2301
  friend class LLVMContextImpl;
2302
  friend class MDNode;
2303
2304
  std::vector<uint64_t> Elements;
2305
2306
  DIExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
2307
      : MDNode(C, DIExpressionKind, Storage, None),
2308
6.57k
        Elements(Elements.begin(), Elements.end()) {}
2309
6.50k
  ~DIExpression() = default;
2310
2311
  static DIExpression *getImpl(LLVMContext &Context,
2312
                               ArrayRef<uint64_t> Elements, StorageType Storage,
2313
                               bool ShouldCreate = true);
2314
2315
1
  TempDIExpression cloneImpl() const {
2316
1
    return getTemporary(getContext(), getElements());
2317
1
  }
2318
2319
public:
2320
  DEFINE_MDNODE_GET(DIExpression, (ArrayRef<uint64_t> Elements), (Elements))
2321
2322
  TempDIExpression clone() const { return cloneImpl(); }
2323
2324
128M
  ArrayRef<uint64_t> getElements() const { return Elements; }
2325
2326
8.01M
  unsigned getNumElements() const { return Elements.size(); }
2327
2328
8.00M
  uint64_t getElement(unsigned I) const {
2329
8.00M
    assert(I < Elements.size() && "Index out of range");
2330
8.00M
    return Elements[I];
2331
8.00M
  }
2332
2333
  /// Determine whether this represents a standalone constant value.
2334
  bool isConstant() const;
2335
2336
  using element_iterator = ArrayRef<uint64_t>::iterator;
2337
2338
64.1M
  element_iterator elements_begin() const { return getElements().begin(); }
2339
64.1M
  element_iterator elements_end() const { return getElements().end(); }
2340
2341
  /// A lightweight wrapper around an expression operand.
2342
  ///
2343
  /// TODO: Store arguments directly and change \a DIExpression to store a
2344
  /// range of these.
2345
  class ExprOperand {
2346
    const uint64_t *Op = nullptr;
2347
2348
  public:
2349
14.5k
    ExprOperand() = default;
2350
128M
    explicit ExprOperand(const uint64_t *Op) : Op(Op) {}
2351
2352
128M
    const uint64_t *get() const { return Op; }
2353
2354
    /// Get the operand code.
2355
64.1M
    uint64_t getOp() const { return *Op; }
2356
2357
    /// Get an argument to the operand.
2358
    ///
2359
    /// Never returns the operand itself.
2360
128M
    uint64_t getArg(unsigned I) const { return Op[I + 1]; }
2361
2362
2.08k
    unsigned getNumArgs() const { return getSize() - 1; }
2363
2364
    /// Return the size of the operand.
2365
    ///
2366
    /// Return the number of elements in the operand (1 + args).
2367
    unsigned getSize() const;
2368
2369
    /// Append the elements of this operand to \p V.
2370
232
    void appendToVector(SmallVectorImpl<uint64_t> &V) const {
2371
232
      V.append(get(), get() + getSize());
2372
232
    }
2373
  };
2374
2375
  /// An iterator for expression operands.
2376
  class expr_op_iterator
2377
      : public std::iterator<std::input_iterator_tag, ExprOperand> {
2378
    ExprOperand Op;
2379
2380
  public:
2381
14.5k
    expr_op_iterator() = default;
2382
128M
    explicit expr_op_iterator(element_iterator I) : Op(I) {}
2383
2384
128M
    element_iterator getBase() const { return Op.get(); }
2385
10.8k
    const ExprOperand &operator*() const { return Op; }
2386
192M
    const ExprOperand *operator->() const { return &Op; }
2387
2388
13.9k
    expr_op_iterator &operator++() {
2389
13.9k
      increment();
2390
13.9k
      return *this;
2391
13.9k
    }
2392
4.98k
    expr_op_iterator operator++(int) {
2393
4.98k
      expr_op_iterator T(*this);
2394
4.98k
      increment();
2395
4.98k
      return T;
2396
4.98k
    }
2397
2398
    /// Get the next iterator.
2399
    ///
2400
    /// \a std::next() doesn't work because this is technically an
2401
    /// input_iterator, but it's a perfectly valid operation.  This is an
2402
    /// accessor to provide the same functionality.
2403
54
    expr_op_iterator getNext() const { return ++expr_op_iterator(*this); }
2404
2405
14.4k
    bool operator==(const expr_op_iterator &X) const {
2406
14.4k
      return getBase() == X.getBase();
2407
14.4k
    }
2408
64.1M
    bool operator!=(const expr_op_iterator &X) const {
2409
64.1M
      return getBase() != X.getBase();
2410
64.1M
    }
2411
2412
  private:
2413
18.9k
    void increment() { Op = ExprOperand(getBase() + Op.getSize()); }
2414
  };
2415
2416
  /// Visit the elements via ExprOperand wrappers.
2417
  ///
2418
  /// These range iterators visit elements through \a ExprOperand wrappers.
2419
  /// This is not guaranteed to be a valid range unless \a isValid() gives \c
2420
  /// true.
2421
  ///
2422
  /// \pre \a isValid() gives \c true.
2423
  /// @{
2424
64.1M
  expr_op_iterator expr_op_begin() const {
2425
64.1M
    return expr_op_iterator(elements_begin());
2426
64.1M
  }
2427
64.1M
  expr_op_iterator expr_op_end() const {
2428
64.1M
    return expr_op_iterator(elements_end());
2429
64.1M
  }
2430
697
  iterator_range<expr_op_iterator> expr_ops() const {
2431
697
    return {expr_op_begin(), expr_op_end()};
2432
697
  }
2433
  /// @}
2434
2435
  bool isValid() const;
2436
2437
460k
  static bool classof(const Metadata *MD) {
2438
460k
    return MD->getMetadataID() == DIExpressionKind;
2439
460k
  }
2440
2441
  /// Return whether the first element a DW_OP_deref.
2442
10
  bool startsWithDeref() const {
2443
10
    return getNumElements() > 0 && 
getElement(0) == dwarf::DW_OP_deref2
;
2444
10
  }
2445
2446
  /// Holds the characteristics of one fragment of a larger variable.
2447
  struct FragmentInfo {
2448
    uint64_t SizeInBits;
2449
    uint64_t OffsetInBits;
2450
  };
2451
2452
  /// Retrieve the details of this fragment expression.
2453
  static Optional<FragmentInfo> getFragmentInfo(expr_op_iterator Start,
2454
                                                expr_op_iterator End);
2455
2456
  /// Retrieve the details of this fragment expression.
2457
64.0M
  Optional<FragmentInfo> getFragmentInfo() const {
2458
64.0M
    return getFragmentInfo(expr_op_begin(), expr_op_end());
2459
64.0M
  }
2460
2461
  /// Return whether this is a piece of an aggregate variable.
2462
32.0M
  bool isFragment() const { return getFragmentInfo().hasValue(); }
2463
2464
  /// Return whether this is an implicit location description.
2465
  bool isImplicit() const;
2466
2467
  /// Return whether the location is computed on the expression stack, meaning
2468
  /// it cannot be a simple register location.
2469
  bool isComplex() const;
2470
2471
  /// Append \p Ops with operations to apply the \p Offset.
2472
  static void appendOffset(SmallVectorImpl<uint64_t> &Ops, int64_t Offset);
2473
2474
  /// If this is a constant offset, extract it. If there is no expression,
2475
  /// return true with an offset of zero.
2476
  bool extractIfOffset(int64_t &Offset) const;
2477
2478
  /// Checks if the last 4 elements of the expression are DW_OP_constu <DWARF
2479
  /// Address Space> DW_OP_swap DW_OP_xderef and extracts the <DWARF Address
2480
  /// Space>.
2481
  static const DIExpression *extractAddressClass(const DIExpression *Expr,
2482
                                                 unsigned &AddrClass);
2483
2484
  /// Used for DIExpression::prepend.
2485
  enum PrependOps : uint8_t {
2486
    ApplyOffset = 0,
2487
    DerefBefore = 1 << 0,
2488
    DerefAfter = 1 << 1,
2489
    StackValue = 1 << 2,
2490
    EntryValue = 1 << 3
2491
  };
2492
2493
  /// Prepend \p DIExpr with a deref and offset operation and optionally turn it
2494
  /// into a stack value or/and an entry value.
2495
  static DIExpression *prepend(const DIExpression *Expr, uint8_t Flags,
2496
                               int64_t Offset = 0);
2497
2498
  /// Prepend \p DIExpr with the given opcodes and optionally turn it into a
2499
  /// stack value.
2500
  static DIExpression *prependOpcodes(const DIExpression *Expr,
2501
                                      SmallVectorImpl<uint64_t> &Ops,
2502
                                      bool StackValue = false,
2503
                                      bool EntryValue = false);
2504
2505
  /// Append the opcodes \p Ops to \p DIExpr. Unlike \ref appendToStack, the
2506
  /// returned expression is a stack value only if \p DIExpr is a stack value.
2507
  /// If \p DIExpr describes a fragment, the returned expression will describe
2508
  /// the same fragment.
2509
  static DIExpression *append(const DIExpression *Expr, ArrayRef<uint64_t> Ops);
2510
2511
  /// Convert \p DIExpr into a stack value if it isn't one already by appending
2512
  /// DW_OP_deref if needed, and appending \p Ops to the resulting expression.
2513
  /// If \p DIExpr describes a fragment, the returned expression will describe
2514
  /// the same fragment.
2515
  static DIExpression *appendToStack(const DIExpression *Expr,
2516
                                     ArrayRef<uint64_t> Ops);
2517
2518
  /// Create a DIExpression to describe one part of an aggregate variable that
2519
  /// is fragmented across multiple Values. The DW_OP_LLVM_fragment operation
2520
  /// will be appended to the elements of \c Expr. If \c Expr already contains
2521
  /// a \c DW_OP_LLVM_fragment \c OffsetInBits is interpreted as an offset
2522
  /// into the existing fragment.
2523
  ///
2524
  /// \param OffsetInBits Offset of the piece in bits.
2525
  /// \param SizeInBits   Size of the piece in bits.
2526
  /// \return             Creating a fragment expression may fail if \c Expr
2527
  ///                     contains arithmetic operations that would be truncated.
2528
  static Optional<DIExpression *>
2529
  createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits,
2530
                           unsigned SizeInBits);
2531
2532
  /// Determine the relative position of the fragments passed in.
2533
  /// Returns -1 if this is entirely before Other, 0 if this and Other overlap,
2534
  /// 1 if this is entirely after Other.
2535
23.9M
  static int fragmentCmp(const FragmentInfo &A, const FragmentInfo &B) {
2536
23.9M
    uint64_t l1 = A.OffsetInBits;
2537
23.9M
    uint64_t l2 = B.OffsetInBits;
2538
23.9M
    uint64_t r1 = l1 + A.SizeInBits;
2539
23.9M
    uint64_t r2 = l2 + B.SizeInBits;
2540
23.9M
    if (r1 <= l2)
2541
110
      return -1;
2542
23.9M
    else if (r2 <= l1)
2543
23.9M
      return 1;
2544
17
    else
2545
17
      return 0;
2546
23.9M
  }
2547
2548
  /// Check if fragments overlap between a pair of FragmentInfos.
2549
7.99M
  static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B) {
2550
7.99M
    return fragmentCmp(A, B) == 0;
2551
7.99M
  }
2552
2553
  /// Determine the relative position of the fragments described by this
2554
  /// DIExpression and \p Other. Calls static fragmentCmp implementation.
2555
15.9M
  int fragmentCmp(const DIExpression *Other) const {
2556
15.9M
    auto Fragment1 = *getFragmentInfo();
2557
15.9M
    auto Fragment2 = *Other->getFragmentInfo();
2558
15.9M
    return fragmentCmp(Fragment1, Fragment2);
2559
15.9M
  }
2560
2561
  /// Check if fragments overlap between this DIExpression and \p Other.
2562
15.9M
  bool fragmentsOverlap(const DIExpression *Other) const {
2563
15.9M
    if (!isFragment() || 
!Other->isFragment()15.9M
)
2564
227
      return true;
2565
15.9M
    return fragmentCmp(Other) == 0;
2566
15.9M
  }
2567
2568
  /// Check if the expression consists of exactly one entry value operand.
2569
  /// (This is the only configuration of entry values that is supported.)
2570
8.00M
  bool isEntryValue() const {
2571
8.00M
    return getNumElements() > 0 &&
2572
8.00M
           
getElement(0) == dwarf::DW_OP_entry_value8.00M
;
2573
8.00M
  }
2574
};
2575
2576
inline bool operator==(const DIExpression::FragmentInfo &A,
2577
3.81M
                       const DIExpression::FragmentInfo &B) {
2578
3.81M
  return std::tie(A.SizeInBits, A.OffsetInBits) ==
2579
3.81M
         std::tie(B.SizeInBits, B.OffsetInBits);
2580
3.81M
}
2581
2582
inline bool operator<(const DIExpression::FragmentInfo &A,
2583
444k
                      const DIExpression::FragmentInfo &B) {
2584
444k
  return std::tie(A.SizeInBits, A.OffsetInBits) <
2585
444k
         std::tie(B.SizeInBits, B.OffsetInBits);
2586
444k
}
2587
2588
template <> struct DenseMapInfo<DIExpression::FragmentInfo> {
2589
  using FragInfo = DIExpression::FragmentInfo;
2590
  static const uint64_t MaxVal = std::numeric_limits<uint64_t>::max();
2591
2592
23.2k
  static inline FragInfo getEmptyKey() { return {MaxVal, MaxVal}; }
2593
2594
17.9k
  static inline FragInfo getTombstoneKey() { return {MaxVal - 1, MaxVal - 1}; }
2595
2596
32.2k
  static unsigned getHashValue(const FragInfo &Frag) {
2597
32.2k
    return (Frag.SizeInBits & 0xffff) << 16 | (Frag.OffsetInBits & 0xffff);
2598
32.2k
  }
2599
2600
1.93M
  static bool isEqual(const FragInfo &A, const FragInfo &B) { return A == B; }
2601
};
2602
2603
/// Global variables.
2604
///
2605
/// TODO: Remove DisplayName.  It's always equal to Name.
2606
class DIGlobalVariable : public DIVariable {
2607
  friend class LLVMContextImpl;
2608
  friend class MDNode;
2609
2610
  bool IsLocalToUnit;
2611
  bool IsDefinition;
2612
2613
  DIGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
2614
                   bool IsLocalToUnit, bool IsDefinition, uint32_t AlignInBits,
2615
                   ArrayRef<Metadata *> Ops)
2616
      : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits),
2617
1.96k
        IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
2618
1.80k
  ~DIGlobalVariable() = default;
2619
2620
  static DIGlobalVariable *
2621
  getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
2622
          StringRef LinkageName, DIFile *File, unsigned Line, DIType *Type,
2623
          bool IsLocalToUnit, bool IsDefinition,
2624
          DIDerivedType *StaticDataMemberDeclaration, MDTuple *TemplateParams,
2625
635
          uint32_t AlignInBits, StorageType Storage, bool ShouldCreate = true) {
2626
635
    return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
2627
635
                   getCanonicalMDString(Context, LinkageName), File, Line, Type,
2628
635
                   IsLocalToUnit, IsDefinition, StaticDataMemberDeclaration,
2629
635
                   cast_or_null<Metadata>(TemplateParams), AlignInBits, Storage,
2630
635
                   ShouldCreate);
2631
635
  }
2632
  static DIGlobalVariable *
2633
  getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
2634
          MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
2635
          bool IsLocalToUnit, bool IsDefinition,
2636
          Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
2637
          uint32_t AlignInBits, StorageType Storage, bool ShouldCreate = true);
2638
2639
2
  TempDIGlobalVariable cloneImpl() const {
2640
2
    return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
2641
2
                        getFile(), getLine(), getType(), isLocalToUnit(),
2642
2
                        isDefinition(), getStaticDataMemberDeclaration(),
2643
2
                        getTemplateParams(), getAlignInBits());
2644
2
  }
2645
2646
public:
2647
  DEFINE_MDNODE_GET(DIGlobalVariable,
2648
                    (DIScope * Scope, StringRef Name, StringRef LinkageName,
2649
                     DIFile *File, unsigned Line, DIType *Type,
2650
                     bool IsLocalToUnit, bool IsDefinition,
2651
                     DIDerivedType *StaticDataMemberDeclaration,
2652
                     MDTuple *TemplateParams, uint32_t AlignInBits),
2653
                    (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
2654
                     IsDefinition, StaticDataMemberDeclaration, TemplateParams,
2655
                     AlignInBits))
2656
  DEFINE_MDNODE_GET(DIGlobalVariable,
2657
                    (Metadata * Scope, MDString *Name, MDString *LinkageName,
2658
                     Metadata *File, unsigned Line, Metadata *Type,
2659
                     bool IsLocalToUnit, bool IsDefinition,
2660
                     Metadata *StaticDataMemberDeclaration,
2661
                     Metadata *TemplateParams, uint32_t AlignInBits),
2662
                    (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
2663
                     IsDefinition, StaticDataMemberDeclaration, TemplateParams,
2664
                     AlignInBits))
2665
2666
  TempDIGlobalVariable clone() const { return cloneImpl(); }
2667
2668
4.62k
  bool isLocalToUnit() const { return IsLocalToUnit; }
2669
4.52k
  bool isDefinition() const { return IsDefinition; }
2670
933
  StringRef getDisplayName() const { return getStringOperand(4); }
2671
2.56k
  StringRef getLinkageName() const { return getStringOperand(5); }
2672
1.08k
  DIDerivedType *getStaticDataMemberDeclaration() const {
2673
1.08k
    return cast_or_null<DIDerivedType>(getRawStaticDataMemberDeclaration());
2674
1.08k
  }
2675
2676
2.82k
  MDString *getRawLinkageName() const { return getOperandAs<MDString>(5); }
2677
19.2k
  Metadata *getRawStaticDataMemberDeclaration() const { return getOperand(6); }
2678
3.43k
  Metadata *getRawTemplateParams() const { return getOperand(7); }
2679
1.08k
  MDTuple *getTemplateParams() const { return getOperandAs<MDTuple>(7); }
2680
2681
57
  static bool classof(const Metadata *MD) {
2682
57
    return MD->getMetadataID() == DIGlobalVariableKind;
2683
57
  }
2684
};
2685
2686
class DICommonBlock : public DIScope {
2687
  unsigned LineNo;
2688
2689
  friend class LLVMContextImpl;
2690
  friend class MDNode;
2691
2692
  DICommonBlock(LLVMContext &Context, StorageType Storage, unsigned LineNo,
2693
                ArrayRef<Metadata *> Ops)
2694
      : DIScope(Context, DICommonBlockKind, Storage, dwarf::DW_TAG_common_block,
2695
5
                Ops), LineNo(LineNo) {}
2696
2697
  static DICommonBlock *getImpl(LLVMContext &Context, DIScope *Scope,
2698
                                DIGlobalVariable *Decl, StringRef Name,
2699
                                DIFile *File, unsigned LineNo,
2700
                                StorageType Storage,
2701
0
                                bool ShouldCreate = true) {
2702
0
    return getImpl(Context, Scope, Decl, getCanonicalMDString(Context, Name),
2703
0
                   File, LineNo, Storage, ShouldCreate);
2704
0
  }
2705
  static DICommonBlock *getImpl(LLVMContext &Context, Metadata *Scope,
2706
                                Metadata *Decl, MDString *Name, Metadata *File,
2707
                                unsigned LineNo, 
2708
                                StorageType Storage, bool ShouldCreate = true);
2709
2710
0
  TempDICommonBlock cloneImpl() const {
2711
0
    return getTemporary(getContext(), getScope(), getDecl(), getName(),
2712
0
                        getFile(), getLineNo());
2713
0
  }
2714
2715
public:
2716
  DEFINE_MDNODE_GET(DICommonBlock,
2717
                    (DIScope *Scope, DIGlobalVariable *Decl, StringRef Name,
2718
                     DIFile *File, unsigned LineNo),
2719
                    (Scope, Decl, Name, File, LineNo))
2720
  DEFINE_MDNODE_GET(DICommonBlock,
2721
                    (Metadata *Scope, Metadata *Decl, MDString *Name,
2722
                     Metadata *File, unsigned LineNo),
2723
                    (Scope, Decl, Name, File, LineNo))
2724
2725
0
  TempDICommonBlock clone() const { return cloneImpl(); }
2726
2727
5
  DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
2728
3
  DIGlobalVariable *getDecl() const {
2729
3
    return cast_or_null<DIGlobalVariable>(getRawDecl());
2730
3
  }
2731
4
  StringRef getName() const { return getStringOperand(2); }
2732
4
  DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
2733
22
  unsigned getLineNo() const { return LineNo; }
2734
2735
34
  Metadata *getRawScope() const { return getOperand(0); }
2736
32
  Metadata *getRawDecl() const { return getOperand(1); }
2737
19
  MDString *getRawName() const { return getOperandAs<MDString>(2); }
2738
23
  Metadata *getRawFile() const { return getOperand(3); }
2739
2740
546k
  static bool classof(const Metadata *MD) {
2741
546k
    return MD->getMetadataID() == DICommonBlockKind;
2742
546k
  }
2743
};
2744
2745
/// Local variable.
2746
///
2747
/// TODO: Split up flags.
2748
class DILocalVariable : public DIVariable {
2749
  friend class LLVMContextImpl;
2750
  friend class MDNode;
2751
2752
  unsigned Arg : 16;
2753
  DIFlags Flags;
2754
2755
  DILocalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
2756
                  unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
2757
                  ArrayRef<Metadata *> Ops)
2758
      : DIVariable(C, DILocalVariableKind, Storage, Line, Ops, AlignInBits),
2759
9.12k
        Arg(Arg), Flags(Flags) {
2760
9.12k
    assert(Arg < (1 << 16) && "DILocalVariable: Arg out of range");
2761
9.12k
  }
2762
8.93k
  ~DILocalVariable() = default;
2763
2764
  static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
2765
                                  StringRef Name, DIFile *File, unsigned Line,
2766
                                  DIType *Type, unsigned Arg, DIFlags Flags,
2767
                                  uint32_t AlignInBits, StorageType Storage,
2768
6.13k
                                  bool ShouldCreate = true) {
2769
6.13k
    return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
2770
6.13k
                   Line, Type, Arg, Flags, AlignInBits, Storage, ShouldCreate);
2771
6.13k
  }
2772
  static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope,
2773
                                  MDString *Name, Metadata *File, unsigned Line,
2774
                                  Metadata *Type, unsigned Arg, DIFlags Flags,
2775
                                  uint32_t AlignInBits, StorageType Storage,
2776
                                  bool ShouldCreate = true);
2777
2778
24
  TempDILocalVariable cloneImpl() const {
2779
24
    return getTemporary(getContext(), getScope(), getName(), getFile(),
2780
24
                        getLine(), getType(), getArg(), getFlags(),
2781
24
                        getAlignInBits());
2782
24
  }
2783
2784
public:
2785
  DEFINE_MDNODE_GET(DILocalVariable,
2786
                    (DILocalScope * Scope, StringRef Name, DIFile *File,
2787
                     unsigned Line, DIType *Type, unsigned Arg, DIFlags Flags,
2788
                     uint32_t AlignInBits),
2789
                    (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
2790
  DEFINE_MDNODE_GET(DILocalVariable,
2791
                    (Metadata * Scope, MDString *Name, Metadata *File,
2792
                     unsigned Line, Metadata *Type, unsigned Arg,
2793
                     DIFlags Flags, uint32_t AlignInBits),
2794
                    (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
2795
2796
  TempDILocalVariable clone() const { return cloneImpl(); }
2797
2798
  /// Get the local scope for this variable.
2799
  ///
2800
  /// Variables must be defined in a local scope.
2801
2.77k
  DILocalScope *getScope() const {
2802
2.77k
    return cast<DILocalScope>(DIVariable::getScope());
2803
2.77k
  }
2804
2805
13.8k
  bool isParameter() const { return Arg; }
2806
55.2k
  unsigned getArg() const { return Arg; }
2807
45.8k
  DIFlags getFlags() const { return Flags; }
2808
2809
17.6k
  bool isArtificial() const { return getFlags() & FlagArtificial; }
2810
1.31k
  bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
2811
2812
  /// Check that an argument is unmodified.
2813
4.66k
  bool isNotModified() const { return getFlags() & FlagArgumentNotModified; }
2814
  /// Set the flag if an argument is unmodified.
2815
4
  void setIsNotModified() { Flags |= FlagArgumentNotModified; }
2816
2817
  /// Check that a location is valid for this variable.
2818
  ///
2819
  /// Check that \c DL exists, is in the same subprogram, and has the same
2820
  /// inlined-at location as \c this.  (Otherwise, it's not a valid attachment
2821
  /// to a \a DbgInfoIntrinsic.)
2822
0
  bool isValidLocationForIntrinsic(const DILocation *DL) const {
2823
0
    return DL && getScope()->getSubprogram() == DL->getScope()->getSubprogram();
2824
0
  }
2825
2826
3.54k
  static bool classof(const Metadata *MD) {
2827
3.54k
    return MD->getMetadataID() == DILocalVariableKind;
2828
3.54k
  }
2829
};
2830
2831
/// Label.
2832
///
2833
class DILabel : public DINode {
2834
  friend class LLVMContextImpl;
2835
  friend class MDNode;
2836
2837
  unsigned Line;
2838
2839
  DILabel(LLVMContext &C, StorageType Storage, unsigned Line,
2840
          ArrayRef<Metadata *> Ops)
2841
45
      : DINode(C, DILabelKind, Storage, dwarf::DW_TAG_label, Ops), Line(Line) {}
2842
45
  ~DILabel() = default;
2843
2844
  static DILabel *getImpl(LLVMContext &Context, DIScope *Scope,
2845
                          StringRef Name, DIFile *File, unsigned Line,
2846
                          StorageType Storage,
2847
7
                          bool ShouldCreate = true) {
2848
7
    return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
2849
7
                   Line, Storage, ShouldCreate);
2850
7
  }
2851
  static DILabel *getImpl(LLVMContext &Context, Metadata *Scope,
2852
                          MDString *Name, Metadata *File, unsigned Line,
2853
                          StorageType Storage,
2854
                          bool ShouldCreate = true);
2855
2856
0
  TempDILabel cloneImpl() const {
2857
0
    return getTemporary(getContext(), getScope(), getName(), getFile(),
2858
0
                        getLine());
2859
0
  }
2860
2861
public:
2862
  DEFINE_MDNODE_GET(DILabel,
2863
                    (DILocalScope * Scope, StringRef Name, DIFile *File,
2864
                     unsigned Line),
2865
                    (Scope, Name, File, Line))
2866
  DEFINE_MDNODE_GET(DILabel,
2867
                    (Metadata * Scope, MDString *Name, Metadata *File,
2868
                     unsigned Line),
2869
                    (Scope, Name, File, Line))
2870
2871
0
  TempDILabel clone() const { return cloneImpl(); }
2872
2873
  /// Get the local scope for this label.
2874
  ///
2875
  /// Labels must be defined in a local scope.
2876
26
  DILocalScope *getScope() const {
2877
26
    return cast_or_null<DILocalScope>(getRawScope());
2878
26
  }
2879
94
  unsigned getLine() const { return Line; }
2880
26
  StringRef getName() const { return getStringOperand(1); }
2881
23
  DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
2882
2883
500
  Metadata *getRawScope() const { return getOperand(0); }
2884
71
  MDString *getRawName() const { return getOperandAs<MDString>(1); }
2885
193
  Metadata *getRawFile() const { return getOperand(2); }
2886
2887
  /// Check that a location is valid for this label.
2888
  ///
2889
  /// Check that \c DL exists, is in the same subprogram, and has the same
2890
  /// inlined-at location as \c this.  (Otherwise, it's not a valid attachment
2891
  /// to a \a DbgInfoIntrinsic.)
2892
0
  bool isValidLocationForIntrinsic(const DILocation *DL) const {
2893
0
    return DL && getScope()->getSubprogram() == DL->getScope()->getSubprogram();
2894
0
  }
2895
2896
10
  static bool classof(const Metadata *MD) {
2897
10
    return MD->getMetadataID() == DILabelKind;
2898
10
  }
2899
};
2900
2901
class DIObjCProperty : public DINode {
2902
  friend class LLVMContextImpl;
2903
  friend class MDNode;
2904
2905
  unsigned Line;
2906
  unsigned Attributes;
2907
2908
  DIObjCProperty(LLVMContext &C, StorageType Storage, unsigned Line,
2909
                 unsigned Attributes, ArrayRef<Metadata *> Ops)
2910
      : DINode(C, DIObjCPropertyKind, Storage, dwarf::DW_TAG_APPLE_property,
2911
               Ops),
2912
91
        Line(Line), Attributes(Attributes) {}
2913
90
  ~DIObjCProperty() = default;
2914
2915
  static DIObjCProperty *
2916
  getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line,
2917
          StringRef GetterName, StringRef SetterName, unsigned Attributes,
2918
84
          DIType *Type, StorageType Storage, bool ShouldCreate = true) {
2919
84
    return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
2920
84
                   getCanonicalMDString(Context, GetterName),
2921
84
                   getCanonicalMDString(Context, SetterName), Attributes, Type,
2922
84
                   Storage, ShouldCreate);
2923
84
  }
2924
  static DIObjCProperty *getImpl(LLVMContext &Context, MDString *Name,
2925
                                 Metadata *File, unsigned Line,
2926
                                 MDString *GetterName, MDString *SetterName,
2927
                                 unsigned Attributes, Metadata *Type,
2928
                                 StorageType Storage, bool ShouldCreate = true);
2929
2930
1
  TempDIObjCProperty cloneImpl() const {
2931
1
    return getTemporary(getContext(), getName(), getFile(), getLine(),
2932
1
                        getGetterName(), getSetterName(), getAttributes(),
2933
1
                        getType());
2934
1
  }
2935
2936
public:
2937
  DEFINE_MDNODE_GET(DIObjCProperty,
2938
                    (StringRef Name, DIFile *File, unsigned Line,
2939
                     StringRef GetterName, StringRef SetterName,
2940
                     unsigned Attributes, DIType *Type),
2941
                    (Name, File, Line, GetterName, SetterName, Attributes,
2942
                     Type))
2943
  DEFINE_MDNODE_GET(DIObjCProperty,
2944
                    (MDString * Name, Metadata *File, unsigned Line,
2945
                     MDString *GetterName, MDString *SetterName,
2946
                     unsigned Attributes, Metadata *Type),
2947
                    (Name, File, Line, GetterName, SetterName, Attributes,
2948
                     Type))
2949
2950
  TempDIObjCProperty clone() const { return cloneImpl(); }
2951
2952
204
  unsigned getLine() const { return Line; }
2953
204
  unsigned getAttributes() const { return Attributes; }
2954
64
  StringRef getName() const { return getStringOperand(0); }
2955
28
  DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
2956
64
  StringRef getGetterName() const { return getStringOperand(2); }
2957
64
  StringRef getSetterName() const { return getStringOperand(3); }
2958
37
  DIType *getType() const { return cast_or_null<DIType>(getRawType()); }
2959
2960
0
  StringRef getFilename() const {
2961
0
    if (auto *F = getFile())
2962
0
      return F->getFilename();
2963
0
    return "";
2964
0
  }
2965
2966
0
  StringRef getDirectory() const {
2967
0
    if (auto *F = getFile())
2968
0
      return F->getDirectory();
2969
0
    return "";
2970
0
  }
2971
2972
0
  Optional<StringRef> getSource() const {
2973
0
    if (auto *F = getFile())
2974
0
      return F->getSource();
2975
0
    return None;
2976
0
  }
2977
2978
141
  MDString *getRawName() const { return getOperandAs<MDString>(0); }
2979
310
  Metadata *getRawFile() const { return getOperand(1); }
2980
140
  MDString *getRawGetterName() const { return getOperandAs<MDString>(2); }
2981
140
  MDString *getRawSetterName() const { return getOperandAs<MDString>(3); }
2982
319
  Metadata *getRawType() const { return getOperand(4); }
2983
2984
16
  static bool classof(const Metadata *MD) {
2985
16
    return MD->getMetadataID() == DIObjCPropertyKind;
2986
16
  }
2987
};
2988
2989
/// An imported module (C++ using directive or similar).
2990
class DIImportedEntity : public DINode {
2991
  friend class LLVMContextImpl;
2992
  friend class MDNode;
2993
2994
  unsigned Line;
2995
2996
  DIImportedEntity(LLVMContext &C, StorageType Storage, unsigned Tag,
2997
                   unsigned Line, ArrayRef<Metadata *> Ops)
2998
356
      : DINode(C, DIImportedEntityKind, Storage, Tag, Ops), Line(Line) {}
2999
354
  ~DIImportedEntity() = default;
3000
3001
  static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
3002
                                   DIScope *Scope, DINode *Entity, DIFile *File,
3003
                                   unsigned Line, StringRef Name,
3004
                                   StorageType Storage,
3005
69
                                   bool ShouldCreate = true) {
3006
69
    return getImpl(Context, Tag, Scope, Entity, File, Line,
3007
69
                   getCanonicalMDString(Context, Name), Storage, ShouldCreate);
3008
69
  }
3009
  static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
3010
                                   Metadata *Scope, Metadata *Entity,
3011
                                   Metadata *File, unsigned Line,
3012
                                   MDString *Name, StorageType Storage,
3013
                                   bool ShouldCreate = true);
3014
3015
1
  TempDIImportedEntity cloneImpl() const {
3016
1
    return getTemporary(getContext(), getTag(), getScope(), getEntity(),
3017
1
                        getFile(), getLine(), getName());
3018
1
  }
3019
3020
public:
3021
  DEFINE_MDNODE_GET(DIImportedEntity,
3022
                    (unsigned Tag, DIScope *Scope, DINode *Entity, DIFile *File,
3023
                     unsigned Line, StringRef Name = ""),
3024
                    (Tag, Scope, Entity, File, Line, Name))
3025
  DEFINE_MDNODE_GET(DIImportedEntity,
3026
                    (unsigned Tag, Metadata *Scope, Metadata *Entity,
3027
                     Metadata *File, unsigned Line, MDString *Name),
3028
                    (Tag, Scope, Entity, File, Line, Name))
3029
3030
  TempDIImportedEntity clone() const { return cloneImpl(); }
3031
3032
1.89k
  unsigned getLine() const { return Line; }
3033
731
  DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
3034
267
  DINode *getEntity() const { return cast_or_null<DINode>(getRawEntity()); }
3035
318
  StringRef getName() const { return getStringOperand(2); }
3036
247
  DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
3037
3038
4.24k
  Metadata *getRawScope() const { return getOperand(0); }
3039
3.71k
  Metadata *getRawEntity() const { return getOperand(1); }
3040
1.57k
  MDString *getRawName() const { return getOperandAs<MDString>(2); }
3041
1.89k
  Metadata *getRawFile() const { return getOperand(3); }
3042
3043
0
  static bool classof(const Metadata *MD) {
3044
0
    return MD->getMetadataID() == DIImportedEntityKind;
3045
0
  }
3046
};
3047
3048
/// A pair of DIGlobalVariable and DIExpression.
3049
class DIGlobalVariableExpression : public MDNode {
3050
  friend class LLVMContextImpl;
3051
  friend class MDNode;
3052
3053
  DIGlobalVariableExpression(LLVMContext &C, StorageType Storage,
3054
                             ArrayRef<Metadata *> Ops)
3055
1.94k
      : MDNode(C, DIGlobalVariableExpressionKind, Storage, Ops) {}
3056
1.78k
  ~DIGlobalVariableExpression() = default;
3057
3058
  static DIGlobalVariableExpression *
3059
  getImpl(LLVMContext &Context, Metadata *Variable, Metadata *Expression,
3060
          StorageType Storage, bool ShouldCreate = true);
3061
3062
2
  TempDIGlobalVariableExpression cloneImpl() const {
3063
2
    return getTemporary(getContext(), getVariable(), getExpression());
3064
2
  }
3065
3066
public:
3067
  DEFINE_MDNODE_GET(DIGlobalVariableExpression,
3068
                    (Metadata * Variable, Metadata *Expression),
3069
                    (Variable, Expression))
3070
3071
  TempDIGlobalVariableExpression clone() const { return cloneImpl(); }
3072
3073
30.2k
  Metadata *getRawVariable() const { return getOperand(0); }
3074
3075
22.9k
  DIGlobalVariable *getVariable() const {
3076
22.9k
    return cast_or_null<DIGlobalVariable>(getRawVariable());
3077
22.9k
  }
3078
3079
18.0k
  Metadata *getRawExpression() const { return getOperand(1); }
3080
3081
12.2k
  DIExpression *getExpression() const {
3082
12.2k
    return cast<DIExpression>(getRawExpression());
3083
12.2k
  }
3084
3085
4.39k
  static bool classof(const Metadata *MD) {
3086
4.39k
    return MD->getMetadataID() == DIGlobalVariableExpressionKind;
3087
4.39k
  }
3088
};
3089
3090
/// Macro Info DWARF-like metadata node.
3091
///
3092
/// A metadata node with a DWARF macro info (i.e., a constant named
3093
/// \c DW_MACINFO_*, defined in llvm/BinaryFormat/Dwarf.h).  Called \a
3094
/// DIMacroNode
3095
/// because it's potentially used for non-DWARF output.
3096
class DIMacroNode : public MDNode {
3097
  friend class LLVMContextImpl;
3098
  friend class MDNode;
3099
3100
protected:
3101
  DIMacroNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned MIType,
3102
              ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None)
3103
1.52k
      : MDNode(C, ID, Storage, Ops1, Ops2) {
3104
1.52k
    assert(MIType < 1u << 16);
3105
1.52k
    SubclassData16 = MIType;
3106
1.52k
  }
3107
1.52k
  ~DIMacroNode() = default;
3108
3109
13.3k
  template <class Ty> Ty *getOperandAs(unsigned I) const {
3110
13.3k
    return cast_or_null<Ty>(getOperand(I));
3111
13.3k
  }
3112
3113
5.78k
  StringRef getStringOperand(unsigned I) const {
3114
5.78k
    if (auto *S = getOperandAs<MDString>(I))
3115
5.66k
      return S->getString();
3116
117
    return StringRef();
3117
117
  }
3118
3119
2.83k
  static MDString *getCanonicalMDString(LLVMContext &Context, StringRef S) {
3120
2.83k
    if (S.empty())
3121
64
      return nullptr;
3122
2.76k
    return MDString::get(Context, S);
3123
2.76k
  }
3124
3125
public:
3126
8.06k
  unsigned getMacinfoType() const { return SubclassData16; }
3127
3128
1.55k
  static bool classof(const Metadata *MD) {
3129
1.55k
    switch (MD->getMetadataID()) {
3130
1.55k
    default:
3131
0
      return false;
3132
1.55k
    case DIMacroKind:
3133
1.55k
    case DIMacroFileKind:
3134
1.55k
      return true;
3135
1.55k
    }
3136
1.55k
  }
3137
};
3138
3139
class DIMacro : public DIMacroNode {
3140
  friend class LLVMContextImpl;
3141
  friend class MDNode;
3142
3143
  unsigned Line;
3144
3145
  DIMacro(LLVMContext &C, StorageType Storage, unsigned MIType, unsigned Line,
3146
          ArrayRef<Metadata *> Ops)
3147
1.43k
      : DIMacroNode(C, DIMacroKind, Storage, MIType, Ops), Line(Line) {}
3148
1.43k
  ~DIMacro() = default;
3149
3150
  static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
3151
                          StringRef Name, StringRef Value, StorageType Storage,
3152
1.41k
                          bool ShouldCreate = true) {
3153
1.41k
    return getImpl(Context, MIType, Line, getCanonicalMDString(Context, Name),
3154
1.41k
                   getCanonicalMDString(Context, Value), Storage, ShouldCreate);
3155
1.41k
  }
3156
  static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
3157
                          MDString *Name, MDString *Value, StorageType Storage,
3158
                          bool ShouldCreate = true);
3159
3160
0
  TempDIMacro cloneImpl() const {
3161
0
    return getTemporary(getContext(), getMacinfoType(), getLine(), getName(),
3162
0
                        getValue());
3163
0
  }
3164
3165
public:
3166
  DEFINE_MDNODE_GET(DIMacro, (unsigned MIType, unsigned Line, StringRef Name,
3167
                              StringRef Value = ""),
3168
                    (MIType, Line, Name, Value))
3169
  DEFINE_MDNODE_GET(DIMacro, (unsigned MIType, unsigned Line, MDString *Name,
3170
                              MDString *Value),
3171
                    (MIType, Line, Name, Value))
3172
3173
0
  TempDIMacro clone() const { return cloneImpl(); }
3174
3175
6.25k
  unsigned getLine() const { return Line; }
3176
3177
2.89k
  StringRef getName() const { return getStringOperand(0); }
3178
2.89k
  StringRef getValue() const { return getStringOperand(1); }
3179
3180
4.79k
  MDString *getRawName() const { return getOperandAs<MDString>(0); }
3181
2.80k
  MDString *getRawValue() const { return getOperandAs<MDString>(1); }
3182
3183
7
  static bool classof(const Metadata *MD) {
3184
7
    return MD->getMetadataID() == DIMacroKind;
3185
7
  }
3186
};
3187
3188
class DIMacroFile : public DIMacroNode {
3189
  friend class LLVMContextImpl;
3190
  friend class MDNode;
3191
3192
  unsigned Line;
3193
3194
  DIMacroFile(LLVMContext &C, StorageType Storage, unsigned MIType,
3195
              unsigned Line, ArrayRef<Metadata *> Ops)
3196
90
      : DIMacroNode(C, DIMacroFileKind, Storage, MIType, Ops), Line(Line) {}
3197
90
  ~DIMacroFile() = default;
3198
3199
  static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
3200
                              unsigned Line, DIFile *File,
3201
                              DIMacroNodeArray Elements, StorageType Storage,
3202
46
                              bool ShouldCreate = true) {
3203
46
    return getImpl(Context, MIType, Line, static_cast<Metadata *>(File),
3204
46
                   Elements.get(), Storage, ShouldCreate);
3205
46
  }
3206
3207
  static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
3208
                              unsigned Line, Metadata *File, Metadata *Elements,
3209
                              StorageType Storage, bool ShouldCreate = true);
3210
3211
0
  TempDIMacroFile cloneImpl() const {
3212
0
    return getTemporary(getContext(), getMacinfoType(), getLine(), getFile(),
3213
0
                        getElements());
3214
0
  }
3215
3216
public:
3217
  DEFINE_MDNODE_GET(DIMacroFile, (unsigned MIType, unsigned Line, DIFile *File,
3218
                                  DIMacroNodeArray Elements),
3219
                    (MIType, Line, File, Elements))
3220
  DEFINE_MDNODE_GET(DIMacroFile, (unsigned MIType, unsigned Line,
3221
                                  Metadata *File, Metadata *Elements),
3222
                    (MIType, Line, File, Elements))
3223
3224
0
  TempDIMacroFile clone() const { return cloneImpl(); }
3225
3226
0
  void replaceElements(DIMacroNodeArray Elements) {
3227
0
#ifndef NDEBUG
3228
0
    for (DIMacroNode *Op : getElements())
3229
0
      assert(is_contained(Elements->operands(), Op) &&
3230
0
             "Lost a macro node during macro node list replacement");
3231
0
#endif
3232
0
    replaceOperandWith(1, Elements.get());
3233
0
  }
3234
3235
196
  unsigned getLine() const { return Line; }
3236
45
  DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
3237
3238
106
  DIMacroNodeArray getElements() const {
3239
106
    return cast_or_null<MDTuple>(getRawElements());
3240
106
  }
3241
3242
294
  Metadata *getRawFile() const { return getOperand(0); }
3243
357
  Metadata *getRawElements() const { return getOperand(1); }
3244
3245
3
  static bool classof(const Metadata *MD) {
3246
3
    return MD->getMetadataID() == DIMacroFileKind;
3247
3
  }
3248
};
3249
3250
} // end namespace llvm
3251
3252
#undef DEFINE_MDNODE_GET_UNPACK_IMPL
3253
#undef DEFINE_MDNODE_GET_UNPACK
3254
#undef DEFINE_MDNODE_GET
3255
3256
#endif // LLVM_IR_DEBUGINFOMETADATA_H