summaryrefslogtreecommitdiffstats
path: root/include/clang/Edit
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <shal1t712@gmail.com>2017-06-08 21:44:45 +0000
committerAlexander Shaposhnikov <shal1t712@gmail.com>2017-06-08 21:44:45 +0000
commit97a93ed9081459ae5590fc787e4163ae435a5028 (patch)
tree4af9185d616bcf72efd91efa670166dcc754ae10 /include/clang/Edit
parentc792502570b849026b75eff97f8c6040a6db06b2 (diff)
[clang] Fix format specifiers fixits
This diff fixes printf "fixits" in the case when there is a wrapping macro and the format string needs multiple replacements. In the presence of a macro there is an extra logic in EditedSource.cpp to handle multiple uses of the same macro argument (see the old comment inside EditedSource::canInsertInOffset) which was mistriggerred when the argument was used only once but required multiple adjustments), as a result the "fixit" was breaking down the format string by dropping the second format specifier, i.e. Log1("test 4: %s %s", getNSInteger(), getNSInteger()) was getting replaced with Log1("test 4: %ld ", (long)getNSInteger(), (long)getNSInteger()) (if one removed the macro and used printf directly it would work fine). In this diff we track the location where the macro argument is used and (as it was before) the modifications originating from all the locations except the first one are rejected, but multiple changes are allowed. Test plan: make check-all Differential revision: https://reviews.llvm.org/D33976 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305018 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Edit')
-rw-r--r--include/clang/Edit/EditedSource.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/clang/Edit/EditedSource.h b/include/clang/Edit/EditedSource.h
index b082e4e0a3..9707914207 100644
--- a/include/clang/Edit/EditedSource.h
+++ b/include/clang/Edit/EditedSource.h
@@ -41,9 +41,11 @@ class EditedSource {
typedef std::map<FileOffset, FileEdit> FileEditsTy;
FileEditsTy FileEdits;
- llvm::DenseMap<unsigned, llvm::TinyPtrVector<IdentifierInfo*>>
+ // Location of argument use inside the macro body
+ typedef std::pair<IdentifierInfo*, SourceLocation> MacroArgUse;
+ llvm::DenseMap<unsigned, SmallVector<MacroArgUse, 2>>
ExpansionToArgMap;
- SmallVector<std::pair<SourceLocation, IdentifierInfo*>, 2>
+ SmallVector<std::pair<SourceLocation, MacroArgUse>, 2>
CurrCommitMacroArgExps;
IdentifierTable IdentTable;
@@ -84,7 +86,7 @@ private:
FileEditsTy::iterator getActionForOffset(FileOffset Offs);
void deconstructMacroArgLoc(SourceLocation Loc,
SourceLocation &ExpansionLoc,
- IdentifierInfo *&II);
+ MacroArgUse &ArgUse);
void startingCommit();
void finishedCommit();