Skip to content

Commit

Permalink
minor improvement on removeFieldDecl
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyang78 committed Sep 27, 2012
1 parent 3e9a81d commit 17528dd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions clang_delta/RewriteUtils.cpp
Expand Up @@ -1328,6 +1328,18 @@ bool RewriteUtils::removeFieldDecl(const FieldDecl *FD)
SourceRange Range = FD->getSourceRange();
SourceLocation StartLoc = Range.getBegin();
SourceLocation EndLoc = getEndLocationUntil(Range, ';');
SourceLocation CurlyEndLoc = getEndLocationUntil(Range, '}');

// handle cases like:
// struct {
// int f <- no semicolon here
// };
const char *SemiPos = SrcManager->getCharacterData(EndLoc);
const char *CurlyPos = SrcManager->getCharacterData(CurlyEndLoc);
if (SemiPos > CurlyPos) {
EndLoc = CurlyEndLoc.getLocWithOffset(-1);
}

return !(TheRewriter->RemoveText(SourceRange(StartLoc, EndLoc)));
}

Expand Down

0 comments on commit 17528dd

Please sign in to comment.