diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-04-11 18:15:01 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-04-11 18:15:01 +0000 |
commit | eba8cd5967e47592285590360bde73063c9c226f (patch) | |
tree | 726103d594238702adf352b5c9925790b1b3c40d /tools | |
parent | 944b5623c3e658f5ceabf1349cdb7371cb2387bb (diff) |
[libclang] In cxloc::translateSourceRange make sure to handle locations in macro arguments
correctly. clang diagnostics can provide fixits inside a macro argument now.
rdar://11014346
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154517 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libclang/CIndex.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 67c56a2674..808de3d253 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -112,10 +112,11 @@ CXSourceRange cxloc::translateSourceRange(const SourceManager &SM, // We want the last character in this location, so we will adjust the // location accordingly. SourceLocation EndLoc = R.getEnd(); - if (EndLoc.isValid() && EndLoc.isMacroID()) + if (EndLoc.isValid() && EndLoc.isMacroID() && !SM.isMacroArgExpansion(EndLoc)) EndLoc = SM.getExpansionRange(EndLoc).second; - if (R.isTokenRange() && !EndLoc.isInvalid() && EndLoc.isFileID()) { - unsigned Length = Lexer::MeasureTokenLength(EndLoc, SM, LangOpts); + if (R.isTokenRange() && !EndLoc.isInvalid()) { + unsigned Length = Lexer::MeasureTokenLength(SM.getSpellingLoc(EndLoc), + SM, LangOpts); EndLoc = EndLoc.getLocWithOffset(Length); } |