[llvm] b63b77a - [Coverity] Add assert for assumption.

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 16 17:53:08 PDT 2023


Author: Luo, Yuanke
Date: 2023-04-17T08:52:46+08:00
New Revision: b63b77a1e087cd85ce770c3b6e32ffcef5ffaa49

URL: https://github.com/llvm/llvm-project/commit/b63b77a1e087cd85ce770c3b6e32ffcef5ffaa49
DIFF: https://github.com/llvm/llvm-project/commit/b63b77a1e087cd85ce770c3b6e32ffcef5ffaa49.diff

LOG: [Coverity] Add assert for assumption.

Added: 
    

Modified: 
    llvm/lib/MC/MCParser/MasmParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index 036d8218c8871..94c87b53aef97 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -6115,6 +6115,7 @@ bool MasmParser::parseDirectiveComm(bool IsLocal) {
 bool MasmParser::parseDirectiveComment(SMLoc DirectiveLoc) {
   std::string FirstLine = parseStringTo(AsmToken::EndOfStatement);
   size_t DelimiterEnd = FirstLine.find_first_of("\b\t\v\f\r\x1A ");
+  assert(DelimiterEnd != std::string::npos);
   StringRef Delimiter = StringRef(FirstLine).take_front(DelimiterEnd);
   if (Delimiter.empty())
     return Error(DirectiveLoc, "no delimiter in 'comment' directive");


        


More information about the llvm-commits mailing list