From 20e6ccd6f74e73eee39386f64e236ce43a2ec210 Mon Sep 17 00:00:00 2001 From: Chris Lattner <sabre@nondot.org> Date: Mon, 16 Jul 2007 06:46:50 +0000 Subject: [PATCH] add better comments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39904 91177308-0d34-0410-b5e6-96231b3b80d8 --- Driver/TextDiagnosticPrinter.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Driver/TextDiagnosticPrinter.cpp b/Driver/TextDiagnosticPrinter.cpp index 1acd210898b..f1a36ba5034 100644 --- a/Driver/TextDiagnosticPrinter.cpp +++ b/Driver/TextDiagnosticPrinter.cpp @@ -101,12 +101,14 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, /// 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. -- GitLab