summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2019-04-04 23:34:38 +0000
committerEric Christopher <echristo@gmail.com>2019-04-04 23:34:38 +0000
commit798e83b5d6853f0c2f68bb4b0785f6a075867a13 (patch)
tree0c99c3a0ed9d838eaea98716135299d9ac04ff7d /llvm/lib/MC
parentf498bdcebfa439218e315be74a62ad52db3e2846 (diff)
downloadbcm5719-llvm-798e83b5d6853f0c2f68bb4b0785f6a075867a13.tar.gz
bcm5719-llvm-798e83b5d6853f0c2f68bb4b0785f6a075867a13.zip
NFC: Move API uses of MD5::MD5Result to Optional rather than a pointer.
Differential Revision: https://reviews.llvm.org/D60290 llvm-svn: 357736
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/MCAsmStreamer.cpp10
-rw-r--r--llvm/lib/MC/MCContext.cpp9
-rw-r--r--llvm/lib/MC/MCDwarf.cpp14
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp9
-rw-r--r--llvm/lib/MC/MCStreamer.cpp4
5 files changed, 24 insertions, 22 deletions
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index f5e40f5c604..4785d3eb790 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -223,11 +223,11 @@ public:
Expected<unsigned> tryEmitDwarfFileDirective(unsigned FileNo,
StringRef Directory,
StringRef Filename,
- MD5::MD5Result *Checksum = 0,
+ Optional<MD5::MD5Result> Checksum = None,
Optional<StringRef> Source = None,
unsigned CUID = 0) override;
void emitDwarfFile0Directive(StringRef Directory, StringRef Filename,
- MD5::MD5Result *Checksum,
+ Optional<MD5::MD5Result> Checksum,
Optional<StringRef> Source,
unsigned CUID = 0) override;
void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
@@ -1151,7 +1151,7 @@ void MCAsmStreamer::EmitFileDirective(StringRef Filename) {
static void printDwarfFileDirective(unsigned FileNo, StringRef Directory,
StringRef Filename,
- MD5::MD5Result *Checksum,
+ Optional<MD5::MD5Result> Checksum,
Optional<StringRef> Source,
bool UseDwarfDirectory,
raw_svector_ostream &OS) {
@@ -1184,7 +1184,7 @@ static void printDwarfFileDirective(unsigned FileNo, StringRef Directory,
Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
unsigned FileNo, StringRef Directory, StringRef Filename,
- MD5::MD5Result *Checksum, Optional<StringRef> Source, unsigned CUID) {
+ Optional<MD5::MD5Result> Checksum, Optional<StringRef> Source, unsigned CUID) {
assert(CUID == 0 && "multiple CUs not supported by MCAsmStreamer");
MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID);
@@ -1212,7 +1212,7 @@ Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
void MCAsmStreamer::emitDwarfFile0Directive(StringRef Directory,
StringRef Filename,
- MD5::MD5Result *Checksum,
+ Optional<MD5::MD5Result> Checksum,
Optional<StringRef> Source,
unsigned CUID) {
assert(CUID == 0);
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 49fad131a2c..4d16715c0ae 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -572,12 +572,13 @@ void MCContext::RemapDebugPaths() {
void MCContext::setGenDwarfRootFile(StringRef InputFileName, StringRef Buffer) {
// MCDwarf needs the root file as well as the compilation directory.
// If we find a '.file 0' directive that will supersede these values.
- MD5::MD5Result *Cksum = nullptr;
+ Optional<MD5::MD5Result> Cksum;
if (getDwarfVersion() >= 5) {
MD5 Hash;
- Cksum = (MD5::MD5Result *)allocate(sizeof(MD5::MD5Result), 1);
+ MD5::MD5Result Sum;
Hash.update(Buffer);
- Hash.final(*Cksum);
+ Hash.final(Sum);
+ Cksum = Sum;
}
// Canonicalize the root filename. It cannot be empty, and should not
// repeat the compilation dir.
@@ -600,7 +601,7 @@ void MCContext::setGenDwarfRootFile(StringRef InputFileName, StringRef Buffer) {
Expected<unsigned> MCContext::getDwarfFile(StringRef Directory,
StringRef FileName,
unsigned FileNumber,
- MD5::MD5Result *Checksum,
+ Optional<MD5::MD5Result> Checksum,
Optional<StringRef> Source,
unsigned CUID) {
MCDwarfLineTable &Table = MCDwarfLineTablesCUMap[CUID];
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 83b6b4f1aa3..ea2cb577661 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -361,10 +361,10 @@ static void emitOneV5FileEntry(MCStreamer *MCOS, const MCDwarfFile &DwarfFile,
}
MCOS->EmitULEB128IntValue(DwarfFile.DirIndex); // Directory number.
if (EmitMD5) {
- MD5::MD5Result *Cksum = DwarfFile.Checksum;
+ const MD5::MD5Result &Cksum = *DwarfFile.Checksum;
MCOS->EmitBinaryData(
- StringRef(reinterpret_cast<const char *>(Cksum->Bytes.data()),
- Cksum->Bytes.size()));
+ StringRef(reinterpret_cast<const char *>(Cksum.Bytes.data()),
+ Cksum.Bytes.size()));
}
if (HasSource) {
if (LineStr)
@@ -536,7 +536,7 @@ void MCDwarfLineTable::EmitCU(MCObjectStreamer *MCOS,
Expected<unsigned> MCDwarfLineTable::tryGetFile(StringRef &Directory,
StringRef &FileName,
- MD5::MD5Result *Checksum,
+ Optional<MD5::MD5Result> Checksum,
Optional<StringRef> Source,
unsigned FileNumber) {
return Header.tryGetFile(Directory, FileName, Checksum, Source, FileNumber);
@@ -545,7 +545,7 @@ Expected<unsigned> MCDwarfLineTable::tryGetFile(StringRef &Directory,
Expected<unsigned>
MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
StringRef &FileName,
- MD5::MD5Result *Checksum,
+ Optional<MD5::MD5Result> Checksum,
Optional<StringRef> &Source,
unsigned FileNumber) {
if (Directory == CompilationDir)
@@ -558,7 +558,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
// Keep track of whether any or all files have an MD5 checksum.
// If any files have embedded source, they all must.
if (MCDwarfFiles.empty()) {
- trackMD5Usage(Checksum);
+ trackMD5Usage(Checksum.hasValue());
HasSource = (Source != None);
}
if (FileNumber == 0) {
@@ -623,7 +623,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
File.Name = FileName;
File.DirIndex = DirIndex;
File.Checksum = Checksum;
- trackMD5Usage(Checksum);
+ trackMD5Usage(Checksum.hasValue());
File.Source = Source;
if (Source)
HasSource = true;
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index a153ee184e3..40e3306a57d 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3388,13 +3388,14 @@ bool AsmParser::parseDirectiveFile(SMLoc DirectiveLoc) {
Ctx.setGenDwarfForAssembly(false);
}
- MD5::MD5Result *CKMem = nullptr;
+ Optional<MD5::MD5Result> CKMem;
if (HasMD5) {
- CKMem = (MD5::MD5Result *)Ctx.allocate(sizeof(MD5::MD5Result), 1);
+ MD5::MD5Result Sum;
for (unsigned i = 0; i != 8; ++i) {
- CKMem->Bytes[i] = uint8_t(MD5Hi >> ((7 - i) * 8));
- CKMem->Bytes[i + 8] = uint8_t(MD5Lo >> ((7 - i) * 8));
+ Sum.Bytes[i] = uint8_t(MD5Hi >> ((7 - i) * 8));
+ Sum.Bytes[i + 8] = uint8_t(MD5Lo >> ((7 - i) * 8));
}
+ CKMem = Sum;
}
if (HasSource) {
char *SourceBuf = static_cast<char *>(Ctx.allocate(SourceString.size()));
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index 2d615f2bfd1..20d360ffc50 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -204,7 +204,7 @@ void MCStreamer::EmitZeros(uint64_t NumBytes) {
Expected<unsigned>
MCStreamer::tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
StringRef Filename,
- MD5::MD5Result *Checksum,
+ Optional<MD5::MD5Result> Checksum,
Optional<StringRef> Source,
unsigned CUID) {
return getContext().getDwarfFile(Directory, Filename, FileNo, Checksum,
@@ -213,7 +213,7 @@ MCStreamer::tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
void MCStreamer::emitDwarfFile0Directive(StringRef Directory,
StringRef Filename,
- MD5::MD5Result *Checksum,
+ Optional<MD5::MD5Result> Checksum,
Optional<StringRef> Source,
unsigned CUID) {
getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
OpenPOWER on IntegriCloud