[PATCH] D20134: [libclang] Fixed bug where ranges in spelling locations (in macro expansions) would get mangled
Cameron via cfe-commits
cfe-commits at lists.llvm.org
Tue May 10 14:08:44 PDT 2016
cameron314 created this revision.
cameron314 added a reviewer: rsmith.
cameron314 added a subscriber: cfe-commits.
The end location of the range would be changed into its expansion location, but the beginning of the range would stay as a spelling location. This would lead to very weird ranges spanning large parts of a file (starting in a macro until its expansion).
This bug was not previously caught because there was no way to actually obtain a spelling location via libclang (see my patch at D20125 which adds support for this), so later obtaining the start location of a range would result in an expansion location anyway, and wind up matching the expansion location that was stored in the end of the range.
http://reviews.llvm.org/D20134
Files:
tools/libclang/CIndex.cpp
Index: tools/libclang/CIndex.cpp
===================================================================
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -142,8 +142,6 @@
// We want the last character in this location, so we will adjust the
// location accordingly.
SourceLocation EndLoc = R.getEnd();
- if (EndLoc.isValid() && EndLoc.isMacroID() && !SM.isMacroArgExpansion(EndLoc))
- EndLoc = SM.getExpansionRange(EndLoc).second;
if (R.isTokenRange() && EndLoc.isValid()) {
unsigned Length = Lexer::MeasureTokenLength(SM.getSpellingLoc(EndLoc),
SM, LangOpts);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20134.56813.patch
Type: text/x-patch
Size: 641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160510/cc0381ef/attachment.bin>
More information about the cfe-commits
mailing list