Remarks - fix shadow variable warnings. NFCI.

Avoid conflict with llvm::remarks::Magic global variable.
This commit is contained in:
Simon Pilgrim 2019-11-08 22:30:12 +00:00
parent 092577e317
commit 0d5ad57ae3
2 changed files with 16 additions and 14 deletions

View File

@ -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 =

View File

@ -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;
}