From: Chris Lattner Date: Fri, 16 Jan 2009 07:10:29 +0000 (+0000) Subject: rename PP::getPhysicalCharacterAt -> PP::getSpelledCharacterAt. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0c21e84b82191ae1c4d04444a84008c464433868;p=clang rename PP::getPhysicalCharacterAt -> PP::getSpelledCharacterAt. Slightly speed up sema of numbers like '1' by going directly to TargetInfo instead of through ASTContext. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62314 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index a94c8c1d84..a631a583a9 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -451,16 +451,16 @@ 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 { + /// getSpelledCharacterAt - Return a pointer to the start of the specified + /// location in the appropriate MemoryBuffer. + char getSpelledCharacterAt(SourceLocation SL) const { if (PTH) { SL = SourceMgr.getSpellingLoc(SL); - unsigned fid = SourceMgr.getCanonicalFileID(SL); - unsigned fpos = SourceMgr.getFullFilePos(SL); - const char* data; - if (PTH->getSpelling(fid, fpos, data)) - return *data; + 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); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index b8d58c101c..bf2d7b1489 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -851,12 +851,12 @@ Sema::ExprResult Sema::ActOnCharacterConstant(const Token &Tok) { } Action::ExprResult Sema::ActOnNumericConstant(const Token &Tok) { - // fast path for a single digit (which is quite common). A single digit + // 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.getPhysicalCharacterAt(Tok.getLocation()); - unsigned IntSize =static_cast(Context.getTypeSize(Context.IntTy)); - return ExprResult(new IntegerLiteral(llvm::APInt(IntSize, Ty-'0'), + const char Val = PP.getSpelledCharacterAt(Tok.getLocation()); + unsigned IntSize = Context.Target.getIntWidth(); + return ExprResult(new IntegerLiteral(llvm::APInt(IntSize, Val-'0'), Context.IntTy, Tok.getLocation())); }