llvm.org GIT mirror llvm / 9563b5a
Debug Info: Add a file: field to DIImportedEntity. DIImportedEntity has a line number, but not a file field. To determine the decl_line/decl_file we combine the line number from the DIImportedEntity with the file from the DIImportedEntity's scope. This does not work correctly when the parent scope is a DINamespace or a DIModule, both of which do not have a source file. This patch adds a file field to DIImportedEntity to unambiguously identify the source location of the using/import declaration. Most testcase updates are mechanical, the interesting one is the removal of the FIXME in test/DebugInfo/Generic/namespace.ll. This fixes PR33822. See https://bugs.llvm.org/show_bug.cgi?id=33822 for more context. <rdar://problem/33357889> https://bugs.llvm.org/show_bug.cgi?id=33822 Differential Revision: https://reviews.llvm.org/D35583 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308398 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 2 years ago
25 changed file(s) with 156 addition(s) and 112 deletion(s). Raw diff Collapse all Expand all
673673
674674 /// Create a descriptor for an imported module.
675675 /// \param Context The scope this module is imported into
676 /// \param NS The namespace being imported here
677 /// \param Line Line number
676 /// \param NS The namespace being imported here.
677 /// \param File File where the declaration is located.
678 /// \param Line Line number of the declaration.
678679 DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
680 DIFile *File, unsigned Line);
681
682 /// Create a descriptor for an imported module.
683 /// \param Context The scope this module is imported into.
684 /// \param NS An aliased namespace.
685 /// \param File File where the declaration is located.
686 /// \param Line Line number of the declaration.
687 DIImportedEntity *createImportedModule(DIScope *Context,
688 DIImportedEntity *NS, DIFile *File,
679689 unsigned Line);
680690
681691 /// Create a descriptor for an imported module.
682 /// \param Context The scope this module is imported into
683 /// \param NS An aliased namespace
684 /// \param Line Line number
685 DIImportedEntity *createImportedModule(DIScope *Context,
686 DIImportedEntity *NS, unsigned Line);
687
688 /// Create a descriptor for an imported module.
689 /// \param Context The scope this module is imported into
690 /// \param M The module being imported here
691 /// \param Line Line number
692 /// \param Context The scope this module is imported into.
693 /// \param M The module being imported here
694 /// \param File File where the declaration is located.
695 /// \param Line Line number of the declaration.
692696 DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M,
693 unsigned Line);
697 DIFile *File, unsigned Line);
694698
695699 /// Create a descriptor for an imported function.
696 /// \param Context The scope this module is imported into
697 /// \param Decl The declaration (or definition) of a function, type, or
698 /// variable
699 /// \param Line Line number
700 /// \param Context The scope this module is imported into.
701 /// \param Decl The declaration (or definition) of a function, type, or
702 /// variable.
703 /// \param File File where the declaration is located.
704 /// \param Line Line number of the declaration.
700705 DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
701 unsigned Line,
706 DIFile *File, unsigned Line,
702707 StringRef Name = "");
703708
704709 /// Insert a new llvm.dbg.declare intrinsic call.
25502550
25512551 static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
25522552 DIScope *Scope, DINodeRef Entity,
2553 unsigned Line, StringRef Name,
2553 DIFile *File, unsigned Line, StringRef Name,
25542554 StorageType Storage,
25552555 bool ShouldCreate = true) {
2556 return getImpl(Context, Tag, Scope, Entity, Line,
2556 return getImpl(Context, Tag, Scope, Entity, File, Line,
25572557 getCanonicalMDString(Context, Name), Storage, ShouldCreate);
25582558 }
25592559 static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
25602560 Metadata *Scope, Metadata *Entity,
2561 unsigned Line, MDString *Name,
2562 StorageType Storage,
2561 Metadata *File, unsigned Line,
2562 MDString *Name, StorageType Storage,
25632563 bool ShouldCreate = true);
25642564
25652565 TempDIImportedEntity cloneImpl() const {
25662566 return getTemporary(getContext(), getTag(), getScope(), getEntity(),
2567 getLine(), getName());
2567 getFile(), getLine(), getName());
25682568 }
25692569
25702570 public:
25712571 DEFINE_MDNODE_GET(DIImportedEntity,
25722572 (unsigned Tag, DIScope *Scope, DINodeRef Entity,
2573 unsigned Line, StringRef Name = ""),
2574 (Tag, Scope, Entity, Line, Name))
2573 DIFile *File, unsigned Line, StringRef Name = ""),
2574 (Tag, Scope, Entity, File, Line, Name))
25752575 DEFINE_MDNODE_GET(DIImportedEntity,
25762576 (unsigned Tag, Metadata *Scope, Metadata *Entity,
2577 unsigned Line, MDString *Name),
2578 (Tag, Scope, Entity, Line, Name))
2577 Metadata *File, unsigned Line, MDString *Name),
2578 (Tag, Scope, Entity, File, Line, Name))
25792579
25802580 TempDIImportedEntity clone() const { return cloneImpl(); }
25812581
25832583 DIScope *getScope() const { return cast_or_null(getRawScope()); }
25842584 DINodeRef getEntity() const { return DINodeRef(getRawEntity()); }
25852585 StringRef getName() const { return getStringOperand(2); }
2586 DIFile *getFile() const { return cast_or_null(getRawFile()); }
25862587
25872588 Metadata *getRawScope() const { return getOperand(0); }
25882589 Metadata *getRawEntity() const { return getOperand(1); }
25892590 MDString *getRawName() const { return getOperandAs(2); }
2591 Metadata *getRawFile() const { return getOperand(3); }
25902592
25912593 static bool classof(const Metadata *MD) {
25922594 return MD->getMetadataID() == DIImportedEntityKind;
44104410 REQUIRED(tag, DwarfTagField, ); \
44114411 REQUIRED(scope, MDField, ); \
44124412 OPTIONAL(entity, MDField, ); \
4413 OPTIONAL(file, MDField, ); \
44134414 OPTIONAL(line, LineField, ); \
44144415 OPTIONAL(name, MDStringField, );
44154416 PARSE_MD_FIELDS();
44164417 #undef VISIT_MD_FIELDS
44174418
4418 Result = GET_OR_DISTINCT(DIImportedEntity, (Context, tag.Val, scope.Val,
4419 entity.Val, line.Val, name.Val));
4419 Result = GET_OR_DISTINCT(
4420 DIImportedEntity,
4421 (Context, tag.Val, scope.Val, entity.Val, file.Val, line.Val, name.Val));
44204422 return false;
44214423 }
44224424
16701670 break;
16711671 }
16721672 case bitc::METADATA_IMPORTED_ENTITY: {
1673 if (Record.size() != 6)
1673 if (Record.size() != 6 && Record.size() != 7)
16741674 return error("Invalid record");
16751675
16761676 IsDistinct = Record[0];
1677 bool HasFile = (Record.size() == 7);
16771678 MetadataList.assignValue(
16781679 GET_OR_DISTINCT(DIImportedEntity,
16791680 (Context, Record[1], getMDOrNull(Record[2]),
1680 getDITypeRefOrNull(Record[3]), Record[4],
1681 getMDString(Record[5]))),
1681 getDITypeRefOrNull(Record[3]),
1682 HasFile ? getMDOrNull(Record[6]) : nullptr,
1683 HasFile ? Record[4] : 0, getMDString(Record[5]))),
16821684 NextMetadataNo);
16831685 NextMetadataNo++;
16841686 break;
17171717 Record.push_back(VE.getMetadataOrNullID(N->getEntity()));
17181718 Record.push_back(N->getLine());
17191719 Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1720 Record.push_back(VE.getMetadataOrNullID(N->getRawFile()));
17201721
17211722 Stream.EmitRecord(bitc::METADATA_IMPORTED_ENTITY, Record, Abbrev);
17221723 Record.clear();
663663 else
664664 EntityDie = getDIE(Entity);
665665 assert(EntityDie);
666 addSourceLine(*IMDie, Module->getLine(), Module->getScope()->getFilename(),
667 Module->getScope()->getDirectory());
666 auto *File = Module->getFile();
667 addSourceLine(*IMDie, Module->getLine(), File ? File->getFilename() : "",
668 File ? File->getDirectory() : "");
668669 addDIEEntry(*IMDie, dwarf::DW_AT_import, *EntityDie);
669670 StringRef Name = Module->getName();
670671 if (!Name.empty())
19631963 Printer.printString("name", N->getName());
19641964 Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false);
19651965 Printer.printMetadata("entity", N->getRawEntity());
1966 Printer.printMetadata("file", N->getRawFile());
19661967 Printer.printInt("line", N->getLine());
19671968 Out << ")";
19681969 }
147147
148148 static DIImportedEntity *
149149 createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context,
150 Metadata *NS, unsigned Line, StringRef Name,
150 Metadata *NS, DIFile *File, unsigned Line, StringRef Name,
151151 SmallVectorImpl &AllImportedModules) {
152 if (Line)
153 assert(File && "Source location has line number but no file");
152154 unsigned EntitiesCount = C.pImpl->DIImportedEntitys.size();
153 auto *M = DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), Line, Name);
155 auto *M =
156 DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), File, Line, Name);
154157 if (EntitiesCount < C.pImpl->DIImportedEntitys.size())
155158 // A new Imported Entity was just added to the context.
156159 // Add it to the Imported Modules list.
159162 }
160163
161164 DIImportedEntity *DIBuilder::createImportedModule(DIScope *Context,
162 DINamespace *NS,
165 DINamespace *NS, DIFile *File,
163166 unsigned Line) {
164167 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
165 Context, NS, Line, StringRef(), AllImportedModules);
168 Context, NS, File, Line, StringRef(),
169 AllImportedModules);
166170 }
167171
168172 DIImportedEntity *DIBuilder::createImportedModule(DIScope *Context,
169173 DIImportedEntity *NS,
170 unsigned Line) {
174 DIFile *File, unsigned Line) {
171175 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
172 Context, NS, Line, StringRef(), AllImportedModules);
176 Context, NS, File, Line, StringRef(),
177 AllImportedModules);
173178 }
174179
175180 DIImportedEntity *DIBuilder::createImportedModule(DIScope *Context, DIModule *M,
176 unsigned Line) {
181 DIFile *File, unsigned Line) {
177182 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
178 Context, M, Line, StringRef(), AllImportedModules);
183 Context, M, File, Line, StringRef(),
184 AllImportedModules);
179185 }
180186
181187 DIImportedEntity *DIBuilder::createImportedDeclaration(DIScope *Context,
182188 DINode *Decl,
189 DIFile *File,
183190 unsigned Line,
184191 StringRef Name) {
185192 // Make sure to use the unique identifier based metadata reference for
186193 // types that have one.
187194 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
188 Context, Decl, Line, Name, AllImportedModules);
195 Context, Decl, File, Line, Name,
196 AllImportedModules);
189197 }
190198
191199 DIFile *DIBuilder::createFile(StringRef Filename, StringRef Directory,
759759
760760 DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
761761 Metadata *Scope, Metadata *Entity,
762 unsigned Line, MDString *Name,
763 StorageType Storage,
762 Metadata *File, unsigned Line,
763 MDString *Name, StorageType Storage,
764764 bool ShouldCreate) {
765765 assert(isCanonical(Name) && "Expected canonical MDString");
766 DEFINE_GETIMPL_LOOKUP(DIImportedEntity, (Tag, Scope, Entity, Line, Name));
767 Metadata *Ops[] = {Scope, Entity, Name};
766 DEFINE_GETIMPL_LOOKUP(DIImportedEntity,
767 (Tag, Scope, Entity, File, Line, Name));
768 Metadata *Ops[] = {Scope, Entity, Name, File};
768769 DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops);
769770 }
770771
989989 unsigned Tag;
990990 Metadata *Scope;
991991 Metadata *Entity;
992 Metadata *File;
992993 unsigned Line;
993994 MDString *Name;
994995
995 MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, unsigned Line,
996 MDString *Name)
997 : Tag(Tag), Scope(Scope), Entity(Entity), Line(Line), Name(Name) {}
996 MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, Metadata *File,
997 unsigned Line, MDString *Name)
998 : Tag(Tag), Scope(Scope), Entity(Entity), File(File), Line(Line),
999 Name(Name) {}
9981000 MDNodeKeyImpl(const DIImportedEntity *N)
9991001 : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
1000 Line(N->getLine()), Name(N->getRawName()) {}
1002 File(N->getRawFile()), Line(N->getLine()), Name(N->getRawName()) {}
10011003
10021004 bool isKeyOf(const DIImportedEntity *RHS) const {
10031005 return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
1004 Entity == RHS->getRawEntity() && Line == RHS->getLine() &&
1005 Name == RHS->getRawName();
1006 }
1007
1008 unsigned getHashValue() const {
1009 return hash_combine(Tag, Scope, Entity, Line, Name);
1006 Entity == RHS->getRawEntity() && File == RHS->getFile() &&
1007 Line == RHS->getLine() && Name == RHS->getRawName();
1008 }
1009
1010 unsigned getHashValue() const {
1011 return hash_combine(Tag, Scope, Entity, File, Line, Name);
10101012 }
10111013 };
10121014
1717 ; CHECK: !3 = !DICompositeType({{.*}})
1818 !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "Class", size: 32, align: 32)
1919
20 ; CHECK-NEXT: !4 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0, entity: !1, line: 7)
20 ; CHECK-NEXT: !4 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0, entity: !1, file: !2, line: 7)
2121 !4 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0,
22 entity: !1, line: 7)
22 entity: !1, file: !2, line: 7)
2323
2424 ; CHECK-NEXT: !5 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0)
2525 !5 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0)
3535 !9 = !{!"clang version 4.0.0 (trunk 286129) (llvm/trunk 286128)"}
3636 !10 = distinct !DIGlobalVariable(name: "c", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true, expr: !DIExpression(DW_OP_constu, 23, DW_OP_stack_value))
3737 !11 = distinct !DIGlobalVariable(name: "h", scope: !1, file: !2, line: 2, type: !5, isLocal: false, isDefinition: true)
38 !12 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 1, scope: !1, entity: !11)
38 !12 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !2, line: 1, scope: !1, entity: !11)
0 ; RUN: llvm-dis < %s.bc | FileCheck %s
1 ; RUN: verify-uselistorder < %s.bc
2
3 !llvm.dbg.cu = !{!0}
4 !llvm.module.flags = !{!9, !10}
5
6 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 308185) (llvm/trunk 308186)", emissionKind: FullDebug, imports: !3)
7 !1 = !DIFile(filename: "using.ii", directory: "/")
8 !3 = !{!4}
9 !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !8, line: 301)
10 ; CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, entity: !5)
11 !5 = !DINamespace(name: "M", scope: null)
12 !8 = !DINamespace(name: "N", scope: null)
13 !9 = !{i32 2, !"Dwarf Version", i32 4}
14 !10 = !{i32 2, !"Debug Info Version", i32 3}
5353
5454 ; CHECK-NOT: NULL
5555 ; CHECK: DW_TAG_imported_module
56 ; This is a bug, it should be in F2 but it inherits the file from its
57 ; enclosing scope
58 ; CHECK-NEXT: DW_AT_decl_file{{.*}}stdin
56 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2:.*]])
5957 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(15)
6058 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS2]]})
6159 ; CHECK: NULL
6260 ; CHECK-NOT: NULL
6361
6462 ; CHECK: DW_TAG_imported_module
65 ; Same bug as above, this should be F2
66 ; CHECK-NEXT: DW_AT_decl_file{{.*}}debug-info-namespace.cpp
63 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2:.*]])
6764 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(18)
6865 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS1]]})
6966 ; CHECK-NOT: NULL
319316 !31 = !DIGlobalVariable(name: "i", linkageName: "_ZN1A1B1iE", line: 20, isLocal: false, isDefinition: true, scope: !6, file: !18, type: !13)
320317 !32 = !DIGlobalVariable(name: "var_fwd", linkageName: "_ZN1A1B7var_fwdE", line: 44, isLocal: false, isDefinition: true, scope: !6, file: !18, type: !13)
321318 !33 = !{!34, !35, !36, !37, !40, !41, !42, !43, !44, !45, !47, !48, !49, !51, !54, !55, !56}
322 !34 = !DIImportedEntity(tag: DW_TAG_imported_module, line: 15, scope: !7, entity: !6)
323 !35 = !DIImportedEntity(tag: DW_TAG_imported_module, line: 18, scope: !0, entity: !7)
324 !36 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 19, name: "E", scope: !0, entity: !7)
325 !37 = !DIImportedEntity(tag: DW_TAG_imported_module, line: 23, scope: !38, entity: !6)
319 !34 = !DIImportedEntity(tag: DW_TAG_imported_module, file: !5, line: 15, scope: !7, entity: !6)
320 !35 = !DIImportedEntity(tag: DW_TAG_imported_module, file: !5, line: 18, scope: !0, entity: !7)
321 !36 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 19, name: "E", scope: !0, entity: !7)
322 !37 = !DIImportedEntity(tag: DW_TAG_imported_module, file: !5, line: 23, scope: !38, entity: !6)
326323 !38 = distinct !DILexicalBlock(line: 22, column: 10, file: !5, scope: !39)
327324 !39 = distinct !DILexicalBlock(line: 22, column: 7, file: !5, scope: !21)
328 !40 = !DIImportedEntity(tag: DW_TAG_imported_module, line: 26, scope: !21, entity: !7)
329 !41 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 27, scope: !21, entity: !4)
330 !42 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 28, scope: !21, entity: !8)
331 !43 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 29, scope: !21, entity: !14)
332 !44 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 30, scope: !21, entity: !31)
333 !45 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 31, scope: !21, entity: !46)
325 !40 = !DIImportedEntity(tag: DW_TAG_imported_module, file: !5, line: 26, scope: !21, entity: !7)
326 !41 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 27, scope: !21, entity: !4)
327 !42 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 28, scope: !21, entity: !8)
328 !43 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 29, scope: !21, entity: !14)
329 !44 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 30, scope: !21, entity: !31)
330 !45 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 31, scope: !21, entity: !46)
334331 !46 = !DIDerivedType(tag: DW_TAG_typedef, name: "baz", line: 7, file: !5, scope: !6, baseType: !8)
335 !47 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 32, name: "X", scope: !21, entity: !7)
336 !48 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 33, name: "Y", scope: !21, entity: !47)
337 !49 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 34, scope: !21, entity: !50)
332 !47 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 32, name: "X", scope: !21, entity: !7)
333 !48 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 33, name: "Y", scope: !21, entity: !47)
334 !49 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 34, scope: !21, entity: !50)
338335 !50 = !DIGlobalVariable(name: "var_decl", linkageName: "_ZN1A1B8var_declE", line: 8, isLocal: false, isDefinition: false, scope: !6, file: !18, type: !13)
339 !51 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 35, scope: !21, entity: !52)
336 !51 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 35, scope: !21, entity: !52)
340337 !52 = !DISubprogram(name: "func_decl", linkageName: "_ZN1A1B9func_declEv", line: 9, isLocal: false, isDefinition: false, flags: DIFlagPrototyped, isOptimized: false, file: !5, scope: !6, type: !19, variables: !53)
341338 !53 = !{} ; previously: invalid DW_TAG_base_type
342 !54 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 36, scope: !21, entity: !32)
343 !55 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 37, scope: !21, entity: !26)
344 !56 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 42, scope: !7, entity: !31)
339 !54 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 36, scope: !21, entity: !32)
340 !55 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 37, scope: !21, entity: !26)
341 !56 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 42, scope: !7, entity: !31)
345342 !57 = !{i32 2, !"Dwarf Version", i32 2}
346343 !58 = !{i32 2, !"Debug Info Version", i32 3}
347344 !59 = !{!"clang version 3.6.0 "}
1717 !1 = !DIFile(filename: "/llvm/tools/clang/test/Modules/", directory: "/")
1818 !2 = !{}
1919 !3 = !{!4}
20 !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !5, line: 5)
20 !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !5, file: !1, line: 5)
2121 !5 = !DIModule(scope: null, name: "DebugModule", configMacros: "-DMODULES=0", includePath: "/llvm/tools/clang/test/Modules/Inputs", isysroot: "/")
2222 !6 = !{i32 2, !"Dwarf Version", i32 4}
2323 !7 = !{i32 2, !"Debug Info Version", i32 3}
2323 !4 = !{}
2424 !5 = !{!0}
2525 !6 = !{!7}
26 !7 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !2, entity: !8, line: 11)
26 !7 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !2, entity: !8, file: !3, line: 11)
2727 !8 = !DIModule(scope: null, name: "Module", includePath: ".", isysroot: "/")
2828 !9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, align: 64)
2929 !10 = !DICompositeType(tag: DW_TAG_structure_type, name: "s", scope: !8, file: !3, line: 1, flags: DIFlagFwdDecl)
109109 !16 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
110110 !17 = !DISubprogram(name: "f2", linkageName: "_ZN3foo2f2IiEEvv", line: 10, isLocal: false, isDefinition: false, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 10, file: !1, scope: !4, type: !12, templateParams: !14)
111111 !18 = !{!19}
112 !19 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 19, scope: !20, entity: !4)
112 !19 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !1, line: 19, scope: !20, entity: !4)
113113 !20 = distinct !DILexicalBlock(line: 16, column: 13, file: !1, scope: !21)
114114 !21 = distinct !DILexicalBlock(line: 16, column: 7, file: !1, scope: !10)
115115 !22 = !{i32 2, !"Dwarf Version", i32 4}
344344 !42 = !DINamespace(scope: !43)
345345 !43 = !DINamespace(name: "outer", scope: null)
346346 !44 = !{!45, !47}
347 !45 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !2, entity: !46, line: 34)
347 !45 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !2, entity: !46, file:!3, line: 34)
348348 !46 = !DIGlobalVariable(name: "global_namespace_variable_decl", linkageName: "_ZN2ns30global_namespace_variable_declE", scope: !18, file: !3, line: 28, type: !9, isLocal: false, isDefinition: false)
349 !47 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !43, entity: !42, line: 43)
349 !47 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !43, entity: !42, file: !3, line: 43)
350350 !48 = !{i32 2, !"Dwarf Version", i32 4}
351351 !49 = !{i32 2, !"Debug Info Version", i32 3}
352352 !50 = !{!"clang version 3.7.0 (trunk 234897) (llvm/trunk 234911)"}
133133 !8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !9, file: !9, line: 6, type: !5, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
134134 !9 = !DIFile(filename: "test.h", directory: "/")
135135 !10 = !{!11}
136 !11 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !12, entity: !14, line: 1)
136 !11 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !12, entity: !14, file: !1, line: 1)
137137 !12 = !DILexicalBlockFile(scope: !13, file: !9, discriminator: 0)
138138 !13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3)
139139 !14 = !DINamespace(name: "N", scope: null)
104104 !19 = !DIDerivedType(tag: DW_TAG_typedef, name: "string", line: 65, file: !20, scope: !10, baseType: !8)
105105 !20 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/stringfwd.h", directory: "/llvm_cmake_gcc")
106106 !21 = !{!22, !26, !29, !33, !38, !41}
107 !22 = !DIImportedEntity(tag: DW_TAG_imported_module, line: 57, scope: !23, entity: !25)
107 !22 = !DIImportedEntity(tag: DW_TAG_imported_module, file: !1, line: 57, scope: !23, entity: !25)
108108 !23 = !DINamespace(name: "__gnu_debug", scope: null)
109109 !24 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/debug/debug.h", directory: "/llvm_cmake_gcc")
110110 !25 = !DINamespace(name: "__debug", scope: !10)
111 !26 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 66, scope: !10, entity: !27)
111 !26 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !1, line: 66, scope: !10, entity: !27)
112112 !27 = !DIDerivedType(tag: DW_TAG_typedef, name: "mbstate_t", line: 106, file: !5, baseType: !28)
113113 !28 = !DIDerivedType(tag: DW_TAG_typedef, name: "__mbstate_t", line: 95, file: !5, baseType: !4)
114 !29 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 141, scope: !10, entity: !30)
114 !29 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !1, line: 141, scope: !10, entity: !30)
115115 !30 = !DIDerivedType(tag: DW_TAG_typedef, name: "wint_t", line: 141, file: !31, baseType: !32)
116116 !31 = !DIFile(filename: "/llvm_cmake_gcc/bin/../lib/clang/3.5.0/include/stddef.h", directory: "/llvm_cmake_gcc")
117117 !32 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
118 !33 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 42, scope: !34, entity: !36)
118 !33 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !1, line: 42, scope: !34, entity: !36)
119119 !34 = !DINamespace(name: "__gnu_cxx", scope: null)
120120 !35 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/cpp_type_traits.h", directory: "/llvm_cmake_gcc")
121121 !36 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_t", line: 155, file: !11, scope: !10, baseType: !37)
122122 !37 = !DIBasicType(tag: DW_TAG_base_type, name: "long unsigned int", size: 64, align: 64, encoding: DW_ATE_unsigned)
123 !38 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 43, scope: !34, entity: !39)
123 !38 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !1, line: 43, scope: !34, entity: !39)
124124 !39 = !DIDerivedType(tag: DW_TAG_typedef, name: "ptrdiff_t", line: 156, file: !11, scope: !10, baseType: !40)
125125 !40 = !DIBasicType(tag: DW_TAG_base_type, name: "long int", size: 64, align: 64, encoding: DW_ATE_signed)
126 !41 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 55, scope: !10, entity: !6)
126 !41 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !1, line: 55, scope: !10, entity: !6)
127127 !42 = !{i32 2, !"Dwarf Version", i32 4}
128128 !43 = !{i32 2, !"Debug Info Version", i32 3}
129129 !44 = !{!"clang version 3.5.0 (209308)"}
4343 !7 = !{null}
4444 !8 = distinct !DISubprogram(name: "b", linkageName: "_ZN1A1bEv", scope: !5, file: !1, line: 8, type: !6, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
4545 !9 = !{!10, !16}
46 !10 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !8, entity: !4, line: 8)
46 !10 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !8, entity: !4, file: !1, line: 8)
4747 !11 = !{i32 2, !"Dwarf Version", i32 4}
4848 !12 = !{i32 2, !"Debug Info Version", i32 3}
4949 !13 = !{!"clang version 3.8.0 (trunk 256934) (llvm/trunk 256936)"}
5050 !14 = !DILocation(line: 7, column: 12, scope: !4)
5151 !15 = !DILocation(line: 8, column: 24, scope: !8)
52 !16 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !17, entity: !19, line: 8)
52 !16 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !17, entity: !19, file: !1, line: 8)
5353 !17 = distinct !DILexicalBlock(scope: !18, file: !1, line: 9, column: 8)
5454 !18 = distinct !DISubprogram(name: "c", linkageName: "_ZN1A1cEv", scope: !5, file: !1, line: 9, type: !6, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
5555 !19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 10, column: 8)
5050 !9 = !DIGlobalVariableExpression(var: !10)
5151 !10 = !DIGlobalVariable(name: "version", scope: !4, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true)
5252 !11 = !{!12, !16}
53 !12 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, entity: !13, line: 8)
53 !12 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, entity: !13, file: !1, line: 8)
5454 !13 = distinct !DISubprogram(name: "a", linkageName: "_ZN1A1aEv", scope: !4, file: !1, line: 7, type: !14, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !5)
5555 !14 = !DISubroutineType(types: !15)
5656 !15 = !{null}
57 !16 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !17, entity: !19, line: 8)
57 !16 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !17, entity: !19, file: !1, line: 8)
5858 !17 = distinct !DILexicalBlock(scope: !18, file: !1, line: 9, column: 8)
5959 !18 = distinct !DISubprogram(name: "c", linkageName: "_ZN1A1cEv", scope: !4, file: !1, line: 9, type: !14, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !5)
6060 !19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 10, column: 8)
462462 TEST_F(IRBuilderTest, DIImportedEntity) {
463463 IRBuilder<> Builder(BB);
464464 DIBuilder DIB(*M);
465 auto F = DIB.createFile("F.CBL", "/");
465466 auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74,
466 DIB.createFile("F.CBL", "/"), "llvm-cobol74",
467 F, "llvm-cobol74",
467468 true, "", 0);
468 DIB.createImportedDeclaration(CU, nullptr, 1);
469 DIB.createImportedDeclaration(CU, nullptr, 1);
470 DIB.createImportedModule(CU, (DIImportedEntity *)nullptr, 2);
471 DIB.createImportedModule(CU, (DIImportedEntity *)nullptr, 2);
469 DIB.createImportedDeclaration(CU, nullptr, F, 1);
470 DIB.createImportedDeclaration(CU, nullptr, F, 1);
471 DIB.createImportedModule(CU, (DIImportedEntity *)nullptr, F, 2);
472 DIB.createImportedModule(CU, (DIImportedEntity *)nullptr, F, 2);
472473 DIB.finalize();
473474 EXPECT_TRUE(verifyModule(*M));
474475 EXPECT_TRUE(CU->getImportedEntities().size() == 2);
21152115 unsigned Tag = dwarf::DW_TAG_imported_module;
21162116 DIScope *Scope = getSubprogram();
21172117 DINode *Entity = getCompositeType();
2118 DIFile *File = getFile();
21182119 unsigned Line = 5;
21192120 StringRef Name = "name";
21202121
2121 auto *N = DIImportedEntity::get(Context, Tag, Scope, Entity, Line, Name);
2122 auto *N =
2123 DIImportedEntity::get(Context, Tag, Scope, Entity, File, Line, Name);
21222124
21232125 EXPECT_EQ(Tag, N->getTag());
21242126 EXPECT_EQ(Scope, N->getScope());
21252127 EXPECT_EQ(Entity, N->getEntity());
2128 EXPECT_EQ(File, N->getFile());
21262129 EXPECT_EQ(Line, N->getLine());
21272130 EXPECT_EQ(Name, N->getName());
2128 EXPECT_EQ(N, DIImportedEntity::get(Context, Tag, Scope, Entity, Line, Name));
2131 EXPECT_EQ(
2132 N, DIImportedEntity::get(Context, Tag, Scope, Entity, File, Line, Name));
21292133
21302134 EXPECT_NE(N,
21312135 DIImportedEntity::get(Context, dwarf::DW_TAG_imported_declaration,
2132 Scope, Entity, Line, Name));
2136 Scope, Entity, File, Line, Name));
21332137 EXPECT_NE(N, DIImportedEntity::get(Context, Tag, getSubprogram(), Entity,
2134 Line, Name));
2138 File, Line, Name));
21352139 EXPECT_NE(N, DIImportedEntity::get(Context, Tag, Scope, getCompositeType(),
2136 Line, Name));
2137 EXPECT_NE(N,
2138 DIImportedEntity::get(Context, Tag, Scope, Entity, Line + 1, Name));
2139 EXPECT_NE(N,
2140 DIImportedEntity::get(Context, Tag, Scope, Entity, Line, "other"));
2140 File, Line, Name));
2141 EXPECT_NE(N, DIImportedEntity::get(Context, Tag, Scope, Entity, nullptr, Line,
2142 Name));
2143 EXPECT_NE(N, DIImportedEntity::get(Context, Tag, Scope, Entity, File,
2144 Line + 1, Name));
2145 EXPECT_NE(N, DIImportedEntity::get(Context, Tag, Scope, Entity, File, Line,
2146 "other"));
21412147
21422148 TempDIImportedEntity Temp = N->clone();
21432149 EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));