llvm.org GIT mirror llvm / 1934a3e
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365118 91177308-0d34-0410-b5e6-96231b3b80d8 Mikael Holmen a month ago
1 changed file(s) with 4 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2424 switch (Format) {
2525 case ParserFormat::YAML:
2626 return llvm::make_unique(Buf);
27 default:
28 llvm_unreachable("Unknown format encountered!");
2729 };
2830 }
2931
3335 switch (Format) {
3436 case ParserFormat::YAML:
3537 return llvm::make_unique(Buf, &StrTab);
38 default:
39 llvm_unreachable("Unknown format encountered!");
3640 };
3741 }
3842