diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-16 05:20:39 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-16 05:20:39 +0000 |
commit | 50f6af7a6d6951a63f3da7d4c5a7d3965bf73b63 (patch) | |
tree | 28f78b0fe61c0b7a80cf3ccf0d1c39a884986120 /include/clang/Lex/Preprocessor.h | |
parent | 36c35ba0aca641e60e5dbee8efbc620c08b9bd61 (diff) |
Introduce optional "Invalid" parameters to routines that invoke the
SourceManager's getBuffer() and, therefore, could fail, along with
Preprocessor::getSpelling(). Use the Invalid parameters in the literal
parsers (string, floating point, integral, character) to make them
robust against errors that stem from, e.g., PCH files that are not
consistent with the underlying file system.
I still need to audit every use caller to all of these routines, to
determine which ones need specific handling of error conditions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98608 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex/Preprocessor.h')
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index e29ece1da6..2b27a06070 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -547,7 +547,9 @@ public: /// after trigraph expansion and escaped-newline folding. In particular, this /// wants to get the true, uncanonicalized, spelling of things like digraphs /// UCNs, etc. - std::string getSpelling(const Token &Tok) const; + /// + /// \param Invalid If non-NULL, will be set \c true if an error occurs. + std::string getSpelling(const Token &Tok, bool *Invalid = 0) const; /// getSpelling() - Return the 'spelling' of the Tok token. The spelling of a /// token is the characters used to represent the token in the source file @@ -556,7 +558,8 @@ public: /// UCNs, etc. static std::string getSpelling(const Token &Tok, const SourceManager &SourceMgr, - const LangOptions &Features); + const LangOptions &Features, + bool *Invalid = 0); /// getSpelling - This method is used to get the spelling of a token into a /// preallocated buffer, instead of as an std::string. The caller is required @@ -568,17 +571,20 @@ public: /// to point to a constant buffer with the data already in it (avoiding a /// copy). The caller is not allowed to modify the returned buffer pointer /// if an internal buffer is returned. - unsigned getSpelling(const Token &Tok, const char *&Buffer) const; + unsigned getSpelling(const Token &Tok, const char *&Buffer, + bool *Invalid = 0) const; /// getSpelling - This method is used to get the spelling of a token into a /// SmallVector. Note that the returned StringRef may not point to the /// supplied buffer if a copy can be avoided. llvm::StringRef getSpelling(const Token &Tok, - llvm::SmallVectorImpl<char> &Buffer) const; + llvm::SmallVectorImpl<char> &Buffer, + bool *Invalid = 0) const; /// getSpellingOfSingleCharacterNumericConstant - Tok is a numeric constant /// with length 1, return the character. - char getSpellingOfSingleCharacterNumericConstant(const Token &Tok) const { + char getSpellingOfSingleCharacterNumericConstant(const Token &Tok, + bool *Invalid = 0) const { assert(Tok.is(tok::numeric_constant) && Tok.getLength() == 1 && "Called on unsupported token"); assert(!Tok.needsCleaning() && "Token can't need cleaning with length 1"); |