From: Simon Pilgrim Date: Wed, 18 Sep 2019 12:11:16 +0000 (+0000) Subject: [AST] CommentLexer - Remove (optional) Invalid parameter from getSpelling. X-Git-Tag: llvmorg-11-init~8921 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4b8b7f249c627639d2c529d460e7f015fe47385f;p=platform%2Fupstream%2Fllvm.git [AST] CommentLexer - Remove (optional) Invalid parameter from getSpelling. The static analyzer noticed that we were dereferencing it even when the default null value was being used. Further investigation showed that we never explicitly set the parameter so I've just removed it entirely. llvm-svn: 372217 --- diff --git a/clang/include/clang/AST/CommentLexer.h b/clang/include/clang/AST/CommentLexer.h index 9ddbb7d..138fdac 100644 --- a/clang/include/clang/AST/CommentLexer.h +++ b/clang/include/clang/AST/CommentLexer.h @@ -352,8 +352,7 @@ public: void lex(Token &T); - StringRef getSpelling(const Token &Tok, const SourceManager &SourceMgr, - bool *Invalid = nullptr) const; + StringRef getSpelling(const Token &Tok, const SourceManager &SourceMgr) const; }; } // end namespace comments diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp index 19485f6..c1ea3ea 100644 --- a/clang/lib/AST/CommentLexer.cpp +++ b/clang/lib/AST/CommentLexer.cpp @@ -850,17 +850,14 @@ again: } StringRef Lexer::getSpelling(const Token &Tok, - const SourceManager &SourceMgr, - bool *Invalid) const { + const SourceManager &SourceMgr) const { SourceLocation Loc = Tok.getLocation(); std::pair LocInfo = SourceMgr.getDecomposedLoc(Loc); bool InvalidTemp = false; StringRef File = SourceMgr.getBufferData(LocInfo.first, &InvalidTemp); - if (InvalidTemp) { - *Invalid = true; + if (InvalidTemp) return StringRef(); - } const char *Begin = File.data() + LocInfo.second; return StringRef(Begin, Tok.getLength());