summaryrefslogtreecommitdiff
path: root/compilerplugins/clang
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-08-10 12:35:21 +0200
committerStephan Bergmann <sbergman@redhat.com>2018-08-10 15:14:03 +0200
commit3cc5149a84c7b8cfaf0deb2e2f6c88c72343ee28 (patch)
tree07bfda734ee36d2ca1dc83e2ac4a1c6ef3222691 /compilerplugins/clang
parentd1a19ef614fd1bf115af15d3cb16e24150d4ceb7 (diff)
Avoid -Werror=deprecated-declarations with recent Clang trunk
...which first added alternative names to and then deprecated getLocBegin/End Change-Id: Iaefb8ce259057abfa6cd20f0b63c0ef2949a96b2 Reviewed-on: https://gerrit.libreoffice.org/58820 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r--compilerplugins/clang/automem.cxx4
-rw-r--r--compilerplugins/clang/blockblock.cxx8
-rw-r--r--compilerplugins/clang/casttovoid.cxx4
-rw-r--r--compilerplugins/clang/changetoolsgen.cxx35
-rw-r--r--compilerplugins/clang/checkunusedparams.cxx6
-rw-r--r--compilerplugins/clang/commaoperator.cxx4
-rw-r--r--compilerplugins/clang/compat.hxx65
-rw-r--r--compilerplugins/clang/constantparam.cxx4
-rw-r--r--compilerplugins/clang/constparams.cxx16
-rw-r--r--compilerplugins/clang/countusersofdefaultparams.cxx4
-rw-r--r--compilerplugins/clang/cstylecast.cxx6
-rw-r--r--compilerplugins/clang/datamembershadow.cxx6
-rw-r--r--compilerplugins/clang/dbgunhandledexception.cxx8
-rw-r--r--compilerplugins/clang/derefnullptr.cxx2
-rw-r--r--compilerplugins/clang/dodgyswitch.cxx4
-rw-r--r--compilerplugins/clang/emptyif.cxx5
-rw-r--r--compilerplugins/clang/expandablemethods.cxx2
-rw-r--r--compilerplugins/clang/expressionalwayszero.cxx8
-rw-r--r--compilerplugins/clang/faileddyncast.cxx2
-rw-r--r--compilerplugins/clang/finalclasses.cxx2
-rw-r--r--compilerplugins/clang/finalprotected.cxx4
-rw-r--r--compilerplugins/clang/flatten.cxx8
-rw-r--r--compilerplugins/clang/fragiledestructor.cxx12
-rw-r--r--compilerplugins/clang/implicitboolconversion.cxx14
-rw-r--r--compilerplugins/clang/inlinesimplememberfunctions.cxx10
-rw-r--r--compilerplugins/clang/literaltoboolconversion.cxx20
-rw-r--r--compilerplugins/clang/mergeclasses.cxx2
-rw-r--r--compilerplugins/clang/nullptr.cxx12
-rw-r--r--compilerplugins/clang/oncevar.cxx2
-rw-r--r--compilerplugins/clang/plugin.hxx3
-rw-r--r--compilerplugins/clang/privatebase.cxx2
-rw-r--r--compilerplugins/clang/rangedforcopy.cxx2
-rw-r--r--compilerplugins/clang/redundantcast.cxx18
-rw-r--r--compilerplugins/clang/redundantinline.cxx10
-rw-r--r--compilerplugins/clang/redundantpointerops.cxx10
-rw-r--r--compilerplugins/clang/refcounting.cxx6
-rw-r--r--compilerplugins/clang/rendercontext.cxx2
-rw-r--r--compilerplugins/clang/returnconstant.cxx11
-rw-r--r--compilerplugins/clang/salbool.cxx32
-rw-r--r--compilerplugins/clang/salcall.cxx4
-rw-r--r--compilerplugins/clang/sallogareas.cxx10
-rw-r--r--compilerplugins/clang/salunicodeliteral.cxx2
-rw-r--r--compilerplugins/clang/sfxpoolitem.cxx2
-rw-r--r--compilerplugins/clang/shouldreturnbool.cxx4
-rw-r--r--compilerplugins/clang/simplifybool.cxx142
-rw-r--r--compilerplugins/clang/simplifydynamiccast.cxx6
-rw-r--r--compilerplugins/clang/singlevalfields.cxx2
-rw-r--r--compilerplugins/clang/staticaccess.cxx2
-rw-r--r--compilerplugins/clang/staticanonymous.cxx2
-rw-r--r--compilerplugins/clang/staticmethods.cxx4
-rw-r--r--compilerplugins/clang/stringconcat.cxx10
-rw-r--r--compilerplugins/clang/stringconstant.cxx14
-rw-r--r--compilerplugins/clang/stringloop.cxx8
-rw-r--r--compilerplugins/clang/unnecessarycatchthrow.cxx2
-rw-r--r--compilerplugins/clang/unnecessaryoverride.cxx2
-rw-r--r--compilerplugins/clang/unnecessaryparen.cxx56
-rw-r--r--compilerplugins/clang/unoany.cxx2
-rw-r--r--compilerplugins/clang/unusedenumconstants.cxx2
-rw-r--r--compilerplugins/clang/unusedfields.cxx16
-rw-r--r--compilerplugins/clang/unusedfieldsremove.cxx2
-rw-r--r--compilerplugins/clang/unusedindex.cxx3
-rw-r--r--compilerplugins/clang/unusedmethodsremove.cxx2
-rw-r--r--compilerplugins/clang/useuniqueptr.cxx18
-rw-r--r--compilerplugins/clang/vclwidgets.cxx26
64 files changed, 395 insertions, 323 deletions
diff --git a/compilerplugins/clang/automem.cxx b/compilerplugins/clang/automem.cxx
index 4675c02325be..5c3d740bb9d0 100644
--- a/compilerplugins/clang/automem.cxx
+++ b/compilerplugins/clang/automem.cxx
@@ -51,7 +51,7 @@ bool AutoMem::VisitCXXDeleteExpr(const CXXDeleteExpr* expr)
{
if (ignoreLocation( expr ))
return true;
- StringRef aFileName = getFileNameOfSpellingLoc(compiler.getSourceManager().getSpellingLoc(expr->getLocStart()));
+ StringRef aFileName = getFileNameOfSpellingLoc(compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(expr)));
if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/salhelper/")
|| loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/osl/")
|| loplugin::hasPathnamePrefix(aFileName, SRCDIR "/salhelper/")
@@ -79,7 +79,7 @@ bool AutoMem::VisitCXXDeleteExpr(const CXXDeleteExpr* expr)
report(
DiagnosticsEngine::Warning,
"calling delete on object field, rather use std::unique_ptr or std::scoped_ptr",
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/blockblock.cxx b/compilerplugins/clang/blockblock.cxx
index bdb7d1361410..b0cba961aba0 100644
--- a/compilerplugins/clang/blockblock.cxx
+++ b/compilerplugins/clang/blockblock.cxx
@@ -47,9 +47,9 @@ bool BlockBlock::VisitCompoundStmt(CompoundStmt const * compound)
auto inner = *compound->body_begin();
if (!isa<CompoundStmt>(inner))
return true;
- if (compiler.getSourceManager().isMacroBodyExpansion(compound->getLocStart()))
+ if (compiler.getSourceManager().isMacroBodyExpansion(compat::getBeginLoc(compound)))
return true;
- if (compiler.getSourceManager().isMacroBodyExpansion(inner->getLocStart()))
+ if (compiler.getSourceManager().isMacroBodyExpansion(compat::getBeginLoc(inner)))
return true;
if (containsPreprocessingConditionalInclusion(compound->getSourceRange())) {
return true;
@@ -57,12 +57,12 @@ bool BlockBlock::VisitCompoundStmt(CompoundStmt const * compound)
report(
DiagnosticsEngine::Warning,
"block directly inside block",
- compound->getLocStart())
+ compat::getBeginLoc(compound))
<< compound->getSourceRange();
report(
DiagnosticsEngine::Note,
"inner block here",
- inner->getLocStart())
+ compat::getBeginLoc(inner))
<< inner->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/casttovoid.cxx b/compilerplugins/clang/casttovoid.cxx
index e8b080dab2a5..35c35da42a9a 100644
--- a/compilerplugins/clang/casttovoid.cxx
+++ b/compilerplugins/clang/casttovoid.cxx
@@ -440,7 +440,7 @@ private:
return nullptr;
}
if (compiler.getSourceManager().isMacroBodyExpansion(
- expr->getLocStart()))
+ compat::getBeginLoc(expr)))
{
return nullptr;
}
@@ -487,7 +487,7 @@ private:
if (usage.firstConsumption != nullptr) {
return;
}
- auto const loc = dre->getLocStart();
+ auto const loc = compat::getBeginLoc(dre);
if (compiler.getSourceManager().isMacroArgExpansion(loc)
&& (compat::getImmediateMacroNameForDiagnostics(
loc, compiler.getSourceManager(), compiler.getLangOpts())
diff --git a/compilerplugins/clang/changetoolsgen.cxx b/compilerplugins/clang/changetoolsgen.cxx
index 0b072c5dcbde..190c4abf2c84 100644
--- a/compilerplugins/clang/changetoolsgen.cxx
+++ b/compilerplugins/clang/changetoolsgen.cxx
@@ -111,7 +111,7 @@ bool ChangeToolsGen::VisitCXXMemberCallExpr(CXXMemberCallExpr const* call)
if (auto unaryOp = dyn_cast<UnaryOperator>(parent))
{
if (!ChangeUnaryOperator(unaryOp, call, methodName))
- report(DiagnosticsEngine::Warning, "Could not fix, unary", call->getLocStart());
+ report(DiagnosticsEngine::Warning, "Could not fix, unary", compat::getBeginLoc(call));
return true;
}
auto binaryOp = dyn_cast<BinaryOperator>(parent);
@@ -130,7 +130,7 @@ bool ChangeToolsGen::VisitCXXMemberCallExpr(CXXMemberCallExpr const* call)
if (parent2 && isa<Expr>(parent2))
{
report(DiagnosticsEngine::Warning, "Could not fix, embedded assign",
- call->getLocStart());
+ compat::getBeginLoc(call));
return true;
}
// Check for
@@ -139,25 +139,25 @@ bool ChangeToolsGen::VisitCXXMemberCallExpr(CXXMemberCallExpr const* call)
if (rhs->getOpcode() == BO_Assign)
{
report(DiagnosticsEngine::Warning, "Could not fix, double assign",
- call->getLocStart());
+ compat::getBeginLoc(call));
return true;
}
if (!ChangeAssignment(parent, methodName, setPrefix))
- report(DiagnosticsEngine::Warning, "Could not fix, assign", call->getLocStart());
+ report(DiagnosticsEngine::Warning, "Could not fix, assign", compat::getBeginLoc(call));
return true;
}
if (opcode == BO_AddAssign || opcode == BO_SubAssign)
{
if (!ChangeBinaryOperatorPlusMinus(binaryOp, call, methodName))
report(DiagnosticsEngine::Warning, "Could not fix, assign-and-change",
- call->getLocStart());
+ compat::getBeginLoc(call));
return true;
}
else if (opcode == BO_RemAssign || opcode == BO_MulAssign || opcode == BO_DivAssign)
{
if (!ChangeBinaryOperatorOther(binaryOp, call, methodName, setPrefix))
report(DiagnosticsEngine::Warning, "Could not fix, assign-and-change",
- call->getLocStart());
+ compat::getBeginLoc(call));
return true;
}
else
@@ -173,8 +173,8 @@ bool ChangeToolsGen::ChangeAssignment(Stmt const* parent, std::string const& met
// and replace with
// aRect.SetLeft( ... );
SourceManager& SM = compiler.getSourceManager();
- SourceLocation startLoc = SM.getExpansionLoc(parent->getLocStart());
- SourceLocation endLoc = SM.getExpansionLoc(parent->getLocEnd());
+ SourceLocation startLoc = SM.getExpansionLoc(compat::getBeginLoc(parent));
+ SourceLocation endLoc = SM.getExpansionLoc(compat::getEndLoc(parent));
const char* p1 = SM.getCharacterData(startLoc);
const char* p2 = SM.getCharacterData(endLoc);
unsigned n = Lexer::MeasureTokenLength(endLoc, SM, compiler.getLangOpts());
@@ -201,8 +201,8 @@ bool ChangeToolsGen::ChangeBinaryOperatorPlusMinus(BinaryOperator const* binaryO
// and replace with
// aRect.MoveLeft( ... );
SourceManager& SM = compiler.getSourceManager();
- SourceLocation startLoc = SM.getExpansionLoc(binaryOp->getLocStart());
- SourceLocation endLoc = SM.getExpansionLoc(binaryOp->getLocEnd());
+ SourceLocation startLoc = SM.getExpansionLoc(compat::getBeginLoc(binaryOp));
+ SourceLocation endLoc = SM.getExpansionLoc(compat::getEndLoc(binaryOp));
const char* p1 = SM.getCharacterData(startLoc);
const char* p2 = SM.getCharacterData(endLoc);
if (p2 < p1) // clang is misbehaving, appears to be macro constant related
@@ -228,7 +228,7 @@ bool ChangeToolsGen::ChangeBinaryOperatorPlusMinus(BinaryOperator const* binaryO
if (newText == callText)
{
report(DiagnosticsEngine::Warning, "binaryop-plusminus regex match failed",
- call->getLocStart());
+ compat::getBeginLoc(call));
return false;
}
@@ -245,8 +245,8 @@ bool ChangeToolsGen::ChangeBinaryOperatorOther(BinaryOperator const* binaryOp,
// and replace with
// aRect.SetLeft( aRect.GetLeft() + ... );
SourceManager& SM = compiler.getSourceManager();
- SourceLocation startLoc = SM.getExpansionLoc(binaryOp->getLocStart());
- SourceLocation endLoc = SM.getExpansionLoc(binaryOp->getLocEnd());
+ SourceLocation startLoc = SM.getExpansionLoc(compat::getBeginLoc(binaryOp));
+ SourceLocation endLoc = SM.getExpansionLoc(compat::getEndLoc(binaryOp));
const char* p1 = SM.getCharacterData(startLoc);
const char* p2 = SM.getCharacterData(endLoc);
if (p2 < p1) // clang is misbehaving, appears to be macro constant related
@@ -284,7 +284,7 @@ bool ChangeToolsGen::ChangeBinaryOperatorOther(BinaryOperator const* binaryOp,
if (newText == callText)
{
report(DiagnosticsEngine::Warning, "binaryop-other regex match failed %0",
- call->getLocStart())
+ compat::getBeginLoc(call))
<< reString;
return false;
}
@@ -308,8 +308,8 @@ bool ChangeToolsGen::ChangeUnaryOperator(UnaryOperator const* unaryOp,
// aRect.MoveLeft( 1 );
SourceManager& SM = compiler.getSourceManager();
- SourceLocation startLoc = SM.getExpansionLoc(unaryOp->getLocStart());
- SourceLocation endLoc = SM.getExpansionLoc(unaryOp->getLocEnd());
+ SourceLocation startLoc = SM.getExpansionLoc(compat::getBeginLoc(unaryOp));
+ SourceLocation endLoc = SM.getExpansionLoc(compat::getEndLoc(unaryOp));
const char* p1 = SM.getCharacterData(startLoc);
const char* p2 = SM.getCharacterData(endLoc);
if (p2 < p1) // clang is misbehaving, appears to be macro constant related
@@ -352,7 +352,8 @@ bool ChangeToolsGen::ChangeUnaryOperator(UnaryOperator const* unaryOp,
}
if (newText == callText)
{
- report(DiagnosticsEngine::Warning, "unaryop regex match failed %0", call->getLocStart())
+ report(DiagnosticsEngine::Warning, "unaryop regex match failed %0",
+ compat::getBeginLoc(call))
<< reString;
return false;
}
diff --git a/compilerplugins/clang/checkunusedparams.cxx b/compilerplugins/clang/checkunusedparams.cxx
index 84f05dca4dab..f0f95f6141db 100644
--- a/compilerplugins/clang/checkunusedparams.cxx
+++ b/compilerplugins/clang/checkunusedparams.cxx
@@ -199,7 +199,7 @@ bool CheckUnusedParams::VisitFunctionDecl(FunctionDecl const * decl) {
return true;
if (isInUnoIncludeFile(compiler.getSourceManager().getSpellingLoc(canon->getLocation())))
return true;
- StringRef fn = getFileNameOfSpellingLoc(compiler.getSourceManager().getSpellingLoc(canon->getLocStart()));
+ StringRef fn = getFileNameOfSpellingLoc(compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(canon)));
// Some backwards compat magic.
// TODO Can probably be removed, but need to do some checking
if (loplugin::isSamePathname(fn, SRCDIR "/include/sax/fshelper.hxx"))
@@ -471,7 +471,7 @@ bool CheckUnusedParams::VisitFunctionDecl(FunctionDecl const * decl) {
continue;
}
report( DiagnosticsEngine::Warning,
- "unused param %0 in %1", param->getLocStart())
+ "unused param %0 in %1", compat::getBeginLoc(param))
<< param->getSourceRange()
<< param->getName()
<< fqn;
@@ -480,7 +480,7 @@ bool CheckUnusedParams::VisitFunctionDecl(FunctionDecl const * decl) {
unsigned idx = param->getFunctionScopeIndex();
const ParmVarDecl* pOther = canon->getParamDecl(idx);
report( DiagnosticsEngine::Note, "declaration is here",
- pOther->getLocStart())
+ compat::getBeginLoc(pOther))
<< pOther->getSourceRange();
}
}
diff --git a/compilerplugins/clang/commaoperator.cxx b/compilerplugins/clang/commaoperator.cxx
index 0693fc83a07b..431cb10a68a9 100644
--- a/compilerplugins/clang/commaoperator.cxx
+++ b/compilerplugins/clang/commaoperator.cxx
@@ -97,11 +97,11 @@ bool CommaOperator::VisitBinComma(const BinaryOperator* binaryOp)
// winsock2.h (TODO: improve heuristic of determining that the whole
// binaryOp is part of a single macro body expansion):
if (compiler.getSourceManager().isMacroBodyExpansion(
- binaryOp->getLocStart())
+ compat::getBeginLoc(binaryOp))
&& compiler.getSourceManager().isMacroBodyExpansion(
binaryOp->getOperatorLoc())
&& compiler.getSourceManager().isMacroBodyExpansion(
- binaryOp->getLocEnd())
+ compat::getEndLoc(binaryOp))
&& ignoreLocation(
compiler.getSourceManager().getSpellingLoc(
binaryOp->getOperatorLoc())))
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index e77846ab1166..a83ed8688278 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -14,6 +14,7 @@
#include <utility>
#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/Basic/SourceManager.h"
@@ -50,6 +51,70 @@ inline clang::FunctionDecl::param_const_range parameters(
}
#endif
+inline clang::SourceLocation getBeginLoc(clang::Decl const * decl) {
+#if CLANG_VERSION >= 80000
+ return decl->getBeginLoc();
+#else
+ return decl->getLocStart();
+#endif
+}
+
+inline clang::SourceLocation getEndLoc(clang::Decl const * decl) {
+#if CLANG_VERSION >= 80000
+ return decl->getEndLoc();
+#else
+ return decl->getLocEnd();
+#endif
+}
+
+inline clang::SourceLocation getBeginLoc(clang::DeclarationNameInfo const & info) {
+#if CLANG_VERSION >= 80000
+ return info.getBeginLoc();
+#else
+ return info.getLocStart();
+#endif
+}
+
+inline clang::SourceLocation getEndLoc(clang::DeclarationNameInfo const & info) {
+#if CLANG_VERSION >= 80000
+ return info.getEndLoc();
+#else
+ return info.getLocEnd();
+#endif
+}
+
+inline clang::SourceLocation getBeginLoc(clang::Stmt const * stmt) {
+#if CLANG_VERSION >= 80000
+ return stmt->getBeginLoc();
+#else
+ return stmt->getLocStart();
+#endif
+}
+
+inline clang::SourceLocation getEndLoc(clang::Stmt const * stmt) {
+#if CLANG_VERSION >= 80000
+ return stmt->getEndLoc();
+#else
+ return stmt->getLocEnd();
+#endif
+}
+
+inline clang::SourceLocation getBeginLoc(clang::CXXBaseSpecifier const * spec) {
+#if CLANG_VERSION >= 80000
+ return spec->getBeginLoc();
+#else
+ return spec->getLocStart();
+#endif
+}
+
+inline clang::SourceLocation getEndLoc(clang::CXXBaseSpecifier const * spec) {
+#if CLANG_VERSION >= 80000
+ return spec->getEndLoc();
+#else
+ return spec->getLocEnd();
+#endif
+}
+
inline std::pair<clang::SourceLocation, clang::SourceLocation> getImmediateExpansionRange(
clang::SourceManager const & SM, clang::SourceLocation Loc)
{
diff --git a/compilerplugins/clang/constantparam.cxx b/compilerplugins/clang/constantparam.cxx
index efff4ac896d5..208fc19ca0f7 100644
--- a/compilerplugins/clang/constantparam.cxx
+++ b/compilerplugins/clang/constantparam.cxx
@@ -199,8 +199,8 @@ std::string ConstantParam::getCallValue(const Expr* arg)
// Get the expression contents.
// This helps us find params which are always initialised with something like "OUString()".
SourceManager& SM = compiler.getSourceManager();
- SourceLocation startLoc = arg->getLocStart();
- SourceLocation endLoc = arg->getLocEnd();
+ SourceLocation startLoc = compat::getBeginLoc(arg);
+ SourceLocation endLoc = compat::getEndLoc(arg);
const char *p1 = SM.getCharacterData( startLoc );
const char *p2 = SM.getCharacterData( endLoc );
if (!p1 || !p2 || (p2 - p1) < 0 || (p2 - p1) > 40) {
diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx
index 08e6aa2f1dc1..ee8ede3c1e2c 100644
--- a/compilerplugins/clang/constparams.cxx
+++ b/compilerplugins/clang/constparams.cxx
@@ -79,7 +79,7 @@ public:
report(
DiagnosticsEngine::Warning,
"this parameter can be const",
- pParmVarDecl->getLocStart())
+ compat::getBeginLoc(pParmVarDecl))
<< pParmVarDecl->getSourceRange();
if (canonicalDecl->getLocation() != functionDecl->getLocation()) {
unsigned idx = pParmVarDecl->getFunctionScopeIndex();
@@ -87,7 +87,7 @@ public:
report(
DiagnosticsEngine::Note,
"canonical parameter declaration here",
- pOther->getLocStart())
+ compat::getBeginLoc(pOther))
<< pOther->getSourceRange();
}
//functionDecl->dump();
@@ -172,13 +172,13 @@ bool ConstParams::CheckTraverseFunctionDecl(FunctionDecl * functionDecl)
// ignore the macros from include/tools/link.hxx
auto canonicalDecl = functionDecl->getCanonicalDecl();
- if (compiler.getSourceManager().isMacroBodyExpansion(canonicalDecl->getLocStart())
- || compiler.getSourceManager().isMacroArgExpansion(canonicalDecl->getLocStart())) {
+ if (compiler.getSourceManager().isMacroBodyExpansion(compat::getBeginLoc(canonicalDecl))
+ || compiler.getSourceManager().isMacroArgExpansion(compat::getBeginLoc(canonicalDecl))) {
StringRef name { Lexer::getImmediateMacroName(
- canonicalDecl->getLocStart(), compiler.getSourceManager(), compiler.getLangOpts()) };
+ compat::getBeginLoc(canonicalDecl), compiler.getSourceManager(), compiler.getLangOpts()) };
if (name.startswith("DECL_LINK") || name.startswith("DECL_STATIC_LINK"))
return false;
- auto loc2 = compat::getImmediateExpansionRange(compiler.getSourceManager(), canonicalDecl->getLocStart()).first;
+ auto loc2 = compat::getImmediateExpansionRange(compiler.getSourceManager(), compat::getBeginLoc(canonicalDecl)).first;
if (compiler.getSourceManager().isMacroBodyExpansion(loc2))
{
StringRef name2 { Lexer::getImmediateMacroName(
@@ -300,7 +300,7 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar
report(
DiagnosticsEngine::Warning,
"no parent?",
- stmt->getLocStart())
+ compat::getBeginLoc(stmt))
<< stmt->getSourceRange();
return false;
}
@@ -549,7 +549,7 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar
report(
DiagnosticsEngine::Warning,
"oh dear, what can the matter be?",
- parent->getLocStart())
+ compat::getBeginLoc(parent))
<< parent->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/countusersofdefaultparams.cxx b/compilerplugins/clang/countusersofdefaultparams.cxx
index f3d68a143aed..12057dec9264 100644
--- a/compilerplugins/clang/countusersofdefaultparams.cxx
+++ b/compilerplugins/clang/countusersofdefaultparams.cxx
@@ -170,7 +170,7 @@ bool CountUsersOfDefaultParams::VisitCallExpr(const CallExpr * callExpr) {
if ( n < (int)callExpr->getNumArgs() && callExpr->getArg(n)->isDefaultArgument()) {
MyCallInfo callInfo;
niceName(functionDecl, callInfo);
- callInfo.sourceLocationOfCall = locationToString(callExpr->getLocStart());
+ callInfo.sourceLocationOfCall = locationToString(compat::getBeginLoc(callExpr));
callSet.insert(callInfo);
}
return true;
@@ -199,7 +199,7 @@ bool CountUsersOfDefaultParams::VisitCXXConstructExpr(const CXXConstructExpr * c
if ( n < (int)constructExpr->getNumArgs() && constructExpr->getArg(n)->isDefaultArgument()) {
MyCallInfo callInfo;
niceName(constructorDecl, callInfo);
- callInfo.sourceLocationOfCall = locationToString(constructExpr->getLocStart());
+ callInfo.sourceLocationOfCall = locationToString(compat::getBeginLoc(constructExpr));
callSet.insert(callInfo);
}
return true;
diff --git a/compilerplugins/clang/cstylecast.cxx b/compilerplugins/clang/cstylecast.cxx
index 4bf3aaf6460f..07f59d8858e5 100644
--- a/compilerplugins/clang/cstylecast.cxx
+++ b/compilerplugins/clang/cstylecast.cxx
@@ -234,7 +234,7 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) {
if( expr->getCastKind() == CK_ToVoid ) {
return true;
}
- if (isSharedCAndCppCode(expr->getLocStart())) {
+ if (isSharedCAndCppCode(compat::getBeginLoc(expr))) {
return true;
}
char const * perf = nullptr;
@@ -407,8 +407,8 @@ bool CStyleCast::rewriteArithmeticCast(CStyleCastExpr const * expr, char const *
firstBegin = compiler.getSourceManager().getSpellingLoc(firstBegin);
secondBegin = compiler.getSourceManager().getSpellingLoc(secondBegin);
}
- auto third = sub->getLocStart();
- auto fourth = sub->getLocEnd();
+ auto third = compat::getBeginLoc(sub);
+ auto fourth = compat::getEndLoc(sub);
bool macro = false;
// Ensure that
//
diff --git a/compilerplugins/clang/datamembershadow.cxx b/compilerplugins/clang/datamembershadow.cxx
index 35c96c6f240f..2bb643d22a86 100644
--- a/compilerplugins/clang/datamembershadow.cxx
+++ b/compilerplugins/clang/datamembershadow.cxx
@@ -45,7 +45,7 @@ bool DataMemberShadow::VisitFieldDecl(FieldDecl const * fieldDecl)
return true;
}
StringRef aFileName = getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(fieldDecl->getLocStart()));
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(fieldDecl)));
// FIXME complex stuff to fix later
@@ -97,13 +97,13 @@ bool DataMemberShadow::VisitFieldDecl(FieldDecl const * fieldDecl)
sPath += baseCXXRecordDecl->getNameAsString();
report(DiagnosticsEngine::Warning,
"data member %0 is shadowing member in superclass, through inheritance path %1",
- fieldDecl->getLocStart())
+ compat::getBeginLoc(fieldDecl))
<< fieldDecl->getName()
<< sPath
<< fieldDecl->getSourceRange();
report(DiagnosticsEngine::Note,
"superclass member here",
- baseFieldDecl->getLocStart())
+ compat::getBeginLoc(baseFieldDecl))
<< baseFieldDecl->getSourceRange();
}
return false;
diff --git a/compilerplugins/clang/dbgunhandledexception.cxx b/compilerplugins/clang/dbgunhandledexception.cxx
index 54b00f57f758..633e655cd109 100644
--- a/compilerplugins/clang/dbgunhandledexception.cxx
+++ b/compilerplugins/clang/dbgunhandledexception.cxx
@@ -69,7 +69,7 @@ bool DbgUnhandledException::VisitCallExpr(const CallExpr* call)
if (!currCatchStmt)
{
report(DiagnosticsEngine::Warning, "DBG_UNHANDLED_EXCEPTION outside catch block",
- call->getLocStart());
+ compat::getBeginLoc(call));
return true;
}
auto catchBlock = dyn_cast<CompoundStmt>(currCatchStmt->getHandlerBlock());
@@ -77,14 +77,14 @@ bool DbgUnhandledException::VisitCallExpr(const CallExpr* call)
{
report(DiagnosticsEngine::Warning,
"something wrong with DBG_UNHANDLED_EXCEPTION, no CompoundStmt?",
- call->getLocStart());
+ compat::getBeginLoc(call));
return true;
}
if (catchBlock->size() < 1)
{
report(DiagnosticsEngine::Warning,
"something wrong with DBG_UNHANDLED_EXCEPTION, CompoundStmt size == 0?",
- call->getLocStart());
+ compat::getBeginLoc(call));
return true;
}
@@ -95,7 +95,7 @@ bool DbgUnhandledException::VisitCallExpr(const CallExpr* call)
{
report(DiagnosticsEngine::Warning,
"DBG_UNHANDLED_EXCEPTION must be first statement in catch block",
- call->getLocStart());
+ compat::getBeginLoc(call));
}
return true;
}
diff --git a/compilerplugins/clang/derefnullptr.cxx b/compilerplugins/clang/derefnullptr.cxx
index 350bed2156dc..db7b3b9eb5ed 100644
--- a/compilerplugins/clang/derefnullptr.cxx
+++ b/compilerplugins/clang/derefnullptr.cxx
@@ -32,7 +32,7 @@ bool DerefNullPtr::VisitUnaryDeref(UnaryOperator const * op) {
{
report(
DiagnosticsEngine::Warning, "null pointer dereference",
- op->getLocStart())
+ compat::getBeginLoc(op))
<< op->getSourceRange();
}
return true;
diff --git a/compilerplugins/clang/dodgyswitch.cxx b/compilerplugins/clang/dodgyswitch.cxx
index 98ac1c161ef5..066d4fcebebb 100644
--- a/compilerplugins/clang/dodgyswitch.cxx
+++ b/compilerplugins/clang/dodgyswitch.cxx
@@ -41,7 +41,7 @@ bool DodgySwitch::VisitDefaultStmt(DefaultStmt const * defaultStmt)
if (!IsParentSwitch(defaultStmt))
report(
DiagnosticsEngine::Warning, "default statement not directly under switch",
- defaultStmt->getLocStart())
+ compat::getBeginLoc(defaultStmt))
<< defaultStmt->getSourceRange();
return true;
}
@@ -55,7 +55,7 @@ bool DodgySwitch::VisitCaseStmt(CaseStmt const * caseStmt)
//parentStmt(parentStmt(caseStmt))->dump();
report(
DiagnosticsEngine::Warning, "case statement not directly under switch",
- caseStmt->getLocStart())
+ compat::getBeginLoc(caseStmt))
<< caseStmt->getSourceRange();
}
return true;
diff --git a/compilerplugins/clang/emptyif.cxx b/compilerplugins/clang/emptyif.cxx
index 6eac86b6bcc7..82bd22338c06 100644
--- a/compilerplugins/clang/emptyif.cxx
+++ b/compilerplugins/clang/emptyif.cxx
@@ -69,14 +69,15 @@ bool EmptyIf::VisitIfStmt(IfStmt const* ifStmt)
if (ifStmt->getElse() && empty(ifStmt->getElse()) && !ContainsComment(ifStmt->getElse()))
{
- report(DiagnosticsEngine::Warning, "empty else body", ifStmt->getElse()->getLocStart())
+ report(DiagnosticsEngine::Warning, "empty else body",
+ compat::getBeginLoc(ifStmt->getElse()))
<< ifStmt->getElse()->getSourceRange();
return true;
}
if (!ifStmt->getElse() && empty(ifStmt->getThen()) && !ContainsComment(ifStmt->getThen()))
{
- report(DiagnosticsEngine::Warning, "empty if body", ifStmt->getLocStart())
+ report(DiagnosticsEngine::Warning, "empty if body", compat::getBeginLoc(ifStmt))
<< ifStmt->getSourceRange();
}
diff --git a/compilerplugins/clang/expandablemethods.cxx b/compilerplugins/clang/expandablemethods.cxx
index 20d5a6998e39..4da75cfd0f02 100644
--- a/compilerplugins/clang/expandablemethods.cxx
+++ b/compilerplugins/clang/expandablemethods.cxx
@@ -268,7 +268,7 @@ void ExpandableMethods::functionTouchedFromExpr( const FunctionDecl* calleeFunct
return;
}
- calledFromSet.emplace(toString(expr->getLocStart()), niceName(canonicalFunctionDecl));
+ calledFromSet.emplace(toString(compat::getBeginLoc(expr)), niceName(canonicalFunctionDecl));
if (const UnaryOperator* unaryOp = dyn_cast_or_null<UnaryOperator>(getParentStmt(expr))) {
if (unaryOp->getOpcode() == UO_AddrOf) {
diff --git a/compilerplugins/clang/expressionalwayszero.cxx b/compilerplugins/clang/expressionalwayszero.cxx
index 0f0eb7a541e6..ab343c1ae902 100644
--- a/compilerplugins/clang/expressionalwayszero.cxx
+++ b/compilerplugins/clang/expressionalwayszero.cxx
@@ -73,7 +73,7 @@ bool ExpressionAlwaysZero::VisitBinaryOperator( BinaryOperator const * binaryOpe
{
if (ignoreLocation(binaryOperator))
return true;
- if (binaryOperator->getLocStart().isMacroID())
+ if (compat::getBeginLoc(binaryOperator).isMacroID())
return true;
auto op = binaryOperator->getOpcode();
@@ -92,7 +92,7 @@ bool ExpressionAlwaysZero::VisitBinaryOperator( BinaryOperator const * binaryOpe
return true;
report(
DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
- binaryOperator->getLocStart())
+ compat::getBeginLoc(binaryOperator))
<< (lhsValue ? lhsValue->toString(10) : "unknown")
<< (rhsValue ? rhsValue->toString(10) : "unknown")
<< binaryOperator->getSourceRange();
@@ -103,7 +103,7 @@ bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr( CXXOperatorCallExpr const *
{
if (ignoreLocation(cxxOperatorCallExpr))
return true;
- if (cxxOperatorCallExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(cxxOperatorCallExpr).isMacroID())
return true;
auto op = cxxOperatorCallExpr->getOperator();
@@ -124,7 +124,7 @@ bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr( CXXOperatorCallExpr const *
return true;
report(
DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
- cxxOperatorCallExpr->getLocStart())
+ compat::getBeginLoc(cxxOperatorCallExpr))
<< (lhsValue ? lhsValue->toString(10) : "unknown")
<< (rhsValue ? rhsValue->toString(10) : "unknown")
<< cxxOperatorCallExpr->getSourceRange();
diff --git a/compilerplugins/clang/faileddyncast.cxx b/compilerplugins/clang/faileddyncast.cxx
index f99077137f9f..eee5be57d584 100644
--- a/compilerplugins/clang/faileddyncast.cxx
+++ b/compilerplugins/clang/faileddyncast.cxx
@@ -116,7 +116,7 @@ bool FailedDynCast::VisitCXXDynamicCastExpr(CXXDynamicCastExpr const * expr) {
if (isAlwaysNull(expr)) {
report(
DiagnosticsEngine::Warning,
- "dynamic_cast from %0 to %1 always fails", expr->getLocStart())
+ "dynamic_cast from %0 to %1 always fails", compat::getBeginLoc(expr))
<< expr->getSubExpr()->getType() << expr->getType()
<< expr->getSourceRange();
}
diff --git a/compilerplugins/clang/finalclasses.cxx b/compilerplugins/clang/finalclasses.cxx
index 6e8596a78421..f31f28d8f895 100644
--- a/compilerplugins/clang/finalclasses.cxx
+++ b/compilerplugins/clang/finalclasses.cxx
@@ -127,7 +127,7 @@ bool FinalClasses::VisitCXXRecordDecl(const CXXRecordDecl* decl)
if (ignoreClass(s))
return true;
- SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(decl->getLocStart());
+ SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(decl));
std::string filename = compiler.getSourceManager().getFilename(spellingLocation);
auto sourceLocation = filename.substr(strlen(SRCDIR)) + ":"
+ std::to_string(compiler.getSourceManager().getSpellingLineNumber(spellingLocation));
diff --git a/compilerplugins/clang/finalprotected.cxx b/compilerplugins/clang/finalprotected.cxx
index 71b3cfca03f1..8032d0d5d743 100644
--- a/compilerplugins/clang/finalprotected.cxx
+++ b/compilerplugins/clang/finalprotected.cxx
@@ -50,7 +50,7 @@ bool FinalProtected::VisitCXXMethodDecl(CXXMethodDecl const * cxxMethodDecl)
cxxMethodDecl = cxxMethodDecl->getCanonicalDecl();
report(DiagnosticsEngine::Warning,
"final class should not have protected members - convert them to private",
- cxxMethodDecl->getLocStart())
+ compat::getBeginLoc(cxxMethodDecl))
<< cxxMethodDecl->getSourceRange();
return true;
}
@@ -69,7 +69,7 @@ bool FinalProtected::VisitFieldDecl(FieldDecl const * fieldDecl)
fieldDecl = fieldDecl->getCanonicalDecl();
report(DiagnosticsEngine::Warning,
"final class should not have protected members - convert them to private",
- fieldDecl->getLocStart())
+ compat::getBeginLoc(fieldDecl))
<< fieldDecl->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/flatten.cxx b/compilerplugins/clang/flatten.cxx
index dd116d7a4ea5..40376d2e1678 100644
--- a/compilerplugins/clang/flatten.cxx
+++ b/compilerplugins/clang/flatten.cxx
@@ -204,7 +204,7 @@ bool Flatten::VisitIfStmt(IfStmt const * ifStmt)
report(
DiagnosticsEngine::Warning,
"large if statement at end of function, rather invert the condition and exit early, and flatten the function",
- ifStmt->getLocStart())
+ compat::getBeginLoc(ifStmt))
<< ifStmt->getSourceRange();
}
return true;
@@ -238,12 +238,12 @@ bool Flatten::VisitIfStmt(IfStmt const * ifStmt)
report(
DiagnosticsEngine::Warning,
"unconditional throw in else branch, rather invert the condition, throw early, and flatten the normal case",
- elseThrowExpr->getLocStart())
+ compat::getBeginLoc(elseThrowExpr))
<< elseThrowExpr->getSourceRange();
report(
DiagnosticsEngine::Note,
"if condition here",
- ifStmt->getLocStart())
+ compat::getBeginLoc(ifStmt))
<< ifStmt->getSourceRange();
}
}
@@ -260,7 +260,7 @@ bool Flatten::VisitIfStmt(IfStmt const * ifStmt)
report(
DiagnosticsEngine::Warning,
"unconditional throw in then branch, just flatten the else",
- thenThrowExpr->getLocStart())
+ compat::getBeginLoc(thenThrowExpr))
<< thenThrowExpr->getSourceRange();
}
}
diff --git a/compilerplugins/clang/fragiledestructor.cxx b/compilerplugins/clang/fragiledestructor.cxx
index d1bff95ddf72..2c4b3235eb38 100644
--- a/compilerplugins/clang/fragiledestructor.cxx
+++ b/compilerplugins/clang/fragiledestructor.cxx
@@ -48,7 +48,7 @@ bool FragileDestructor::TraverseCXXDestructorDecl(CXXDestructorDecl* pCXXDestruc
}
// ignore this for now, too tricky for me to work out
StringRef aFileName = getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(pCXXDestructorDecl->getLocStart()));
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(pCXXDestructorDecl)));
if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/comphelper/")
|| loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/cppuhelper/")
|| loplugin::hasPathnamePrefix(aFileName, SRCDIR "/cppuhelper/")
@@ -80,15 +80,15 @@ bool FragileDestructor::VisitCXXMemberCallExpr(const CXXMemberCallExpr* callExpr
return true;
}
// if we see an explicit call to its own method, that's OK
- auto s1 = compiler.getSourceManager().getCharacterData(callExpr->getLocStart());
- auto s2 = compiler.getSourceManager().getCharacterData(callExpr->getLocEnd());
+ auto s1 = compiler.getSourceManager().getCharacterData(compat::getBeginLoc(callExpr));
+ auto s2 = compiler.getSourceManager().getCharacterData(compat::getEndLoc(callExpr));
std::string tok(s1, s2-s1);
if (tok.find("::") != std::string::npos) {
return true;
}
// e.g. osl/thread.hxx and cppuhelper/compbase.hxx
StringRef aFileName = getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(methodDecl->getLocStart()));
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(methodDecl)));
if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/osl/")
|| loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/comphelper/")
|| loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/cppuhelper/"))
@@ -96,12 +96,12 @@ bool FragileDestructor::VisitCXXMemberCallExpr(const CXXMemberCallExpr* callExpr
report(
DiagnosticsEngine::Warning,
"calling virtual method from destructor, either make the virtual method SAL_FINAL, or make this class SAL_FINAL",
- callExpr->getLocStart())
+ compat::getBeginLoc(callExpr))
<< callExpr->getSourceRange();
report(
DiagnosticsEngine::Note,
"callee method here",
- methodDecl->getLocStart())
+ compat::getBeginLoc(methodDecl))
<< methodDecl->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index d7e80f56ab36..dd1eb4c1718b 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -686,7 +686,7 @@ bool ImplicitBoolConversion::TraverseBinAndAssign(CompoundAssignOperator * expr)
{
report(
DiagnosticsEngine::Warning, "mix of %0 and %1 in operator &=",
- expr->getRHS()->getLocStart())
+ compat::getBeginLoc(expr->getRHS()))
<< expr->getLHS()->getType()
<< expr->getRHS()->IgnoreParenImpCasts()->getType()
<< expr->getSourceRange();
@@ -712,7 +712,7 @@ bool ImplicitBoolConversion::TraverseBinOrAssign(CompoundAssignOperator * expr)
{
report(
DiagnosticsEngine::Warning, "mix of %0 and %1 in operator |=",
- expr->getRHS()->getLocStart())
+ compat::getBeginLoc(expr->getRHS()))
<< expr->getLHS()->getType()
<< expr->getRHS()->IgnoreParenImpCasts()->getType()
<< expr->getSourceRange();
@@ -738,7 +738,7 @@ bool ImplicitBoolConversion::TraverseBinXorAssign(CompoundAssignOperator * expr)
{
report(
DiagnosticsEngine::Warning, "mix of %0 and %1 in operator ^=",
- expr->getRHS()->getLocStart())
+ compat::getBeginLoc(expr->getRHS()))
<< expr->getLHS()->getType()
<< expr->getRHS()->IgnoreParenImpCasts()->getType()
<< expr->getSourceRange();
@@ -870,7 +870,7 @@ bool ImplicitBoolConversion::VisitImplicitCastExpr(
DiagnosticsEngine::Warning,
("explicit conversion (%0) from %1 to %2 implicitly cast back"
" to %3"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< sub->getCastKindName() << subsub->getType() << sub->getType()
<< expr->getType() << expr->getSourceRange();
return true;
@@ -888,7 +888,7 @@ bool ImplicitBoolConversion::VisitImplicitCastExpr(
report(
DiagnosticsEngine::Warning,
"implicit conversion (%0) of call argument from %1 to %2",
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getCastKindName() << expr->getSubExpr()->getType()
<< expr->getType() << expr->getSourceRange();
return true;
@@ -912,7 +912,7 @@ bool ImplicitBoolConversion::VisitMaterializeTemporaryExpr(
DiagnosticsEngine::Warning,
("explicit conversion (%0) from %1 to %2 implicitly converted"
" back to %3"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< sub->getCastKindName() << subsub->getType() << sub->getType()
<< expr->getType() << expr->getSourceRange();
return true;
@@ -1017,7 +1017,7 @@ void ImplicitBoolConversion::reportWarning(ImplicitCastExpr const * expr) {
if (compiler.getLangOpts().CPlusPlus) {
report(
DiagnosticsEngine::Warning,
- "implicit conversion (%0) from %1 to %2", expr->getLocStart())
+ "implicit conversion (%0) from %1 to %2", compat::getBeginLoc(expr))
<< expr->getCastKindName() << expr->getSubExprAsWritten()->getType()
<< expr->getType() << expr->getSourceRange();
}
diff --git a/compilerplugins/clang/inlinesimplememberfunctions.cxx b/compilerplugins/clang/inlinesimplememberfunctions.cxx
index 9a1d1f6f3abb..64734dc9de9a 100644
--- a/compilerplugins/clang/inlinesimplememberfunctions.cxx
+++ b/compilerplugins/clang/inlinesimplememberfunctions.cxx
@@ -243,8 +243,8 @@ bool InlineSimpleMemberFunctions::rewrite(const CXXMethodDecl * functionDecl) {
const char *p1, *p2;
// get the function body contents
- p1 = compiler.getSourceManager().getCharacterData( functionDecl->getBody()->getLocStart() );
- p2 = compiler.getSourceManager().getCharacterData( functionDecl->getBody()->getLocEnd() );
+ p1 = compiler.getSourceManager().getCharacterData( compat::getBeginLoc(functionDecl->getBody()) );
+ p2 = compiler.getSourceManager().getCharacterData( compat::getEndLoc(functionDecl->getBody()) );
std::string s1( p1, p2 - p1 + 1);
/* we can't safely move around stuff containing comments, we mess up the resulting code */
@@ -274,18 +274,18 @@ bool InlineSimpleMemberFunctions::rewrite(const CXXMethodDecl * functionDecl) {
// remove the function's out of line body and declaration
RewriteOptions opts;
opts.RemoveLineIfEmpty = true;
- if (!removeText(SourceRange(functionDecl->getLocStart(), functionDecl->getBody()->getLocEnd()), opts)) {
+ if (!removeText(SourceRange(compat::getBeginLoc(functionDecl), compat::getEndLoc(functionDecl->getBody())), opts)) {
return false;
}
// scan forward until we find the semicolon
const FunctionDecl * canonicalDecl = functionDecl->getCanonicalDecl();
- p1 = compiler.getSourceManager().getCharacterData( canonicalDecl->getLocEnd() );
+ p1 = compiler.getSourceManager().getCharacterData( compat::getEndLoc(canonicalDecl) );
p2 = ++p1;
while (*p2 != 0 && *p2 != ';') p2++;
// insert the function body into the inline function definition (i.e. the one inside the class definition)
- return replaceText(canonicalDecl->getLocEnd().getLocWithOffset(p2 - p1 + 1), 1, s1);
+ return replaceText(compat::getEndLoc(canonicalDecl).getLocWithOffset(p2 - p1 + 1), 1, s1);
}
loplugin::Plugin::Registration< InlineSimpleMemberFunctions > X("inlinesimplememberfunctions");
diff --git a/compilerplugins/clang/literaltoboolconversion.cxx b/compilerplugins/clang/literaltoboolconversion.cxx
index 19c18a4ca765..270ebc3455ca 100644
--- a/compilerplugins/clang/literaltoboolconversion.cxx
+++ b/compilerplugins/clang/literaltoboolconversion.cxx
@@ -118,7 +118,7 @@ void LiteralToBoolConversion::handleImplicitCastSubExpr(
&& subExpr->isIntegerConstantExpr(res, compiler.getASTContext())
&& res.getLimitedValue() <= 1)
{
- SourceLocation loc { subExpr->getLocStart() };
+ SourceLocation loc { compat::getBeginLoc(subExpr) };
while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc);
}
@@ -134,7 +134,7 @@ void LiteralToBoolConversion::handleImplicitCastSubExpr(
}
}
if (isa<clang::StringLiteral>(subExpr)) {
- SourceLocation loc { subExpr->getLocStart() };
+ SourceLocation loc { compat::getBeginLoc(subExpr) };
if (compiler.getSourceManager().isMacroArgExpansion(loc)
&& (Lexer::getImmediateMacroName(
loc, compiler.getSourceManager(), compiler.getLangOpts())
@@ -150,25 +150,25 @@ void LiteralToBoolConversion::handleImplicitCastSubExpr(
bool bRewritten = false;
if (rewriter != nullptr) {
SourceLocation loc { compiler.getSourceManager().getExpansionLoc(
- expr2->getLocStart()) };
- if (compiler.getSourceManager().getExpansionLoc(expr2->getLocEnd())
+ compat::getBeginLoc(expr2)) };
+ if (compiler.getSourceManager().getExpansionLoc(compat::getEndLoc(expr2))
== loc)
{
char const * s = compiler.getSourceManager().getCharacterData(
loc);
unsigned n = Lexer::MeasureTokenLength(
- expr2->getLocEnd(), compiler.getSourceManager(),
+ compat::getEndLoc(expr2), compiler.getSourceManager(),
compiler.getLangOpts());
std::string tok { s, n };
if (tok == "sal_False" || tok == "0") {
bRewritten = replaceText(
compiler.getSourceManager().getExpansionLoc(
- expr2->getLocStart()),
+ compat::getBeginLoc(expr2)),
n, "false");
} else if (tok == "sal_True" || tok == "1") {
bRewritten = replaceText(
compiler.getSourceManager().getExpansionLoc(
- expr2->getLocStart()),
+ compat::getBeginLoc(expr2)),
n, "true");
}
}
@@ -177,7 +177,7 @@ void LiteralToBoolConversion::handleImplicitCastSubExpr(
report(
DiagnosticsEngine::Warning,
"implicit conversion (%0) of literal of type %1 to %2",
- expr2->getLocStart())
+ compat::getBeginLoc(expr2))
<< castExpr->getCastKindName() << subExpr->getType()
<< castExpr->getType() << expr2->getSourceRange();
}
@@ -194,7 +194,7 @@ void LiteralToBoolConversion::handleImplicitCastSubExpr(
DiagnosticsEngine::Warning,
("implicit conversion (%0) of null pointer constant of type %1 to"
" %2"),
- expr2->getLocStart())
+ compat::getBeginLoc(expr2))
<< castExpr->getCastKindName() << subExpr->getType()
<< castExpr->getType() << expr2->getSourceRange();
} else if (!subExpr->isValueDependent()
@@ -204,7 +204,7 @@ void LiteralToBoolConversion::handleImplicitCastSubExpr(
DiagnosticsEngine::Warning,
("implicit conversion (%0) of integer constant expression of type"
" %1 with value %2 to %3"),
- expr2->getLocStart())
+ compat::getBeginLoc(expr2))
<< castExpr->getCastKindName() << subExpr->getType()
<< res.toString(10) << castExpr->getType()
<< expr2->getSourceRange();
diff --git a/compilerplugins/clang/mergeclasses.cxx b/compilerplugins/clang/mergeclasses.cxx
index 6035e7c275dc..ce08d627b931 100644
--- a/compilerplugins/clang/mergeclasses.cxx
+++ b/compilerplugins/clang/mergeclasses.cxx
@@ -148,7 +148,7 @@ bool MergeClasses::VisitCXXRecordDecl(const CXXRecordDecl* decl)
}
if (decl->isThisDeclarationADefinition())
{
- SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(decl->getLocStart());
+ SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(decl));
std::string filename = compiler.getSourceManager().getFilename(spellingLocation);
filename = filename.substr(strlen(SRCDIR));
std::string s = decl->getQualifiedNameAsString();
diff --git a/compilerplugins/clang/nullptr.cxx b/compilerplugins/clang/nullptr.cxx
index ccd5837b226f..c463caec7c5d 100644
--- a/compilerplugins/clang/nullptr.cxx
+++ b/compilerplugins/clang/nullptr.cxx
@@ -121,7 +121,7 @@ bool Nullptr::VisitImplicitCastExpr(CastExpr const * expr) {
case Expr::NPCK_ZeroLiteral:
report(
DiagnosticsEngine::Warning,
- "suspicious ValueDependentIsNull %0", expr->getLocStart())
+ "suspicious ValueDependentIsNull %0", compat::getBeginLoc(expr))
<< kindName(k) << expr->getSourceRange();
break;
default:
@@ -304,7 +304,7 @@ void Nullptr::handleNull(
SourceLocation loc;
for (;;) {
e = e->IgnoreImpCasts();
- loc = e->getLocStart();
+ loc = compat::getBeginLoc(e);
while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc);
}
@@ -369,7 +369,7 @@ void Nullptr::rewriteOrWarn(
Expr::NullPointerConstantKind nullPointerKind, char const * replacement)
{
if (rewriter != nullptr) {
- SourceLocation locStart(expr->getLocStart());
+ SourceLocation locStart(compat::getBeginLoc(expr));
while (compiler.getSourceManager().isMacroArgExpansion(locStart)) {
locStart = compiler.getSourceManager()
.getImmediateMacroCallerLoc(locStart);
@@ -384,7 +384,7 @@ void Nullptr::rewriteOrWarn(
locStart = compat::getImmediateExpansionRange(compiler.getSourceManager(), locStart)
.first;
}
- SourceLocation locEnd(expr->getLocEnd());
+ SourceLocation locEnd(compat::getEndLoc(expr));
while (compiler.getSourceManager().isMacroArgExpansion(locEnd)) {
locEnd = compiler.getSourceManager()
.getImmediateMacroCallerLoc(locEnd);
@@ -403,13 +403,13 @@ void Nullptr::rewriteOrWarn(
}
}
if (castKind == nullptr) {
- report(DiagnosticsEngine::Warning, "%0 -> %1", expr->getLocStart())
+ report(DiagnosticsEngine::Warning, "%0 -> %1", compat::getBeginLoc(expr))
<< kindName(nullPointerKind) << replacement
<< expr->getSourceRange();
} else {
report(
DiagnosticsEngine::Warning, "%0 ValueDependentIsNotNull %1 -> %2",
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< castKind << kindName(nullPointerKind) << replacement
<< expr->getSourceRange();
}
diff --git a/compilerplugins/clang/oncevar.cxx b/compilerplugins/clang/oncevar.cxx
index afb1b0fa85e9..be03b4d96589 100644
--- a/compilerplugins/clang/oncevar.cxx
+++ b/compilerplugins/clang/oncevar.cxx
@@ -322,7 +322,7 @@ bool OnceVar::VisitVarDecl( const VarDecl* varDecl )
return true;
}
// Ignore macros like FD_ZERO
- if (compiler.getSourceManager().isMacroBodyExpansion(varDecl->getLocStart())) {
+ if (compiler.getSourceManager().isMacroBodyExpansion(compat::getBeginLoc(varDecl))) {
return true;
}
if (varDecl->hasGlobalStorage()) {
diff --git a/compilerplugins/clang/plugin.hxx b/compilerplugins/clang/plugin.hxx
index 4c4d9a70fcb3..0820f311c1a1 100644
--- a/compilerplugins/clang/plugin.hxx
+++ b/compilerplugins/clang/plugin.hxx
@@ -25,6 +25,7 @@
#include <clang/Rewrite/Core/Rewriter.h>
+#include "compat.hxx"
#include "pluginhandler.hxx"
using namespace clang;
@@ -195,7 +196,7 @@ bool Plugin::ignoreLocation( const Stmt* stmt ) const
{
// Invalid location can happen at least for ImplicitCastExpr of
// ImplicitParam 'self' in Objective C method declarations:
- return stmt->getLocStart().isValid() && ignoreLocation( stmt->getLocStart());
+ return compat::getBeginLoc(stmt).isValid() && ignoreLocation( compat::getBeginLoc(stmt));
}
template< typename T >
diff --git a/compilerplugins/clang/privatebase.cxx b/compilerplugins/clang/privatebase.cxx
index 60acfc347ed9..3b1862a7bc6c 100644
--- a/compilerplugins/clang/privatebase.cxx
+++ b/compilerplugins/clang/privatebase.cxx
@@ -41,7 +41,7 @@ bool PrivateBase::VisitCXXRecordDecl(CXXRecordDecl const * decl) {
DiagnosticsEngine::Warning,
"base class is private by default; explicitly give an access"
" specifier",
- i->getLocStart())
+ compat::getBeginLoc(i))
<< i->getSourceRange();
}
}
diff --git a/compilerplugins/clang/rangedforcopy.cxx b/compilerplugins/clang/rangedforcopy.cxx
index 4baed6b6e5db..4a05de1c6558 100644
--- a/compilerplugins/clang/rangedforcopy.cxx
+++ b/compilerplugins/clang/rangedforcopy.cxx
@@ -51,7 +51,7 @@ bool RangedForCopy::VisitCXXForRangeStmt( const CXXForRangeStmt* stmt )
report(
DiagnosticsEngine::Warning,
"Loop variable passed by value, pass by reference instead, e.g. 'const %0&'",
- varDecl->getLocStart())
+ compat::getBeginLoc(varDecl))
<< name << varDecl->getSourceRange();
}
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index b6db47495a6d..ad7818f4a981 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -207,7 +207,7 @@ bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) {
dyn_cast<CXXStaticCastExpr>(e)->getSubExpr()
->IgnoreParenImpCasts()->getType())
&& !compiler.getSourceManager().isMacroBodyExpansion(
- e->getLocStart()))
+ compat::getBeginLoc(e)))
{
report(
DiagnosticsEngine::Warning,
@@ -287,7 +287,7 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) {
if (ignoreLocation(expr)) {
return true;
}
- if (isInUnoIncludeFile(compiler.getSourceManager().getSpellingLoc(expr->getLocStart()))) {
+ if (isInUnoIncludeFile(compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(expr)))) {
return true;
}
auto t1 = compat::getSubExprAsWritten(expr)->getType();
@@ -308,7 +308,7 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) {
// Ignore FD_ISSET expanding to "...(SOCKET)(fd)..." in some Microsoft
// winsock2.h (TODO: improve heuristic of determining that the whole
// expr is part of a single macro body expansion):
- auto l1 = expr->getLocStart();
+ auto l1 = compat::getBeginLoc(expr);
while (compiler.getSourceManager().isMacroArgExpansion(l1)) {
l1 = compiler.getSourceManager().getImmediateMacroCallerLoc(l1);
}
@@ -316,7 +316,7 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) {
while (compiler.getSourceManager().isMacroArgExpansion(l2)) {
l2 = compiler.getSourceManager().getImmediateMacroCallerLoc(l2);
}
- auto l3 = expr->getLocEnd();
+ auto l3 = compat::getEndLoc(expr);
while (compiler.getSourceManager().isMacroArgExpansion(l3)) {
l3 = compiler.getSourceManager().getImmediateMacroCallerLoc(l3);
}
@@ -445,7 +445,7 @@ bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) {
// h=b5889d25e9bf944a89fdd7bcabf3b6c6f6bb6f7c> "assert: Support types
// without operator== (int) [BZ #21972]":
if (t1->isBooleanType() && t2->isBooleanType()) {
- auto loc = expr->getLocStart();
+ auto loc = compat::getBeginLoc(expr);
if (compiler.getSourceManager().isMacroBodyExpansion(loc)
&& (Lexer::getImmediateMacroName(
loc, compiler.getSourceManager(), compiler.getLangOpts())
@@ -477,13 +477,13 @@ bool RedundantCast::VisitCXXReinterpretCastExpr(
return true;
}
if (rewriter != nullptr) {
- auto loc = expr->getLocStart();
+ auto loc = compat::getBeginLoc(expr);
while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(
loc);
}
if (compiler.getSourceManager().isMacroBodyExpansion(loc)) {
- auto loc2 = expr->getLocEnd();
+ auto loc2 = compat::getEndLoc(expr);
while (compiler.getSourceManager().isMacroArgExpansion(loc2)) {
loc2 = compiler.getSourceManager()
.getImmediateMacroCallerLoc(loc2);
@@ -665,8 +665,8 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp
//
// in sal/osl/unx/socket.cxx:
//TODO: Better check that sub is exactly an expansion of FD_ISSET:
- if (sub->getLocEnd().isMacroID()) {
- for (auto loc = sub->getLocStart();
+ if (compat::getEndLoc(sub).isMacroID()) {
+ for (auto loc = compat::getBeginLoc(sub);
loc.isMacroID()
&& (compiler.getSourceManager()
.isAtStartOfImmediateMacroExpansion(loc));
diff --git a/compilerplugins/clang/redundantinline.cxx b/compilerplugins/clang/redundantinline.cxx
index 67347febb443..70cdbd6fdce6 100644
--- a/compilerplugins/clang/redundantinline.cxx
+++ b/compilerplugins/clang/redundantinline.cxx
@@ -35,18 +35,18 @@ public:
{
return true;
}
- auto l1 = unwindToQObject(decl->getLocStart());
- if (l1.isValid() && l1 == unwindToQObject(decl->getLocEnd())) {
+ auto l1 = unwindToQObject(compat::getBeginLoc(decl));
+ if (l1.isValid() && l1 == unwindToQObject(compat::getEndLoc(decl))) {
return true;
}
SourceLocation inlineLoc;
unsigned n;
auto end = Lexer::getLocForEndOfToken(
- compiler.getSourceManager().getExpansionLoc(decl->getLocEnd()), 0,
+ compiler.getSourceManager().getExpansionLoc(compat::getEndLoc(decl)), 0,
compiler.getSourceManager(), compiler.getLangOpts());
assert(end.isValid());
for (auto loc = compiler.getSourceManager().getExpansionLoc(
- decl->getLocStart());
+ compat::getBeginLoc(decl));
loc != end; loc = loc.getLocWithOffset(std::max<unsigned>(n, 1)))
{
n = Lexer::MeasureTokenLength(
@@ -102,7 +102,7 @@ public:
report(
DiagnosticsEngine::Warning,
"function definition redundantly declared 'inline'",
- inlineLoc.isValid() ? inlineLoc : decl->getLocStart())
+ inlineLoc.isValid() ? inlineLoc : compat::getBeginLoc(decl))
<< decl->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/redundantpointerops.cxx b/compilerplugins/clang/redundantpointerops.cxx
index 0340b7c12c19..1c28052f046a 100644
--- a/compilerplugins/clang/redundantpointerops.cxx
+++ b/compilerplugins/clang/redundantpointerops.cxx
@@ -63,7 +63,7 @@ bool RedundantPointerOps::VisitMemberExpr(MemberExpr const * memberExpr)
{
if (ignoreLocation(memberExpr))
return true;
- if (memberExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(memberExpr).isMacroID())
return true;
auto base = memberExpr->getBase()->IgnoreParenImpCasts();
//parentStmt(parentStmt(memberExpr))->dump();
@@ -74,7 +74,7 @@ bool RedundantPointerOps::VisitMemberExpr(MemberExpr const * memberExpr)
if (unaryOp->getOpcode() == UO_AddrOf)
report(
DiagnosticsEngine::Warning, "'&' followed by '->', rather use '.'",
- memberExpr->getLocStart())
+ compat::getBeginLoc(memberExpr))
<< memberExpr->getSourceRange();
}
@@ -83,7 +83,7 @@ bool RedundantPointerOps::VisitMemberExpr(MemberExpr const * memberExpr)
if (operatorCallExpr->getOperator() == OO_Amp)
report(
DiagnosticsEngine::Warning, "'&' followed by '->', rather use '.'",
- memberExpr->getLocStart())
+ compat::getBeginLoc(memberExpr))
<< memberExpr->getSourceRange();
}
@@ -107,7 +107,7 @@ bool RedundantPointerOps::VisitUnaryOperator(UnaryOperator const * unaryOperator
{
if (ignoreLocation(unaryOperator))
return true;
- if (unaryOperator->getLocStart().isMacroID())
+ if (compat::getBeginLoc(unaryOperator).isMacroID())
return true;
if (unaryOperator->getOpcode() != UO_Deref)
return true;
@@ -117,7 +117,7 @@ bool RedundantPointerOps::VisitUnaryOperator(UnaryOperator const * unaryOperator
report(
DiagnosticsEngine::Warning, "'&' followed by '*', rather use '.'",
- unaryOperator->getLocStart())
+ compat::getBeginLoc(unaryOperator))
<< unaryOperator->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
index f4e7e8e5929b..426127c76862 100644
--- a/compilerplugins/clang/refcounting.cxx
+++ b/compilerplugins/clang/refcounting.cxx
@@ -357,7 +357,7 @@ bool RefCounting::visitTemporaryObjectExpr(Expr const * expr) {
DiagnosticsEngine::Warning,
("Temporary object of SvRefBase subclass %0 being directly stack"
" managed, should be managed via tools::SvRef"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< t.getUnqualifiedType() << expr->getSourceRange();
} else if (containsSalhelperReferenceObjectSubclass(t.getTypePtr())) {
report(
@@ -365,7 +365,7 @@ bool RefCounting::visitTemporaryObjectExpr(Expr const * expr) {
("Temporary object of salhelper::SimpleReferenceObject subclass %0"
" being directly stack managed, should be managed via"
" rtl::Reference"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< t.getUnqualifiedType() << expr->getSourceRange();
} else if (containsXInterfaceSubclass(t)) {
report(
@@ -373,7 +373,7 @@ bool RefCounting::visitTemporaryObjectExpr(Expr const * expr) {
("Temporary object of css::uno::XInterface subclass %0 being"
" directly stack managed, should be managed via"
" css::uno::Reference"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< t.getUnqualifiedType() << expr->getSourceRange();
}
return true;
diff --git a/compilerplugins/clang/rendercontext.cxx b/compilerplugins/clang/rendercontext.cxx
index c0f3acf4f3cc..ada566561377 100644
--- a/compilerplugins/clang/rendercontext.cxx
+++ b/compilerplugins/clang/rendercontext.cxx
@@ -121,7 +121,7 @@ bool RenderContext::VisitCXXMemberCallExpr(const CXXMemberCallExpr* pCXXMemberCa
report(
DiagnosticsEngine::Warning,
"Should be calling OutputDevice method through RenderContext.",
- pCXXMemberCallExpr->getLocStart())
+ compat::getBeginLoc(pCXXMemberCallExpr))
<< pCXXMemberCallExpr->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/returnconstant.cxx b/compilerplugins/clang/returnconstant.cxx
index 0c6e747bc348..eff3495191fd 100644
--- a/compilerplugins/clang/returnconstant.cxx
+++ b/compilerplugins/clang/returnconstant.cxx
@@ -552,10 +552,11 @@ bool ReturnConstant::TraverseCXXMethodDecl(CXXMethodDecl* functionDecl)
// ignore LINK macro stuff
std::string aImmediateMacro = "";
- if (compiler.getSourceManager().isMacroBodyExpansion(functionDecl->getLocStart()))
+ if (compiler.getSourceManager().isMacroBodyExpansion(compat::getBeginLoc(functionDecl)))
{
- StringRef name{ Lexer::getImmediateMacroName(
- functionDecl->getLocStart(), compiler.getSourceManager(), compiler.getLangOpts()) };
+ StringRef name{ Lexer::getImmediateMacroName(compat::getBeginLoc(functionDecl),
+ compiler.getSourceManager(),
+ compiler.getLangOpts()) };
aImmediateMacro = name;
if (name.startswith("IMPL_LINK_"))
{
@@ -571,11 +572,11 @@ bool ReturnConstant::TraverseCXXMethodDecl(CXXMethodDecl* functionDecl)
{
report(DiagnosticsEngine::Warning,
"Method only returns a single constant value %0, does it make sense?",
- functionDecl->getLocStart())
+ compat::getBeginLoc(functionDecl))
<< *rContext.values.begin() << functionDecl->getSourceRange();
if (functionDecl != functionDecl->getCanonicalDecl())
report(DiagnosticsEngine::Note, "decl here",
- functionDecl->getCanonicalDecl()->getLocStart())
+ compat::getBeginLoc(functionDecl->getCanonicalDecl()))
<< functionDecl->getCanonicalDecl()->getSourceRange();
}
m_functionStack.pop_back();
diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx
index 02cc2f609661..f0024e96da27 100644
--- a/compilerplugins/clang/salbool.cxx
+++ b/compilerplugins/clang/salbool.cxx
@@ -200,7 +200,7 @@ void SalBool::run() {
if (compiler.getLangOpts().CPlusPlus) {
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
for (auto decl: varDecls_) {
- SourceLocation loc { decl->getLocStart() };
+ SourceLocation loc { compat::getBeginLoc(decl) };
TypeSourceInfo * tsi = decl->getTypeSourceInfo();
if (tsi != nullptr) {
SourceLocation l {
@@ -321,7 +321,7 @@ bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) {
return true;
}
if (isSalBool(expr->getType())) {
- SourceLocation loc { expr->getLocStart() };
+ SourceLocation loc { compat::getBeginLoc(expr) };
while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc);
}
@@ -334,7 +334,7 @@ bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) {
if (!isSharedCAndCppCode(callLoc)) {
SourceLocation argLoc;
if (compat::isMacroArgExpansion(
- compiler, expr->getLocStart(), &argLoc)
+ compiler, compat::getBeginLoc(expr), &argLoc)
//TODO: check it's the complete (first) arg to the macro
&& (Lexer::getImmediateMacroName(
argLoc, compiler.getSourceManager(),
@@ -373,7 +373,7 @@ bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) {
report(
DiagnosticsEngine::Warning,
"CStyleCastExpr, suspicious cast from %0 to %1",
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSubExpr()->IgnoreParenImpCasts()->getType()
<< expr->getType() << expr->getSourceRange();
}
@@ -386,12 +386,12 @@ bool SalBool::VisitCXXStaticCastExpr(CXXStaticCastExpr * expr) {
}
if (isSalBool(expr->getType())
&& !isInSpecialMainFile(
- compiler.getSourceManager().getSpellingLoc(expr->getLocStart())))
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(expr))))
{
report(
DiagnosticsEngine::Warning,
"CXXStaticCastExpr, suspicious cast from %0 to %1",
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSubExpr()->IgnoreParenImpCasts()->getType()
<< expr->getType() << expr->getSourceRange();
}
@@ -406,7 +406,7 @@ bool SalBool::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
report(
DiagnosticsEngine::Warning,
"CXXFunctionalCastExpr, suspicious cast from %0 to %1",
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSubExpr()->IgnoreParenImpCasts()->getType()
<< expr->getType() << expr->getSourceRange();
}
@@ -420,7 +420,7 @@ bool SalBool::VisitImplicitCastExpr(ImplicitCastExpr * expr) {
if (!isSalBool(expr->getType())) {
return true;
}
- auto l = expr->getLocStart();
+ auto l = compat::getBeginLoc(expr);
while (compiler.getSourceManager().isMacroArgExpansion(l)) {
l = compiler.getSourceManager().getImmediateMacroCallerLoc(l);
}
@@ -455,7 +455,7 @@ bool SalBool::VisitImplicitCastExpr(ImplicitCastExpr * expr) {
}
report(
DiagnosticsEngine::Warning, "conversion from %0 to sal_Bool",
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< t << expr->getSourceRange();
return true;
}
@@ -528,7 +528,7 @@ bool SalBool::VisitParmVarDecl(ParmVarDecl const * decl) {
{
OverrideKind k = getOverrideKind(f);
if (k != OverrideKind::YES) {
- SourceLocation loc { decl->getLocStart() };
+ SourceLocation loc { compat::getBeginLoc(decl) };
TypeSourceInfo * tsi = decl->getTypeSourceInfo();
if (tsi != nullptr) {
SourceLocation l {
@@ -611,7 +611,7 @@ bool SalBool::VisitVarDecl(VarDecl const * decl) {
if (!decl->isExternC()
&& (isSalBool(decl->getType()) || isSalBoolArray(decl->getType()))
&& !isInSpecialMainFile(
- compiler.getSourceManager().getSpellingLoc(decl->getLocStart())))
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(decl))))
{
varDecls_.insert(decl);
}
@@ -628,7 +628,7 @@ bool SalBool::VisitFieldDecl(FieldDecl const * decl) {
}
if ((isSalBool(decl->getType()) || isSalBoolArray(decl->getType()))
&& !isInSpecialMainFile(
- compiler.getSourceManager().getSpellingLoc(decl->getLocStart())))
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(decl))))
{
TagDecl const * td = dyn_cast<TagDecl>(decl->getDeclContext());
assert(td != nullptr);
@@ -637,7 +637,7 @@ bool SalBool::VisitFieldDecl(FieldDecl const * decl) {
compiler.getSourceManager().getSpellingLoc(
decl->getLocation()))))
{
- SourceLocation loc { decl->getLocStart() };
+ SourceLocation loc { compat::getBeginLoc(decl) };
TypeSourceInfo * tsi = decl->getTypeSourceInfo();
if (tsi != nullptr) {
SourceLocation l {
@@ -698,7 +698,7 @@ bool SalBool::VisitFunctionDecl(FunctionDecl const * decl) {
|| (isInUnoIncludeFile(f)
&& (!f->isInlined() || f->hasAttr<DeprecatedAttr>()))))
{
- SourceLocation loc { decl->getLocStart() };
+ SourceLocation loc { compat::getBeginLoc(decl) };
SourceLocation l { compiler.getSourceManager().getExpansionLoc(
loc) };
SourceLocation end { compiler.getSourceManager().getExpansionLoc(
@@ -749,11 +749,11 @@ bool SalBool::VisitValueDecl(ValueDecl const * decl) {
if (ignoreLocation(decl)) {
return true;
}
- if (isSalBool(decl->getType()) && !rewrite(decl->getLocStart())) {
+ if (isSalBool(decl->getType()) && !rewrite(compat::getBeginLoc(decl))) {
report(
DiagnosticsEngine::Warning,
"ValueDecl, use \"bool\" instead of \"sal_Bool\"",
- decl->getLocStart())
+ compat::getBeginLoc(decl))
<< decl->getSourceRange();
}
return true;
diff --git a/compilerplugins/clang/salcall.cxx b/compilerplugins/clang/salcall.cxx
index a84cbd9825d5..2a6160162527 100644
--- a/compilerplugins/clang/salcall.cxx
+++ b/compilerplugins/clang/salcall.cxx
@@ -382,7 +382,7 @@ bool SalCall::isSalCallFunction(FunctionDecl const* functionDecl, SourceLocation
// qualified names this will point after the qualifiers, but needlessly including those in
// the search should be harmless---modulo issues with using "SAL_CALL" as the name of a
// function-like macro parameter as discussed below):
- endLoc = functionDecl->getNameInfo().getLocStart();
+ endLoc = compat::getBeginLoc(functionDecl->getNameInfo());
while (SM.isMacroArgExpansion(endLoc, &endLoc))
{
}
@@ -463,7 +463,7 @@ bool SalCall::isSalCallFunction(FunctionDecl const* functionDecl, SourceLocation
// Stop searching for "SAL_CALL" at the start of the function declaration's name (for
// qualified names this will point after the qualifiers, but needlessly including those in
// the search should be harmless):
- endLoc = functionDecl->getNameInfo().getLocStart();
+ endLoc = compat::getBeginLoc(functionDecl->getNameInfo());
while (endLoc.isMacroID() && SM.isAtStartOfImmediateMacroExpansion(endLoc, &endLoc))
{
}
diff --git a/compilerplugins/clang/sallogareas.cxx b/compilerplugins/clang/sallogareas.cxx
index e18f100043e5..9100b8973f00 100644
--- a/compilerplugins/clang/sallogareas.cxx
+++ b/compilerplugins/clang/sallogareas.cxx
@@ -80,7 +80,7 @@ bool SalLogAreas::VisitCallExpr( const CallExpr* call )
// from the same macro should be the same).
if( kind == LogCallKind::Sal )
{
- SourceLocation expansionLocation = compiler.getSourceManager().getExpansionLoc( call->getLocStart());
+ SourceLocation expansionLocation = compiler.getSourceManager().getExpansionLoc( compat::getBeginLoc(call));
if( expansionLocation == lastSalDetailLogStreamMacro )
return true;
lastSalDetailLogStreamMacro = expansionLocation;
@@ -91,7 +91,7 @@ bool SalLogAreas::VisitCallExpr( const CallExpr* call )
checkArea( area->getBytes(), area->getExprLoc());
else
report( DiagnosticsEngine::Warning, "unsupported string literal kind (plugin needs fixing?)",
- area->getLocStart());
+ compat::getBeginLoc(area));
return true;
}
if( loplugin::DeclCheck(inFunction).Function("log").Namespace("detail").Namespace("sal").GlobalNamespace()
@@ -101,7 +101,7 @@ bool SalLogAreas::VisitCallExpr( const CallExpr* call )
Expr::NPC_ValueDependentIsNotNull ) != Expr::NPCK_NotNull )
{ // If the area argument is a null pointer, that is allowed only for SAL_DEBUG.
const SourceManager& source = compiler.getSourceManager();
- for( SourceLocation loc = call->getLocStart();
+ for( SourceLocation loc = compat::getBeginLoc(call);
loc.isMacroID();
loc = compat::getImmediateExpansionRange(source, loc ).first )
{
@@ -110,11 +110,11 @@ bool SalLogAreas::VisitCallExpr( const CallExpr* call )
return true; // ok
}
report( DiagnosticsEngine::Warning, "missing log area",
- call->getArg( 1 )->IgnoreParenImpCasts()->getLocStart());
+ compat::getBeginLoc(call->getArg( 1 )->IgnoreParenImpCasts()));
return true;
}
report( DiagnosticsEngine::Warning, "cannot analyse log area argument (plugin needs fixing?)",
- call->getLocStart());
+ compat::getBeginLoc(call));
return true;
}
diff --git a/compilerplugins/clang/salunicodeliteral.cxx b/compilerplugins/clang/salunicodeliteral.cxx
index 529d20c970eb..cf06b6ccaad7 100644
--- a/compilerplugins/clang/salunicodeliteral.cxx
+++ b/compilerplugins/clang/salunicodeliteral.cxx
@@ -71,7 +71,7 @@ private:
t = tt->desugar();
}
auto const e1 = expr->getSubExprAsWritten();
- auto const loc = e1->getLocStart();
+ auto const loc = compat::getBeginLoc(e1);
if (loc.isMacroID()
&& compiler.getSourceManager().isAtStartOfImmediateMacroExpansion(
loc))
diff --git a/compilerplugins/clang/sfxpoolitem.cxx b/compilerplugins/clang/sfxpoolitem.cxx
index d269070e03fe..f41a006f30b0 100644
--- a/compilerplugins/clang/sfxpoolitem.cxx
+++ b/compilerplugins/clang/sfxpoolitem.cxx
@@ -122,7 +122,7 @@ bool SfxPoolItem::VisitCXXRecordDecl(const CXXRecordDecl* decl)
report(
DiagnosticsEngine::Warning,
"SfxPoolItem subclass %0 declares new fields, but does not override operator==",
- decl->getLocStart())
+ compat::getBeginLoc(decl))
<< decl->getQualifiedNameAsString() << decl->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/shouldreturnbool.cxx b/compilerplugins/clang/shouldreturnbool.cxx
index ea9e696674de..937dba126da0 100644
--- a/compilerplugins/clang/shouldreturnbool.cxx
+++ b/compilerplugins/clang/shouldreturnbool.cxx
@@ -111,12 +111,12 @@ public:
continue;
report(DiagnosticsEngine::Warning,
"only returning one or zero is an indication you want to return bool",
- functionDecl->getLocStart())
+ compat::getBeginLoc(functionDecl))
<< functionDecl->getSourceRange();
if (canonicalDecl->getLocation() != functionDecl->getLocation())
{
report(DiagnosticsEngine::Note, "canonical function declaration here",
- canonicalDecl->getLocStart())
+ compat::getBeginLoc(canonicalDecl))
<< canonicalDecl->getSourceRange();
}
}
diff --git a/compilerplugins/clang/simplifybool.cxx b/compilerplugins/clang/simplifybool.cxx
index 9167014f8c84..23f75a9a6705 100644
--- a/compilerplugins/clang/simplifybool.cxx
+++ b/compilerplugins/clang/simplifybool.cxx
@@ -116,7 +116,7 @@ bool SimplifyBool::VisitUnaryLNot(UnaryOperator const * expr) {
// Ignore macros, otherwise
// OSL_ENSURE(!b, ...);
// triggers.
- if (e->getLocStart().isMacroID())
+ if (compat::getBeginLoc(e).isMacroID())
return true;
// double logical not of an int is an idiom to convert to bool
auto const sub = ignoreAllImplicit(e);
@@ -126,7 +126,7 @@ bool SimplifyBool::VisitUnaryLNot(UnaryOperator const * expr) {
DiagnosticsEngine::Warning,
("double logical negation expression of the form '!!A' (with A of type"
" %0) can %select{logically|literally}1 be simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< sub->getType()
<< sub->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -136,7 +136,7 @@ bool SimplifyBool::VisitUnaryLNot(UnaryOperator const * expr) {
// Ignore macros, otherwise
// OSL_ENSURE(!b, ...);
// triggers.
- if (binaryOp->getLocStart().isMacroID())
+ if (compat::getBeginLoc(binaryOp).isMacroID())
return true;
auto t = binaryOp->getLHS()->IgnoreImpCasts()->getType()->getUnqualifiedDesugaredType();
// RecordType would require more smarts - we'd need to verify that an inverted operator actually existed
@@ -151,7 +151,7 @@ bool SimplifyBool::VisitUnaryLNot(UnaryOperator const * expr) {
report(
DiagnosticsEngine::Warning,
("logical negation of comparison operator, can be simplified by inverting operator"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
}
return true;
@@ -178,7 +178,7 @@ bool SimplifyBool::VisitBinLT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than expression of the form 'A < false' (with A of type"
" %0) can logically be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< expr->getSourceRange();
break;
@@ -191,7 +191,7 @@ bool SimplifyBool::VisitBinLT(BinaryOperator const * expr) {
("less-than expression of the form 'A < true' (with A"
" of type %0) can %select{logically|literally}1 be"
" simplified as '!A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< (expr->getLHS()->IgnoreImpCasts()->getType()
->isBooleanType())
@@ -202,7 +202,7 @@ bool SimplifyBool::VisitBinLT(BinaryOperator const * expr) {
("less-than expression of the form '!A < true' (with A"
" of type %0) can %select{logically|literally}1 be"
" simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -218,7 +218,7 @@ bool SimplifyBool::VisitBinLT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than expression of the form 'false < A' (with A of type"
" %0) can %select{logically|literally}1 be simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< expr->getRHS()->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -228,7 +228,7 @@ bool SimplifyBool::VisitBinLT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than expression of the form 'false < false' can"
" literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -236,7 +236,7 @@ bool SimplifyBool::VisitBinLT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than expression of the form 'false < true' can"
" literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -248,7 +248,7 @@ bool SimplifyBool::VisitBinLT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than expression of the form 'true < A' (with A of type"
" %0) can logically be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< expr->getSourceRange();
break;
@@ -257,7 +257,7 @@ bool SimplifyBool::VisitBinLT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than expression of the form 'true < false' can"
" literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -265,7 +265,7 @@ bool SimplifyBool::VisitBinLT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than expression of the form 'true < true' can"
" literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -296,7 +296,7 @@ bool SimplifyBool::VisitBinGT(BinaryOperator const * expr) {
("greater-than expression of the form 'A > false' (with A of"
" type %0) can %select{logically|literally}1 be simplified as"
" 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< expr->getLHS()->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -306,7 +306,7 @@ bool SimplifyBool::VisitBinGT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than expression of the form 'A > true' (with A of"
" type %0) can logically be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< expr->getSourceRange();
break;
@@ -319,7 +319,7 @@ bool SimplifyBool::VisitBinGT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than expression of the form 'false > A' (with A of"
" type %0) can logically be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< expr->getSourceRange();
break;
@@ -328,7 +328,7 @@ bool SimplifyBool::VisitBinGT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than expression of the form 'false > false' can"
" literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -336,7 +336,7 @@ bool SimplifyBool::VisitBinGT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than expression of the form 'false > true' can"
" literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -352,7 +352,7 @@ bool SimplifyBool::VisitBinGT(BinaryOperator const * expr) {
("greater-than expression of the form 'true > A' (with"
" A of type %0) can %select{logically|literally}1 be"
" simplified as '!A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< (expr->getRHS()->IgnoreImpCasts()->getType()
->isBooleanType())
@@ -363,7 +363,7 @@ bool SimplifyBool::VisitBinGT(BinaryOperator const * expr) {
("greater-than expression of the form 'true > !A' (with"
" A of type %0) can %select{logically|literally}1 be"
" simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -375,7 +375,7 @@ bool SimplifyBool::VisitBinGT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than expression of the form 'true > false' can"
" literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -383,7 +383,7 @@ bool SimplifyBool::VisitBinGT(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than expression of the form 'true > true' can"
" literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -418,7 +418,7 @@ bool SimplifyBool::VisitBinLE(BinaryOperator const * expr) {
" false' (with A of type %0) can"
" %select{logically|literally}1 be simplified as"
" '!A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< (expr->getLHS()->IgnoreImpCasts()->getType()
->isBooleanType())
@@ -429,7 +429,7 @@ bool SimplifyBool::VisitBinLE(BinaryOperator const * expr) {
("less-than-or-equal-to expression of the form '!A <="
" false' (with A of type %0) can"
" %select{logically|literally}1 be simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -441,7 +441,7 @@ bool SimplifyBool::VisitBinLE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than-or-equal-to expression of the form 'A <= true'"
" (with A of type %0) can logically be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< expr->getSourceRange();
break;
@@ -454,7 +454,7 @@ bool SimplifyBool::VisitBinLE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than-or-equal-to expression of the form 'false <= A'"
" (with A of type %0) can logically be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< expr->getSourceRange();
break;
@@ -463,7 +463,7 @@ bool SimplifyBool::VisitBinLE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than-or-equal-to expression of the form 'false <= false'"
" can literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -471,7 +471,7 @@ bool SimplifyBool::VisitBinLE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than-or-equal-to expression of the form 'false <= true'"
" can literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -484,7 +484,7 @@ bool SimplifyBool::VisitBinLE(BinaryOperator const * expr) {
("less-than-or-equal-to expression of the form 'true <= A'"
" (with A of type %0) can %select{logically|literally}1 be"
" simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< expr->getRHS()->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -494,7 +494,7 @@ bool SimplifyBool::VisitBinLE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than-or-equal-to expression of the form 'true <= false'"
" can literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -502,7 +502,7 @@ bool SimplifyBool::VisitBinLE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("less-than-or-equal-to expression of the form 'true <= true'"
" can literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -532,7 +532,7 @@ bool SimplifyBool::VisitBinGE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than-or-equal-to expression of the form 'A >= false'"
" (with A of type %0) can logically be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< expr->getSourceRange();
break;
@@ -542,7 +542,7 @@ bool SimplifyBool::VisitBinGE(BinaryOperator const * expr) {
("greater-than-or-equal-to expression of the form 'A >= true'"
" (with A of type %0) can %select{logically|literally}1 be"
" simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< expr->getLHS()->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -561,7 +561,7 @@ bool SimplifyBool::VisitBinGE(BinaryOperator const * expr) {
" 'false >= A' (with A of type %0) can"
" %select{logically|literally}1 be simplified as"
" '!A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< (expr->getRHS()->IgnoreImpCasts()->getType()
->isBooleanType())
@@ -572,7 +572,7 @@ bool SimplifyBool::VisitBinGE(BinaryOperator const * expr) {
("greater-than-or-equal-to expression of the form"
" 'false >= !A' (with A of type %0) can"
" %select{logically|literally}1 be simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -584,7 +584,7 @@ bool SimplifyBool::VisitBinGE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than-or-equal-to expression of the form 'false >="
" false' can literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -592,7 +592,7 @@ bool SimplifyBool::VisitBinGE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than-or-equal-to expression of the form 'false >="
" true' can literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -604,7 +604,7 @@ bool SimplifyBool::VisitBinGE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than-or-equal-to expression of the form 'true >= A'"
" (with A of type %0) can logically be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< expr->getSourceRange();
break;
@@ -613,7 +613,7 @@ bool SimplifyBool::VisitBinGE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than-or-equal-to expression of the form 'true >="
" false' can literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -621,7 +621,7 @@ bool SimplifyBool::VisitBinGE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("greater-than-or-equal-to expression of the form 'true >="
" true' can literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -655,7 +655,7 @@ bool SimplifyBool::VisitBinEQ(BinaryOperator const * expr) {
("equal-to expression of the form 'A == false' (with A"
" of type %0) can %select{logically|literally}1 be"
" simplified as '!A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< (expr->getLHS()->IgnoreImpCasts()->getType()
->isBooleanType())
@@ -666,7 +666,7 @@ bool SimplifyBool::VisitBinEQ(BinaryOperator const * expr) {
("equal-to expression of the form '!A == false' (with A"
" of type %0) can %select{logically|literally}1 be"
" simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -678,7 +678,7 @@ bool SimplifyBool::VisitBinEQ(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("equal-to expression of the form 'A == true' (with A of type"
" %0) can %select{logically|literally}1 be simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< expr->getLHS()->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -696,7 +696,7 @@ bool SimplifyBool::VisitBinEQ(BinaryOperator const * expr) {
("equal-to expression of the form 'false == A' (with A"
" of type %0) can %select{logically|literally}1 be"
" simplified as '!A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< (expr->getRHS()->IgnoreImpCasts()->getType()
->isBooleanType())
@@ -707,7 +707,7 @@ bool SimplifyBool::VisitBinEQ(BinaryOperator const * expr) {
("equal-to expression of the form 'false == !A' (with A"
" of type %0) can %select{logically|literally}1 be"
" simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -719,7 +719,7 @@ bool SimplifyBool::VisitBinEQ(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("equal-to expression of the form 'false == false' can"
" literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -727,7 +727,7 @@ bool SimplifyBool::VisitBinEQ(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("equal-to expression of the form 'false == true' can"
" literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -739,7 +739,7 @@ bool SimplifyBool::VisitBinEQ(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("equal-to expression of the form 'true == A' (with A of type"
" %0) can %select{logically|literally}1 be simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< expr->getRHS()->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -749,7 +749,7 @@ bool SimplifyBool::VisitBinEQ(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("equal-to expression of the form 'true == false' can"
" literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -757,7 +757,7 @@ bool SimplifyBool::VisitBinEQ(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("equal-to expression of the form 'true == true' can"
" literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -788,7 +788,7 @@ bool SimplifyBool::VisitBinNE(BinaryOperator const * expr) {
("not-equal-to expression of the form 'A != false' (with A of"
" type %0) can %select{logically|literally}1 be simplified as"
" 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< expr->getLHS()->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -802,7 +802,7 @@ bool SimplifyBool::VisitBinNE(BinaryOperator const * expr) {
("not-equal-to expression of the form 'A != true' (with"
" A of type %0) can %select{logically|literally}1 be"
" simplified as '!A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getLHS()->IgnoreImpCasts()->getType()
<< (expr->getLHS()->IgnoreImpCasts()->getType()
->isBooleanType())
@@ -813,7 +813,7 @@ bool SimplifyBool::VisitBinNE(BinaryOperator const * expr) {
("not-equal-to expression of the form '!A != true'"
" (with A of type %0) can"
" %select{logically|literally}1 be simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -830,7 +830,7 @@ bool SimplifyBool::VisitBinNE(BinaryOperator const * expr) {
("not-equal-to expression of the form 'false != A' (with A of"
" type %0) can %select{logically|literally}1 be simplified as"
" 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< expr->getRHS()->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -840,7 +840,7 @@ bool SimplifyBool::VisitBinNE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("not-equal-to expression of the form 'false != false' can"
" literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -848,7 +848,7 @@ bool SimplifyBool::VisitBinNE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("not-equal-to expression of the form 'false != true' can"
" literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -864,7 +864,7 @@ bool SimplifyBool::VisitBinNE(BinaryOperator const * expr) {
("not-equal-to expression of the form 'true != A' (with"
" A of type %0) can %select{logically|literally}1 be"
" simplified as '!A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getRHS()->IgnoreImpCasts()->getType()
<< (expr->getRHS()->IgnoreImpCasts()->getType()
->isBooleanType())
@@ -875,7 +875,7 @@ bool SimplifyBool::VisitBinNE(BinaryOperator const * expr) {
("not-equal-to expression of the form 'true != !A'"
" (with A of type %0) can"
" %select{logically|literally}1 be simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -887,7 +887,7 @@ bool SimplifyBool::VisitBinNE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("not-equal-to expression of the form 'true != false' can"
" literally be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
case Value::True:
@@ -895,7 +895,7 @@ bool SimplifyBool::VisitBinNE(BinaryOperator const * expr) {
DiagnosticsEngine::Warning,
("not-equal-to expression of the form 'true != true' can"
" literally be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getSourceRange();
break;
}
@@ -921,7 +921,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
("conditional expression of the form 'A ? B : false' (with A of"
" type %0 and B of type %1) can %select{logically|literally}2"
" be simplified as 'A && B'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getCond()->IgnoreImpCasts()->getType()
<< expr->getTrueExpr()->IgnoreImpCasts()->getType()
<< ((expr->getCond()->IgnoreImpCasts()->getType()
@@ -940,7 +940,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
" (with A of type %0 and B of type %1) can"
" %select{logically|literally}2 be simplified as '!A"
" || B'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getCond()->IgnoreImpCasts()->getType()
<< expr->getTrueExpr()->IgnoreImpCasts()->getType()
<< ((expr->getCond()->IgnoreImpCasts()->getType()
@@ -955,7 +955,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
" (with A of type %0 and B of type %1) can"
" %select{logically|literally}2 be simplified as 'A ||"
" B'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< expr->getTrueExpr()->IgnoreImpCasts()->getType()
<< (e->IgnoreImpCasts()->getType()->isBooleanType()
@@ -979,7 +979,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
" (with A of type %0 and B of type %1) can"
" %select{logically|literally}2 be simplified as '!A"
" && B'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getCond()->IgnoreImpCasts()->getType()
<< expr->getFalseExpr()->IgnoreImpCasts()->getType()
<< ((expr->getCond()->IgnoreImpCasts()->getType()
@@ -994,7 +994,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
" (with A of type %0 and B of type %1) can"
" %select{logically|literally}2 be simplified as 'A &&"
" B'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< expr->getFalseExpr()->IgnoreImpCasts()->getType()
<< (e->IgnoreImpCasts()->getType()->isBooleanType()
@@ -1009,7 +1009,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
DiagnosticsEngine::Warning,
("conditional expression of the form 'A ? false : false' (with"
" A of type %0) can logically be simplified as 'false'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getCond()->IgnoreImpCasts()->getType()
<< expr->getSourceRange();
break;
@@ -1023,7 +1023,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
" (with A of type %0) can"
" %select{logically|literally}1 be simplified as"
" '!A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getCond()->IgnoreImpCasts()->getType()
<< (expr->getCond()->IgnoreImpCasts()->getType()
->isBooleanType())
@@ -1034,7 +1034,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
("conditional expression of the form '!A ? false :"
" true' (with A of type %0) can"
" %select{logically|literally}1 be simplified as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -1051,7 +1051,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
("conditional expression of the form 'A ? true : B' (with A of"
" type %0 and B of type %1) can %select{logically|literally}2"
" be simplified as 'A || B'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getCond()->IgnoreImpCasts()->getType()
<< expr->getFalseExpr()->IgnoreImpCasts()->getType()
<< ((expr->getCond()->IgnoreImpCasts()->getType()
@@ -1066,7 +1066,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
("conditional expression of the form 'A ? true : false' (with A"
" of type %0) can %select{logically|literally}1 be simplified"
" as 'A'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getCond()->IgnoreImpCasts()->getType()
<< expr->getCond()->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
@@ -1076,7 +1076,7 @@ bool SimplifyBool::VisitConditionalOperator(ConditionalOperator const * expr) {
DiagnosticsEngine::Warning,
("conditional expression of the form 'A ? true : true' (with A"
" of type %0) can logically be simplified as 'true'"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< expr->getCond()->IgnoreImpCasts()->getType()
<< expr->getSourceRange();
break;
diff --git a/compilerplugins/clang/simplifydynamiccast.cxx b/compilerplugins/clang/simplifydynamiccast.cxx
index eb5d111d11a7..a82976c7ae27 100644
--- a/compilerplugins/clang/simplifydynamiccast.cxx
+++ b/compilerplugins/clang/simplifydynamiccast.cxx
@@ -102,10 +102,12 @@ bool SimplifyDynamicCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const* static
return true;
if (dynamicCastSubExprVec[idx] != subExprDecl->getDecl())
return true;
- report(DiagnosticsEngine::Warning, "simplify, use var in if", staticCastExpr->getLocStart())
+ report(DiagnosticsEngine::Warning, "simplify, use var in if",
+ compat::getBeginLoc(staticCastExpr))
<< staticCastExpr->getSourceRange();
auto ifStmt = ifVec[idx];
- report(DiagnosticsEngine::Note, "if here", ifStmt->getLocStart()) << ifStmt->getSourceRange();
+ report(DiagnosticsEngine::Note, "if here", compat::getBeginLoc(ifStmt))
+ << ifStmt->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/singlevalfields.cxx b/compilerplugins/clang/singlevalfields.cxx
index e24781e3a099..fc2a38017e4a 100644
--- a/compilerplugins/clang/singlevalfields.cxx
+++ b/compilerplugins/clang/singlevalfields.cxx
@@ -387,7 +387,7 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
report(
DiagnosticsEngine::Warning,
"oh dear, what can the matter be?",
- memberExpr->getLocStart())
+ compat::getBeginLoc(memberExpr))
<< memberExpr->getSourceRange();
parent->dump();
}
diff --git a/compilerplugins/clang/staticaccess.cxx b/compilerplugins/clang/staticaccess.cxx
index 3fce436a80d5..c48861978d61 100644
--- a/compilerplugins/clang/staticaccess.cxx
+++ b/compilerplugins/clang/staticaccess.cxx
@@ -84,7 +84,7 @@ bool StaticAccess::VisitMemberExpr(MemberExpr const * expr) {
DiagnosticsEngine::Warning,
("accessing %select{static class member|member enumerator}0 through"
" class member access syntax, use a qualified name like '%1' instead"),
- expr->getLocStart())
+ compat::getBeginLoc(expr))
<< me << decl->getQualifiedNameAsString() << expr->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/staticanonymous.cxx b/compilerplugins/clang/staticanonymous.cxx
index 92d18c4017d8..0fcb15000a3d 100644
--- a/compilerplugins/clang/staticanonymous.cxx
+++ b/compilerplugins/clang/staticanonymous.cxx
@@ -51,7 +51,7 @@ bool StaticAnonymous::VisitFunctionDecl( FunctionDecl* func )
{
report( DiagnosticsEngine::Warning,
"redundant 'static' keyword in unnamed namespace",
- func->getLocStart());
+ compat::getBeginLoc(func));
}
}
}
diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx
index aa1b97e01015..b18f9c79c8b1 100644
--- a/compilerplugins/clang/staticmethods.cxx
+++ b/compilerplugins/clang/staticmethods.cxx
@@ -92,11 +92,11 @@ bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl)
return true;
}
// don't mess with the backwards compatibility stuff
- if (loplugin::isSamePathname(getFilename(pCXXMethodDecl->getLocStart()), SRCDIR "/cppuhelper/source/compat.cxx")) {
+ if (loplugin::isSamePathname(getFilename(compat::getBeginLoc(pCXXMethodDecl)), SRCDIR "/cppuhelper/source/compat.cxx")) {
return true;
}
// the DDE has a dummy implementation on Linux and a real one on Windows
- auto aFilename = getFilename(pCXXMethodDecl->getCanonicalDecl()->getLocStart());
+ auto aFilename = getFilename(compat::getBeginLoc(pCXXMethodDecl->getCanonicalDecl()));
if (loplugin::isSamePathname(aFilename, SRCDIR "/include/svl/svdde.hxx")) {
return true;
}
diff --git a/compilerplugins/clang/stringconcat.cxx b/compilerplugins/clang/stringconcat.cxx
index 818d8314fa45..43300fba5656 100644
--- a/compilerplugins/clang/stringconcat.cxx
+++ b/compilerplugins/clang/stringconcat.cxx
@@ -76,7 +76,7 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) {
SourceLocation leftLoc;
auto const leftExpr = expr->getArg(0)->IgnoreParenImpCasts();
if (isStringLiteral(leftExpr)) {
- leftLoc = leftExpr->getLocStart();
+ leftLoc = compat::getBeginLoc(leftExpr);
} else {
CallExpr const * left = dyn_cast<CallExpr>(leftExpr);
if (left == nullptr) {
@@ -94,11 +94,11 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) {
{
return true;
}
- leftLoc = left->getArg(1)->getLocStart();
+ leftLoc = compat::getBeginLoc(left->getArg(1));
}
StringRef name {
getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(expr->getLocStart())) };
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(expr))) };
if (loplugin::isSamePathname(
name, SRCDIR "/sal/qa/rtl/strings/test_ostring_concat.cxx")
|| loplugin::isSamePathname(
@@ -112,7 +112,7 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) {
"replace '%0' between string literals with juxtaposition",
op == nullptr ? expr->getExprLoc() : op->getOperatorLoc())
<< (oo == OverloadedOperatorKind::OO_Plus ? "+" : "<<")
- << SourceRange(leftLoc, expr->getArg(1)->getLocEnd());
+ << SourceRange(leftLoc, compat::getEndLoc(expr->getArg(1)));
return true;
}
@@ -124,7 +124,7 @@ bool StringConcat::isStringLiteral(Expr const * expr) {
// OSL_THIS_FUNC may be defined as "" in include/osl/diagnose.h, so don't
// warn about expressions like 'SAL_INFO(..., OSL_THIS_FUNC << ":")' or
// 'OUString(OSL_THIS_FUNC) + ":"':
- auto loc = expr->getLocStart();
+ auto loc = compat::getBeginLoc(expr);
while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc);
}
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx
index 8c01c9e5c017..a8914ff5385f 100644
--- a/compilerplugins/clang/stringconstant.cxx
+++ b/compilerplugins/clang/stringconstant.cxx
@@ -327,7 +327,7 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
// u.equalsIngoreAsciiCase("foo"):
auto file = getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(expr->getLocStart()));
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(expr)));
if (loplugin::isSamePathname(
file, SRCDIR "/sal/qa/rtl/strings/test_oustring_compare.cxx"))
{
@@ -345,7 +345,7 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
// u.equalsIgnoreAsciiCaseAsciiL("foo", 3) ->
// u.equalsIngoreAsciiCase("foo"):
auto file = getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(expr->getLocStart()));
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(expr)));
if (loplugin::isSamePathname(
file, SRCDIR "/sal/qa/rtl/strings/test_oustring_compare.cxx"))
{
@@ -713,7 +713,7 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
// b.append("foo", 3) -> b.append("foo"):
auto file = getFileNameOfSpellingLoc(
compiler.getSourceManager().getSpellingLoc(
- expr->getLocStart()));
+ compat::getBeginLoc(expr)));
if (loplugin::isSamePathname(
file,
SRCDIR "/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx"))
@@ -800,7 +800,7 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
}
// OSL_THIS_FUNC may be defined as "" or as something other
// than a string literal in include/osl/diagnose.h:
- auto loc = arg->getLocStart();
+ auto loc = compat::getBeginLoc(arg);
if (compiler.getSourceManager().isMacroBodyExpansion(loc)
&& (Lexer::getImmediateMacroName(
loc, compiler.getSourceManager(),
@@ -1081,7 +1081,7 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
auto file = getFileNameOfSpellingLoc(
compiler.getSourceManager()
.getSpellingLoc(
- expr->getLocStart()));
+ compat::getBeginLoc(expr)));
if (loplugin::isSamePathname(
file,
(SRCDIR
@@ -1094,7 +1094,7 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
return true;
}
}
- auto loc = expr->getArg(0)->getLocStart();
+ auto loc = compat::getBeginLoc(expr->getArg(0));
while (compiler.getSourceManager()
.isMacroArgExpansion(loc))
{
@@ -1855,7 +1855,7 @@ void StringConstant::handleOUStringCtor(
}
//TODO: cont, emb, trm
if (rewriter != nullptr) {
- auto loc1 = e3->getLocStart();
+ auto loc1 = compat::getBeginLoc(e3);
auto range = e3->getParenOrBraceRange();
if (loc1.isFileID() && range.getBegin().isFileID()
&& range.getEnd().isFileID())
diff --git a/compilerplugins/clang/stringloop.cxx b/compilerplugins/clang/stringloop.cxx
index 31f1bfe08a37..cb3ad327738f 100644
--- a/compilerplugins/clang/stringloop.cxx
+++ b/compilerplugins/clang/stringloop.cxx
@@ -256,9 +256,9 @@ bool StringLoop::VisitCallExpr(CallExpr const* callExpr)
return true;
report(DiagnosticsEngine::Warning,
"appending to OUString in loop, rather use OUStringBuffer",
- operatorCallExpr->getLocStart())
+ compat::getBeginLoc(operatorCallExpr))
<< operatorCallExpr->getSourceRange();
- report(DiagnosticsEngine::Note, "field here", fieldDecl->getLocStart())
+ report(DiagnosticsEngine::Note, "field here", compat::getBeginLoc(fieldDecl))
<< fieldDecl->getSourceRange();
}
else if (auto declRefExpr = dyn_cast<DeclRefExpr>(callExpr->getArg(0)))
@@ -275,9 +275,9 @@ bool StringLoop::VisitCallExpr(CallExpr const* callExpr)
return true;
report(DiagnosticsEngine::Warning,
"appending to OUString in loop, rather use OUStringBuffer",
- operatorCallExpr->getLocStart())
+ compat::getBeginLoc(operatorCallExpr))
<< operatorCallExpr->getSourceRange();
- report(DiagnosticsEngine::Note, "var here", varDecl->getLocStart())
+ report(DiagnosticsEngine::Note, "var here", compat::getBeginLoc(varDecl))
<< varDecl->getSourceRange();
}
}
diff --git a/compilerplugins/clang/unnecessarycatchthrow.cxx b/compilerplugins/clang/unnecessarycatchthrow.cxx
index 1802cde2073d..4dff6ae852d9 100644
--- a/compilerplugins/clang/unnecessarycatchthrow.cxx
+++ b/compilerplugins/clang/unnecessarycatchthrow.cxx
@@ -75,7 +75,7 @@ bool UnnecessaryCatchThrow::VisitCXXTryStmt(CXXTryStmt const * tryStmt)
}
report( DiagnosticsEngine::Warning, "unnecessary catch and throw",
- catchStmt->getLocStart())
+ compat::getBeginLoc(catchStmt))
<< catchStmt->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/unnecessaryoverride.cxx b/compilerplugins/clang/unnecessaryoverride.cxx
index a4cf1da809c0..09361730a302 100644
--- a/compilerplugins/clang/unnecessaryoverride.cxx
+++ b/compilerplugins/clang/unnecessaryoverride.cxx
@@ -113,7 +113,7 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
}
StringRef aFileName = getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(methodDecl->getLocStart()));
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(methodDecl)));
if (isa<CXXDestructorDecl>(methodDecl)
&& !isInUnoIncludeFile(methodDecl))
diff --git a/compilerplugins/clang/unnecessaryparen.cxx b/compilerplugins/clang/unnecessaryparen.cxx
index 0cad779ca7dd..f2e67cfefb2c 100644
--- a/compilerplugins/clang/unnecessaryparen.cxx
+++ b/compilerplugins/clang/unnecessaryparen.cxx
@@ -134,7 +134,7 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
{
if (ignoreLocation(parenExpr))
return true;
- if (parenExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(parenExpr).isMacroID())
return true;
if (handled_.find(parenExpr) != handled_.end())
return true;
@@ -143,11 +143,11 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
if (auto subParenExpr = dyn_cast<ParenExpr>(subExpr))
{
- if (subParenExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(subParenExpr).isMacroID())
return true;
report(
DiagnosticsEngine::Warning, "parentheses around parentheses",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(subParenExpr);
}
@@ -160,7 +160,7 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
if (!isPrecededBy_BAD_CAST(parenExpr)) {
report(
DiagnosticsEngine::Warning, "unnecessary parentheses around identifier",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
}
@@ -169,7 +169,7 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
|| isa<CXXBoolLiteralExpr>(subExpr) || isa<CXXNullPtrLiteralExpr>(subExpr)
|| isa<ObjCBoolLiteralExpr>(subExpr))
{
- auto const loc = subExpr->getLocStart();
+ auto const loc = compat::getBeginLoc(subExpr);
if (loc.isMacroID() && compiler.getSourceManager().isAtStartOfImmediateMacroExpansion(loc))
{
// just in case the macro could also expand to something that /would/ require
@@ -178,7 +178,7 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
}
report(
DiagnosticsEngine::Warning, "unnecessary parentheses around literal",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
} else if (auto const e = dyn_cast<clang::StringLiteral>(subExpr)) {
@@ -186,7 +186,7 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
report(
DiagnosticsEngine::Warning,
"unnecessary parentheses around single-token string literal",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
}
@@ -198,7 +198,7 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
report(
DiagnosticsEngine::Warning,
"unnecessary parentheses around signed numeric literal",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
}
@@ -207,7 +207,7 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
if (!removeParens(parenExpr)) {
report(
DiagnosticsEngine::Warning, "unnecessary parentheses around cast",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
}
handled_.insert(parenExpr);
@@ -265,7 +265,7 @@ bool UnnecessaryParen::VisitReturnStmt(const ReturnStmt* returnStmt)
auto parenExpr = dyn_cast<ParenExpr>(ignoreAllImplicit(returnStmt->getRetValue()));
if (!parenExpr)
return true;
- if (parenExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(parenExpr).isMacroID())
return true;
// assignments need extra parentheses or they generate a compiler warning
auto binaryOp = dyn_cast<BinaryOperator>(parenExpr->getSubExpr());
@@ -278,7 +278,7 @@ bool UnnecessaryParen::VisitReturnStmt(const ReturnStmt* returnStmt)
{
report(
DiagnosticsEngine::Warning, "parentheses immediately inside return statement",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
}
@@ -295,7 +295,7 @@ void UnnecessaryParen::VisitSomeStmt(const Stmt * stmt, const Expr* cond, String
if (handled_.find(parenExpr) != handled_.end()) {
return;
}
- if (parenExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(parenExpr).isMacroID())
return;
// assignments need extra parentheses or they generate a compiler warning
auto binaryOp = dyn_cast<BinaryOperator>(parenExpr->getSubExpr());
@@ -308,7 +308,7 @@ void UnnecessaryParen::VisitSomeStmt(const Stmt * stmt, const Expr* cond, String
}
report(
DiagnosticsEngine::Warning, "parentheses immediately inside %0 statement",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< stmtName
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
@@ -325,7 +325,7 @@ bool UnnecessaryParen::VisitCallExpr(const CallExpr* callExpr)
auto parenExpr = dyn_cast<ParenExpr>(ignoreAllImplicit(callExpr->getArg(0)));
if (!parenExpr)
return true;
- if (parenExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(parenExpr).isMacroID())
return true;
// assignments need extra parentheses or they generate a compiler warning
auto binaryOp = dyn_cast<BinaryOperator>(parenExpr->getSubExpr());
@@ -333,7 +333,7 @@ bool UnnecessaryParen::VisitCallExpr(const CallExpr* callExpr)
return true;
report(
DiagnosticsEngine::Warning, "parentheses immediately inside single-arg call",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
return true;
@@ -347,7 +347,7 @@ bool UnnecessaryParen::VisitCXXDeleteExpr(const CXXDeleteExpr* deleteExpr)
auto parenExpr = dyn_cast<ParenExpr>(ignoreAllImplicit(deleteExpr->getArgument()));
if (!parenExpr)
return true;
- if (parenExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(parenExpr).isMacroID())
return true;
// assignments need extra parentheses or they generate a compiler warning
auto binaryOp = dyn_cast<BinaryOperator>(parenExpr->getSubExpr());
@@ -355,7 +355,7 @@ bool UnnecessaryParen::VisitCXXDeleteExpr(const CXXDeleteExpr* deleteExpr)
return true;
report(
DiagnosticsEngine::Warning, "parentheses immediately inside delete expr",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
return true;
@@ -382,7 +382,7 @@ bool UnnecessaryParen::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr* callE
auto parenExpr = dyn_cast<ParenExpr>(ignoreAllImplicit(callExpr->getArg(1)));
if (!parenExpr)
return true;
- if (parenExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(parenExpr).isMacroID())
return true;
// Sometimes parentheses make the RHS of an assignment easier to read by
// visually disambiguating the = from a call to ==
@@ -394,7 +394,7 @@ bool UnnecessaryParen::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr* callE
report(
DiagnosticsEngine::Warning, "parentheses immediately inside assignment",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
return true;
@@ -410,7 +410,7 @@ bool UnnecessaryParen::VisitVarDecl(const VarDecl* varDecl)
auto parenExpr = dyn_cast<ParenExpr>(ignoreAllImplicit(varDecl->getInit()));
if (!parenExpr)
return true;
- if (parenExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(parenExpr).isMacroID())
return true;
auto sub = parenExpr->getSubExpr();
if (isa<BinaryOperator>(sub)
@@ -423,7 +423,7 @@ bool UnnecessaryParen::VisitVarDecl(const VarDecl* varDecl)
report(
DiagnosticsEngine::Warning, "parentheses immediately inside vardecl statement",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
return true;
@@ -439,7 +439,7 @@ bool UnnecessaryParen::VisitMemberExpr(const MemberExpr* memberExpr)
return true;
if (handled_.find(parenExpr) != handled_.end())
return true;
- if (parenExpr->getLocStart().isMacroID())
+ if (compat::getBeginLoc(parenExpr).isMacroID())
return true;
auto sub = parenExpr->getSubExpr();
@@ -457,7 +457,7 @@ bool UnnecessaryParen::VisitMemberExpr(const MemberExpr* memberExpr)
report(
DiagnosticsEngine::Warning, "unnecessary parentheses around member expr",
- parenExpr->getLocStart())
+ compat::getBeginLoc(parenExpr))
<< parenExpr->getSourceRange();
handled_.insert(parenExpr);
return true;
@@ -492,12 +492,12 @@ void UnnecessaryParen::handleUnreachableCodeConditionParens(Expr const * expr) {
}
bool UnnecessaryParen::isPrecededBy_BAD_CAST(Expr const * expr) {
- if (expr->getLocStart().isMacroID()) {
+ if (compat::getBeginLoc(expr).isMacroID()) {
return false;
}
SourceManager& SM = compiler.getSourceManager();
- const char *p1 = SM.getCharacterData( expr->getLocStart().getLocWithOffset(-10) );
- const char *p2 = SM.getCharacterData( expr->getLocStart() );
+ const char *p1 = SM.getCharacterData( compat::getBeginLoc(expr).getLocWithOffset(-10) );
+ const char *p2 = SM.getCharacterData( compat::getBeginLoc(expr) );
return std::string(p1, p2 - p1).find("BAD_CAST") != std::string::npos;
}
@@ -526,8 +526,8 @@ bool UnnecessaryParen::removeParens(ParenExpr const * expr) {
if (rewriter == nullptr) {
return false;
}
- auto const firstBegin = expr->getLocStart();
- auto secondBegin = expr->getLocEnd();
+ auto const firstBegin = compat::getBeginLoc(expr);
+ auto secondBegin = compat::getEndLoc(expr);
if (firstBegin.isMacroID() || secondBegin.isMacroID()) {
return false;
}
diff --git a/compilerplugins/clang/unoany.cxx b/compilerplugins/clang/unoany.cxx
index 8caa7c2a54cf..1272ed409964 100644
--- a/compilerplugins/clang/unoany.cxx
+++ b/compilerplugins/clang/unoany.cxx
@@ -29,7 +29,7 @@ bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr)
return true;
}
StringRef aFileName = getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(expr->getLocStart()));
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(expr)));
if (loplugin::isSamePathname(aFileName, SRCDIR "/include/com/sun/star/uno/Any.hxx")) {
return true;
}
diff --git a/compilerplugins/clang/unusedenumconstants.cxx b/compilerplugins/clang/unusedenumconstants.cxx
index fd159cea5ab5..8a0aaace2669 100644
--- a/compilerplugins/clang/unusedenumconstants.cxx
+++ b/compilerplugins/clang/unusedenumconstants.cxx
@@ -210,7 +210,7 @@ try_again:
declRefExpr->dump();
report( DiagnosticsEngine::Warning,
"unhandled clang AST node type",
- parent->getLocStart());
+ compat::getBeginLoc(parent));
}
if (bWrite) {
diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx
index 94ad63a6f3a3..389baac0dc9b 100644
--- a/compilerplugins/clang/unusedfields.cxx
+++ b/compilerplugins/clang/unusedfields.cxx
@@ -210,13 +210,13 @@ void UnusedFields::run()
report(
DiagnosticsEngine::Warning,
"read %0",
- s.parentRecord->getLocStart())
+ compat::getBeginLoc(s.parentRecord))
<< s.fieldName;
for (const MyFieldInfo & s : writeToSet)
report(
DiagnosticsEngine::Warning,
"write %0",
- s.parentRecord->getLocStart())
+ compat::getBeginLoc(s.parentRecord))
<< s.fieldName;
}
}
@@ -333,8 +333,8 @@ bool UnusedFields::isSomeKindOfZero(const Expr* arg)
// Get the expression contents.
// This helps us find params which are always initialised with something like "OUString()".
SourceManager& SM = compiler.getSourceManager();
- SourceLocation startLoc = arg->getLocStart();
- SourceLocation endLoc = arg->getLocEnd();
+ SourceLocation startLoc = compat::getBeginLoc(arg);
+ SourceLocation endLoc = compat::getEndLoc(arg);
const char *p1 = SM.getCharacterData( startLoc );
const char *p2 = SM.getCharacterData( endLoc );
if (!p1 || !p2 || (p2 - p1) < 0 || (p2 - p1) > 40) {
@@ -645,12 +645,12 @@ void UnusedFields::checkWriteOnly(const FieldDecl* fieldDecl, const Expr* member
report(
DiagnosticsEngine::Warning,
"oh dear, what can the matter be?",
- memberExpr->getLocStart())
+ compat::getBeginLoc(memberExpr))
<< memberExpr->getSourceRange();
report(
DiagnosticsEngine::Note,
"parent over here",
- parent->getLocStart())
+ compat::getBeginLoc(parent))
<< parent->getSourceRange();
parent->dump();
memberExpr->dump();
@@ -871,7 +871,7 @@ void UnusedFields::checkReadOnly(const FieldDecl* fieldDecl, const Expr* memberE
report(
DiagnosticsEngine::Warning,
"oh dear, what can the matter be? writtenTo=%0",
- memberExpr->getLocStart())
+ compat::getBeginLoc(memberExpr))
<< bPotentiallyWrittenTo
<< memberExpr->getSourceRange();
if (parent)
@@ -879,7 +879,7 @@ void UnusedFields::checkReadOnly(const FieldDecl* fieldDecl, const Expr* memberE
report(
DiagnosticsEngine::Note,
"parent over here",
- parent->getLocStart())
+ compat::getBeginLoc(parent))
<< parent->getSourceRange();
parent->dump();
}
diff --git a/compilerplugins/clang/unusedfieldsremove.cxx b/compilerplugins/clang/unusedfieldsremove.cxx
index 31997fe1817a..417ced9f3891 100644
--- a/compilerplugins/clang/unusedfieldsremove.cxx
+++ b/compilerplugins/clang/unusedfieldsremove.cxx
@@ -119,7 +119,7 @@ bool UnusedFieldsRemove::VisitFieldDecl( const FieldDecl* fieldDecl )
report(
DiagnosticsEngine::Warning,
"Could not remove unused field (" + niceName(fieldDecl) + ")",
- fieldDecl->getLocStart())
+ compat::getBeginLoc(fieldDecl))
<< fieldDecl->getSourceRange();
}
return true;
diff --git a/compilerplugins/clang/unusedindex.cxx b/compilerplugins/clang/unusedindex.cxx
index 1235e32b3a28..ba57705afcf8 100644
--- a/compilerplugins/clang/unusedindex.cxx
+++ b/compilerplugins/clang/unusedindex.cxx
@@ -63,7 +63,8 @@ bool UnusedIndex::TraverseForStmt(ForStmt* stmt)
auto ret = RecursiveASTVisitor::TraverseStmt(stmt->getBody());
if (loopVarDecl && mFoundSet.erase(loopVarDecl) == 0)
- report(DiagnosticsEngine::Warning, "loop variable not used", loopVarDecl->getLocStart())
+ report(DiagnosticsEngine::Warning, "loop variable not used",
+ compat::getBeginLoc(loopVarDecl))
<< loopVarDecl->getSourceRange();
if (loopVarDecl)
diff --git a/compilerplugins/clang/unusedmethodsremove.cxx b/compilerplugins/clang/unusedmethodsremove.cxx
index 33c7ee7a1fec..4dc3a7be7a51 100644
--- a/compilerplugins/clang/unusedmethodsremove.cxx
+++ b/compilerplugins/clang/unusedmethodsremove.cxx
@@ -136,7 +136,7 @@ bool UnusedMethodsRemove::VisitCXXMethodDecl( const CXXMethodDecl* functionDecl
report(
DiagnosticsEngine::Warning,
"Could not remove unused method (" + niceName(functionDecl) + ")",
- functionDecl->getLocStart())
+ compat::getBeginLoc(functionDecl))
<< functionDecl->getSourceRange();
}
return true;
diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx
index d93c40205a8d..7095ddff0b62 100644
--- a/compilerplugins/clang/useuniqueptr.cxx
+++ b/compilerplugins/clang/useuniqueptr.cxx
@@ -295,7 +295,7 @@ void UseUniquePtr::CheckDeleteExpr(const CXXMethodDecl* methodDecl, const CXXDel
return;
// to ignore things like the CPPUNIT macros
StringRef aFileName = getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(fieldDecl->getLocStart()));
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(fieldDecl)));
if (loplugin::hasPathnamePrefix(aFileName, WORKDIR "/"))
return;
// passes and stores pointers to member fields
@@ -351,12 +351,12 @@ void UseUniquePtr::CheckDeleteExpr(const CXXMethodDecl* methodDecl, const CXXDel
report(
DiagnosticsEngine::Warning,
message,
- deleteExpr->getLocStart())
+ compat::getBeginLoc(deleteExpr))
<< deleteExpr->getSourceRange();
report(
DiagnosticsEngine::Note,
"member is here",
- fieldDecl->getLocStart())
+ compat::getBeginLoc(fieldDecl))
<< fieldDecl->getSourceRange();
}
@@ -426,7 +426,7 @@ bool UseUniquePtr::VisitCompoundStmt(const CompoundStmt* compoundStmt)
{
if (ignoreLocation(compoundStmt))
return true;
- if (isInUnoIncludeFile(compoundStmt->getLocStart()))
+ if (isInUnoIncludeFile(compat::getBeginLoc(compoundStmt)))
return true;
if (compoundStmt->size() == 0) {
return true;
@@ -457,18 +457,18 @@ bool UseUniquePtr::VisitCompoundStmt(const CompoundStmt* compoundStmt)
return true;
// determine if the var is declared inside the same block as the delete.
// @TODO there should surely be a better way to do this
- if (varDecl->getLocStart() < compoundStmt->getLocStart())
+ if (compat::getBeginLoc(varDecl) < compat::getBeginLoc(compoundStmt))
return true;
report(
DiagnosticsEngine::Warning,
"deleting a local variable at the end of a block, is a sure sign it should be using std::unique_ptr for that var",
- deleteExpr->getLocStart())
+ compat::getBeginLoc(deleteExpr))
<< deleteExpr->getSourceRange();
report(
DiagnosticsEngine::Note,
"var is here",
- varDecl->getLocStart())
+ compat::getBeginLoc(varDecl))
<< varDecl->getSourceRange();
return true;
}
@@ -492,7 +492,7 @@ bool UseUniquePtr::VisitCXXDeleteExpr(const CXXDeleteExpr* deleteExpr)
return true;
if (ignoreLocation(mpCurrentFunctionDecl))
return true;
- if (isInUnoIncludeFile(mpCurrentFunctionDecl->getCanonicalDecl()->getLocStart()))
+ if (isInUnoIncludeFile(compat::getBeginLoc(mpCurrentFunctionDecl->getCanonicalDecl())))
return true;
if (mpCurrentFunctionDecl->getIdentifier())
{
@@ -527,7 +527,7 @@ bool UseUniquePtr::VisitCXXDeleteExpr(const CXXDeleteExpr* deleteExpr)
report(
DiagnosticsEngine::Warning,
"calling delete on a pointer param, should be either whitelisted here or simplified",
- deleteExpr->getLocStart())
+ compat::getBeginLoc(deleteExpr))
<< deleteExpr->getSourceRange();
return true;
}
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index b20963510181..9b50c72ecbd4 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -189,7 +189,7 @@ bool VCLWidgets::VisitCXXDestructorDecl(const CXXDestructorDecl* pCXXDestructorD
report(
DiagnosticsEngine::Warning,
BASE_REF_COUNTED_CLASS " subclass with VclPtr field must call disposeOnce() from its destructor",
- pCXXDestructorDecl->getLocStart())
+ compat::getBeginLoc(pCXXDestructorDecl))
<< pCXXDestructorDecl->getSourceRange();
return true;
}
@@ -207,7 +207,7 @@ bool VCLWidgets::VisitCXXDestructorDecl(const CXXDestructorDecl* pCXXDestructorD
// assert(true), ...;
//
auto skip = false;
- for (auto loc = (*i)->getLocStart();
+ for (auto loc = compat::getBeginLoc(*i);
compiler.getSourceManager().isMacroBodyExpansion(loc);
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(
loc))
@@ -238,7 +238,7 @@ bool VCLWidgets::VisitCXXDestructorDecl(const CXXDestructorDecl* pCXXDestructorD
}
if (!bOk) {
SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(
- pCXXDestructorDecl->getLocStart());
+ compat::getBeginLoc(pCXXDestructorDecl));
StringRef filename = getFileNameOfSpellingLoc(spellingLocation);
if ( !(loplugin::isSamePathname(filename, SRCDIR "/vcl/source/window/window.cxx"))
&& !(loplugin::isSamePathname(filename, SRCDIR "/vcl/source/gdi/virdev.cxx"))
@@ -247,7 +247,7 @@ bool VCLWidgets::VisitCXXDestructorDecl(const CXXDestructorDecl* pCXXDestructorD
report(
DiagnosticsEngine::Warning,
BASE_REF_COUNTED_CLASS " subclass should have nothing in its destructor but a call to disposeOnce()",
- pCXXDestructorDecl->getLocStart())
+ compat::getBeginLoc(pCXXDestructorDecl))
<< pCXXDestructorDecl->getSourceRange();
}
}
@@ -263,7 +263,7 @@ bool VCLWidgets::VisitBinaryOperator(const BinaryOperator * binaryOperator)
return true;
}
SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(
- binaryOperator->getLocStart());
+ compat::getBeginLoc(binaryOperator));
checkAssignmentForVclPtrToRawConversion(spellingLocation, binaryOperator->getLHS()->getType().getTypePtr(), binaryOperator->getRHS());
return true;
}
@@ -356,7 +356,7 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) {
return true;
}
SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(
- pVarDecl->getLocStart());
+ compat::getBeginLoc(pVarDecl));
if (pVarDecl->getInit()) {
checkAssignmentForVclPtrToRawConversion(spellingLocation, pVarDecl->getType().getTypePtr(), pVarDecl->getInit());
}
@@ -413,7 +413,7 @@ bool VCLWidgets::VisitFieldDecl(const FieldDecl * fieldDecl) {
return true;
}
StringRef aFileName = getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(fieldDecl->getLocStart()));
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(fieldDecl)));
if (loplugin::isSamePathname(aFileName, SRCDIR "/include/vcl/vclptr.hxx"))
return true;
if (loplugin::isSamePathname(aFileName, SRCDIR "/include/rtl/ref.hxx"))
@@ -598,7 +598,7 @@ bool VCLWidgets::VisitFunctionDecl( const FunctionDecl* functionDecl )
report(
DiagnosticsEngine::Warning,
BASE_REF_COUNTED_CLASS " subclass dispose() function MUST call dispose() of its superclass as the last thing it does",
- functionDecl->getLocStart())
+ compat::getBeginLoc(functionDecl))
<< functionDecl->getSourceRange();
}
}
@@ -652,7 +652,7 @@ bool VCLWidgets::VisitFunctionDecl( const FunctionDecl* functionDecl )
report(
DiagnosticsEngine::Warning,
aMessage,
- functionDecl->getLocStart())
+ compat::getBeginLoc(functionDecl))
<< functionDecl->getSourceRange();
}
}
@@ -669,14 +669,14 @@ bool VCLWidgets::VisitCXXDeleteExpr(const CXXDeleteExpr *pCXXDeleteExpr)
const CXXRecordDecl *pPointee = pCXXDeleteExpr->getArgument()->getType()->getPointeeCXXRecordDecl();
if (pPointee && isDerivedFromVclReferenceBase(pPointee)) {
SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(
- pCXXDeleteExpr->getLocStart());
+ compat::getBeginLoc(pCXXDeleteExpr));
StringRef filename = getFileNameOfSpellingLoc(spellingLocation);
if ( !(loplugin::isSamePathname(filename, SRCDIR "/include/vcl/vclreferencebase.hxx")))
{
report(
DiagnosticsEngine::Warning,
"calling delete on instance of " BASE_REF_COUNTED_CLASS " subclass, must rather call disposeAndClear()",
- pCXXDeleteExpr->getLocStart())
+ compat::getBeginLoc(pCXXDeleteExpr))
<< pCXXDeleteExpr->getSourceRange();
}
}
@@ -690,7 +690,7 @@ bool VCLWidgets::VisitCXXDeleteExpr(const CXXDeleteExpr *pCXXDeleteExpr)
report(
DiagnosticsEngine::Warning,
"calling delete on instance of VclPtr, must rather call disposeAndClear()",
- pCXXDeleteExpr->getLocStart())
+ compat::getBeginLoc(pCXXDeleteExpr))
<< pCXXDeleteExpr->getSourceRange();
return true;
}
@@ -847,7 +847,7 @@ bool VCLWidgets::VisitCXXConstructExpr( const CXXConstructExpr* constructExpr )
const CXXRecordDecl* recordDecl = pConstructorDecl->getParent();
if (isDerivedFromVclReferenceBase(recordDecl)) {
StringRef aFileName = getFileNameOfSpellingLoc(
- compiler.getSourceManager().getSpellingLoc(constructExpr->getLocStart()));
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(constructExpr)));
if (!loplugin::isSamePathname(aFileName, SRCDIR "/include/vcl/vclptr.hxx")) {
report(
DiagnosticsEngine::Warning,