diff options
author | John McCall <rjmccall@apple.com> | 2011-03-08 07:59:04 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-03-08 07:59:04 +0000 |
commit | 834e3f6c77d9ac03997a3f0c56934edcf406a355 (patch) | |
tree | 9996ca50172c3a9cb33026731c560de98b8f4cc7 /include/clang | |
parent | 2792fa5115c5de7cbe11d99d23663c569bfb4cae (diff) |
Fix my earlier commit to work with escaped newlines and leave breadcrumbs
in case we want to make a world where we can check intermediate instantiations
for this kind of breadcrumb.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127221 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Lex/Lexer.h | 14 | ||||
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 12 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 3 |
3 files changed, 27 insertions, 2 deletions
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h index fc9a8de434..91fcd6700d 100644 --- a/include/clang/Lex/Lexer.h +++ b/include/clang/Lex/Lexer.h @@ -236,6 +236,20 @@ public: const SourceManager &SourceMgr, const LangOptions &Features, bool *Invalid = 0); + + /// getSpelling - This method is used to get the spelling of the + /// token at the given source location. If, as is usually true, it + /// is not necessary to copy any data, then the returned string may + /// not point into the provided buffer. + /// + /// This method lexes at the instantiation depth of the given + /// location and does not jump to the instantiation or spelling + /// location. + static llvm::StringRef getSpelling(SourceLocation loc, + llvm::SmallVectorImpl<char> &buffer, + const SourceManager &SourceMgr, + const LangOptions &Features, + bool *invalid = 0); /// MeasureTokenLength - Relex the token at the specified location and return /// its length in bytes in the input file. If the token needs cleaning (e.g. diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 0b01710abf..42af489d90 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -644,10 +644,18 @@ public: return Diags->Report(Tok.getLocation(), DiagID); } - /// getSpelling() - Return the 'spelling' of the token at the given location. + /// getSpelling() - Return the 'spelling' of the token at the given + /// location; does not go up to the spelling location or down to the + /// instantiation location. /// + /// \param buffer A buffer which will be used only if the token requires + /// "cleaning", e.g. if it contains trigraphs or escaped newlines /// \param invalid If non-null, will be set \c true if an error occurs. - llvm::StringRef getSpelling(SourceLocation loc, bool *invalid = 0) const; + llvm::StringRef getSpelling(SourceLocation loc, + llvm::SmallVectorImpl<char> &buffer, + bool *invalid = 0) const { + return Lexer::getSpelling(loc, buffer, SourceMgr, Features, invalid); + } /// 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 diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 70ec778289..0a55228494 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -678,6 +678,8 @@ public: /// \brief Build a partial diagnostic. PartialDiagnostic PDiag(unsigned DiagID = 0); // in SemaInternal.h + bool findMacroSpelling(SourceLocation &loc, llvm::StringRef name); + ExprResult Owned(Expr* E) { return E; } ExprResult Owned(ExprResult R) { return R; } StmtResult Owned(Stmt* S) { return S; } @@ -1704,6 +1706,7 @@ public: /// initialization. void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars); + //===--------------------------------------------------------------------===// // Statement Parsing Callbacks: SemaStmt.cpp. public: |