clang: lib/Tooling/Transformer/Transformer.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
14#include "llvm/Support/Error.h"
15#include
16#include
17#include
18
20namespace tooling {
21
22using ::clang::ast_matchers::MatchFinder;
23
24namespace detail {
25
28 if (Result.Context->getDiagnostics().hasErrorOccurred())
29 return;
30
32}
33
38
39
40 std::map<FileID, AtomicChange> ChangesByFileID;
41 for (const auto &T : Edits) {
42 auto ID = Result.SourceManager->getFileID(T.Range.getBegin());
43 auto Iter = ChangesByFileID
45 T.Range.getBegin(), T.Metadata))
46 .first;
47 auto &AC = Iter->second;
48 switch (T.Kind) {
50 if (auto Err =
51 AC.replace(*Result.SourceManager, T.Range, T.Replacement)) {
52 return std::move(Err);
53 }
54 break;
56 AC.addHeader(T.Replacement);
57 break;
58 }
59 }
60
62 Changes.reserve(ChangesByFileID.size());
63 for (auto &IDChangePair : ChangesByFileID)
64 Changes.push_back(std::move(IDChangePair.second));
65
66 return Changes;
67}
68
69}
70
72 for (auto &Matcher : Impl->buildMatchers())
74}
75
77 if (Result.Context->getDiagnostics().hasErrorOccurred())
78 return;
79
80 Impl->onMatch(Result);
81}
82
83}
84}
Defines the clang::SourceLocation class and associated facilities.
A class to allow finding matches over the Clang AST.
bool addDynamicMatcher(const internal::DynTypedMatcher &NodeMatch, MatchCallback *Action)
Adds a matcher to execute when running over the AST.
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
const FunctionProtoType * T
Contains all information for a given match.