[cfe-commits] r39904 - /cfe/trunk/Driver/TextDiagnosticPrinter.cpp

Chris Lattner sabre at nondot.org
Sun Jul 15 23:46:51 PDT 2007


Author: lattner
Date: Mon Jul 16 01:46:50 2007
New Revision: 39904

URL: http://llvm.org/viewvc/llvm-project?rev=39904&view=rev
Log:
add better comments.


Modified:
    cfe/trunk/Driver/TextDiagnosticPrinter.cpp

Modified: cfe/trunk/Driver/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticPrinter.cpp?rev=39904&r1=39903&r2=39904&view=diff

==============================================================================
--- cfe/trunk/Driver/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/Driver/TextDiagnosticPrinter.cpp Mon Jul 16 01:46:50 2007
@@ -101,12 +101,14 @@
 /// GetTokenLength - Given the source location of a token, determine its length.
 /// This is a fully general function that uses a lexer to relex the token.
 unsigned TextDiagnosticPrinter::GetTokenLength(SourceLocation Loc) {
-  const char *StrData = 
-    SourceMgr.getCharacterData(SourceMgr.getLogicalLoc(Loc));
-  
-  // Note, this could be special cased for common tokens like identifiers, ')',
-  // etc to make this faster, if it mattered.
-
+  // If this comes from a macro expansion, we really do want the macro name, not
+  // the token this macro expanded to.
+  Loc = SourceMgr.getLogicalLoc(Loc);
+  const char *StrData = SourceMgr.getCharacterData(Loc);
+  
+  // TODO: this could be special cased for common tokens like identifiers, ')',
+  // etc to make this faster, if it mattered.  This could use 
+  // Lexer::isObviouslySimpleCharacter for example.
   unsigned FileID = Loc.getFileID();
   
   // Create a lexer starting at the beginning of this token.





More information about the cfe-commits mailing list