aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-01-13 23:19:12 +0000
committerTed Kremenek <kremenek@apple.com>2009-01-13 23:19:12 +0000
commit28396608ec20d44e9d1470e1ea51689bb504d0de (patch)
tree06502671ae427dde72a63f98063d6ee5ad431426 /lib
parentee159c14c1ac99d7944645e2b111b04dca089855 (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 'lib')
-rw-r--r--lib/Lex/PTHLexer.cpp2
-rw-r--r--lib/Lex/Preprocessor.cpp4
-rw-r--r--lib/Sema/SemaExpr.cpp6
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index c5fc6f3da7..8d04736ced 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -423,7 +423,7 @@ unsigned PTHSpellingSearch::getSpellingBinarySearch(unsigned fpos,
unsigned PTHLexer::getSpelling(SourceLocation sloc, const char *&Buffer) {
SourceManager& SM = PP->getSourceManager();
sloc = SM.getPhysicalLoc(sloc);
- unsigned fid = sloc.getFileID();
+ unsigned fid = SM.getCanonicalFileID(sloc);
unsigned fpos = SM.getFullFilePos(sloc);
return (fid == FileID ) ? MySpellingSrch.getSpellingLinearSearch(fpos, Buffer)
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index a815265e7c..e09ce1312d 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -199,7 +199,7 @@ std::string Preprocessor::getSpelling(const Token &Tok) const {
if (PTH) {
SourceLocation sloc = SourceMgr.getPhysicalLoc(Tok.getLocation());
- unsigned fid = sloc.getFileID();
+ unsigned fid = SourceMgr.getCanonicalFileID(sloc);
unsigned fpos = SourceMgr.getFullFilePos(sloc);
if (unsigned len = PTH->getSpelling(fid, fpos, TokStart)) {
assert(!Tok.needsCleaning());
@@ -265,7 +265,7 @@ unsigned Preprocessor::getSpelling(const Token &Tok,
}
else {
SourceLocation sloc = SourceMgr.getPhysicalLoc(Tok.getLocation());
- unsigned fid = sloc.getFileID();
+ unsigned fid = SourceMgr.getCanonicalFileID(sloc);
unsigned fpos = SourceMgr.getFullFilePos(sloc);
len = PTH->getSpelling(fid, fpos, Buffer);
}
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 41881a2e5b..d7a041d0ec 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -846,13 +846,13 @@ Action::ExprResult Sema::ActOnNumericConstant(const Token &Tok) {
// fast path for a single digit (which is quite common). A single digit
// cannot have a trigraph, escaped newline, radix prefix, or type suffix.
if (Tok.getLength() == 1) {
- const char *Ty = PP.getSourceManager().getCharacterData(Tok.getLocation());
-
+ const char Ty = PP.getPhysicalCharacterAt(Tok.getLocation());
unsigned IntSize =static_cast<unsigned>(Context.getTypeSize(Context.IntTy));
- return ExprResult(new IntegerLiteral(llvm::APInt(IntSize, *Ty-'0'),
+ return ExprResult(new IntegerLiteral(llvm::APInt(IntSize, Ty-'0'),
Context.IntTy,
Tok.getLocation()));
}
+
llvm::SmallString<512> IntegerBuffer;
// Add padding so that NumericLiteralParser can overread by one character.
IntegerBuffer.resize(Tok.getLength()+1);