[cfe-commits] r62314 - in /cfe/trunk: include/clang/Lex/Preprocessor.h lib/Sema/SemaExpr.cpp

Chris Lattner sabre at nondot.org
Thu Jan 15 23:10:29 PST 2009


Author: lattner
Date: Fri Jan 16 01:10:29 2009
New Revision: 62314

URL: http://llvm.org/viewvc/llvm-project?rev=62314&view=rev
Log:
rename PP::getPhysicalCharacterAt -> PP::getSpelledCharacterAt.
Slightly speed up sema of numbers like '1' by going directly to 
TargetInfo instead of through ASTContext.

Modified:
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=62314&r1=62313&r2=62314&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri Jan 16 01:10:29 2009
@@ -451,16 +451,16 @@
   /// 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);

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=62314&r1=62313&r2=62314&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jan 16 01:10:29 2009
@@ -851,12 +851,12 @@
 }
 
 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<unsigned>(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()));
   }





More information about the cfe-commits mailing list