-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Add checksum option for create file #162592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1095,6 +1095,38 @@ LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename, | |
StringRef(Directory, DirectoryLen))); | ||
} | ||
|
||
static llvm::DIFile::ChecksumKind | ||
map_from_llvmChecksumKind(LLVMChecksumKind CSKind) { | ||
switch (CSKind) { | ||
case LLVMChecksumKind::CSK_MD5: | ||
return llvm::DIFile::CSK_MD5; | ||
case LLVMChecksumKind::CSK_SHA1: | ||
return llvm::DIFile::CSK_SHA1; | ||
case LLVMChecksumKind::CSK_SHA256: | ||
return llvm::DIFile::CSK_SHA256; | ||
} | ||
llvm_unreachable("Unhandled Checksum Kind"); | ||
} | ||
|
||
LLVMMetadataRef LLVMDIBuilderCreateFileWithCheckSum( | ||
LLVMDIBuilderRef Builder, const char *Filename, size_t FilenameLen, | ||
const char *Directory, size_t DirectoryLen, LLVMChecksumKind ChecksumKind, | ||
const char *Checksum, size_t ChecksumLen, const char *Source, | ||
size_t SourceLen) { | ||
StringRef ChkSum = StringRef(Checksum, ChecksumLen); | ||
std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we drop the optional part here, since it looks like we're expecting to always have a value. I think you can pass the |
||
auto CSK = map_from_llvmChecksumKind(ChecksumKind); | ||
CSInfo.emplace(CSK, ChkSum); | ||
std::optional<StringRef> Src; | ||
if (SourceLen > 0) | ||
Src = StringRef(Source, SourceLen); | ||
else | ||
Src = std::nullopt; | ||
Comment on lines
+1123
to
+1124
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can drop the else block as I believe a default initialized |
||
return wrap(unwrap(Builder)->createFile(StringRef(Filename, FilenameLen), | ||
StringRef(Directory, DirectoryLen), | ||
CSInfo, Src)); | ||
} | ||
|
||
LLVMMetadataRef | ||
LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope, | ||
const char *Name, size_t NameLen, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think checksum should be one word (so the S should be lower case in the function name).