From b72a31b37f9bdcfd3f59b3256b465bf0fb5a50ca Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 3 May 2018 21:13:35 +0200 Subject: Adapt to Clang trunk SourceManager::getImmediateExpansionRange changes ...of "PR37189 Fix incorrect end source location and spelling for a split '>>' token", changing (among others) the return type of getImmediateExpansionRange from a std::pair of token locations to CharSourceRange (which will typically also represent token locations, but might also represent char locations). For now, map the return value of getImmediateExpansionRange back to a std::pair (as expected by our compilerplugins code in its current form), and mark the char location case with a TODO (which will need to be addressed if any of our plugins starts to produce wrong results due to not handling that char location case). In the long run, we should instead adapt our code to use the new return type of getImmediateExpansionRange directly. Change-Id: Idc2f5dc43830af4798b55bf605976c4ab146c522 Reviewed-on: https://gerrit.libreoffice.org/53817 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- compilerplugins/clang/compat.hxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'compilerplugins/clang/compat.hxx') diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index 5a540b8ef695..e77846ab1166 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -11,6 +11,7 @@ #define INCLUDED_COMPILERPLUGINS_CLANG_COMPAT_HXX #include +#include #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" @@ -49,6 +50,17 @@ inline clang::FunctionDecl::param_const_range parameters( } #endif +inline std::pair getImmediateExpansionRange( + clang::SourceManager const & SM, clang::SourceLocation Loc) +{ +#if CLANG_VERSION >= 70000 + auto const csr = SM.getImmediateExpansionRange(Loc); + if (csr.isCharRange()) { /*TODO*/ } + return {csr.getBegin(), csr.getEnd()}; +#else + return SM.getImmediateExpansionRange(Loc); +#endif +} inline bool isPointWithin( clang::SourceManager const & SM, clang::SourceLocation Location, clang::SourceLocation Start, -- cgit