Browse Source

[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372217 91177308-0d34-0410-b5e6-96231b3b80d8
Simon Pilgrim 6 years ago
parent
commit
557742540d
2 changed files with 3 additions and 7 deletions
  1. 1 2
      include/clang/AST/CommentLexer.h
  2. 2 5
      lib/AST/CommentLexer.cpp

+ 1 - 2
include/clang/AST/CommentLexer.h

@@ -352,8 +352,7 @@ public:
 
 
   void lex(Token &T);
   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
 } // end namespace comments

+ 2 - 5
lib/AST/CommentLexer.cpp

@@ -850,17 +850,14 @@ again:
 }
 }
 
 
 StringRef Lexer::getSpelling(const Token &Tok,
 StringRef Lexer::getSpelling(const Token &Tok,
-                             const SourceManager &SourceMgr,
-                             bool *Invalid) const {
+                             const SourceManager &SourceMgr) const {
   SourceLocation Loc = Tok.getLocation();
   SourceLocation Loc = Tok.getLocation();
   std::pair<FileID, unsigned> LocInfo = SourceMgr.getDecomposedLoc(Loc);
   std::pair<FileID, unsigned> LocInfo = SourceMgr.getDecomposedLoc(Loc);
 
 
   bool InvalidTemp = false;
   bool InvalidTemp = false;
   StringRef File = SourceMgr.getBufferData(LocInfo.first, &InvalidTemp);
   StringRef File = SourceMgr.getBufferData(LocInfo.first, &InvalidTemp);
-  if (InvalidTemp) {
-    *Invalid = true;
+  if (InvalidTemp)
     return StringRef();
     return StringRef();
-  }
 
 
   const char *Begin = File.data() + LocInfo.second;
   const char *Begin = File.data() + LocInfo.second;
   return StringRef(Begin, Tok.getLength());
   return StringRef(Begin, Tok.getLength());