[llvm] 0d5ad57 - Remarks - fix shadow variable warnings. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 9 05:05:58 PST 2019
Author: Simon Pilgrim
Date: 2019-11-09T13:01:03Z
New Revision: 0d5ad57ae34bacbc4f5e5f42508d579bf39bb8cf
URL: https://github.com/llvm/llvm-project/commit/0d5ad57ae34bacbc4f5e5f42508d579bf39bb8cf
DIFF: https://github.com/llvm/llvm-project/commit/0d5ad57ae34bacbc4f5e5f42508d579bf39bb8cf.diff
LOG: Remarks - fix shadow variable warnings. NFCI.
Avoid conflict with llvm::remarks::Magic global variable.
Added:
Modified:
llvm/lib/Remarks/BitstreamRemarkParser.cpp
llvm/lib/Remarks/RemarkFormat.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Remarks/BitstreamRemarkParser.cpp b/llvm/lib/Remarks/BitstreamRemarkParser.cpp
index 99a82e1ee3af..1cfde1192229 100644
--- a/llvm/lib/Remarks/BitstreamRemarkParser.cpp
+++ b/llvm/lib/Remarks/BitstreamRemarkParser.cpp
@@ -278,19 +278,20 @@ Expected<bool> BitstreamParserHelper::isRemarkBlock() {
return isBlock(Stream, META_BLOCK_ID);
}
-static Error validateMagicNumber(StringRef Magic) {
- if (Magic != remarks::ContainerMagic)
+static Error validateMagicNumber(StringRef MagicNumber) {
+ if (MagicNumber != remarks::ContainerMagic)
return createStringError(std::make_error_code(std::errc::invalid_argument),
"Unknown magic number: expecting %s, got %.4s.",
- remarks::ContainerMagic.data(), Magic.data());
+ remarks::ContainerMagic.data(), MagicNumber.data());
return Error::success();
}
static Error advanceToMetaBlock(BitstreamParserHelper &Helper) {
- Expected<std::array<char, 4>> Magic = Helper.parseMagic();
- if (!Magic)
- return Magic.takeError();
- if (Error E = validateMagicNumber(StringRef(Magic->data(), Magic->size())))
+ Expected<std::array<char, 4>> MagicNumber = Helper.parseMagic();
+ if (!MagicNumber)
+ return MagicNumber.takeError();
+ if (Error E = validateMagicNumber(
+ StringRef(MagicNumber->data(), MagicNumber->size())))
return E;
if (Error E = Helper.parseBlockInfoBlock())
return E;
@@ -309,11 +310,12 @@ remarks::createBitstreamParserFromMeta(
StringRef Buf, Optional<ParsedStringTable> StrTab,
Optional<StringRef> ExternalFilePrependPath) {
BitstreamParserHelper Helper(Buf);
- Expected<std::array<char, 4>> Magic = Helper.parseMagic();
- if (!Magic)
- return Magic.takeError();
+ Expected<std::array<char, 4>> MagicNumber = Helper.parseMagic();
+ if (!MagicNumber)
+ return MagicNumber.takeError();
- if (Error E = validateMagicNumber(StringRef(Magic->data(), Magic->size())))
+ if (Error E = validateMagicNumber(
+ StringRef(MagicNumber->data(), MagicNumber->size())))
return std::move(E);
auto Parser =
diff --git a/llvm/lib/Remarks/RemarkFormat.cpp b/llvm/lib/Remarks/RemarkFormat.cpp
index c7fce151eff0..5006421a3c63 100644
--- a/llvm/lib/Remarks/RemarkFormat.cpp
+++ b/llvm/lib/Remarks/RemarkFormat.cpp
@@ -32,9 +32,9 @@ Expected<Format> llvm::remarks::parseFormat(StringRef FormatStr) {
return Result;
}
-Expected<Format> llvm::remarks::magicToFormat(StringRef Magic) {
+Expected<Format> llvm::remarks::magicToFormat(StringRef MagicStr) {
auto Result =
- StringSwitch<Format>(Magic)
+ StringSwitch<Format>(MagicStr)
.StartsWith("--- ", Format::YAML) // This is only an assumption.
.StartsWith(remarks::Magic, Format::YAMLStrTab)
.StartsWith(remarks::ContainerMagic, Format::Bitstream)
@@ -42,6 +42,6 @@ Expected<Format> llvm::remarks::magicToFormat(StringRef Magic) {
if (Result == Format::Unknown)
return createStringError(std::make_error_code(std::errc::invalid_argument),
- "Unknown remark magic: '%s'", Magic.data());
+ "Unknown remark magic: '%s'", MagicStr.data());
return Result;
}
More information about the llvm-commits
mailing list