summaryrefslogtreecommitdiff
path: root/AspectC++/ClangWeaverBase.cc
diff options
context:
space:
mode:
Diffstat (limited to 'AspectC++/ClangWeaverBase.cc')
-rw-r--r--AspectC++/ClangWeaverBase.cc34
1 files changed, 33 insertions, 1 deletions
diff --git a/AspectC++/ClangWeaverBase.cc b/AspectC++/ClangWeaverBase.cc
index 068ed4a..ab8eb04 100644
--- a/AspectC++/ClangWeaverBase.cc
+++ b/AspectC++/ClangWeaverBase.cc
@@ -320,7 +320,9 @@ void WeaverBase::lex_and_filter_attr(clang::Preprocessor &PP, clang::Token &resu
int pos = 0;
for (list<clang::Token>::const_iterator i = reinsert_tokens.begin(); i != reinsert_tokens.end(); ++i)
input[pos++] = *i;
-#if CLANG_VERSION_NUMBER >= VERSION_NUMBER_3_9_1
+#if CLANG_VERSION_NUMBER >= VERSION_NUMBER_9_0_0
+ PP.EnterTokenStream(std::move(input), reinsert_tokens.size(), true, false);
+#elif CLANG_VERSION_NUMBER >= VERSION_NUMBER_3_9_1
PP.EnterTokenStream(std::move(input), reinsert_tokens.size(), true);
#else
PP.EnterTokenStream(input, reinsert_tokens.size(), true, true);
@@ -472,8 +474,14 @@ void WeaverBase::commit_kill (clang::SourceLocation from, clang::SourceLocation
_rewriter->RemoveText(clang::CharSourceRange::getCharRange(loc1, macro_end));
clang::SourceLocation somewhere_inside = macro_info->second._somewhere_inside;
+#if CLANG_VERSION_NUMBER >= VERSION_NUMBER_9_0_0
+ clang::CharSourceRange source_range = SM.getExpansionRange(somewhere_inside);
+ std::pair<clang::SourceLocation, clang::SourceLocation> range =
+ std::pair<clang::SourceLocation, clang::SourceLocation> (source_range.getBegin(), source_range.getEnd());
+#else
std::pair<clang::SourceLocation, clang::SourceLocation> range =
SM.getExpansionRange(somewhere_inside);
+#endif
unsigned len = _rewriter->getRangeSize(clang::SourceRange(range.second, range.second));
_rewriter->RemoveText(clang::CharSourceRange::getCharRange(
range.second.getLocWithOffset(len), loc2), opts);
@@ -488,8 +496,14 @@ void WeaverBase::commit_kill (clang::SourceLocation from, clang::SourceLocation
_rewriter->RemoveText(clang::CharSourceRange::getCharRange(macro_start, loc2));
clang::SourceLocation somewhere_inside = macro_info->second._somewhere_inside;
+#if CLANG_VERSION_NUMBER >= VERSION_NUMBER_9_0_0
+ clang::CharSourceRange source_range = SM.getExpansionRange(somewhere_inside);
+ std::pair<clang::SourceLocation, clang::SourceLocation> range =
+ std::pair<clang::SourceLocation, clang::SourceLocation> (source_range.getBegin(), source_range.getEnd());
+#else
std::pair<clang::SourceLocation, clang::SourceLocation> range =
SM.getExpansionRange(somewhere_inside);
+#endif
_rewriter->RemoveText(clang::CharSourceRange::getCharRange(
loc1, range.first), opts);
}
@@ -518,13 +532,25 @@ void WeaverBase::commit_kill (clang::SourceLocation from, clang::SourceLocation
// remove from first macro expansion end to second macro expansion begin
clang::SourceLocation somewhere_inside1 = macro_info1->second._somewhere_inside;
+#if CLANG_VERSION_NUMBER >= VERSION_NUMBER_9_0_0
+ clang::CharSourceRange source_range1 = SM.getExpansionRange(somewhere_inside1);
+ std::pair<clang::SourceLocation, clang::SourceLocation> range1 =
+ std::pair<clang::SourceLocation, clang::SourceLocation> (source_range1.getBegin(), source_range1.getEnd());
+#else
std::pair<clang::SourceLocation, clang::SourceLocation> range1 =
SM.getExpansionRange(somewhere_inside1);
+#endif
unsigned len = _rewriter->getRangeSize(clang::SourceRange(range1.second, range1.second));
clang::SourceLocation somewhere_inside2 = macro_info2->second._somewhere_inside;
+#if CLANG_VERSION_NUMBER >= VERSION_NUMBER_9_0_0
+ clang::CharSourceRange source_range2 = SM.getExpansionRange(somewhere_inside2);
+ std::pair<clang::SourceLocation, clang::SourceLocation> range2 =
+ std::pair<clang::SourceLocation, clang::SourceLocation> (source_range2.getBegin(), source_range2.getEnd());
+#else
std::pair<clang::SourceLocation, clang::SourceLocation> range2 =
SM.getExpansionRange(somewhere_inside2);
+#endif
_rewriter->RemoveText(clang::CharSourceRange::getCharRange(
range1.second.getLocWithOffset(len), range2.first), opts);
@@ -623,8 +649,14 @@ void WeaverBase::resolve_macros() {
// cout << mm_iter->second._expanded_macro_text << endl;
// expand macro
+#if CLANG_VERSION_NUMBER >= VERSION_NUMBER_9_0_0
+ clang::CharSourceRange source_range = SM.getExpansionRange(somewhere_inside);
+ std::pair<clang::SourceLocation, clang::SourceLocation> range =
+ std::pair<clang::SourceLocation, clang::SourceLocation> (source_range.getBegin(), source_range.getEnd());
+#else
std::pair<clang::SourceLocation, clang::SourceLocation> range =
SM.getExpansionRange(somewhere_inside);
+#endif
const clang::RewriteBuffer *RB = _rewriter->getRewriteBufferFor(fid);
if (!RB) {
cout << "fatal: Rewrite buffer not found" << endl;