summaryrefslogtreecommitdiff
path: root/include/clang/Edit/EditedSource.h
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <shal1t712@gmail.com>2017-06-20 20:46:58 +0000
committerAlexander Shaposhnikov <shal1t712@gmail.com>2017-06-20 20:46:58 +0000
commitd0f47eb94f60fa5fbe4fa1a7a7cc24405a98d4c2 (patch)
treec21cdc9c2e8bc895b037c8132077a12714245914 /include/clang/Edit/EditedSource.h
parent6e3f80de39298b1ac410e59841c60853e807fa37 (diff)
downloadclang-d0f47eb94f60fa5fbe4fa1a7a7cc24405a98d4c2.tar.gz
[clang] Fix format specifiers fixits for nested macros
ExpansionLoc was previously calculated incorrectly in the case of nested macros expansions. In this diff we build the stack of expansions where the last one is the actual expansion which should be used for grouping together the edits. The definition of MacroArgUse is adjusted accordingly. Test plan: make check-all Differential revision: https://reviews.llvm.org/D34268 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305845 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Edit/EditedSource.h')
-rw-r--r--include/clang/Edit/EditedSource.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/include/clang/Edit/EditedSource.h b/include/clang/Edit/EditedSource.h
index 9707914207..d95a0c2be8 100644
--- a/include/clang/Edit/EditedSource.h
+++ b/include/clang/Edit/EditedSource.h
@@ -17,6 +17,7 @@
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/Support/Allocator.h"
#include <map>
+#include <tuple>
namespace clang {
class LangOptions;
@@ -41,10 +42,20 @@ class EditedSource {
typedef std::map<FileOffset, FileEdit> FileEditsTy;
FileEditsTy FileEdits;
- // Location of argument use inside the macro body
- typedef std::pair<IdentifierInfo*, SourceLocation> MacroArgUse;
- llvm::DenseMap<unsigned, SmallVector<MacroArgUse, 2>>
- ExpansionToArgMap;
+ struct MacroArgUse {
+ IdentifierInfo *Identifier;
+ SourceLocation ImmediateExpansionLoc;
+ // Location of argument use inside the top-level macro
+ SourceLocation UseLoc;
+
+ bool operator==(const MacroArgUse &Other) const {
+ return std::tie(Identifier, ImmediateExpansionLoc, UseLoc) ==
+ std::tie(Other.Identifier, Other.ImmediateExpansionLoc,
+ Other.UseLoc);
+ }
+ };
+
+ llvm::DenseMap<unsigned, SmallVector<MacroArgUse, 2>> ExpansionToArgMap;
SmallVector<std::pair<SourceLocation, MacroArgUse>, 2>
CurrCommitMacroArgExps;