llvm.org GIT mirror llvm / 4863252
[DebugInfo] Unify ChecksumKind and Checksum value in DIFile Rather than encode the absence of a checksum with a Kind variant, instead put both the kind and value in a struct and wrap it in an Optional. Differential Revision: http://reviews.llvm.org/D43043 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324928 91177308-0d34-0410-b5e6-96231b3b80d8 Scott Linder 1 year, 9 months ago
17 changed file(s) with 202 addition(s) and 126 deletion(s). Raw diff Collapse all Expand all
140140 /// Create a file descriptor to hold debugging information for a file.
141141 /// \param Filename File name.
142142 /// \param Directory Directory.
143 /// \param CSKind Checksum kind (e.g. CSK_None, CSK_MD5, CSK_SHA1, etc.).
144 /// \param Checksum Checksum data.
145 DIFile *createFile(StringRef Filename, StringRef Directory,
146 DIFile::ChecksumKind CSKind = DIFile::CSK_None,
147 StringRef Checksum = StringRef());
143 /// \param Checksum Checksum kind (e.g. CSK_MD5, CSK_SHA1, etc.) and value.
144 DIFile *
145 createFile(StringRef Filename, StringRef Directory,
146 Optional> Checksum = None);
148147
149148 /// Create debugging information entry for a macro.
150149 /// \param Parent Macro parent (could be nullptr).
498498 friend class MDNode;
499499
500500 public:
501 // These values must be explictly set, as they end up in the final object
502 // file.
501 /// Which algorithm (e.g. MD5) a checksum was generated with.
502 ///
503 /// The encoding is explicit because it is used directly in Bitcode. The
504 /// value 0 is reserved to indicate the absence of a checksum in Bitcode.
503505 enum ChecksumKind {
504 CSK_None = 0,
506 // The first variant was originally CSK_None, encoded as 0. The new
507 // internal representation removes the need for this by wrapping the
508 // ChecksumInfo in an Optional, but to preserve Bitcode compatibility the 0
509 // encoding is reserved.
505510 CSK_MD5 = 1,
506511 CSK_SHA1 = 2,
507512 CSK_Last = CSK_SHA1 // Should be last enumeration.
508513 };
509514
515 /// A single checksum, represented by a \a Kind and a \a Value (a string).
516 template
517 struct ChecksumInfo {
518 /// The kind of checksum which \a Value encodes.
519 ChecksumKind Kind;
520 /// The string value of the checksum.
521 T Value;
522
523 ChecksumInfo(ChecksumKind Kind, T Value) : Kind(Kind), Value(Value) { }
524 ~ChecksumInfo() = default;
525 bool operator==(const ChecksumInfo &X) const {
526 return Kind == X.Kind && Value == X.Value;
527 }
528 bool operator!=(const ChecksumInfo &X) const { return !(*this == X); }
529 StringRef getKindAsString() const { return getChecksumKindAsString(Kind); }
530 };
531
510532 private:
511 ChecksumKind CSKind;
512
513 DIFile(LLVMContext &C, StorageType Storage, ChecksumKind CSK,
533 Optional> Checksum;
534
535 DIFile(LLVMContext &C, StorageType Storage,
536 Optional> CS,
514537 ArrayRef Ops)
515538 : DIScope(C, DIFileKind, Storage, dwarf::DW_TAG_file_type, Ops),
516 CSKind(CSK) {}
539 Checksum(CS) {}
517540 ~DIFile() = default;
518541
519542 static DIFile *getImpl(LLVMContext &Context, StringRef Filename,
520 StringRef Directory, ChecksumKind CSK, StringRef CS,
543 StringRef Directory,
544 Optional> CS,
521545 StorageType Storage, bool ShouldCreate = true) {
546 Optional> MDChecksum;
547 if (CS)
548 MDChecksum.emplace(CS->Kind, getCanonicalMDString(Context, CS->Value));
522549 return getImpl(Context, getCanonicalMDString(Context, Filename),
523 getCanonicalMDString(Context, Directory), CSK,
524 getCanonicalMDString(Context, CS), Storage, ShouldCreate);
550 getCanonicalMDString(Context, Directory), MDChecksum,
551 Storage, ShouldCreate);
525552 }
526553 static DIFile *getImpl(LLVMContext &Context, MDString *Filename,
527 MDString *Directory, ChecksumKind CSK, MDString *CS,
554 MDString *Directory,
555 Optional> CS,
528556 StorageType Storage, bool ShouldCreate = true);
529557
530558 TempDIFile cloneImpl() const {
531559 return getTemporary(getContext(), getFilename(), getDirectory(),
532 getChecksumKind(), getChecksum());
560 getChecksum());
533561 }
534562
535563 public:
536564 DEFINE_MDNODE_GET(DIFile, (StringRef Filename, StringRef Directory,
537 ChecksumKind CSK = CSK_None,
538 StringRef CS = StringRef()),
539 (Filename, Directory, CSK, CS))
565 Optional> CS = None),
566 (Filename, Directory, CS))
540567 DEFINE_MDNODE_GET(DIFile, (MDString * Filename, MDString *Directory,
541 ChecksumKind CSK = CSK_None,
542 MDString *CS = nullptr),
543 (Filename, Directory, CSK, CS))
568 Optional> CS = None),
569 (Filename, Directory, CS))
544570
545571 TempDIFile clone() const { return cloneImpl(); }
546572
547573 StringRef getFilename() const { return getStringOperand(0); }
548574 StringRef getDirectory() const { return getStringOperand(1); }
549 StringRef getChecksum() const { return getStringOperand(2); }
550 ChecksumKind getChecksumKind() const { return CSKind; }
551 StringRef getChecksumKindAsString() const;
575 Optional> getChecksum() const {
576 Optional> StringRefChecksum;
577 if (Checksum)
578 StringRefChecksum.emplace(Checksum->Kind, Checksum->Value->getString());
579 return StringRefChecksum;
580 }
552581
553582 MDString *getRawFilename() const { return getOperandAs(0); }
554583 MDString *getRawDirectory() const { return getOperandAs(1); }
555 MDString *getRawChecksum() const { return getOperandAs(2); }
556
557 static ChecksumKind getChecksumKind(StringRef CSKindStr);
584 Optional> getRawChecksum() const { return Checksum; }
585
586 static StringRef getChecksumKindAsString(ChecksumKind CSKind);
587 static Optional getChecksumKind(StringRef CSKindStr);
558588
559589 static bool classof(const Metadata *MD) {
560590 return MD->getMetadataID() == DIFileKind;
36113611 };
36123612
36133613 struct ChecksumKindField : public MDFieldImpl {
3614 ChecksumKindField() : ImplTy(DIFile::CSK_None) {}
36153614 ChecksumKindField(DIFile::ChecksumKind CSKind) : ImplTy(CSKind) {}
36163615 };
36173616
39753974 template <>
39763975 bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
39773976 ChecksumKindField &Result) {
3978 if (Lex.getKind() != lltok::ChecksumKind)
3977 Optional CSKind =
3978 DIFile::getChecksumKind(Lex.getStrVal());
3979
3980 if (Lex.getKind() != lltok::ChecksumKind || !CSKind)
39793981 return TokError(
39803982 "invalid checksum kind" + Twine(" '") + Lex.getStrVal() + "'");
39813983
3982 DIFile::ChecksumKind CSKind = DIFile::getChecksumKind(Lex.getStrVal());
3983
3984 Result.assign(CSKind);
3984 Result.assign(*CSKind);
39853985 Lex.Lex();
39863986 return false;
39873987 }
42464246 /// checksumkind: CSK_MD5,
42474247 /// checksum: "000102030405060708090a0b0c0d0e0f")
42484248 bool LLParser::ParseDIFile(MDNode *&Result, bool IsDistinct) {
4249 // The default constructed value for checksumkind is required, but will never
4250 // be used, as the parser checks if the field was actually Seen before using
4251 // the Val.
42494252 #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
42504253 REQUIRED(filename, MDStringField, ); \
42514254 REQUIRED(directory, MDStringField, ); \
4252 OPTIONAL(checksumkind, ChecksumKindField, ); \
4255 OPTIONAL(checksumkind, ChecksumKindField, (DIFile::CSK_MD5)); \
42534256 OPTIONAL(checksum, MDStringField, );
42544257 PARSE_MD_FIELDS();
42554258 #undef VISIT_MD_FIELDS
42564259
4260 Optional> OptChecksum;
4261 if (checksumkind.Seen && checksum.Seen)
4262 OptChecksum.emplace(checksumkind.Val, checksum.Val);
4263 else if (checksumkind.Seen || checksum.Seen)
4264 return Lex.Error("'checksumkind' and 'checksum' must be provided together");
4265
42574266 Result = GET_OR_DISTINCT(DIFile, (Context, filename.Val, directory.Val,
4258 checksumkind.Val, checksum.Val));
4267 OptChecksum));
42594268 return false;
42604269 }
42614270
13531353 return error("Invalid record");
13541354
13551355 IsDistinct = Record[0];
1356 Optional> Checksum;
1357 // The BitcodeWriter writes null bytes into Record[3:4] when the Checksum
1358 // is not present. This matches up with the old internal representation,
1359 // and the old encoding for CSK_None in the ChecksumKind. The new
1360 // representation reserves the value 0 in the ChecksumKind to continue to
1361 // encode None in a backwards-compatible way.
1362 if (Record.size() == 5 && Record[3] && Record[4])
1363 Checksum.emplace(static_cast(Record[3]),
1364 getMDString(Record[4]));
13561365 MetadataList.assignValue(
13571366 GET_OR_DISTINCT(
13581367 DIFile,
13591368 (Context, getMDString(Record[1]), getMDString(Record[2]),
1360 Record.size() == 3 ? DIFile::CSK_None
1361 : static_cast(Record[3]),
1362 Record.size() == 3 ? nullptr : getMDString(Record[4]))),
1369 Checksum)),
13631370 NextMetadataNo);
13641371 NextMetadataNo++;
13651372 break;
15501550 Record.push_back(N->isDistinct());
15511551 Record.push_back(VE.getMetadataOrNullID(N->getRawFilename()));
15521552 Record.push_back(VE.getMetadataOrNullID(N->getRawDirectory()));
1553 Record.push_back(N->getChecksumKind());
1554 Record.push_back(VE.getMetadataOrNullID(N->getRawChecksum()));
1553 if (N->getRawChecksum()) {
1554 Record.push_back(N->getRawChecksum()->Kind);
1555 Record.push_back(VE.getMetadataOrNullID(N->getRawChecksum()->Value));
1556 } else {
1557 // Maintain backwards compatibility with the old internal representation of
1558 // CSK_None in ChecksumKind by writing nulls here when Checksum is None.
1559 Record.push_back(0);
1560 Record.push_back(VE.getMetadataOrNullID(nullptr));
1561 }
15551562
15561563 Stream.EmitRecord(bitc::METADATA_FILE, Record, Abbrev);
15571564 Record.clear();
164164 auto Insertion = FileIdMap.insert(std::make_pair(FullPath, NextId));
165165 if (Insertion.second) {
166166 // We have to compute the full filepath and emit a .cv_file directive.
167 std::string Checksum = fromHex(F->getChecksum());
168 void *CKMem = OS.getContext().allocate(Checksum.size(), 1);
169 memcpy(CKMem, Checksum.data(), Checksum.size());
170 ArrayRef ChecksumAsBytes(reinterpret_cast(CKMem),
171 Checksum.size());
172 DIFile::ChecksumKind ChecksumKind = F->getChecksumKind();
167 ArrayRef ChecksumAsBytes;
168 FileChecksumKind CSKind = FileChecksumKind::None;
169 if (F->getChecksum()) {
170 std::string Checksum = fromHex(F->getChecksum()->Value);
171 void *CKMem = OS.getContext().allocate(Checksum.size(), 1);
172 memcpy(CKMem, Checksum.data(), Checksum.size());
173 ChecksumAsBytes = ArrayRef(
174 reinterpret_cast(CKMem), Checksum.size());
175 switch (F->getChecksum()->Kind) {
176 case DIFile::CSK_MD5: CSKind = FileChecksumKind::MD5; break;
177 case DIFile::CSK_SHA1: CSKind = FileChecksumKind::SHA1; break;
178 }
179 }
173180 bool Success = OS.EmitCVFileDirective(NextId, FullPath, ChecksumAsBytes,
174 static_cast(ChecksumKind));
181 static_cast(CSKind));
175182 (void)Success;
176183 assert(Success && ".cv_file directive failed");
177184 }
279279
280280 MD5::MD5Result *DwarfUnit::getMD5AsBytes(const DIFile *File) {
281281 assert(File);
282 if (File->getChecksumKind() != DIFile::CSK_MD5)
282 Optional> Checksum = File->getChecksum();
283 if (!Checksum || Checksum->Kind != DIFile::CSK_MD5)
283284 return nullptr;
284285
285286 // Convert the string checksum to an MD5Result for the streamer.
286287 // The verifier validates the checksum so we assume it's okay.
287288 // An MD5 checksum is 16 bytes.
288 std::string Checksum = fromHex(File->getChecksum());
289 std::string ChecksumString = fromHex(Checksum->Value);
289290 void *CKMem = Asm->OutStreamer->getContext().allocate(16, 1);
290 memcpy(CKMem, Checksum.data(), 16);
291 memcpy(CKMem, ChecksumString.data(), 16);
291292 return reinterpret_cast(CKMem);
292293 }
293294
14521452
14531453 void printTag(const DINode *N);
14541454 void printMacinfoType(const DIMacroNode *N);
1455 void printChecksumKind(const DIFile *N);
1455 void printChecksum(const DIFile::ChecksumInfo &N);
14561456 void printString(StringRef Name, StringRef Value,
14571457 bool ShouldSkipEmpty = true);
14581458 void printMetadata(StringRef Name, const Metadata *MD,
14871487 Out << N->getMacinfoType();
14881488 }
14891489
1490 void MDFieldPrinter::printChecksumKind(const DIFile *N) {
1491 if (N->getChecksumKind() == DIFile::CSK_None)
1492 // Skip CSK_None checksum kind.
1493 return;
1494 Out << FS << "checksumkind: " << N->getChecksumKindAsString();
1490 void MDFieldPrinter::printChecksum(
1491 const DIFile::ChecksumInfo &Checksum) {
1492 Out << FS << "checksumkind: " << Checksum.getKindAsString();
1493 printString("checksum", Checksum.Value, /* ShouldSkipEmpty */ false);
14951494 }
14961495
14971496 void MDFieldPrinter::printString(StringRef Name, StringRef Value,
17201719 /* ShouldSkipEmpty */ false);
17211720 Printer.printString("directory", N->getDirectory(),
17221721 /* ShouldSkipEmpty */ false);
1723 Printer.printChecksumKind(N);
1724 Printer.printString("checksum", N->getChecksum(), /* ShouldSkipEmpty */ true);
1722 // Print all values for checksum together, or not at all.
1723 if (N->getChecksum())
1724 Printer.printChecksum(*N->getChecksum());
17251725 Out << ")";
17261726 }
17271727
203203 }
204204
205205 DIFile *DIBuilder::createFile(StringRef Filename, StringRef Directory,
206 DIFile::ChecksumKind CSKind, StringRef Checksum) {
207 return DIFile::get(VMContext, Filename, Directory, CSKind, Checksum);
206 Optional> CS) {
207 return DIFile::get(VMContext, Filename, Directory, CS);
208208 }
209209
210210 DIMacro *DIBuilder::createMacro(DIMacroFile *Parent, unsigned LineNumber,
393393
394394 // FIXME: Implement this string-enum correspondence with a .def file and macros,
395395 // so that the association is explicit rather than implied.
396 static const char *ChecksumKindName[DIFile::CSK_Last + 1] = {
397 "CSK_None",
396 static const char *ChecksumKindName[DIFile::CSK_Last] = {
398397 "CSK_MD5",
399398 "CSK_SHA1"
400399 };
401400
402 DIFile::ChecksumKind DIFile::getChecksumKind(StringRef CSKindStr) {
403 return StringSwitch(CSKindStr)
401 StringRef DIFile::getChecksumKindAsString(ChecksumKind CSKind) {
402 assert(CSKind <= DIFile::CSK_Last && "Invalid checksum kind");
403 // The first space was originally the CSK_None variant, which is now
404 // obsolete, but the space is still reserved in ChecksumKind, so we account
405 // for it here.
406 return ChecksumKindName[CSKind - 1];
407 }
408
409 Optional DIFile::getChecksumKind(StringRef CSKindStr) {
410 return StringSwitch>(CSKindStr)
404411 .Case("CSK_MD5", DIFile::CSK_MD5)
405412 .Case("CSK_SHA1", DIFile::CSK_SHA1)
406 .Default(DIFile::CSK_None);
407 }
408
409 StringRef DIFile::getChecksumKindAsString() const {
410 assert(CSKind <= DIFile::CSK_Last && "Invalid checksum kind");
411 return ChecksumKindName[CSKind];
413 .Default(None);
412414 }
413415
414416 DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
415 MDString *Directory, DIFile::ChecksumKind CSKind,
416 MDString *Checksum, StorageType Storage,
417 bool ShouldCreate) {
417 MDString *Directory,
418 Optional> CS,
419 StorageType Storage, bool ShouldCreate) {
418420 assert(isCanonical(Filename) && "Expected canonical MDString");
419421 assert(isCanonical(Directory) && "Expected canonical MDString");
420 assert(isCanonical(Checksum) && "Expected canonical MDString");
421 DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory, CSKind, Checksum));
422 Metadata *Ops[] = {Filename, Directory, Checksum};
423 DEFINE_GETIMPL_STORE(DIFile, (CSKind), Ops);
422 assert((!CS || isCanonical(CS->Value)) && "Expected canonical MDString");
423 DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory, CS));
424 Metadata *Ops[] = {Filename, Directory, CS ? CS->Value : nullptr};
425 DEFINE_GETIMPL_STORE(DIFile, (CS), Ops);
424426 }
425427
426428 DICompileUnit *DICompileUnit::getImpl(
900902 Metadata *Ops[] = { File, Elements };
901903 DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops);
902904 }
903
573573 template <> struct MDNodeKeyImpl {
574574 MDString *Filename;
575575 MDString *Directory;
576 DIFile::ChecksumKind CSKind;
577 MDString *Checksum;
576 Optional> Checksum;
578577
579578 MDNodeKeyImpl(MDString *Filename, MDString *Directory,
580 DIFile::ChecksumKind CSKind, MDString *Checksum)
581 : Filename(Filename), Directory(Directory), CSKind(CSKind),
582 Checksum(Checksum) {}
579 Optional> Checksum)
580 : Filename(Filename), Directory(Directory), Checksum(Checksum) {}
583581 MDNodeKeyImpl(const DIFile *N)
584582 : Filename(N->getRawFilename()), Directory(N->getRawDirectory()),
585 CSKind(N->getChecksumKind()), Checksum(N->getRawChecksum()) {}
583 Checksum(N->getRawChecksum()) {}
586584
587585 bool isKeyOf(const DIFile *RHS) const {
588586 return Filename == RHS->getRawFilename() &&
589587 Directory == RHS->getRawDirectory() &&
590 CSKind == RHS->getChecksumKind() &&
591588 Checksum == RHS->getRawChecksum();
592589 }
593590
594591 unsigned getHashValue() const {
595 return hash_combine(Filename, Directory, CSKind, Checksum);
592 if (Checksum)
593 return hash_combine(Filename, Directory, Checksum->Kind, Checksum->Value);
594 return hash_combine(Filename, Directory);
596595 }
597596 };
598597
987987
988988 void Verifier::visitDIFile(const DIFile &N) {
989989 AssertDI(N.getTag() == dwarf::DW_TAG_file_type, "invalid tag", &N);
990 AssertDI(N.getChecksumKind() <= DIFile::CSK_Last, "invalid checksum kind",
991 &N);
992 size_t Size;
993 switch (N.getChecksumKind()) {
994 case DIFile::CSK_None:
995 Size = 0;
996 break;
997 case DIFile::CSK_MD5:
998 Size = 32;
999 break;
1000 case DIFile::CSK_SHA1:
1001 Size = 40;
1002 break;
1003 }
1004 AssertDI(N.getChecksum().size() == Size, "invalid checksum length", &N);
1005 AssertDI(N.getChecksum().find_if_not(llvm::isHexDigit) == StringRef::npos,
1006 "invalid checksum", &N);
990 Optional> Checksum = N.getChecksum();
991 if (Checksum) {
992 AssertDI(Checksum->Kind <= DIFile::ChecksumKind::CSK_Last,
993 "invalid checksum kind", &N);
994 size_t Size;
995 switch (Checksum->Kind) {
996 case DIFile::CSK_MD5:
997 Size = 32;
998 break;
999 case DIFile::CSK_SHA1:
1000 Size = 40;
1001 break;
1002 }
1003 AssertDI(Checksum->Value.size() == Size, "invalid checksum length", &N);
1004 AssertDI(Checksum->Value.find_if_not(llvm::isHexDigit) == StringRef::npos,
1005 "invalid checksum", &N);
1006 }
10071007 }
10081008
10091009 void Verifier::visitDICompileUnit(const DICompileUnit &N) {
0 ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
11 ; RUN: verify-uselistorder %s
22
3 ; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36}
4 !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !38, !39, !40}
3 ; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !27, !28, !29, !30, !31, !32, !33, !34, !35}
4 !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38}
55
66 ; CHECK: !0 = !DISubrange(count: 3)
77 ; CHECK-NEXT: !1 = !DISubrange(count: 3, lowerBound: 4)
8080 !34 = !DIMacroFile(type: DW_MACINFO_start_file, line: 11, file: !14)
8181
8282 ; CHECK-NEXT: !32 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_MD5, checksum: "000102030405060708090a0b0c0d0e0f")
83 ; CHECK-NEXT: !33 = !DIFile(filename: "file", directory: "dir")
8483 !35 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_MD5, checksum: "000102030405060708090a0b0c0d0e0f")
85 !36 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_None)
86 !37 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_None, checksum: "")
8784
88 ; CHECK-NEXT: !34 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !14, size: 64)
89 ; CHECK-NEXT: !35 = !DIDerivedType(tag: DW_TAG_member, scope: !34, baseType: !36, size: 64, align: 64, flags: DIFlagArtificial)
90 ; CHECK-NEXT: !36 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned)
91 !38 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !16, size: 64, discriminator: !39)
92 !39 = !DIDerivedType(tag: DW_TAG_member, scope: !38, baseType: !40, size: 64, align: 64, flags: DIFlagArtificial)
93 !40 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned)
85 ; CHECK-NEXT: !33 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !14, size: 64)
86 ; CHECK-NEXT: !34 = !DIDerivedType(tag: DW_TAG_member, scope: !33, baseType: !35, size: 64, align: 64, flags: DIFlagArtificial)
87 ; CHECK-NEXT: !35 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned)
88 !36 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !16, size: 64, discriminator: !37)
89 !37 = !DIDerivedType(tag: DW_TAG_member, scope: !36, baseType: !38, size: 64, align: 64, flags: DIFlagArtificial)
90 !38 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned)
0 ; Test that DIFile(checksumkind, checksum) representation in Bitcode does
1 ; not change.
2 ;
3 ; RUN: llvm-dis < %s.bc | FileCheck %s
4 ; RUN: verify-uselistorder < %s.bc
5
6 !llvm.dbg.cu = !{!1, !2, !3}
7 !llvm.module.flags = !{!7}
8
9 !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !4, producer: "clang version 5.0.1 (tags/RELEASE_501/final)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
10 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !5, producer: "clang version 5.0.1 (tags/RELEASE_501/final)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
11 !3 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6, producer: "clang version 5.0.1 (tags/RELEASE_501/final)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
12 ; CHECK: !DIFile(filename: "a.c", directory: "/test")
13 !4 = !DIFile(filename: "a.c", directory: "/test", checksumkind: CSK_None, checksum: "")
14 ; CHECK: !DIFile(filename: "b.h", directory: "/test", checksumkind: CSK_MD5, checksum: "595f44fec1e92a71d3e9e77456ba80d1")
15 !5 = !DIFile(filename: "b.h", directory: "/test", checksumkind: CSK_MD5, checksum: "595f44fec1e92a71d3e9e77456ba80d1")
16 ; CHECK: !DIFile(filename: "c.h", directory: "/test", checksumkind: CSK_SHA1, checksum: "d5db29cd03a2ed055086cef9c31c252b4587d6d0")
17 !6 = !DIFile(filename: "c.h", directory: "/test", checksumkind: CSK_SHA1, checksum: "d5db29cd03a2ed055086cef9c31c252b4587d6d0")
18 !7 = !{i32 2, !"Debug Info Version", i32 3}
0 ; RUN: llvm-as -disable-output < %s 2>&1 | FileCheck %s
11
22 ; The lengths for None and MD5 are wrong; SHA1 has a non-hex digit.
3 ; CHECK: invalid checksum length
43 ; CHECK: invalid checksum{{$}}
54 ; CHECK: invalid checksum length
65 ; CHECK: warning: ignoring invalid debug info in
1514 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
1615 !1 = distinct !DIGlobalVariable(name: "t1", scope: !2, file: !10, line: 1, type: !9, isLocal: false, isDefinition: true)
1716 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 322159)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
18 !3 = !DIFile(filename: "t.c", directory: "/scratch", checksumkind: CSK_None, checksum: "00")
17 !3 = !DIFile(filename: "t.c", directory: "/scratch")
1918 !4 = !{}
2019 !5 = !{!0, !6}
2120 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
14461446 TEST_F(DIFileTest, get) {
14471447 StringRef Filename = "file";
14481448 StringRef Directory = "dir";
1449 DIFile::ChecksumKind CSKind = DIFile::CSK_MD5;
1450 StringRef Checksum = "000102030405060708090a0b0c0d0e0f";
1451 auto *N = DIFile::get(Context, Filename, Directory, CSKind, Checksum);
1449 DIFile::ChecksumKind CSKind = DIFile::ChecksumKind::CSK_MD5;
1450 StringRef ChecksumString = "000102030405060708090a0b0c0d0e0f";
1451 DIFile::ChecksumInfo Checksum(CSKind, ChecksumString);
1452 auto *N = DIFile::get(Context, Filename, Directory, Checksum);
14521453
14531454 EXPECT_EQ(dwarf::DW_TAG_file_type, N->getTag());
14541455 EXPECT_EQ(Filename, N->getFilename());
14551456 EXPECT_EQ(Directory, N->getDirectory());
1456 EXPECT_EQ(CSKind, N->getChecksumKind());
14571457 EXPECT_EQ(Checksum, N->getChecksum());
1458 EXPECT_EQ(N, DIFile::get(Context, Filename, Directory, CSKind, Checksum));
1459
1460 EXPECT_NE(N, DIFile::get(Context, "other", Directory, CSKind, Checksum));
1461 EXPECT_NE(N, DIFile::get(Context, Filename, "other", CSKind, Checksum));
1458 EXPECT_EQ(N, DIFile::get(Context, Filename, Directory, Checksum));
1459
1460 EXPECT_NE(N, DIFile::get(Context, "other", Directory, Checksum));
1461 EXPECT_NE(N, DIFile::get(Context, Filename, "other", Checksum));
1462 DIFile::ChecksumInfo OtherChecksum(DIFile::ChecksumKind::CSK_SHA1, ChecksumString);
14621463 EXPECT_NE(
1463 N, DIFile::get(Context, Filename, Directory, DIFile::CSK_SHA1, Checksum));
1464 N, DIFile::get(Context, Filename, Directory, OtherChecksum));
14641465 EXPECT_NE(N, DIFile::get(Context, Filename, Directory));
14651466
14661467 TempDIFile Temp = N->clone();