1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[Remarks] Silence gcc warning by catching unhandled values in switches

Without this fix gcc (7.4) complains with
 ../lib/Remarks/RemarkParser.cpp: In function 'std::unique_ptr<llvm::remarks::ParserImpl> formatToParserImpl(llvm::remarks::ParserFormat, llvm::StringRef)':
 ../lib/Remarks/RemarkParser.cpp:29:1: error: control reaches end of non-void function [-Werror=return-type]
  }
  ^
 ../lib/Remarks/RemarkParser.cpp: In function 'std::unique_ptr<llvm::remarks::ParserImpl> formatToParserImpl(llvm::remarks::ParserFormat, llvm::StringRef, const llvm::remarks::ParsedStringTable&)':
 ../lib/Remarks/RemarkParser.cpp:38:1: error: control reaches end of non-void function [-Werror=return-type]
  }
  ^

The Format enum currently only contains the value YAML which is indeed
already handled in the switches, but gcc complains anyway.

Adding a default case with an llvm_unreachable silences gcc.

llvm-svn: 365118
This commit is contained in:
Mikael Holmen 2019-07-04 09:29:18 +00:00
parent 48e4d991e8
commit 0a0fbcd1db

View File

@ -25,6 +25,8 @@ static std::unique_ptr<ParserImpl> formatToParserImpl(ParserFormat Format,
switch (Format) {
case ParserFormat::YAML:
return llvm::make_unique<YAMLParserImpl>(Buf);
default:
llvm_unreachable("Unknown format encountered!");
};
}
@ -34,6 +36,8 @@ formatToParserImpl(ParserFormat Format, StringRef Buf,
switch (Format) {
case ParserFormat::YAML:
return llvm::make_unique<YAMLParserImpl>(Buf, &StrTab);
default:
llvm_unreachable("Unknown format encountered!");
};
}