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 | 408403c4b59a667806d8537d52a161baf8fcf1b4 (patch) | |
| tree | 7d809399adbd362ef20da119de157e02cb015abf /clang/tools/libclang | |
| parent | be646db000f08c673ed181fd399303c9d10014b4 (diff) | |
| download | bcm5719-llvm-408403c4b59a667806d8537d52a161baf8fcf1b4.tar.gz bcm5719-llvm-408403c4b59a667806d8537d52a161baf8fcf1b4.zip | |
[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
llvm-svn: 154517
Diffstat (limited to 'clang/tools/libclang')
| -rw-r--r-- | clang/tools/libclang/CIndex.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 67c56a26746..808de3d253c 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/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); } |

