diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-01-13 23:19:12 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-01-13 23:19:12 +0000 |
commit | 28396608ec20d44e9d1470e1ea51689bb504d0de (patch) | |
tree | 06502671ae427dde72a63f98063d6ee5ad431426 /include/clang/Lex/Preprocessor.h | |
parent | ee159c14c1ac99d7944645e2b111b04dca089855 (diff) |
PTH:
- Use canonical FileID when using getSpelling() caching. This
addresses some cache misses we were seeing with -fsyntax-only on
Cocoa.h
- Added Preprocessor::getPhysicalCharacterAt() utility method for
clients to grab the first character at a specified sourcelocation.
This uses the PTH spelling cache.
- Modified Sema::ActOnNumericConstant() to use
Preprocessor::getPhysicalCharacterAt() instead of
SourceManager::getCharacterData() (to get PTH hits).
These changes cause -fsyntax-only to not page in any sources from
Cocoa.h. We see a speedup of 27%.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62193 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex/Preprocessor.h')
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 54dc1b62df..5ee8378d52 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -449,6 +449,20 @@ public: /// if an internal buffer is returned. unsigned getSpelling(const Token &Tok, const char *&Buffer) const; + /// getPhysicalCharacterAt - Return a pointer to the start of the specified + /// location in the appropriate MemoryBuffer. + char getPhysicalCharacterAt(SourceLocation SL) const { + if (PTH) { + SL = SourceMgr.getPhysicalLoc(SL); + unsigned fid = SourceMgr.getCanonicalFileID(SL); + unsigned fpos = SourceMgr.getFullFilePos(SL); + const char* data; + if (PTH->getSpelling(fid, fpos, data)) + return *data; + } + + return *SourceMgr.getCharacterData(SL); + } /// CreateString - Plop the specified string into a scratch buffer and return /// a location for it. If specified, the source location provides a source |