From: Chris Lattner Date: Sat, 17 Jan 2009 08:30:10 +0000 (+0000) Subject: simplify some lookups. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8350394c65b81bba3986dfe44ae17423873741de;p=clang simplify some lookups. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62426 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index e6c3056547..90785b5e19 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -216,15 +216,15 @@ unsigned Lexer::MeasureTokenLength(SourceLocation Loc, // the token this macro expanded to. Loc = SM.getInstantiationLoc(Loc); - const char *StrData = SM.getCharacterData(Loc); - // TODO: this could be special cased for common tokens like identifiers, ')', // etc to make this faster, if it mattered. Just look at StrData[0] to handle // all obviously single-char tokens. This could use // Lexer::isObviouslySimpleCharacter for example to handle identifiers or // something. - std::pair Buffer = SM.getBufferData(Loc); - + std::pair LocInfo = SM.getDecomposedFileLoc(Loc); + std::pair Buffer = SM.getBufferData(LocInfo.first); + const char *StrData = Buffer.first+LocInfo.second; + // Create a langops struct and enable trigraphs. This is sufficient for // measuring tokens. LangOptions LangOpts;