aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Lohnau <alexander.lohnau@gmx.de>2024-02-05 15:04:08 +0100
committerAlexander Lohnau <alexander.lohnau@gmx.de>2024-02-11 14:34:15 +0100
commit39f8e5450a01a46912621762b1d37925938033e7 (patch)
treee7a24006fd807c6a8163ddf1e690f97ea451cdb1
parentc73cab4f692bdef4ecfef3524965d56e29b478d7 (diff)
Remove clazy::getLocStart and clazy::getLocEnd helpers
Also remove unused includes since most files no longer need the compat header and its transient includes.
-rw-r--r--src/AccessSpecifierManager.cpp10
-rw-r--r--src/Clazy.cpp5
-rw-r--r--src/ContextUtils.cpp2
-rw-r--r--src/FixItUtils.cpp21
-rw-r--r--src/HierarchyUtils.h2
-rw-r--r--src/LoopUtils.cpp3
-rw-r--r--src/LoopUtils.h2
-rw-r--r--src/MiniAstDumper.h1
-rw-r--r--src/NormalizedSignatureUtils.h1
-rw-r--r--src/SourceCompatibilityHelpers.h19
-rw-r--r--src/StmtBodyRange.h2
-rw-r--r--src/StringUtils.h5
-rw-r--r--src/SuppressionManager.cpp1
-rw-r--r--src/Utils.h3
-rw-r--r--src/checkbase.cpp4
-rw-r--r--src/checkmanager.cpp1
-rw-r--r--src/checks/detachingbase.cpp1
-rw-r--r--src/checks/detachingbase.h2
-rw-r--r--src/checks/level0/connect-non-signal.cpp3
-rw-r--r--src/checks/level0/connect-not-normalized.cpp3
-rw-r--r--src/checks/level0/container-anti-pattern.cpp7
-rw-r--r--src/checks/level0/empty-qstringliteral.cpp6
-rw-r--r--src/checks/level0/fully-qualified-moc-types.cpp7
-rw-r--r--src/checks/level0/mutable-container-key.cpp3
-rw-r--r--src/checks/level0/overloaded-signal.cpp2
-rw-r--r--src/checks/level0/qcolor-from-literal.cpp8
-rw-r--r--src/checks/level0/qdatetime-utc.cpp5
-rw-r--r--src/checks/level0/qfileinfo-exists.cpp3
-rw-r--r--src/checks/level0/qgetenv.cpp3
-rw-r--r--src/checks/level0/qmap-with-pointer-key.cpp3
-rw-r--r--src/checks/level0/qstring-arg.cpp10
-rw-r--r--src/checks/level0/qstring-insensitive-allocation.cpp2
-rw-r--r--src/checks/level0/qstring-ref.cpp10
-rw-r--r--src/checks/level0/temporary-iterator.cpp2
-rw-r--r--src/checks/level0/unused-non-trivial-variable.cpp2
-rw-r--r--src/checks/level0/use-static-qregularexpression.cpp8
-rw-r--r--src/checks/level0/writing-to-temporary.cpp5
-rw-r--r--src/checks/level0/wrong-qglobalstatic.cpp2
-rw-r--r--src/checks/level1/auto-unexpected-qstringbuilder.cpp6
-rw-r--r--src/checks/level1/detaching-temporary.cpp2
-rw-r--r--src/checks/level1/foreach.cpp10
-rw-r--r--src/checks/level1/incorrect-emit.cpp6
-rw-r--r--src/checks/level1/non-pod-global-static.cpp4
-rw-r--r--src/checks/level1/qdeleteall.cpp2
-rw-r--r--src/checks/level1/qhash-namespace.cpp2
-rw-r--r--src/checks/level1/range-loop-detach.cpp6
-rw-r--r--src/checks/level1/range-loop-reference.cpp4
-rw-r--r--src/checks/level1/rule-of-two-soft.cpp4
-rw-r--r--src/checks/level2/base-class-event.cpp2
-rw-r--r--src/checks/level2/copyable-polymorphic.cpp2
-rw-r--r--src/checks/level2/ctor-missing-parent-argument.cpp2
-rw-r--r--src/checks/level2/function-args-by-ref.cpp6
-rw-r--r--src/checks/level2/function-args-by-value.cpp8
-rw-r--r--src/checks/level2/global-const-char-pointer.cpp4
-rw-r--r--src/checks/level2/implicit-casts.cpp8
-rw-r--r--src/checks/level2/missing-qobject-macro.cpp4
-rw-r--r--src/checks/level2/missing-typeinfo.cpp2
-rw-r--r--src/checks/level2/old-style-connect.cpp13
-rw-r--r--src/checks/level2/qstring-allocations.cpp58
-rw-r--r--src/checks/level2/rule-of-three.cpp6
-rw-r--r--src/checks/level2/virtual-call-ctor.cpp8
-rw-r--r--src/checks/manuallevel/assert-with-side-effects.cpp6
-rw-r--r--src/checks/manuallevel/container-inside-loop.cpp3
-rw-r--r--src/checks/manuallevel/detaching-member.cpp5
-rw-r--r--src/checks/manuallevel/isempty-vs-count.cpp6
-rw-r--r--src/checks/manuallevel/jnisignatures.cpp1
-rw-r--r--src/checks/manuallevel/qhash-with-char-pointer-key.cpp3
-rw-r--r--src/checks/manuallevel/qproperty-type-mismatch.cpp3
-rw-r--r--src/checks/manuallevel/qt4-qstring-from-array.cpp23
-rw-r--r--src/checks/manuallevel/qt6-fwd-fixes.cpp3
-rw-r--r--src/checks/manuallevel/qt6-fwd-fixes.h1
-rw-r--r--src/checks/manuallevel/qt6-header-fixes.cpp3
-rw-r--r--src/checks/manuallevel/qt6-header-fixes.h1
-rw-r--r--src/checks/manuallevel/qt6-qhash-signature.cpp11
-rw-r--r--src/checks/manuallevel/qt6-qlatin1stringchar-to-u.cpp13
-rw-r--r--src/checks/manuallevel/qvariant-template-instantiation.cpp2
-rw-r--r--src/checks/manuallevel/reserve-candidates.cpp15
-rw-r--r--src/checks/manuallevel/sanitize-inline-keyword.cpp6
-rw-r--r--src/checks/manuallevel/unneeded-cast.cpp13
-rw-r--r--src/checks/manuallevel/unused-result-check.h1
-rw-r--r--src/checks/manuallevel/use-arrow-operator-instead-of-data.cpp2
-rw-r--r--src/checks/manuallevel/use-chrono-in-qtimer.cpp2
-rw-r--r--src/checks/requiredresults.cpp2
83 files changed, 204 insertions, 269 deletions
diff --git a/src/AccessSpecifierManager.cpp b/src/AccessSpecifierManager.cpp
index bd141986..5b2a29c4 100644
--- a/src/AccessSpecifierManager.cpp
+++ b/src/AccessSpecifierManager.cpp
@@ -147,7 +147,7 @@ const CXXRecordDecl *AccessSpecifierManager::classDefinitionForLoc(SourceLocatio
{
for (const auto &it : m_specifiersMap) {
const CXXRecordDecl *record = it.first;
- if (clazy::getLocStart(record) < loc && loc < clazy::getLocEnd(record)) {
+ if (record->getBeginLoc() < loc && loc < record->getEndLoc()) {
return record;
}
}
@@ -197,13 +197,13 @@ void AccessSpecifierManager::VisitDeclaration(Decl *decl)
continue;
}
ClazySpecifierList &specifiers = entryForClassDefinition(record);
- sorted_insert(specifiers, {clazy::getLocStart(accessSpec), accessSpec->getAccess(), QtAccessSpecifier_None}, sm);
+ sorted_insert(specifiers, {accessSpec->getBeginLoc(), accessSpec->getAccess(), QtAccessSpecifier_None}, sm);
}
}
QtAccessSpecifierType AccessSpecifierManager::qtAccessSpecifierType(const CXXMethodDecl *method) const
{
- if (!method || clazy::getLocStart(method).isMacroID()) {
+ if (!method || method->getBeginLoc().isMacroID()) {
return QtAccessSpecifier_Unknown;
}
@@ -216,7 +216,7 @@ QtAccessSpecifierType AccessSpecifierManager::qtAccessSpecifierType(const CXXMet
return QtAccessSpecifier_None;
}
- const SourceLocation methodLoc = clazy::getLocStart(method);
+ const SourceLocation methodLoc = method->getBeginLoc();
// Process Q_SIGNAL:
for (auto signalLoc : m_preprocessorCallbacks->m_individualSignals) {
@@ -270,7 +270,7 @@ bool AccessSpecifierManager::isScriptable(const CXXMethodDecl *method) const
return false;
}
- const SourceLocation methodLoc = clazy::getLocStart(method);
+ const SourceLocation methodLoc = method->getBeginLoc();
if (methodLoc.isMacroID()) {
return false;
}
diff --git a/src/Clazy.cpp b/src/Clazy.cpp
index c6f71002..00c72706 100644
--- a/src/Clazy.cpp
+++ b/src/Clazy.cpp
@@ -10,7 +10,6 @@
#include "Clazy.h"
#include "AccessSpecifierManager.h"
#include "FixItExporter.h"
-#include "SourceCompatibilityHelpers.h"
#include "Utils.h"
#include "checkbase.h"
#include "clazy_stl.h"
@@ -94,7 +93,7 @@ bool ClazyASTConsumer::VisitDecl(Decl *decl)
}
const bool isTypeDefToVisit = m_context->visitsAllTypedefs() && isa<TypedefNameDecl>(decl);
- const SourceLocation locStart = clazy::getLocStart(decl);
+ const SourceLocation locStart = decl->getBeginLoc();
if (locStart.isInvalid() || (m_context->sm.isInSystemHeader(locStart) && !isTypeDefToVisit)) {
return true;
}
@@ -121,7 +120,7 @@ bool ClazyASTConsumer::VisitDecl(Decl *decl)
bool ClazyASTConsumer::VisitStmt(Stmt *stm)
{
- const SourceLocation locStart = clazy::getLocStart(stm);
+ const SourceLocation locStart = stm->getBeginLoc();
if (locStart.isInvalid() || m_context->sm.isInSystemHeader(locStart)) {
return true;
}
diff --git a/src/ContextUtils.cpp b/src/ContextUtils.cpp
index c7c8c915..5fd20561 100644
--- a/src/ContextUtils.cpp
+++ b/src/ContextUtils.cpp
@@ -78,7 +78,7 @@ std::string clazy::getMostNeededQualifiedName(const SourceManager &sourceManager
for (UsingDirectiveDecl *u : usings) {
NamespaceDecl *ns = u->getNominatedNamespace();
if (ns) {
- if (sourceManager.isBeforeInSLocAddrSpace(usageLoc, clazy::getLocStart(u))) {
+ if (sourceManager.isBeforeInSLocAddrSpace(usageLoc, u->getBeginLoc())) {
continue;
}
diff --git a/src/FixItUtils.cpp b/src/FixItUtils.cpp
index d608a346..390fb9fe 100644
--- a/src/FixItUtils.cpp
+++ b/src/FixItUtils.cpp
@@ -6,7 +6,6 @@
*/
#include "FixItUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include <clang/AST/ASTContext.h>
@@ -51,7 +50,7 @@ SourceRange clazy::rangeForLiteral(const ASTContext *context, StringLiteral *lt)
}
SourceRange range;
- range.setBegin(clazy::getLocStart(lt));
+ range.setBegin(lt->getBeginLoc());
SourceLocation end = Lexer::getLocForEndOfToken(lastTokenLoc,
0,
@@ -114,7 +113,7 @@ SourceLocation clazy::biggestSourceLocationInStmt(const SourceManager &sm, Stmt
return {};
}
- SourceLocation biggestLoc = getLocEnd(stmt);
+ SourceLocation biggestLoc = stmt->getEndLoc();
for (auto *child : stmt->children()) {
SourceLocation candidateLoc = biggestSourceLocationInStmt(sm, child);
@@ -142,14 +141,14 @@ bool clazy::transformTwoCallsIntoOne(const ASTContext *context,
return false;
}
- const SourceLocation start1 = clazy::getLocStart(call1);
+ const SourceLocation start1 = call1->getBeginLoc();
const SourceLocation end1 = clazy::locForEndOfToken(context, start1, -1); // -1 of offset, so we don't need to insert '('
if (end1.isInvalid()) {
return false;
}
- const SourceLocation start2 = getLocEnd(implicitArgument);
- const SourceLocation end2 = getLocEnd(call2);
+ const SourceLocation start2 = implicitArgument->getEndLoc();
+ const SourceLocation end2 = call2->getEndLoc();
if (start2.isInvalid() || end2.isInvalid()) {
return false;
}
@@ -172,9 +171,9 @@ bool clazy::transformTwoCallsIntoOneV2(const ASTContext *context, CXXMemberCallE
return false;
}
- SourceLocation start = clazy::getLocStart(implicitArgument);
+ SourceLocation start = implicitArgument->getBeginLoc();
start = clazy::locForEndOfToken(context, start, 0);
- const SourceLocation end = getLocEnd(call2);
+ const SourceLocation end = call2->getEndLoc();
if (start.isInvalid() || end.isInvalid()) {
return false;
}
@@ -186,7 +185,7 @@ bool clazy::transformTwoCallsIntoOneV2(const ASTContext *context, CXXMemberCallE
FixItHint clazy::fixItReplaceWordWithWord(const ASTContext *context, clang::Stmt *begin, const std::string &replacement, const std::string &replacee)
{
const auto &sm = context->getSourceManager();
- SourceLocation rangeStart = clazy::getLocStart(begin);
+ SourceLocation rangeStart = begin->getBeginLoc();
SourceLocation rangeEnd = Lexer::getLocForEndOfToken(rangeStart, -1, sm, context->getLangOpts());
if (rangeEnd.isInvalid()) {
@@ -205,7 +204,7 @@ FixItHint clazy::fixItReplaceWordWithWord(const ASTContext *context, clang::Stmt
std::vector<FixItHint> clazy::fixItRemoveToken(const ASTContext *context, Stmt *stmt, bool removeParenthesis)
{
- SourceLocation start = clazy::getLocStart(stmt);
+ SourceLocation start = stmt->getBeginLoc();
SourceLocation end = Lexer::getLocForEndOfToken(start, removeParenthesis ? 0 : -1, context->getSourceManager(), context->getLangOpts());
std::vector<FixItHint> fixits;
@@ -215,7 +214,7 @@ std::vector<FixItHint> clazy::fixItRemoveToken(const ASTContext *context, Stmt *
if (removeParenthesis) {
// Remove the last parenthesis
- fixits.push_back(FixItHint::CreateRemoval(SourceRange(clazy::getLocEnd(stmt), clazy::getLocEnd(stmt))));
+ fixits.push_back(FixItHint::CreateRemoval(SourceRange(stmt->getEndLoc(), stmt->getEndLoc())));
}
}
diff --git a/src/HierarchyUtils.h b/src/HierarchyUtils.h
index cc4ba40e..55e82d24 100644
--- a/src/HierarchyUtils.h
+++ b/src/HierarchyUtils.h
@@ -230,7 +230,7 @@ std::vector<T *> getStatements(clang::Stmt *body,
continue; // can happen
}
if (T *childT = clang::dyn_cast<T>(child)) {
- if (!startLocation.isValid() || (sm && sm->isBeforeInSLocAddrSpace(sm->getSpellingLoc(startLocation), clazy::getLocStart(child)))) {
+ if (!startLocation.isValid() || (sm && sm->isBeforeInSLocAddrSpace(sm->getSpellingLoc(startLocation), child->getBeginLoc()))) {
statements.push_back(childT);
}
}
diff --git a/src/LoopUtils.cpp b/src/LoopUtils.cpp
index cd54b563..e15e3d96 100644
--- a/src/LoopUtils.cpp
+++ b/src/LoopUtils.cpp
@@ -8,7 +8,6 @@
*/
#include "LoopUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "clazy_stl.h"
@@ -61,7 +60,7 @@ bool clazy::loopCanBeInterrupted(clang::Stmt *stmt, const clang::SourceManager &
if (isa<ReturnStmt>(stmt) || isa<BreakStmt>(stmt) || isa<ContinueStmt>(stmt)) {
if (onlyBeforeThisLoc.isValid()) {
- FullSourceLoc sourceLoc(clazy::getLocStart(stmt), sm);
+ FullSourceLoc sourceLoc(stmt->getBeginLoc(), sm);
FullSourceLoc otherSourceLoc(onlyBeforeThisLoc, sm);
if (sourceLoc.isBeforeInTranslationUnitThan(otherSourceLoc)) {
return true;
diff --git a/src/LoopUtils.h b/src/LoopUtils.h
index dc73180f..2105d83e 100644
--- a/src/LoopUtils.h
+++ b/src/LoopUtils.h
@@ -10,8 +10,6 @@
#ifndef CLAZY_LOOP_UTILS_H
#define CLAZY_LOOP_UTILS_H
-#include "clazy_stl.h"
-
#include <clang/AST/Stmt.h>
#include <clang/AST/StmtCXX.h>
#include <llvm/Support/Casting.h>
diff --git a/src/MiniAstDumper.h b/src/MiniAstDumper.h
index bc24c7ec..5ffcaf74 100644
--- a/src/MiniAstDumper.h
+++ b/src/MiniAstDumper.h
@@ -15,7 +15,6 @@
#include <memory>
#include <string>
-#include <utility>
#include <vector>
namespace clang
diff --git a/src/NormalizedSignatureUtils.h b/src/NormalizedSignatureUtils.h
index a5a09826..aa5c8810 100644
--- a/src/NormalizedSignatureUtils.h
+++ b/src/NormalizedSignatureUtils.h
@@ -14,7 +14,6 @@ SPDX-License-Identifier: LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR LGPL-3.0-on
#define CLAZY_NORMALIZED_SIGNATURE_UTILS_H
#include <string>
-#include <vector>
namespace clazy
{
diff --git a/src/SourceCompatibilityHelpers.h b/src/SourceCompatibilityHelpers.h
index d02c06e8..c19e4ab9 100644
--- a/src/SourceCompatibilityHelpers.h
+++ b/src/SourceCompatibilityHelpers.h
@@ -19,25 +19,6 @@
namespace clazy
{
-template<typename T>
-inline clang::SourceLocation getLocStart(const T *t)
-{
-#if LLVM_VERSION_MAJOR >= 8
- return t->getBeginLoc();
-#else
- return t->getLocStart();
-#endif
-}
-
-template<typename T>
-inline clang::SourceLocation getLocEnd(const T *t)
-{
-#if LLVM_VERSION_MAJOR >= 8
- return t->getEndLoc();
-#else
- return t->getLocEnd();
-#endif
-}
inline bool hasUnusedResultAttr(clang::FunctionDecl *func)
{
diff --git a/src/StmtBodyRange.h b/src/StmtBodyRange.h
index b332e7c3..6fb8aad2 100644
--- a/src/StmtBodyRange.h
+++ b/src/StmtBodyRange.h
@@ -30,7 +30,7 @@ struct StmtBodyRange {
bool isOutsideRange(clang::Stmt *stmt) const
{
- return isOutsideRange(stmt ? clazy::getLocStart(stmt) : clang::SourceLocation());
+ return isOutsideRange(stmt ? stmt->getBeginLoc() : clang::SourceLocation());
}
bool isOutsideRange(clang::SourceLocation loc) const
diff --git a/src/StringUtils.h b/src/StringUtils.h
index ca680df2..c99a3af3 100644
--- a/src/StringUtils.h
+++ b/src/StringUtils.h
@@ -10,7 +10,6 @@
#ifndef CLANG_LAZY_STRING_UTILS_H
#define CLANG_LAZY_STRING_UTILS_H
-#include "SourceCompatibilityHelpers.h"
#include "Utils.h"
#include "clazy_stl.h"
@@ -189,7 +188,7 @@ inline void printRange(const clang::SourceManager &sm, clang::SourceRange range,
inline void printLocation(const clang::SourceManager &sm, const clang::Stmt *s, bool newLine = true)
{
if (s) {
- printLocation(sm, clazy::getLocStart(s), newLine);
+ printLocation(sm, s->getBeginLoc(), newLine);
}
}
@@ -315,7 +314,7 @@ inline void dump(const clang::SourceManager &sm, clang::Stmt *s)
return;
}
- llvm::errs() << "Start=" << getLocStart(s).printToString(sm) << "; end=" << getLocStart(s).printToString(sm) << "\n";
+ llvm::errs() << "Start=" << s->getBeginLoc().printToString(sm) << "; end=" << s->getBeginLoc().printToString(sm) << "\n";
for (auto *child : s->children()) {
dump(sm, child);
diff --git a/src/SuppressionManager.cpp b/src/SuppressionManager.cpp
index 51c2c698..ea37c2db 100644
--- a/src/SuppressionManager.cpp
+++ b/src/SuppressionManager.cpp
@@ -15,6 +15,7 @@
#include <llvm/Support/MemoryBuffer.h>
#include <llvm/Support/raw_ostream.h>
+#include <regex>
#include <vector>
using namespace clang;
diff --git a/src/Utils.h b/src/Utils.h
index 5fc88138..82daa866 100644
--- a/src/Utils.h
+++ b/src/Utils.h
@@ -8,8 +8,6 @@
#ifndef MOREWARNINGS_UTILS_H
#define MOREWARNINGS_UTILS_H
-#include "SourceCompatibilityHelpers.h"
-
#include <clang/AST/DeclCXX.h>
#include <clang/AST/DeclTemplate.h>
#include <clang/AST/Expr.h>
@@ -21,7 +19,6 @@
#include <llvm/ADT/StringRef.h>
#include <llvm/Config/llvm-config.h>
-#include <map>
#include <string>
#include <vector>
diff --git a/src/checkbase.cpp b/src/checkbase.cpp
index 60f7fc4b..6531f7e0 100644
--- a/src/checkbase.cpp
+++ b/src/checkbase.cpp
@@ -211,12 +211,12 @@ bool CheckBase::shouldIgnoreFile(SourceLocation loc) const
void CheckBase::emitWarning(const clang::Decl *d, const std::string &error, bool printWarningTag)
{
- emitWarning(clazy::getLocStart(d), error, printWarningTag);
+ emitWarning(d->getBeginLoc(), error, printWarningTag);
}
void CheckBase::emitWarning(const clang::Stmt *s, const std::string &error, bool printWarningTag)
{
- emitWarning(clazy::getLocStart(s), error, printWarningTag);
+ emitWarning(s->getBeginLoc(), error, printWarningTag);
}
void CheckBase::emitWarning(clang::SourceLocation loc, const std::string &error, bool printWarningTag)
diff --git a/src/checkmanager.cpp b/src/checkmanager.cpp
index b3fa88b3..f5b969ff 100644
--- a/src/checkmanager.cpp
+++ b/src/checkmanager.cpp
@@ -17,7 +17,6 @@
#include <algorithm>
#include <assert.h>
#include <iterator>
-#include <memory>
#include <stdlib.h>
#include <string.h>
diff --git a/src/checks/detachingbase.cpp b/src/checks/detachingbase.cpp
index ec670847..75fbf29d 100644
--- a/src/checks/detachingbase.cpp
+++ b/src/checks/detachingbase.cpp
@@ -16,7 +16,6 @@
#include <llvm/ADT/StringRef.h>
#include <unordered_map>
-#include <utility>
#include <vector>
class ClazyContext;
diff --git a/src/checks/detachingbase.h b/src/checks/detachingbase.h
index 2df5782c..bae814d0 100644
--- a/src/checks/detachingbase.h
+++ b/src/checks/detachingbase.h
@@ -12,9 +12,7 @@
#include "checkbase.h"
-#include <map>
#include <string>
-#include <vector>
class ClazyContext;
diff --git a/src/checks/level0/connect-non-signal.cpp b/src/checks/level0/connect-non-signal.cpp
index 5f172c2d..04f9f7e8 100644
--- a/src/checks/level0/connect-non-signal.cpp
+++ b/src/checks/level0/connect-non-signal.cpp
@@ -9,7 +9,6 @@
#include "AccessSpecifierManager.h"
#include "ClazyContext.h"
#include "QtUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include <clang/AST/Decl.h>
#include <clang/AST/DeclCXX.h>
@@ -43,7 +42,7 @@ void ConnectNonSignal::VisitStmt(clang::Stmt *stmt)
if (clazy::isQMetaMethod(call, 1)) {
return;
}
- emitWarning(clazy::getLocStart(call), "couldn't find method from pmf connect, please report a bug");
+ emitWarning(call->getBeginLoc(), "couldn't find method from pmf connect, please report a bug");
return;
}
diff --git a/src/checks/level0/connect-not-normalized.cpp b/src/checks/level0/connect-not-normalized.cpp
index a3e7cc24..e700ee44 100644
--- a/src/checks/level0/connect-not-normalized.cpp
+++ b/src/checks/level0/connect-not-normalized.cpp
@@ -9,7 +9,6 @@
#include "ClazyContext.h"
#include "HierarchyUtils.h"
#include "NormalizedSignatureUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include <clang/AST/Decl.h>
@@ -120,6 +119,6 @@ bool ConnectNotNormalized::handleConnect(CallExpr *callExpr)
normalized.erase(0, 1);
original.erase(0, 1);
- emitWarning(clazy::getLocStart(callExpr), "Signature is not normalized. Use " + normalized + " instead of " + original);
+ emitWarning(callExpr->getBeginLoc(), "Signature is not normalized. Use " + normalized + " instead of " + original);
return true;
}
diff --git a/src/checks/level0/container-anti-pattern.cpp b/src/checks/level0/container-anti-pattern.cpp
index 46f2ded4..c83a522b 100644
--- a/src/checks/level0/container-anti-pattern.cpp
+++ b/src/checks/level0/container-anti-pattern.cpp
@@ -7,7 +7,6 @@
#include "container-anti-pattern.h"
#include "HierarchyUtils.h"
#include "LoopUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "Utils.h"
#include "clazy_stl.h"
@@ -76,7 +75,7 @@ void ContainerAntiPattern::VisitStmt(clang::Stmt *stmt)
return;
}
- emitWarning(clazy::getLocStart(stmt), "allocating an unneeded temporary container");
+ emitWarning(stmt->getBeginLoc(), "allocating an unneeded temporary container");
}
bool ContainerAntiPattern::VisitQSet(Stmt *stmt)
@@ -108,7 +107,7 @@ bool ContainerAntiPattern::VisitQSet(Stmt *stmt)
return false;
}
- emitWarning(clazy::getLocStart(stmt), "Use QSet::intersects() instead");
+ emitWarning(stmt->getBeginLoc(), "Use QSet::intersects() instead");
return true;
}
@@ -121,7 +120,7 @@ bool ContainerAntiPattern::handleLoop(Stmt *stm)
auto *memberExpr = clazy::getFirstChildOfType2<CXXMemberCallExpr>(containerExpr);
if (isInterestingCall(memberExpr)) {
- emitWarning(clazy::getLocStart(stm), "allocating an unneeded temporary container");
+ emitWarning(stm->getBeginLoc(), "allocating an unneeded temporary container");
return true;
}
diff --git a/src/checks/level0/empty-qstringliteral.cpp b/src/checks/level0/empty-qstringliteral.cpp
index 8dfc9244..3c48cff7 100644
--- a/src/checks/level0/empty-qstringliteral.cpp
+++ b/src/checks/level0/empty-qstringliteral.cpp
@@ -9,8 +9,6 @@
#include "HierarchyUtils.h"
#include "PreProcessorVisitor.h"
#include "QtUtils.h"
-#include "SourceCompatibilityHelpers.h"
-#include "StringUtils.h"
#include <clang/AST/Decl.h>
#include <clang/AST/Expr.h>
@@ -30,11 +28,11 @@ EmptyQStringliteral::EmptyQStringliteral(const std::string &name, ClazyContext *
void EmptyQStringliteral::VisitStmt(clang::Stmt *stmt)
{
- if (!clazy::getLocStart(stmt).isMacroID()) {
+ if (!stmt->getBeginLoc().isMacroID()) {
return;
}
- const std::string filepath = static_cast<std::string>(sm().getFilename(sm().getExpansionLoc(clazy::getLocStart(stmt))));
+ const std::string filepath = static_cast<std::string>(sm().getFilename(sm().getExpansionLoc(stmt->getBeginLoc())));
if (clazy::contains(filepath, ".rcc/qmlcache/")) {
return; // This is an autogenerated file
}
diff --git a/src/checks/level0/fully-qualified-moc-types.cpp b/src/checks/level0/fully-qualified-moc-types.cpp
index d95c4b27..19c3cf65 100644
--- a/src/checks/level0/fully-qualified-moc-types.cpp
+++ b/src/checks/level0/fully-qualified-moc-types.cpp
@@ -9,7 +9,6 @@
#include "AccessSpecifierManager.h"
#include "ClazyContext.h"
#include "HierarchyUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "TypeUtils.h"
@@ -158,13 +157,13 @@ bool FullyQualifiedMocTypes::typeIsFullyQualified(QualType t, std::string &quali
bool FullyQualifiedMocTypes::isGadget(CXXRecordDecl *record) const
{
- SourceLocation startLoc = clazy::getLocStart(record);
+ SourceLocation startLoc = record->getBeginLoc();
for (const SourceLocation &loc : m_qgadgetMacroLocations) {
if (sm().getFileID(loc) != sm().getFileID(startLoc)) {
continue; // Different file
}
- if (sm().isBeforeInSLocAddrSpace(startLoc, loc) && sm().isBeforeInSLocAddrSpace(loc, clazy::getLocEnd(record))) {
+ if (sm().isBeforeInSLocAddrSpace(startLoc, loc) && sm().isBeforeInSLocAddrSpace(loc, record->getEndLoc())) {
return true; // We found a Q_GADGET after start and before end, it's ours.
}
}
@@ -211,7 +210,7 @@ bool FullyQualifiedMocTypes::handleQ_PROPERTY(CXXMethodDecl *method)
if (!typeIsFullyQualified(qt, qualifiedName, nameAsWritten)) {
// warn in the cxxrecorddecl, since we don't want to warn in the .moc files.
// Ideally we would do some cross checking with the Q_PROPERTIES, but that's not in the AST
- emitWarning(clazy::getLocStart(method->getParent()),
+ emitWarning(method->getParent()->getBeginLoc(),
"Q_PROPERTY of type " + nameAsWritten + " should use full qualification (" + qualifiedName + ")");
}
}
diff --git a/src/checks/level0/mutable-container-key.cpp b/src/checks/level0/mutable-container-key.cpp
index de6d76b0..77a79441 100644
--- a/src/checks/level0/mutable-container-key.cpp
+++ b/src/checks/level0/mutable-container-key.cpp
@@ -5,7 +5,6 @@
*/
#include "mutable-container-key.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "Utils.h"
#include "clazy_stl.h"
@@ -56,5 +55,5 @@ void MutableContainerKey::VisitDecl(clang::Decl *decl)
return;
}
- emitWarning(clazy::getLocStart(decl), "Associative container key might be modified externally");
+ emitWarning(decl->getBeginLoc(), "Associative container key might be modified externally");
}
diff --git a/src/checks/level0/overloaded-signal.cpp b/src/checks/level0/overloaded-signal.cpp
index b7f2fbe0..0674140f 100644
--- a/src/checks/level0/overloaded-signal.cpp
+++ b/src/checks/level0/overloaded-signal.cpp
@@ -51,7 +51,7 @@ void OverloadedSignal::VisitDecl(clang::Decl *decl)
emitWarning(decl, "signal " + methodName.str() + " is overloaded");
continue; // No point in spitting more warnings for the same signal
}
- emitWarning(decl, "signal " + methodName.str() + " is overloaded (with " + clazy::getLocStart(p).printToString(sm()) + ")");
+ emitWarning(decl, "signal " + methodName.str() + " is overloaded (with " + p->getBeginLoc().printToString(sm()) + ")");
}
}
}
diff --git a/src/checks/level0/qcolor-from-literal.cpp b/src/checks/level0/qcolor-from-literal.cpp
index 79a078bc..c9370e86 100644
--- a/src/checks/level0/qcolor-from-literal.cpp
+++ b/src/checks/level0/qcolor-from-literal.cpp
@@ -84,13 +84,13 @@ public:
const bool doubleDigit = isDoubleDigitRgb(str);
const bool doubleDigitA = isDoubleDigitRgba(str);
if (bool isAnyValidPattern = singleDigit || doubleDigit || doubleDigitA || isTripleDigitRgb(str) || isQuadrupleDigitRgb(str); !isAnyValidPattern) {
- m_check->emitWarning(clazy::getLocStart(replaceExpr), "Pattern length does not match any supported one by QColor, check the documentation");
+ m_check->emitWarning(replaceExpr->getBeginLoc(), "Pattern length does not match any supported one by QColor, check the documentation");
return;
}
for (unsigned int i = 1; i < str.size(); ++i) {
if (!isxdigit(str[i])) {
- m_check->emitWarning(clazy::getLocStart(replaceExpr), "QColor pattern may only contain hexadecimal digits");
+ m_check->emitWarning(replaceExpr->getBeginLoc(), "QColor pattern may only contain hexadecimal digits");
return;
}
}
@@ -118,10 +118,10 @@ public:
if (isStaticFromString) {
fixit = "QColor(" + fixit + ")";
}
- m_check->emitWarning(clazy::getLocStart(replaceExpr), message, {clang::FixItHint::CreateReplacement(replaceExpr->getSourceRange(), fixit)});
+ m_check->emitWarning(replaceExpr->getBeginLoc(), message, {clang::FixItHint::CreateReplacement(replaceExpr->getSourceRange(), fixit)});
} else {
// triple or quadruple digit RGBA
- m_check->emitWarning(clazy::getLocStart(replaceExpr), "The QColor ctor taking QRgba64 is cheaper than one taking string literals");
+ m_check->emitWarning(replaceExpr->getBeginLoc(), "The QColor ctor taking QRgba64 is cheaper than one taking string literals");
}
}
inline std::string twoDigit(const std::string &in)
diff --git a/src/checks/level0/qdatetime-utc.cpp b/src/checks/level0/qdatetime-utc.cpp
index 3815d776..bed67979 100644
--- a/src/checks/level0/qdatetime-utc.cpp
+++ b/src/checks/level0/qdatetime-utc.cpp
@@ -10,7 +10,6 @@
#include "qdatetime-utc.h"
#include "FixItUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "Utils.h"
#include <clang/AST/Decl.h>
@@ -75,8 +74,8 @@ void QDateTimeUtc::VisitStmt(clang::Stmt *stmt)
std::vector<FixItHint> fixits;
const bool success = clazy::transformTwoCallsIntoOneV2(&m_astContext, secondCall, replacement, fixits);
if (!success) {
- queueManualFixitWarning(clazy::getLocStart(secondCall));
+ queueManualFixitWarning(secondCall->getBeginLoc());
}
- emitWarning(clazy::getLocStart(stmt), "Use QDateTime" + replacement + " instead. It is significantly faster", fixits);
+ emitWarning(stmt->getBeginLoc(), "Use QDateTime" + replacement + " instead. It is significantly faster", fixits);
}
diff --git a/src/checks/level0/qfileinfo-exists.cpp b/src/checks/level0/qfileinfo-exists.cpp
index 16996347..18940577 100644
--- a/src/checks/level0/qfileinfo-exists.cpp
+++ b/src/checks/level0/qfileinfo-exists.cpp
@@ -7,7 +7,6 @@
#include "qfileinfo-exists.h"
#include "HierarchyUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include <clang/AST/DeclCXX.h>
@@ -39,7 +38,7 @@ void QFileInfoExists::VisitStmt(clang::Stmt *stmt)
}
std::string userArgText = Lexer::getSourceText(CharSourceRange::getTokenRange(ctorExpr->getArg(0)->getSourceRange()), sm(), lo()).str();
- emitWarning(clazy::getLocStart(stmt),
+ emitWarning(stmt->getBeginLoc(),
"Use the static QFileInfo::exists() instead. It's documented to be faster.",
{clang::FixItHint::CreateReplacement(stmt->getSourceRange(), "QFileInfo::exists(" + userArgText + ")")});
}
diff --git a/src/checks/level0/qgetenv.cpp b/src/checks/level0/qgetenv.cpp
index 91a8d8bd..43d9fe8c 100644
--- a/src/checks/level0/qgetenv.cpp
+++ b/src/checks/level0/qgetenv.cpp
@@ -9,7 +9,6 @@
#include "qgetenv.h"
#include "FixItUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "Utils.h"
@@ -108,5 +107,5 @@ void QGetEnv::VisitStmt(clang::Stmt *stmt)
if (changesToBaseAutodetection) {
errorMsg += ". This uses internally a base of 0, supporting decimal, hex and octal values";
}
- emitWarning(clazy::getLocStart(memberCall), errorMsg, {FixItHint::CreateReplacement(stmt->getSourceRange(), replacement + "(" + getEnvArgStr + ")")});
+ emitWarning(memberCall->getBeginLoc(), errorMsg, {FixItHint::CreateReplacement(stmt->getSourceRange(), replacement + "(" + getEnvArgStr + ")")});
}
diff --git a/src/checks/level0/qmap-with-pointer-key.cpp b/src/checks/level0/qmap-with-pointer-key.cpp
index 4abde4ac..09c28ab9 100644
--- a/src/checks/level0/qmap-with-pointer-key.cpp
+++ b/src/checks/level0/qmap-with-pointer-key.cpp
@@ -8,7 +8,6 @@
*/
#include "qmap-with-pointer-key.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "Utils.h"
@@ -42,6 +41,6 @@ void QMapWithPointerKey::VisitDecl(clang::Decl *decl)
QualType qt = templateArguments[0].getAsType();
const Type *t = qt.getTypePtrOrNull();
if (t && t->isPointerType()) {
- emitWarning(clazy::getLocStart(decl), "Use QHash<K,T> instead of QMap<K,T> when K is a pointer");
+ emitWarning(decl->getBeginLoc(), "Use QHash<K,T> instead of QMap<K,T> when K is a pointer");
}
}
diff --git a/src/checks/level0/qstring-arg.cpp b/src/checks/level0/qstring-arg.cpp
index 5d8f66d3..98b3a663 100644
--- a/src/checks/level0/qstring-arg.cpp
+++ b/src/checks/level0/qstring-arg.cpp
@@ -99,7 +99,7 @@ bool QStringArg::checkMultiArgWarningCase(const std::vector<clang::CallExpr *> &
for (int i = 1; i < size; ++i) {
auto *call = calls.at(i);
if (calls.at(i - 1)->getNumArgs() + call->getNumArgs() <= 9) {
- emitWarning(clazy::getLocEnd(call), "Use multi-arg instead");
+ emitWarning(call->getEndLoc(), "Use multi-arg instead");
return true;
}
}
@@ -113,8 +113,8 @@ void QStringArg::checkForMultiArgOpportunities(CXXMemberCallExpr *memberCall)
return;
}
- if (clazy::getLocStart(memberCall).isMacroID()) {
- auto macroName = Lexer::getImmediateMacroName(clazy::getLocStart(memberCall), sm(), lo());
+ if (memberCall->getBeginLoc().isMacroID()) {
+ auto macroName = Lexer::getImmediateMacroName(memberCall->getBeginLoc(), sm(), lo());
if (macroName == "QT_REQUIRE_VERSION") { // bug #391851
return;
}
@@ -170,7 +170,7 @@ void QStringArg::VisitStmt(clang::Stmt *stmt)
return;
}
- if (shouldIgnoreFile(clazy::getLocStart(stmt))) {
+ if (shouldIgnoreFile(stmt->getBeginLoc())) {
return;
}
@@ -226,6 +226,6 @@ void QStringArg::VisitStmt(clang::Stmt *stmt)
}
}
- emitWarning(clazy::getLocStart(stmt), "Using QString::arg() with fillChar overload");
+ emitWarning(stmt->getBeginLoc(), "Using QString::arg() with fillChar overload");
}
}
diff --git a/src/checks/level0/qstring-insensitive-allocation.cpp b/src/checks/level0/qstring-insensitive-allocation.cpp
index a19e9fe4..0cb2b402 100644
--- a/src/checks/level0/qstring-insensitive-allocation.cpp
+++ b/src/checks/level0/qstring-insensitive-allocation.cpp
@@ -66,5 +66,5 @@ void QStringInsensitiveAllocation::VisitStmt(clang::Stmt *stmt)
return;
}
- emitWarning(clazy::getLocStart(stmt), "unneeded allocation");
+ emitWarning(stmt->getBeginLoc(), "unneeded allocation");
}
diff --git a/src/checks/level0/qstring-ref.cpp b/src/checks/level0/qstring-ref.cpp
index 6f04194e..92d703e4 100644
--- a/src/checks/level0/qstring-ref.cpp
+++ b/src/checks/level0/qstring-ref.cpp
@@ -196,7 +196,7 @@ bool StringRefCandidates::processCase1(CXXMemberCallExpr *memberCall)
const std::string firstMethodName = firstMemberCall->getMethodDecl()->getNameAsString();
const std::vector<FixItHint> fixits = fixit(firstMemberCall);
- emitWarning(clazy::getLocEnd(firstMemberCall), "Use " + firstMethodName + "Ref() instead", fixits);
+ emitWarning(firstMemberCall->getEndLoc(), "Use " + firstMethodName + "Ref() instead", fixits);
return true;
}
@@ -241,7 +241,7 @@ bool StringRefCandidates::processCase2(CallExpr *call)
const std::vector<FixItHint> fixits = fixit(innerMemberCall);
- emitWarning(clazy::getLocStart(call), "Use " + innerMethod->getNameAsString() + "Ref() instead", fixits);
+ emitWarning(call->getBeginLoc(), "Use " + innerMethod->getNameAsString() + "Ref() instead", fixits);
return true;
}
@@ -249,14 +249,14 @@ std::vector<FixItHint> StringRefCandidates::fixit(CXXMemberCallExpr *call)
{
auto *memberExpr = clazy::getFirstChildOfType<MemberExpr>(call);
if (!memberExpr) {
- queueManualFixitWarning(clazy::getLocStart(call), "Internal error 1");
+ queueManualFixitWarning(call->getBeginLoc(), "Internal error 1");
return {};
}
- auto insertionLoc = Lexer::getLocForEndOfToken(clazy::getLocEnd(memberExpr), 0, sm(), lo());
+ auto insertionLoc = Lexer::getLocForEndOfToken(memberExpr->getEndLoc(), 0, sm(), lo());
// llvm::errs() << insertionLoc.printToString(sm()) << "\n";
if (!insertionLoc.isValid()) {
- queueManualFixitWarning(clazy::getLocStart(call), "Internal error 2");
+ queueManualFixitWarning(call->getBeginLoc(), "Internal error 2");
return {};
}
diff --git a/src/checks/level0/temporary-iterator.cpp b/src/checks/level0/temporary-iterator.cpp
index a53b9e22..bf6451a0 100644
--- a/src/checks/level0/temporary-iterator.cpp
+++ b/src/checks/level0/temporary-iterator.cpp
@@ -148,5 +148,5 @@ void TemporaryIterator::VisitStmt(clang::Stmt *stm)
// llvm::errs() << "Expression: " << expr->getStmtClassName() << "\n";
std::string error = "Don't call " + clazy::qualifiedMethodName(methodDecl) + "() on temporary";
- emitWarning(clazy::getLocStart(stm), error);
+ emitWarning(stm->getBeginLoc(), error);
}
diff --git a/src/checks/level0/unused-non-trivial-variable.cpp b/src/checks/level0/unused-non-trivial-variable.cpp
index 47dda5ab..9b0045f8 100644
--- a/src/checks/level0/unused-non-trivial-variable.cpp
+++ b/src/checks/level0/unused-non-trivial-variable.cpp
@@ -211,7 +211,7 @@ void UnusedNonTrivialVariable::handleVarDecl(VarDecl *varDecl)
return;
}
- SourceLocation locStart = clazy::getLocStart(varDecl);
+ SourceLocation locStart = varDecl->getBeginLoc();
locStart = sm().getExpansionLoc(locStart);
auto declRefs = clazy::getStatements<DeclRefExpr>(body, &sm(), locStart);
diff --git a/src/checks/level0/use-static-qregularexpression.cpp b/src/checks/level0/use-static-qregularexpression.cpp
index cf3a15c4..15d59539 100644
--- a/src/checks/level0/use-static-qregularexpression.cpp
+++ b/src/checks/level0/use-static-qregularexpression.cpp
@@ -193,7 +193,7 @@ void UseStaticQRegularExpression::VisitStmt(clang::Stmt *stmt)
if (obj->isLValue()) {
if (isArgNonStaticLocalVar(obj, lo())) {
- emitWarning(clazy::getLocStart(obj), "Don't create temporary QRegularExpression objects. Use a static QRegularExpression object instead");
+ emitWarning(obj->getBeginLoc(), "Don't create temporary QRegularExpression objects. Use a static QRegularExpression object instead");
return;
}
} else if (obj->isXValue()) {
@@ -203,7 +203,7 @@ void UseStaticQRegularExpression::VisitStmt(clang::Stmt *stmt)
return;
}
if (isTemporaryQRegexObj(temp, lo())) {
- emitWarning(clazy::getLocStart(temp), "Don't create temporary QRegularExpression objects. Use a static QRegularExpression object instead");
+ emitWarning(temp->getBeginLoc(), "Don't create temporary QRegularExpression objects. Use a static QRegularExpression object instead");
}
}
return;
@@ -221,12 +221,12 @@ void UseStaticQRegularExpression::VisitStmt(clang::Stmt *stmt)
// Its a QString*().method(QRegularExpression(arg)) ?
if (auto *temp = isArgTemporaryObj(qregexArg)) {
if (isTemporaryQRegexObj(temp, lo())) {
- emitWarning(clazy::getLocStart(qregexArg), "Don't create temporary QRegularExpression objects. Use a static QRegularExpression object instead");
+ emitWarning(qregexArg->getBeginLoc(), "Don't create temporary QRegularExpression objects. Use a static QRegularExpression object instead");
}
}
// Its a local QRegularExpression variable?
if (isArgNonStaticLocalVar(qregexArg, lo())) {
- emitWarning(clazy::getLocStart(qregexArg), "Don't create temporary QRegularExpression objects. Use a static QRegularExpression object instead");
+ emitWarning(qregexArg->getBeginLoc(), "Don't create temporary QRegularExpression objects. Use a static QRegularExpression object instead");
}
}
diff --git a/src/checks/level0/writing-to-temporary.cpp b/src/checks/level0/writing-to-temporary.cpp
index d01f9bcf..70fcbb83 100644
--- a/src/checks/level0/writing-to-temporary.cpp
+++ b/src/checks/level0/writing-to-temporary.cpp
@@ -8,7 +8,6 @@
*/
#include "writing-to-temporary.h"
-#include "SourceCompatibilityHelpers.h"
#include "Utils.h"
#include "clazy_stl.h"
@@ -62,7 +61,7 @@ void WritingToTemporary::VisitStmt(clang::Stmt *stmt)
return;
}
- if (shouldIgnoreFile(clazy::getLocStart(stmt))) {
+ if (shouldIgnoreFile(stmt->getBeginLoc())) {
return;
}
@@ -115,5 +114,5 @@ void WritingToTemporary::VisitStmt(clang::Stmt *stmt)
return;
}
- emitWarning(clazy::getLocStart(stmt), "Call to temporary is a no-op: " + methodName);
+ emitWarning(stmt->getBeginLoc(), "Call to temporary is a no-op: " + methodName);
}
diff --git a/src/checks/level0/wrong-qglobalstatic.cpp b/src/checks/level0/wrong-qglobalstatic.cpp
index b51a4e14..cb134791 100644
--- a/src/checks/level0/wrong-qglobalstatic.cpp
+++ b/src/checks/level0/wrong-qglobalstatic.cpp
@@ -46,7 +46,7 @@ void WrongQGlobalStatic::VisitStmt(clang::Stmt *stmt)
return; // Only consider relevant Qt5 and Qt6 ctors
}
- SourceLocation loc = clazy::getLocStart(stmt);
+ SourceLocation loc = stmt->getBeginLoc();
if (clazy::isInMacro(&m_astContext, loc, "Q_GLOBAL_STATIC_WITH_ARGS")) {
return;
}
diff --git a/src/checks/level1/auto-unexpected-qstringbuilder.cpp b/src/checks/level1/auto-unexpected-qstringbuilder.cpp
index ea465e51..ec2f2865 100644
--- a/src/checks/level1/auto-unexpected-qstringbuilder.cpp
+++ b/src/checks/level1/auto-unexpected-qstringbuilder.cpp
@@ -59,12 +59,12 @@ void AutoUnexpectedQStringBuilder::VisitDecl(Decl *decl)
replacement = "const " + replacement;
}
- SourceLocation start = clazy::getLocStart(varDecl);
+ SourceLocation start = varDecl->getBeginLoc();
SourceLocation end = varDecl->getLocation();
std::vector<FixItHint> fixits;
fixits.push_back(clazy::createReplacement({start, end}, replacement));
- emitWarning(clazy::getLocStart(decl), "auto deduced to be QStringBuilder instead of QString. Possible crash.", fixits);
+ emitWarning(decl->getBeginLoc(), "auto deduced to be QStringBuilder instead of QString. Possible crash.", fixits);
}
void AutoUnexpectedQStringBuilder::VisitStmt(Stmt *stmt)
@@ -79,5 +79,5 @@ void AutoUnexpectedQStringBuilder::VisitStmt(Stmt *stmt)
return;
}
- emitWarning(clazy::getLocStart(stmt), "lambda return type deduced to be QStringBuilder instead of QString. Possible crash.");
+ emitWarning(stmt->getBeginLoc(), "lambda return type deduced to be QStringBuilder instead of QString. Possible crash.");
}
diff --git a/src/checks/level1/detaching-temporary.cpp b/src/checks/level1/detaching-temporary.cpp
index d23c5ed2..f07acbd8 100644
--- a/src/checks/level1/detaching-temporary.cpp
+++ b/src/checks/level1/detaching-temporary.cpp
@@ -177,7 +177,7 @@ void DetachingTemporary::VisitStmt(clang::Stmt *stm)
}
if (!error.empty()) {
- emitWarning(clazy::getLocStart(stm), error);
+ emitWarning(stm->getBeginLoc(), error);
}
}
diff --git a/src/checks/level1/foreach.cpp b/src/checks/level1/foreach.cpp
index ed01c6ce..2527ff71 100644
--- a/src/checks/level1/foreach.cpp
+++ b/src/checks/level1/foreach.cpp
@@ -99,14 +99,14 @@ void Foreach::VisitStmt(clang::Stmt *stmt)
StringRef containerClassName = clazy::name(rootBaseClass);
const bool isQtContainer = clazy::isQtIterableClass(containerClassName);
if (containerClassName.empty()) {
- emitWarning(clazy::getLocStart(stmt), "internal error, couldn't get class name of foreach container, please report a bug");
+ emitWarning(stmt->getBeginLoc(), "internal error, couldn't get class name of foreach container, please report a bug");
return;
}
if (!isQtContainer) {
- emitWarning(clazy::getLocStart(stmt), "foreach with STL container causes deep-copy (" + rootBaseClass->getQualifiedNameAsString() + ')');
+ emitWarning(stmt->getBeginLoc(), "foreach with STL container causes deep-copy (" + rootBaseClass->getQualifiedNameAsString() + ')');
return;
} else if (containerClassName == "QVarLengthArray") {
- emitWarning(clazy::getLocStart(stmt), "foreach with QVarLengthArray causes deep-copy");
+ emitWarning(stmt->getBeginLoc(), "foreach with QVarLengthArray causes deep-copy");
return;
}
@@ -123,7 +123,7 @@ void Foreach::VisitStmt(clang::Stmt *stmt)
// Now look inside the for statement for detachments
if (containsDetachments(m_lastForStmt, valueDecl)) {
- emitWarning(clazy::getLocStart(stmt), "foreach container detached");
+ emitWarning(stmt->getBeginLoc(), "foreach container detached");
}
}
@@ -169,7 +169,7 @@ void Foreach::checkBigTypeMissingRef()
return;
}
- emitWarning(clazy::getLocStart(varDecl), error);
+ emitWarning(varDecl->getBeginLoc(), error);
}
}
diff --git a/src/checks/level1/incorrect-emit.cpp b/src/checks/level1/incorrect-emit.cpp
index a3ba3381..1ea00667 100644
--- a/src/checks/level1/incorrect-emit.cpp
+++ b/src/checks/level1/incorrect-emit.cpp
@@ -61,7 +61,7 @@ void IncorrectEmit::VisitStmt(Stmt *stmt)
return;
}
- if (shouldIgnoreFile(clazy::getLocStart(stmt))) {
+ if (shouldIgnoreFile(stmt->getBeginLoc())) {
return;
}
@@ -112,12 +112,12 @@ void IncorrectEmit::checkCallSignalInsideCTOR(CXXMemberCallExpr *callExpr)
return; // Emit is inside a lambda, it's fine
}
- emitWarning(clazy::getLocStart(callExpr), "Emitting inside constructor probably has no effect");
+ emitWarning(callExpr->getBeginLoc(), "Emitting inside constructor probably has no effect");
}
bool IncorrectEmit::hasEmitKeyboard(CXXMemberCallExpr *call) const
{
- SourceLocation callLoc = clazy::getLocStart(call);
+ SourceLocation callLoc = call->getBeginLoc();
if (callLoc.isMacroID()) {
callLoc = sm().getFileLoc(callLoc);
}
diff --git a/src/checks/level1/non-pod-global-static.cpp b/src/checks/level1/non-pod-global-static.cpp
index 9dc94e0b..f2781ecb 100644
--- a/src/checks/level1/non-pod-global-static.cpp
+++ b/src/checks/level1/non-pod-global-static.cpp
@@ -49,7 +49,7 @@ void NonPodGlobalStatic::VisitStmt(clang::Stmt *stm)
return;
}
- if (shouldIgnoreFile(clazy::getLocStart(stm))) {
+ if (shouldIgnoreFile(stm->getBeginLoc())) {
return;
}
@@ -58,7 +58,7 @@ void NonPodGlobalStatic::VisitStmt(clang::Stmt *stm)
return;
}
- const SourceLocation declStart = clazy::getLocStart(varDecl);
+ const SourceLocation declStart = varDecl->getBeginLoc();
if (declStart.isMacroID()) {
auto macroName = static_cast<std::string>(Lexer::getImmediateMacroName(declStart, sm(), lo()));
diff --git a/src/checks/level1/qdeleteall.cpp b/src/checks/level1/qdeleteall.cpp
index 626306d6..40ff5bb4 100644
--- a/src/checks/level1/qdeleteall.cpp
+++ b/src/checks/level1/qdeleteall.cpp
@@ -69,7 +69,7 @@ void QDeleteAll::VisitStmt(clang::Stmt *stmt)
} else {
msg += ", use qDeleteAll(mycontainer.keyBegin(), mycontainer.keyEnd()) instead";
}
- emitWarning(clazy::getLocStart(p), msg);
+ emitWarning(p->getBeginLoc(), msg);
}
}
break;
diff --git a/src/checks/level1/qhash-namespace.cpp b/src/checks/level1/qhash-namespace.cpp
index 63d66cc9..a091b556 100644
--- a/src/checks/level1/qhash-namespace.cpp
+++ b/src/checks/level1/qhash-namespace.cpp
@@ -63,7 +63,7 @@ void QHashNamespace::VisitDecl(clang::Decl *decl)
if (m_context->isQtDeveloper()) {
PreProcessorVisitor *preProcessorVisitor = m_context->preprocessorVisitor;
- if (preProcessorVisitor && !preProcessorVisitor->isBetweenQtNamespaceMacros(clazy::getLocStart(func))) {
+ if (preProcessorVisitor && !preProcessorVisitor->isBetweenQtNamespaceMacros(func->getBeginLoc())) {
emitWarning(decl, "qHash(" + clazy::simpleTypeName(firstArg->getType(), lo()) + ") must be declared before QT_END_NAMESPACE");
}
}
diff --git a/src/checks/level1/range-loop-detach.cpp b/src/checks/level1/range-loop-detach.cpp
index 36429bc8..b04d85ae 100644
--- a/src/checks/level1/range-loop-detach.cpp
+++ b/src/checks/level1/range-loop-detach.cpp
@@ -97,7 +97,7 @@ void RangeLoopDetach::VisitStmt(clang::Stmt *stmt)
bool RangeLoopDetach::islvalue(Expr *exp, SourceLocation &endLoc)
{
if (isa<DeclRefExpr>(exp)) {
- endLoc = clazy::locForEndOfToken(&m_astContext, clazy::getLocStart(exp));
+ endLoc = clazy::locForEndOfToken(&m_astContext, exp->getBeginLoc());
return true;
}
@@ -141,7 +141,7 @@ void RangeLoopDetach::processForRangeLoop(CXXForRangeStmt *rangeLoop)
return;
}
- StmtBodyRange bodyRange(nullptr, &sm(), clazy::getLocStart(rangeLoop));
+ StmtBodyRange bodyRange(nullptr, &sm(), rangeLoop->getBeginLoc());
if (clazy::containerNeverDetaches(clazy::containerDeclForLoop(rangeLoop), bodyRange)) {
return;
}
@@ -161,5 +161,5 @@ void RangeLoopDetach::processForRangeLoop(CXXForRangeStmt *rangeLoop)
auto *typedefType = t->getAs<TypedefType>(); // Typedefs in internal Qt code, like QStringList should not be resolved
const std::string name = typedefType ? typedefType->getDecl()->getNameAsString() : record->getNameAsString();
- emitWarning(clazy::getLocStart(rangeLoop), "c++11 range-loop might detach Qt container (" + name + ')', fixits);
+ emitWarning(rangeLoop->getBeginLoc(), "c++11 range-loop might detach Qt container (" + name + ')', fixits);
}
diff --git a/src/checks/level1/range-loop-reference.cpp b/src/checks/level1/range-loop-reference.cpp
index 11044e71..34d48637 100644
--- a/src/checks/level1/range-loop-reference.cpp
+++ b/src/checks/level1/range-loop-reference.cpp
@@ -68,7 +68,7 @@ void RangeLoopReference::processForRangeLoop(CXXForRangeStmt *rangeLoop)
const bool isConst = varDecl->getType().isConstQualified();
if (!isConst) {
- SourceLocation start = clazy::getLocStart(varDecl);
+ SourceLocation start = varDecl->getBeginLoc();
fixits.push_back(clazy::createInsertion(start, "const "));
}
@@ -77,6 +77,6 @@ void RangeLoopReference::processForRangeLoop(CXXForRangeStmt *rangeLoop)
// We ignore classif.passSmallTrivialByValue because it doesn't matter, the compiler is able
// to optimize it, generating the same assembly, regardless of pass by value.
- emitWarning(clazy::getLocStart(varDecl), msg, fixits);
+ emitWarning(varDecl->getBeginLoc(), msg, fixits);
}
}
diff --git a/src/checks/level1/rule-of-two-soft.cpp b/src/checks/level1/rule-of-two-soft.cpp
index c296ca0c..2b5e5b4a 100644
--- a/src/checks/level1/rule-of-two-soft.cpp
+++ b/src/checks/level1/rule-of-two-soft.cpp
@@ -35,7 +35,7 @@ void RuleOfTwoSoft::VisitStmt(Stmt *s)
if (hasCopyCtor && !hasCopyAssignOp && !isBlacklisted(record)) {
std::string msg = "Using assign operator but class " + record->getQualifiedNameAsString() + " has copy-ctor but no assign operator";
- emitWarning(clazy::getLocStart(s), msg);
+ emitWarning(s->getBeginLoc(), msg);
}
}
} else if (auto *ctorExpr = dyn_cast<CXXConstructExpr>(s)) {
@@ -47,7 +47,7 @@ void RuleOfTwoSoft::VisitStmt(Stmt *s)
if (!hasCopyCtor && hasCopyAssignOp && !isBlacklisted(record)) {
std::string msg =
"Using copy-ctor but class " + record->getQualifiedNameAsString() + " has a trivial copy-ctor but non trivial assign operator";
- emitWarning(clazy::getLocStart(s), msg);
+ emitWarning(s->getBeginLoc(), msg);
}
}
}
diff --git a/src/checks/level2/base-class-event.cpp b/src/checks/level2/base-class-event.cpp
index 4bd2f002..18ae587f 100644
--- a/src/checks/level2/base-class-event.cpp
+++ b/src/checks/level2/base-class-event.cpp
@@ -79,6 +79,6 @@ void BaseClassEvent::VisitDecl(Decl *decl)
continue;
}
- emitWarning(clazy::getLocStart(returnStmt), "Return " + baseClassName + "::" + methodName + "() instead of false");
+ emitWarning(returnStmt->getBeginLoc(), "Return " + baseClassName + "::" + methodName + "() instead of false");
}
}
diff --git a/src/checks/level2/copyable-polymorphic.cpp b/src/checks/level2/copyable-polymorphic.cpp
index 89ae1b92..b3a590d1 100644
--- a/src/checks/level2/copyable-polymorphic.cpp
+++ b/src/checks/level2/copyable-polymorphic.cpp
@@ -85,7 +85,7 @@ void CopyablePolymorphic::VisitDecl(clang::Decl *decl)
return;
}
- emitWarning(clazy::getLocStart(record), "Polymorphic class " + record->getQualifiedNameAsString() + " is copyable. Potential slicing.", fixits(record));
+ emitWarning(record->getBeginLoc(), "Polymorphic class " + record->getQualifiedNameAsString() + " is copyable. Potential slicing.", fixits(record));
}
std::vector<clang::FixItHint> CopyablePolymorphic::fixits(clang::CXXRecordDecl *record)
diff --git a/src/checks/level2/ctor-missing-parent-argument.cpp b/src/checks/level2/ctor-missing-parent-argument.cpp
index 73ab955c..aaf6bd70 100644
--- a/src/checks/level2/ctor-missing-parent-argument.cpp
+++ b/src/checks/level2/ctor-missing-parent-argument.cpp
@@ -72,7 +72,7 @@ void CtorMissingParentArgument::VisitDecl(Decl *decl)
if (numCtors > 0 && !hasQObjectParam) {
clang::CXXRecordDecl *baseClass = clazy::getQObjectBaseClass(record);
const bool baseHasQObjectParam = clazy::recordHasCtorWithParam(baseClass, parentType, /*by-ref*/ ok, /*by-ref*/ numCtors);
- if (ok && !baseHasQObjectParam && sm().isInSystemHeader(clazy::getLocStart(baseClass))) {
+ if (ok && !baseHasQObjectParam && sm().isInSystemHeader(baseClass->getBeginLoc())) {
// If the base class ctors don't accept QObject, and it's declared in a system header don't warn
return;
}
diff --git a/src/checks/level2/function-args-by-ref.cpp b/src/checks/level2/function-args-by-ref.cpp
index a7aca14d..57406334 100644
--- a/src/checks/level2/function-args-by-ref.cpp
+++ b/src/checks/level2/function-args-by-ref.cpp
@@ -144,7 +144,7 @@ void FunctionArgsByRef::processFunction(FunctionDecl *func)
}
addFixits(fixits, func, i);
- emitWarning(clazy::getLocStart(param), error, fixits);
+ emitWarning(param->getBeginLoc(), error, fixits);
}
}
}
@@ -163,7 +163,7 @@ void FunctionArgsByRef::addFixits(std::vector<FixItHint> &fixits, FunctionDecl *
const bool isConst = paramQt.isConstQualified();
if (!isConst) {
- SourceLocation start = clazy::getLocStart(param);
+ SourceLocation start = param->getBeginLoc();
fixits.push_back(clazy::createInsertion(start, "const "));
}
@@ -180,7 +180,7 @@ void FunctionArgsByRef::VisitDecl(Decl *decl)
void FunctionArgsByRef::VisitStmt(Stmt *stmt)
{
if (auto *lambda = dyn_cast<LambdaExpr>(stmt)) {
- if (!shouldIgnoreFile(clazy::getLocStart(stmt))) {
+ if (!shouldIgnoreFile(stmt->getBeginLoc())) {
processFunction(lambda->getCallOperator());
}
}
diff --git a/src/checks/level2/function-args-by-value.cpp b/src/checks/level2/function-args-by-value.cpp
index 3d60d6b0..cdd3d61f 100644
--- a/src/checks/level2/function-args-by-value.cpp
+++ b/src/checks/level2/function-args-by-value.cpp
@@ -195,7 +195,7 @@ void FunctionArgsByValue::processFunction(FunctionDecl *func)
const std::string paramStr = param->getType().getAsString(lo());
std::string error = "Pass small and trivially-copyable type by value (" + paramStr + ')';
- emitWarning(clazy::getLocStart(param), error, fixits);
+ emitWarning(param->getBeginLoc(), error, fixits);
}
}
}
@@ -206,15 +206,15 @@ FixItHint FunctionArgsByValue::fixit(FunctionDecl *func, const ParmVarDecl *para
qt.removeLocalConst();
const std::string typeName = qt.getAsString(PrintingPolicy(lo()));
std::string replacement = typeName + ' ' + std::string(clazy::name(param));
- SourceLocation startLoc = clazy::getLocStart(param);
- SourceLocation endLoc = clazy::getLocEnd(param);
+ SourceLocation startLoc = param->getBeginLoc();
+ SourceLocation endLoc = param->getEndLoc();
const int numRedeclarations = std::distance(func->redecls_begin(), func->redecls_end());
const bool definitionIsAlsoDeclaration = numRedeclarations == 1;
const bool isDeclarationButNotDefinition = !func->doesThisDeclarationHaveABody();
if (param->hasDefaultArg() && (isDeclarationButNotDefinition || definitionIsAlsoDeclaration)) {
- endLoc = clazy::getLocStart(param->getDefaultArg()).getLocWithOffset(-1);
+ endLoc = param->getDefaultArg()->getBeginLoc().getLocWithOffset(-1);
replacement += " =";
}
diff --git a/src/checks/level2/global-const-char-pointer.cpp b/src/checks/level2/global-const-char-pointer.cpp
index 458e079e..22ab6eae 100644
--- a/src/checks/level2/global-const-char-pointer.cpp
+++ b/src/checks/level2/global-const-char-pointer.cpp
@@ -36,7 +36,7 @@ void GlobalConstCharPointer::VisitDecl(clang::Decl *decl)
return;
}
- if (shouldIgnoreFile(clazy::getLocStart(decl))) {
+ if (shouldIgnoreFile(decl->getBeginLoc())) {
return;
}
@@ -52,5 +52,5 @@ void GlobalConstCharPointer::VisitDecl(clang::Decl *decl)
return;
}
- emitWarning(clazy::getLocStart(decl), "non const global char *");
+ emitWarning(decl->getBeginLoc(), "non const global char *");
}
diff --git a/src/checks/level2/implicit-casts.cpp b/src/checks/level2/implicit-casts.cpp
index e7b41db2..b04a5c19 100644
--- a/src/checks/level2/implicit-casts.cpp
+++ b/src/checks/level2/implicit-casts.cpp
@@ -87,7 +87,7 @@ static bool iterateCallExpr(T *callExpr, CheckBase *check)
continue;
}
- check->emitWarning(clazy::getLocStart(implicitCast), "Implicit pointer to bool cast (argument " + std::to_string(i) + ')');
+ check->emitWarning(implicitCast->getBeginLoc(), "Implicit pointer to bool cast (argument " + std::to_string(i) + ')');
result = true;
}
@@ -139,7 +139,7 @@ static bool iterateCallExpr2(T *callExpr, CheckBase *check, ParentMap *parentMap
continue;
}
- check->emitWarning(clazy::getLocStart(implicitCast), "Implicit bool to int cast (argument " + std::to_string(i) + ')');
+ check->emitWarning(implicitCast->getBeginLoc(), "Implicit bool to int cast (argument " + std::to_string(i) + ')');
result = true;
}
@@ -164,11 +164,11 @@ void ImplicitCasts::VisitStmt(clang::Stmt *stmt)
return;
}
- if (isMacroToIgnore(clazy::getLocStart(stmt))) {
+ if (isMacroToIgnore(stmt->getBeginLoc())) {
return;
}
- if (shouldIgnoreFile(clazy::getLocStart(stmt))) {
+ if (shouldIgnoreFile(stmt->getBeginLoc())) {
return;
}
diff --git a/src/checks/level2/missing-qobject-macro.cpp b/src/checks/level2/missing-qobject-macro.cpp
index 36e19ddc..50df0a37 100644
--- a/src/checks/level2/missing-qobject-macro.cpp
+++ b/src/checks/level2/missing-qobject-macro.cpp
@@ -58,14 +58,14 @@ void MissingQObjectMacro::VisitDecl(clang::Decl *decl)
return;
}
- const SourceLocation startLoc = clazy::getLocStart(decl);
+ const SourceLocation startLoc = decl->getBeginLoc();
for (const SourceLocation &loc : m_qobjectMacroLocations) {
if (sm().getFileID(loc) != sm().getFileID(startLoc)) {
continue; // Different file
}
- if (sm().isBeforeInSLocAddrSpace(startLoc, loc) && sm().isBeforeInSLocAddrSpace(loc, clazy::getLocEnd(decl))) {
+ if (sm().isBeforeInSLocAddrSpace(startLoc, loc) && sm().isBeforeInSLocAddrSpace(loc, decl->getEndLoc())) {
return; // We found a Q_OBJECT after start and before end, it's ours.
}
}
diff --git a/src/checks/level2/missing-typeinfo.cpp b/src/checks/level2/missing-typeinfo.cpp
index 84cc82b6..3509fc8b 100644
--- a/src/checks/level2/missing-typeinfo.cpp
+++ b/src/checks/level2/missing-typeinfo.cpp
@@ -68,7 +68,7 @@ void MissingTypeInfo::VisitDecl(clang::Decl *decl)
const bool isTooBigForQList = isQList && checkTooBigForQList(qt2, &m_astContext);
if ((isQVector || isTooBigForQList) && isCopyable) {
- if (sm().isInSystemHeader(clazy::getLocStart(record))) {
+ if (sm().isInSystemHeader(record->getBeginLoc())) {
return;
}
diff --git a/src/checks/level2/old-style-connect.cpp b/src/checks/level2/old-style-connect.cpp
index cfed83b4..c88867d0 100644
--- a/src/checks/level2/old-style-connect.cpp
+++ b/src/checks/level2/old-style-connect.cpp
@@ -14,7 +14,6 @@
#include "FixItUtils.h"
#include "HierarchyUtils.h"
#include "QtUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "Utils.h"
#include "clazy_stl.h"
@@ -161,7 +160,7 @@ int OldStyleConnect::classifyConnect(FunctionDecl *connectFunc, T *connectCall)
// It's old style, but check if all macros are literals
int numLiterals = 0;
for (auto arg : connectCall->arguments()) {
- auto argLocation = clazy::getLocStart(arg);
+ auto argLocation = arg->getBeginLoc();
std::string dummy;
if (isSignalOrSlot(argLocation, dummy)) {
++numLiterals;
@@ -254,11 +253,11 @@ void OldStyleConnect::VisitStmt(Stmt *s)
}
if (classification & ConnectFlag_Bogus) {
- emitWarning(clazy::getLocStart(s), "Internal error");
+ emitWarning(s->getBeginLoc(), "Internal error");
return;
}
- emitWarning(clazy::getLocStart(s), "Old Style Connect", call ? fixits(classification, call) : fixits(classification, ctorExpr));
+ emitWarning(s->getBeginLoc(), "Old Style Connect", call ? fixits(classification, call) : fixits(classification, ctorExpr));
}
void OldStyleConnect::addPrivateSlot(const PrivateSlot &slot)
@@ -330,7 +329,7 @@ std::vector<FixItHint> OldStyleConnect::fixits(int classification, T *callOrCtor
return {};
}
- const SourceLocation locStart = clazy::getLocStart(callOrCtor);
+ const SourceLocation locStart = callOrCtor->getBeginLoc();
if (classification & ConnectFlag_2ArgsDisconnect) {
// Not implemented yet
@@ -358,7 +357,7 @@ std::vector<FixItHint> OldStyleConnect::fixits(int classification, T *callOrCtor
std::string macroName;
CXXMethodDecl *senderMethod = nullptr;
for (auto arg : callOrCtor->arguments()) {
- SourceLocation s = clazy::getLocStart(arg);
+ SourceLocation s = arg->getBeginLoc();
static const CXXRecordDecl *lastRecordDecl = nullptr;
if (isSignalOrSlot(s, macroName)) {
macroNum++;
@@ -498,7 +497,7 @@ std::vector<FixItHint> OldStyleConnect::fixits(int classification, T *callOrCtor
if (record) {
lastRecordDecl = record;
if (isQPointer(expr)) {
- auto endLoc = clazy::locForNextToken(&m_astContext, clazy::getLocStart(arg), tok::comma);
+ auto endLoc = clazy::locForNextToken(&m_astContext, arg->getBeginLoc(), tok::comma);
if (endLoc.isValid()) {
fixits.push_back(FixItHint::CreateInsertion(endLoc, ".data()"));
} else {
diff --git a/src/checks/level2/qstring-allocations.cpp b/src/checks/level2/qstring-allocations.cpp
index 9a7079c0..9c038749 100644
--- a/src/checks/level2/qstring-allocations.cpp
+++ b/src/checks/level2/qstring-allocations.cpp
@@ -271,8 +271,8 @@ void QStringAllocations::VisitCtor(CXXConstructExpr *ctorExpr)
auto *qlatin1Ctor = qlatin1expr.qlatin1ctorexpr;
- if (clazy::getLocStart(qlatin1Ctor).isMacroID()) {
- auto macroName = Lexer::getImmediateMacroName(clazy::getLocStart(qlatin1Ctor), sm(), lo());
+ if (qlatin1Ctor->getBeginLoc().isMacroID()) {
+ auto macroName = Lexer::getImmediateMacroName(qlatin1Ctor->getBeginLoc(), sm(), lo());
if (macroName == "Q_GLOBAL_STATIC_WITH_ARGS") { // bug #391807
return;
}
@@ -280,16 +280,16 @@ void QStringAllocations::VisitCtor(CXXConstructExpr *ctorExpr)
std::vector<FixItHint> fixits;
if (qlatin1expr.enableFixit) {
- if (!clazy::getLocStart(qlatin1Ctor).isMacroID()) {
+ if (!qlatin1Ctor->getBeginLoc().isMacroID()) {
if (!ternary) {
fixits = fixItReplaceWordWithWord(qlatin1Ctor, "QStringLiteral", "QLatin1String");
- bool shouldRemoveQString = clazy::getLocStart(qlatin1Ctor).getRawEncoding() != clazy::getLocStart(ctorExpr).getRawEncoding()
+ bool shouldRemoveQString = qlatin1Ctor->getBeginLoc().getRawEncoding() != ctorExpr->getBeginLoc().getRawEncoding()
&& dyn_cast_or_null<CXXBindTemporaryExpr>(clazy::parent(m_context->parentMap, ctorExpr));
if (shouldRemoveQString) {
// This is the case of QString(QLatin1String("foo")), which we just fixed to be QString(QStringLiteral("foo")), so now remove QString
auto removalFixits = clazy::fixItRemoveToken(&m_astContext, ctorExpr, true);
if (removalFixits.empty()) {
- queueManualFixitWarning(clazy::getLocStart(ctorExpr), "Internal error: invalid start or end location");
+ queueManualFixitWarning(ctorExpr->getBeginLoc(), "Internal error: invalid start or end location");
} else {
clazy::append(removalFixits, fixits);
}
@@ -298,11 +298,11 @@ void QStringAllocations::VisitCtor(CXXConstructExpr *ctorExpr)
fixits = fixItReplaceWordWithWordInTernary(ternary);
}
} else {
- queueManualFixitWarning(clazy::getLocStart(qlatin1Ctor), "Can't use QStringLiteral in macro");
+ queueManualFixitWarning(qlatin1Ctor->getBeginLoc(), "Can't use QStringLiteral in macro");
}
}
- maybeEmitWarning(clazy::getLocStart(ctorExpr), msg, fixits);
+ maybeEmitWarning(ctorExpr->getBeginLoc(), msg, fixits);
} else {
std::vector<FixItHint> fixits;
if (clazy::hasChildren(ctorExpr)) {
@@ -320,10 +320,10 @@ void QStringAllocations::VisitCtor(CXXConstructExpr *ctorExpr)
const bool literalIsEmpty = lt->getLength() == 0;
if (literalIsEmpty && clazy::getFirstParentOfType<MemberExpr>(m_context->parentMap, ctorExpr) == nullptr) {
fixits = fixItReplaceWordWithWord(ctorExpr, "QLatin1String", "QString");
- } else if (!clazy::getLocStart(ctorExpr).isMacroID()) {
+ } else if (!ctorExpr->getBeginLoc().isMacroID()) {
fixits = fixItReplaceWordWithWord(ctorExpr, "QStringLiteral", "QString");
} else {
- queueManualFixitWarning(clazy::getLocStart(ctorExpr), "Can't use QStringLiteral in macro.");
+ queueManualFixitWarning(ctorExpr->getBeginLoc(), "Can't use QStringLiteral in macro.");
}
} else {
auto *parentMemberCallExpr =
@@ -348,7 +348,7 @@ void QStringAllocations::VisitCtor(CXXConstructExpr *ctorExpr)
}
}
- maybeEmitWarning(clazy::getLocStart(ctorExpr), msg, fixits);
+ maybeEmitWarning(ctorExpr->getBeginLoc(), msg, fixits);
}
}
@@ -357,7 +357,7 @@ std::vector<FixItHint> QStringAllocations::fixItReplaceWordWithWord(clang::Stmt
StringLiteral *lt = stringLiteralForCall(begin);
if (replacee == "QLatin1String") {
if (lt && !Utils::isAscii(lt)) {
- maybeEmitWarning(clazy::getLocStart(lt), "Don't use QLatin1String with non-latin1 literals");
+ maybeEmitWarning(lt->getBeginLoc(), "Don't use QLatin1String with non-latin1 literals");
return {};
}
}
@@ -369,7 +369,7 @@ std::vector<FixItHint> QStringAllocations::fixItReplaceWordWithWord(clang::Stmt
std::vector<FixItHint> fixits;
FixItHint fixit = clazy::fixItReplaceWordWithWord(&m_astContext, begin, replacement, replacee);
if (fixit.isNull()) {
- queueManualFixitWarning(clazy::getLocStart(begin), "");
+ queueManualFixitWarning(begin->getBeginLoc(), "");
} else {
fixits.push_back(fixit);
}
@@ -395,7 +395,7 @@ std::vector<FixItHint> QStringAllocations::fixItReplaceWordWithWordInTernary(cla
addConstructExpr(ternary->getFalseExpr());
if (constructExprs.size() != 2) {
- llvm::errs() << "Weird ternary operator with " << constructExprs.size() << " constructExprs at " << clazy::getLocStart(ternary).printToString(sm())
+ llvm::errs() << "Weird ternary operator with " << constructExprs.size() << " constructExprs at " << ternary->getBeginLoc().printToString(sm())
<< "\n";
ternary->dump();
assert(false);
@@ -405,7 +405,7 @@ std::vector<FixItHint> QStringAllocations::fixItReplaceWordWithWordInTernary(cla
std::vector<FixItHint> fixits;
fixits.reserve(2);
for (CXXConstructExpr *constructExpr : constructExprs) {
- SourceLocation rangeStart = clazy::getLocStart(constructExpr);
+ SourceLocation rangeStart = constructExpr->getBeginLoc();
SourceLocation rangeEnd = Lexer::getLocForEndOfToken(rangeStart, -1, sm(), lo());
fixits.push_back(FixItHint::CreateReplacement(SourceRange(rangeStart, rangeEnd), "QStringLiteral"));
}
@@ -487,8 +487,8 @@ std::vector<FixItHint> QStringAllocations::fixItReplaceFromLatin1OrFromUtf8(Call
std::vector<FixItHint> fixits;
std::string replacement = isQStringLiteralCandidate(callExpr, m_context->parentMap, lo(), sm()) ? "QStringLiteral" : "QLatin1String";
- if (replacement == "QStringLiteral" && clazy::getLocStart(callExpr).isMacroID()) {
- queueManualFixitWarning(clazy::getLocStart(callExpr), "Can't use QStringLiteral in macro!");
+ if (replacement == "QStringLiteral" && callExpr->getBeginLoc().isMacroID()) {
+ queueManualFixitWarning(callExpr->getBeginLoc(), "Can't use QStringLiteral in macro!");
return {};
}
@@ -509,13 +509,13 @@ std::vector<FixItHint> QStringAllocations::fixItReplaceFromLatin1OrFromUtf8(Call
}
}
- auto classNameLoc = Lexer::getLocForEndOfToken(clazy::getLocStart(callExpr), 0, sm(), lo());
+ auto classNameLoc = Lexer::getLocForEndOfToken(callExpr->getBeginLoc(), 0, sm(), lo());
auto scopeOperatorLoc = Lexer::getLocForEndOfToken(classNameLoc, 0, sm(), lo());
auto methodNameLoc = Lexer::getLocForEndOfToken(scopeOperatorLoc, -1, sm(), lo());
- SourceRange range(clazy::getLocStart(callExpr), methodNameLoc);
+ SourceRange range(callExpr->getBeginLoc(), methodNameLoc);
fixits.push_back(FixItHint::CreateReplacement(range, replacement));
} else {
- queueManualFixitWarning(clazy::getLocStart(callExpr), "Internal error: literal is null");
+ queueManualFixitWarning(callExpr->getBeginLoc(), "Internal error: literal is null");
}
return fixits;
@@ -546,12 +546,12 @@ std::vector<FixItHint> QStringAllocations::fixItRawLiteral(StringLiteral *lt, co
SourceRange range = clazy::rangeForLiteral(&m_astContext, lt);
if (range.isInvalid()) {
if (lt) {
- queueManualFixitWarning(clazy::getLocStart(lt), "Internal error: Can't calculate source location");
+ queueManualFixitWarning(lt->getBeginLoc(), "Internal error: Can't calculate source location");
}
return {};
}
- SourceLocation start = clazy::getLocStart(lt);
+ SourceLocation start = lt->getBeginLoc();
if (start.isMacroID()) {
queueManualFixitWarning(start, "Can't use QStringLiteral in macro");
} else {
@@ -581,8 +581,8 @@ std::vector<FixItHint> QStringAllocations::fixItRawLiteral(StringLiteral *lt, co
}
std::string revisedReplacement = lt->getLength() == 0 ? "QLatin1String" : replacement; // QLatin1String("") is better than QStringLiteral("")
- if (revisedReplacement == "QStringLiteral" && clazy::getLocStart(lt).isMacroID()) {
- queueManualFixitWarning(clazy::getLocStart(lt), "Can't use QStringLiteral in macro...");
+ if (revisedReplacement == "QStringLiteral" && lt->getBeginLoc().isMacroID()) {
+ queueManualFixitWarning(lt->getBeginLoc(), "Can't use QStringLiteral in macro...");
return {};
}
@@ -641,14 +641,14 @@ void QStringAllocations::VisitOperatorCall(Stmt *stm)
}
if (literals.empty()) {
- queueManualFixitWarning(clazy::getLocStart(stm), "Couldn't find literal");
+ queueManualFixitWarning(stm->getBeginLoc(), "Couldn't find literal");
} else {
const std::string replacement = Utils::isAscii(literals[0]) ? "QLatin1String" : "QStringLiteral";
fixits = fixItRawLiteral(literals[0], replacement, operatorCall);
}
std::string msg("QString(const char*) being called");
- maybeEmitWarning(clazy::getLocStart(stm), msg, fixits);
+ maybeEmitWarning(stm->getBeginLoc(), msg, fixits);
}
void QStringAllocations::VisitFromLatin1OrUtf8(Stmt *stmt)
@@ -693,7 +693,7 @@ void QStringAllocations::VisitFromLatin1OrUtf8(Stmt *stmt)
if (!ternaries.empty()) {
auto *ternary = ternaries[0];
if (Utils::ternaryOperatorIsOfStringLiteral(ternary)) {
- maybeEmitWarning(clazy::getLocStart(stmt), std::string("QString::fromLatin1() being passed a literal"));
+ maybeEmitWarning(stmt->getBeginLoc(), std::string("QString::fromLatin1() being passed a literal"));
}
return;
@@ -703,9 +703,9 @@ void QStringAllocations::VisitFromLatin1OrUtf8(Stmt *stmt)
const std::vector<FixItHint> fixits = fixItReplaceFromLatin1OrFromUtf8(callExpr, fromFunction);
if (clazy::name(functionDecl) == "fromLatin1") {
- maybeEmitWarning(clazy::getLocStart(stmt), std::string("QString::fromLatin1() being passed a literal"), fixits);
+ maybeEmitWarning(stmt->getBeginLoc(), std::string("QString::fromLatin1() being passed a literal"), fixits);
} else {
- maybeEmitWarning(clazy::getLocStart(stmt), std::string("QString::fromUtf8() being passed a literal"), fixits);
+ maybeEmitWarning(stmt->getBeginLoc(), std::string("QString::fromUtf8() being passed a literal"), fixits);
}
}
@@ -733,7 +733,7 @@ void QStringAllocations::VisitAssignOperatorQLatin1String(Stmt *stmt)
const std::vector<FixItHint> fixits =
ternary == nullptr ? fixItReplaceWordWithWord(begin, "QStringLiteral", "QLatin1String") : fixItReplaceWordWithWordInTernary(ternary);
- maybeEmitWarning(clazy::getLocStart(stmt), std::string("QString::operator=(QLatin1String(\"literal\")"), fixits);
+ maybeEmitWarning(stmt->getBeginLoc(), std::string("QString::operator=(QLatin1String(\"literal\")"), fixits);
}
void QStringAllocations::maybeEmitWarning(SourceLocation loc, std::string error, std::vector<FixItHint> fixits)
diff --git a/src/checks/level2/rule-of-three.cpp b/src/checks/level2/rule-of-three.cpp
index d1d563c2..d31f2077 100644
--- a/src/checks/level2/rule-of-three.cpp
+++ b/src/checks/level2/rule-of-three.cpp
@@ -44,11 +44,11 @@ void RuleOfThree::VisitDecl(clang::Decl *decl)
return;
}
- if (shouldIgnoreFile(clazy::getLocStart(decl))) {
+ if (shouldIgnoreFile(decl->getBeginLoc())) {
return;
}
- const SourceLocation recordStart = clazy::getLocStart(record);
+ const SourceLocation recordStart = record->getBeginLoc();
if (recordStart.isMacroID()) {
if (clazy::isInMacro(&m_astContext, recordStart, "Q_GLOBAL_STATIC_INTERNAL")) {
return;
@@ -160,5 +160,5 @@ void RuleOfThree::VisitDecl(clang::Decl *decl)
}
}
- emitWarning(clazy::getLocStart(decl), msg);
+ emitWarning(decl->getBeginLoc(), msg);
}
diff --git a/src/checks/level2/virtual-call-ctor.cpp b/src/checks/level2/virtual-call-ctor.cpp
index caf809b1..21289205 100644
--- a/src/checks/level2/virtual-call-ctor.cpp
+++ b/src/checks/level2/virtual-call-ctor.cpp
@@ -73,9 +73,9 @@ void VirtualCallCtor::VisitDecl(Decl *decl)
SourceLocation loc = containsVirtualCall(classDecl, ctorOrDtorBody, processedStmts);
if (loc.isValid()) {
if (ctorDecl) {
- emitWarning(clazy::getLocStart(decl), "Calling pure virtual function in CTOR");
+ emitWarning(decl->getBeginLoc(), "Calling pure virtual function in CTOR");
} else {
- emitWarning(clazy::getLocStart(decl), "Calling pure virtual function in DTOR");
+ emitWarning(decl->getBeginLoc(), "Calling pure virtual function in DTOR");
}
emitWarning(loc, "Called here");
}
@@ -112,10 +112,10 @@ SourceLocation VirtualCallCtor::containsVirtualCall(clang::CXXRecordDecl *classD
#else
if (memberDecl->isPure()) {
#endif
- return clazy::getLocStart(callExpr);
+ return callExpr->getBeginLoc();
}
if (containsVirtualCall(classDecl, memberDecl->getBody(), processedStmts).isValid()) {
- return clazy::getLocStart(callExpr);
+ return callExpr->getBeginLoc();
}
}
}
diff --git a/src/checks/manuallevel/assert-with-side-effects.cpp b/src/checks/manuallevel/assert-with-side-effects.cpp
index 99c6c98f..234e0753 100644
--- a/src/checks/manuallevel/assert-with-side-effects.cpp
+++ b/src/checks/manuallevel/assert-with-side-effects.cpp
@@ -72,7 +72,7 @@ static bool methodIsOK(const std::string &name)
void AssertWithSideEffects::VisitStmt(Stmt *stm)
{
- const SourceLocation stmStart = clazy::getLocStart(stm);
+ const SourceLocation stmStart = stm->getBeginLoc();
if (!clazy::isInMacro(&m_astContext, stmStart, "Q_ASSERT")) {
return;
}
@@ -108,7 +108,7 @@ void AssertWithSideEffects::VisitStmt(Stmt *stm)
if (op->isAssignmentOp()) {
if (auto *declRef = dyn_cast<DeclRefExpr>(op->getLHS())) {
ValueDecl *valueDecl = declRef->getDecl();
- if (valueDecl && sm().isBeforeInSLocAddrSpace(clazy::getLocStart(valueDecl), stmStart)) {
+ if (valueDecl && sm().isBeforeInSLocAddrSpace(valueDecl->getBeginLoc(), stmStart)) {
// llvm::errs() << "reason3\n";
warn = true;
}
@@ -119,7 +119,7 @@ void AssertWithSideEffects::VisitStmt(Stmt *stm)
ValueDecl *valueDecl = declRef->getDecl();
auto type = op->getOpcode();
if (type != UnaryOperatorKind::UO_Deref && type != UnaryOperatorKind::UO_AddrOf) {
- if (valueDecl && sm().isBeforeInSLocAddrSpace(clazy::getLocStart(valueDecl), stmStart)) {
+ if (valueDecl && sm().isBeforeInSLocAddrSpace(valueDecl->getBeginLoc(), stmStart)) {
// llvm::errs() << "reason5 " << op->getOpcodeStr() << "\n";
warn = true;
}
diff --git a/src/checks/manuallevel/container-inside-loop.cpp b/src/checks/manuallevel/container-inside-loop.cpp
index ebe06fc5..e8368247 100644
--- a/src/checks/manuallevel/container-inside-loop.cpp
+++ b/src/checks/manuallevel/container-inside-loop.cpp
@@ -7,7 +7,6 @@
#include "container-inside-loop.h"
#include "ClazyContext.h"
#include "LoopUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StmtBodyRange.h"
#include "StringUtils.h"
#include "Utils.h"
@@ -63,5 +62,5 @@ void ContainerInsideLoop::VisitStmt(clang::Stmt *stmt)
return;
}
- emitWarning(clazy::getLocStart(stmt), "container inside loop causes unneeded allocations");
+ emitWarning(stmt->getBeginLoc(), "container inside loop causes unneeded allocations");
}
diff --git a/src/checks/manuallevel/detaching-member.cpp b/src/checks/manuallevel/detaching-member.cpp
index 0ecda4e5..c35784b2 100644
--- a/src/checks/manuallevel/detaching-member.cpp
+++ b/src/checks/manuallevel/detaching-member.cpp
@@ -10,7 +10,6 @@
#include "detaching-member.h"
#include "ClazyContext.h"
#include "HierarchyUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "Utils.h"
#include "checkbase.h"
@@ -49,7 +48,7 @@ void DetachingMember::VisitStmt(clang::Stmt *stm)
return;
}
- if (shouldIgnoreFile(clazy::getLocStart(stm))) {
+ if (shouldIgnoreFile(stm->getBeginLoc())) {
return;
}
@@ -142,5 +141,5 @@ void DetachingMember::VisitStmt(clang::Stmt *stm)
}
}
- emitWarning(clazy::getLocStart(stm), "Potential detachment due to calling " + method->getQualifiedNameAsString() + "()");
+ emitWarning(stm->getBeginLoc(), "Potential detachment due to calling " + method->getQualifiedNameAsString() + "()");
}
diff --git a/src/checks/manuallevel/isempty-vs-count.cpp b/src/checks/manuallevel/isempty-vs-count.cpp
index 995b7560..953ce70d 100644
--- a/src/checks/manuallevel/isempty-vs-count.cpp
+++ b/src/checks/manuallevel/isempty-vs-count.cpp
@@ -47,14 +47,14 @@ void IsEmptyVSCount::VisitStmt(clang::Stmt *stmt)
}
if (clazy::classIsOneOf(method->getParent(), {"QMultiHash", "QMultiMap"}) && memberCall->getNumArgs() == 2) {
- emitWarning(clazy::getLocStart(stmt), "use contains() instead");
+ emitWarning(stmt->getBeginLoc(), "use contains() instead");
return;
}
if (clazy::classIsOneOf(method->getParent(), {"QHash", "QMap", "QMultiHash", "QMultiMap"}) && memberCall->getNumArgs() == 1) {
- emitWarning(clazy::getLocStart(stmt), "use contains() instead");
+ emitWarning(stmt->getBeginLoc(), "use contains() instead");
return;
}
- emitWarning(clazy::getLocStart(stmt), "use isEmpty() instead");
+ emitWarning(stmt->getBeginLoc(), "use isEmpty() instead");
}
diff --git a/src/checks/manuallevel/jnisignatures.cpp b/src/checks/manuallevel/jnisignatures.cpp
index c15c6d1e..88ba4e4c 100644
--- a/src/checks/manuallevel/jnisignatures.cpp
+++ b/src/checks/manuallevel/jnisignatures.cpp
@@ -6,6 +6,7 @@
*/
#include "jnisignatures.h"
+#include "HierarchyUtils.h"
#include "StringUtils.h"
#include "clazy_stl.h"
diff --git a/src/checks/manuallevel/qhash-with-char-pointer-key.cpp b/src/checks/manuallevel/qhash-with-char-pointer-key.cpp
index 62d9e553..bd849569 100644
--- a/src/checks/manuallevel/qhash-with-char-pointer-key.cpp
+++ b/src/checks/manuallevel/qhash-with-char-pointer-key.cpp
@@ -5,7 +5,6 @@
*/
#include "qhash-with-char-pointer-key.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "TypeUtils.h"
#include "Utils.h"
@@ -41,7 +40,7 @@ void QHashWithCharPointerKey::VisitDecl(clang::Decl *decl)
if (!qt.isNull() && qt->isPointerType()) {
qt = clazy::pointeeQualType(qt);
if (!qt.isNull() && !qt->isPointerType() && qt->isCharType()) {
- emitWarning(clazy::getLocStart(decl), "Using QHash<const char *, T> is dangerous");
+ emitWarning(decl->getBeginLoc(), "Using QHash<const char *, T> is dangerous");
}
}
}
diff --git a/src/checks/manuallevel/qproperty-type-mismatch.cpp b/src/checks/manuallevel/qproperty-type-mismatch.cpp
index a9b1e4be..e495f880 100644
--- a/src/checks/manuallevel/qproperty-type-mismatch.cpp
+++ b/src/checks/manuallevel/qproperty-type-mismatch.cpp
@@ -7,9 +7,6 @@
#include "qproperty-type-mismatch.h"
#include "AccessSpecifierManager.h"
#include "ClazyContext.h"
-#include "HierarchyUtils.h"
-#include "SourceCompatibilityHelpers.h"
-#include "StringUtils.h"
#include "TypeUtils.h"
#include <clang/AST/Decl.h>
diff --git a/src/checks/manuallevel/qt4-qstring-from-array.cpp b/src/checks/manuallevel/qt4-qstring-from-array.cpp
index 33b36d12..5d7dbfce 100644
--- a/src/checks/manuallevel/qt4-qstring-from-array.cpp
+++ b/src/checks/manuallevel/qt4-qstring-from-array.cpp
@@ -9,7 +9,6 @@
#include "ClazyContext.h"
#include "FixItUtils.h"
#include "HierarchyUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "Utils.h"
#include "clazy_stl.h"
@@ -163,7 +162,7 @@ void Qt4QStringFromArray::VisitStmt(clang::Stmt *stm)
}
}
- emitWarning(clazy::getLocStart(stm), message, fixits);
+ emitWarning(stm->getBeginLoc(), message, fixits);
}
std::vector<FixItHint> Qt4QStringFromArray::fixCtorCall(CXXConstructExpr *ctorExpr)
@@ -182,19 +181,19 @@ std::vector<FixItHint> Qt4QStringFromArray::fixOperatorCall(CXXOperatorCallExpr
std::vector<FixItHint> fixits;
if (op->getNumArgs() == 2) {
Expr *e = op->getArg(1);
- SourceLocation start = clazy::getLocStart(e);
+ SourceLocation start = e->getBeginLoc();
SourceLocation end = Lexer::getLocForEndOfToken(clazy::biggestSourceLocationInStmt(sm(), e), 0, sm(), lo());
SourceRange range = {start, end};
if (range.isInvalid()) {
- emitWarning(clazy::getLocStart(op), "internal error");
+ emitWarning(op->getBeginLoc(), "internal error");
return {};
}
clazy::insertParentMethodCall("QString::fromLatin1", {start, end}, /*by-ref*/ fixits);
} else {
- emitWarning(clazy::getLocStart(op), "internal error");
+ emitWarning(op->getBeginLoc(), "internal error");
}
return fixits;
@@ -206,18 +205,18 @@ std::vector<FixItHint> Qt4QStringFromArray::fixMethodCallCall(clang::CXXMemberCa
if (memberExpr->getNumArgs() == 1) {
Expr *e = *(memberExpr->arg_begin());
- SourceLocation start = clazy::getLocStart(e);
+ SourceLocation start = e->getBeginLoc();
SourceLocation end = Lexer::getLocForEndOfToken(clazy::biggestSourceLocationInStmt(sm(), e), 0, sm(), lo());
SourceRange range = {start, end};
if (range.isInvalid()) {
- emitWarning(clazy::getLocStart(memberExpr), "internal error");
+ emitWarning(memberExpr->getBeginLoc(), "internal error");
return {};
}
clazy::insertParentMethodCall("QString::fromLatin1", {start, end}, /*by-ref*/ fixits);
} else {
- emitWarning(clazy::getLocStart(memberExpr), "internal error");
+ emitWarning(memberExpr->getBeginLoc(), "internal error");
}
return fixits;
@@ -229,7 +228,7 @@ std::vector<FixItHint> Qt4QStringFromArray::fixitReplaceWithFromLatin1(CXXConstr
const std::string replacee = "QString";
std::vector<FixItHint> fixits;
- SourceLocation rangeStart = clazy::getLocStart(ctorExpr);
+ SourceLocation rangeStart = ctorExpr->getBeginLoc();
SourceLocation rangeEnd = Lexer::getLocForEndOfToken(rangeStart, -1, sm(), lo());
if (rangeEnd.isInvalid()) {
@@ -239,7 +238,7 @@ std::vector<FixItHint> Qt4QStringFromArray::fixitReplaceWithFromLatin1(CXXConstr
clazy::printLocation(sm(), rangeStart);
clazy::printLocation(sm(), rangeEnd);
clazy::printLocation(sm(), Lexer::getLocForEndOfToken(rangeStart, 0, sm(), lo()));
- queueManualFixitWarning(clazy::getLocStart(ctorExpr));
+ queueManualFixitWarning(ctorExpr->getBeginLoc());
return {};
}
}
@@ -254,10 +253,10 @@ std::vector<FixItHint> Qt4QStringFromArray::fixitInsertFromLatin1(CXXConstructEx
SourceRange range;
Expr *arg = *(ctorExpr->arg_begin());
- range.setBegin(clazy::getLocStart(arg));
+ range.setBegin(arg->getBeginLoc());
range.setEnd(Lexer::getLocForEndOfToken(clazy::biggestSourceLocationInStmt(sm(), ctorExpr), 0, sm(), lo()));
if (range.isInvalid()) {
- emitWarning(clazy::getLocStart(ctorExpr), "Internal error");
+ emitWarning(ctorExpr->getBeginLoc(), "Internal error");
return {};
}
diff --git a/src/checks/manuallevel/qt6-fwd-fixes.cpp b/src/checks/manuallevel/qt6-fwd-fixes.cpp
index e632f3cd..5ee9ce8b 100644
--- a/src/checks/manuallevel/qt6-fwd-fixes.cpp
+++ b/src/checks/manuallevel/qt6-fwd-fixes.cpp
@@ -8,11 +8,9 @@
#include "qt6-fwd-fixes.h"
#include "ClazyContext.h"
#include "FixItUtils.h"
-#include "HierarchyUtils.h"
#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "Utils.h"
-#include "clazy_stl.h"
#include <clang/AST/Decl.h>
#include <clang/AST/DeclCXX.h>
@@ -28,7 +26,6 @@
#include <llvm/ADT/StringRef.h>
#include <llvm/Support/Casting.h>
-#include "llvm/MC/MCAsmMacro.h"
#include <clang/Basic/Specifiers.h>
using namespace clang;
diff --git a/src/checks/manuallevel/qt6-fwd-fixes.h b/src/checks/manuallevel/qt6-fwd-fixes.h
index 6f1fe975..c70f5504 100644
--- a/src/checks/manuallevel/qt6-fwd-fixes.h
+++ b/src/checks/manuallevel/qt6-fwd-fixes.h
@@ -11,7 +11,6 @@
#include "checkbase.h"
#include <string>
-#include <vector>
class ClazyContext;
diff --git a/src/checks/manuallevel/qt6-header-fixes.cpp b/src/checks/manuallevel/qt6-header-fixes.cpp
index 1e33689d..0c9cb48f 100644
--- a/src/checks/manuallevel/qt6-header-fixes.cpp
+++ b/src/checks/manuallevel/qt6-header-fixes.cpp
@@ -8,11 +8,8 @@
#include "qt6-header-fixes.h"
#include "ClazyContext.h"
#include "FixItUtils.h"
-#include "HierarchyUtils.h"
#include "SourceCompatibilityHelpers.h"
-#include "StringUtils.h"
#include "Utils.h"
-#include "clazy_stl.h"
#include <clang/AST/Decl.h>
#include <clang/AST/DeclCXX.h>
diff --git a/src/checks/manuallevel/qt6-header-fixes.h b/src/checks/manuallevel/qt6-header-fixes.h
index b980f549..d21440df 100644
--- a/src/checks/manuallevel/qt6-header-fixes.h
+++ b/src/checks/manuallevel/qt6-header-fixes.h
@@ -11,7 +11,6 @@
#include "checkbase.h"
#include <string>
-#include <vector>
class ClazyContext;
diff --git a/src/checks/manuallevel/qt6-qhash-signature.cpp b/src/checks/manuallevel/qt6-qhash-signature.cpp
index 62c7d081..bea1a950 100644
--- a/src/checks/manuallevel/qt6-qhash-signature.cpp
+++ b/src/checks/manuallevel/qt6-qhash-signature.cpp
@@ -9,7 +9,6 @@
#include "ClazyContext.h"
#include "FixItUtils.h"
#include "HierarchyUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "Utils.h"
#include <clang/AST/Decl.h>
@@ -143,15 +142,15 @@ void Qt6QHashSignature::VisitStmt(clang::Stmt *stmt)
}
declType = funcDecl->getReturnType().getAsString();
fixitRange = funcDecl->getReturnTypeSourceRange();
- warningLocation = clazy::getLocStart(funcDecl);
+ warningLocation = funcDecl->getBeginLoc();
} else if (varDecl) {
declType = varDecl->getType().getAsString();
fixitRange = varDecl->getTypeSourceInfo()->getTypeLoc().getSourceRange();
- warningLocation = clazy::getLocStart(varDecl);
+ warningLocation = varDecl->getBeginLoc();
} else if (fieldDecl) {
declType = fieldDecl->getType().getAsString();
fixitRange = fieldDecl->getTypeSourceInfo()->getTypeLoc().getSourceRange();
- warningLocation = clazy::getLocStart(fieldDecl);
+ warningLocation = fieldDecl->getBeginLoc();
}
std::string qhashReturnType = declRefExpr->getDecl()->getAsFunction()->getReturnType().getAsString();
@@ -165,7 +164,7 @@ void Qt6QHashSignature::VisitStmt(clang::Stmt *stmt)
// just emit warning...
if (declType == "size_t" && qhashReturnType != "size_t") {
message = name + " should return size_t";
- emitWarning(clazy::getLocStart(declRefExpr), message, fixits);
+ emitWarning(declRefExpr->getBeginLoc(), message, fixits);
return;
}
@@ -198,7 +197,7 @@ void Qt6QHashSignature::VisitDecl(clang::Decl *decl)
std::string message;
message = funcDecl->getNameAsString() + " with uint signature";
fixits = fixitReplace(funcDecl, wrongReturnType, wrongParamType);
- emitWarning(clazy::getLocStart(funcDecl), message, fixits);
+ emitWarning(funcDecl->getBeginLoc(), message, fixits);
}
return;
diff --git a/src/checks/manuallevel/qt6-qlatin1stringchar-to-u.cpp b/src/checks/manuallevel/qt6-qlatin1stringchar-to-u.cpp
index cea4ca74..cc58ba53 100644
--- a/src/checks/manuallevel/qt6-qlatin1stringchar-to-u.cpp
+++ b/src/checks/manuallevel/qt6-qlatin1stringchar-to-u.cpp
@@ -9,7 +9,6 @@
#include "ClazyContext.h"
#include "FixItUtils.h"
#include "HierarchyUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "Utils.h"
#include "clazy_stl.h"
@@ -192,15 +191,15 @@ void Qt6QLatin1StringCharToU::VisitStmt(clang::Stmt *stmt)
std::string message;
for (auto macro_pos : m_listingMacroExpand) {
- if (m_sm.isPointWithin(macro_pos, clazy::getLocStart(stmt), clazy::getLocEnd(stmt))) {
+ if (m_sm.isPointWithin(macro_pos, stmt->getBeginLoc(), stmt->getEndLoc())) {
message = "QLatin1Char or QLatin1String is being called (fix it not supported because of macro)";
- emitWarning(clazy::getLocStart(stmt), message, fixits);
+ emitWarning(stmt->getBeginLoc(), message, fixits);
return;
}
}
if (!m_QStringOrQChar_fix) {
message = "QLatin1Char or QLatin1String is being called (fix it not supported)";
- emitWarning(clazy::getLocStart(stmt), message, fixits);
+ emitWarning(stmt->getBeginLoc(), message, fixits);
return;
}
@@ -223,14 +222,14 @@ bool Qt6QLatin1StringCharToU::checkCTorExpr(clang::Stmt *stmt, bool check_parent
bool noFix = false;
- SourceLocation warningLocation = clazy::getLocStart(stmt);
+ SourceLocation warningLocation = stmt->getBeginLoc();
if (!isInterestingCtorCall(ctorExpr, m_context, check_parents)) {
return false;
}
message = "QLatin1Char or QLatin1String is being called";
- if (clazy::getLocStart(stmt).isMacroID()) {
- SourceLocation callLoc = clazy::getLocStart(stmt);
+ if (stmt->getBeginLoc().isMacroID()) {
+ SourceLocation callLoc = stmt->getBeginLoc();
message += " in macro ";
message += Lexer::getImmediateMacroName(callLoc, m_sm, lo());
message += ". Please replace with `u` call manually.";
diff --git a/src/checks/manuallevel/qvariant-template-instantiation.cpp b/src/checks/manuallevel/qvariant-template-instantiation.cpp
index 3ad57222..0925d317 100644
--- a/src/checks/manuallevel/qvariant-template-instantiation.cpp
+++ b/src/checks/manuallevel/qvariant-template-instantiation.cpp
@@ -107,6 +107,6 @@ void QVariantTemplateInstantiation::VisitStmt(clang::Stmt *stm)
typeName2.erase(0, 1); // Remove first letter
}
std::string error = std::string("Use QVariant::to" + typeName2 + "() instead of QVariant::value<" + typeName + ">()");
- emitWarning(clazy::getLocStart(stm), error);
+ emitWarning(stm->getBeginLoc(), error);
}
}
diff --git a/src/checks/manuallevel/reserve-candidates.cpp b/src/checks/manuallevel/reserve-candidates.cpp
index 0122ddab..1a899484 100644
--- a/src/checks/manuallevel/reserve-candidates.cpp
+++ b/src/checks/manuallevel/reserve-candidates.cpp
@@ -14,7 +14,6 @@
#include "LoopUtils.h"
#include "MacroUtils.h"
#include "QtUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "StringUtils.h"
#include "Utils.h"
#include "clazy_stl.h"
@@ -131,15 +130,15 @@ bool ReserveCandidates::isReserveCandidate(ValueDecl *valueDecl, Stmt *loopBody,
const bool isMemberVariable = Utils::isMemberVariable(valueDecl);
// We only want containers defined outside of the loop we're examining
- if (!isMemberVariable && sm().isBeforeInSLocAddrSpace(clazy::getLocStart(loopBody), clazy::getLocStart(valueDecl))) {
+ if (!isMemberVariable && sm().isBeforeInSLocAddrSpace(loopBody->getBeginLoc(), valueDecl->getBeginLoc())) {
return false;
}
- if (isInComplexLoop(callExpr, clazy::getLocStart(valueDecl), isMemberVariable)) {
+ if (isInComplexLoop(callExpr, valueDecl->getBeginLoc(), isMemberVariable)) {
return false;
}
- if (clazy::loopCanBeInterrupted(loopBody, m_context->sm, clazy::getLocStart(callExpr))) {
+ if (clazy::loopCanBeInterrupted(loopBody, m_context->sm, callExpr->getBeginLoc())) {
return false;
}
@@ -157,7 +156,7 @@ void ReserveCandidates::VisitStmt(clang::Stmt *stm)
return;
}
- const bool isForeach = clazy::isInMacro(&m_astContext, clazy::getLocStart(stm), "Q_FOREACH");
+ const bool isForeach = clazy::isInMacro(&m_astContext, stm->getBeginLoc(), "Q_FOREACH");
// If the body is another loop, we have nesting, ignore it now since the inner loops will be visited soon.
if (isa<DoStmt>(body) || isa<WhileStmt>(body) || (!isForeach && isa<ForStmt>(body))) {
@@ -185,7 +184,7 @@ void ReserveCandidates::VisitStmt(clang::Stmt *stm)
ValueDecl *valueDecl = Utils::valueDeclForCallExpr(callExpr);
if (isReserveCandidate(valueDecl, body, callExpr)) {
- emitWarning(clazy::getLocStart(callExpr), "Reserve candidate");
+ emitWarning(callExpr->getBeginLoc(), "Reserve candidate");
}
}
}
@@ -302,7 +301,7 @@ bool ReserveCandidates::isInComplexLoop(clang::Stmt *s, SourceLocation declLocat
static std::vector<unsigned int> nonComplexOnesCache;
static std::vector<unsigned int> complexOnesCache;
- auto rawLoc = clazy::getLocStart(s).getRawEncoding();
+ auto rawLoc = s->getBeginLoc().getRawEncoding();
// For some reason we generate two warnings on some foreaches, so cache the ones we processed
// and return true so we don't trigger a warning
@@ -313,7 +312,7 @@ bool ReserveCandidates::isInComplexLoop(clang::Stmt *s, SourceLocation declLocat
Stmt *parent = s;
PresumedLoc lastForeachForStm;
while ((parent = clazy::parent(m_context->parentMap, parent))) {
- const SourceLocation parentStart = clazy::getLocStart(parent);
+ const SourceLocation parentStart = parent->getBeginLoc();
if (!isMemberVariable && sm().isBeforeInSLocAddrSpace(parentStart, declLocation)) {
nonComplexOnesCache.push_back(rawLoc);
return false;
diff --git a/src/checks/manuallevel/sanitize-inline-keyword.cpp b/src/checks/manuallevel/sanitize-inline-keyword.cpp
index 007a42fa..07c56a73 100644
--- a/src/checks/manuallevel/sanitize-inline-keyword.cpp
+++ b/src/checks/manuallevel/sanitize-inline-keyword.cpp
@@ -86,11 +86,11 @@ void SanitizeInlineKeyword::VisitDecl(Decl *decl)
"This could lead to hard-to-suppress warnings with some compilers (e.g. MinGW). "
"The 'inline' keyword should be used for the declaration only.";
- SourceLocation loc = clazy::getLocStart(member);
+ SourceLocation loc = member->getBeginLoc();
std::vector<FixItHint> fixits{clazy::createInsertion(loc, "inline "s)};
- SourceLocation def = clazy::getLocStart(cxxDefinition);
- SourceLocation defEnd = clazy::getLocEnd(cxxDefinition);
+ SourceLocation def = cxxDefinition->getBeginLoc();
+ SourceLocation defEnd = cxxDefinition->getEndLoc();
Token tok;
for (; def.isValid() && def != defEnd; def = Utils::locForNextToken(def, sm(), lo())) {
if (!Lexer::getRawToken(def, tok, sm(), lo())) { // false means success!
diff --git a/src/checks/manuallevel/unneeded-cast.cpp b/src/checks/manuallevel/unneeded-cast.cpp
index 97850646..95b47b4e 100644
--- a/src/checks/manuallevel/unneeded-cast.cpp
+++ b/src/checks/manuallevel/unneeded-cast.cpp
@@ -11,7 +11,6 @@
#include "ClazyContext.h"
#include "HierarchyUtils.h"
#include "QtUtils.h"
-#include "SourceCompatibilityHelpers.h"
#include "TypeUtils.h"
#include "Utils.h"
@@ -95,7 +94,7 @@ bool UnneededCast::handleNamedCast(CXXNamedCastExpr *namedCast)
return false;
}
- if (clazy::getLocStart(namedCast).isMacroID()) {
+ if (namedCast->getBeginLoc().isMacroID()) {
return false;
}
@@ -119,7 +118,7 @@ bool UnneededCast::handleNamedCast(CXXNamedCastExpr *namedCast)
}
if (isDynamicCast && !isOptionSet("prefer-dynamic-cast-over-qobject") && clazy::isQObject(castFrom)) {
- emitWarning(clazy::getLocStart(namedCast), "Use qobject_cast rather than dynamic_cast");
+ emitWarning(namedCast->getBeginLoc(), "Use qobject_cast rather than dynamic_cast");
}
CXXRecordDecl *castTo = Utils::namedCastOuterDecl(namedCast);
@@ -148,19 +147,19 @@ bool UnneededCast::maybeWarn(Stmt *stmt, CXXRecordDecl *castFrom, CXXRecordDecl
castTo = castTo->getCanonicalDecl();
if (castFrom == castTo) {
- emitWarning(clazy::getLocStart(stmt), "Casting to itself");
+ emitWarning(stmt->getBeginLoc(), "Casting to itself");
return true;
}
if (clazy::derivesFrom(/*child=*/castFrom, castTo)) {
if (isQObjectCast) {
const bool isTernaryOperator = clazy::getFirstParentOfType<ConditionalOperator>(m_context->parentMap, stmt) != nullptr;
if (isTernaryOperator) {
- emitWarning(clazy::getLocStart(stmt), "use static_cast instead of qobject_cast");
+ emitWarning(stmt->getBeginLoc(), "use static_cast instead of qobject_cast");
} else {
- emitWarning(clazy::getLocStart(stmt), "explicitly casting to base is unnecessary");
+ emitWarning(stmt->getBeginLoc(), "explicitly casting to base is unnecessary");
}
} else {
- emitWarning(clazy::getLocStart(stmt), "explicitly casting to base is unnecessary");
+ emitWarning(stmt->getBeginLoc(), "explicitly casting to base is unnecessary");
}
return true;
diff --git a/src/checks/manuallevel/unused-result-check.h b/src/checks/manuallevel/unused-result-check.h
index 7082dc94..05119c82 100644
--- a/src/checks/manuallevel/unused-result-check.h
+++ b/src/checks/manuallevel/unused-result-check.h
@@ -11,7 +11,6 @@
#include "checkbase.h"
#include <string>
-#include <vector>
class Caller;
class ClazyContext;
diff --git a/src/checks/manuallevel/use-arrow-operator-instead-of-data.cpp b/src/checks/manuallevel/use-arrow-operator-instead-of-data.cpp
index fe5a5117..fe33875c 100644
--- a/src/checks/manuallevel/use-arrow-operator-instead-of-data.cpp
+++ b/src/checks/manuallevel/use-arrow-operator-instead-of-data.cpp
@@ -69,5 +69,5 @@ void UseArrowOperatorInsteadOfData::VisitStmt(clang::Stmt *stmt)
FixItHint removal = FixItHint::CreateRemoval(sourceRange);
fixits.push_back(std::move(removal));
- emitWarning(clazy::getLocStart(callExpr), "Use operator -> directly instead of " + ClassName + "::data()->", fixits);
+ emitWarning(callExpr->getBeginLoc(), "Use operator -> directly instead of " + ClassName + "::data()->", fixits);
}
diff --git a/src/checks/manuallevel/use-chrono-in-qtimer.cpp b/src/checks/manuallevel/use-chrono-in-qtimer.cpp
index ac764a3b..b5c41cc7 100644
--- a/src/checks/manuallevel/use-chrono-in-qtimer.cpp
+++ b/src/checks/manuallevel/use-chrono-in-qtimer.cpp
@@ -78,7 +78,7 @@ void UseChronoInQTimer::warn(const clang::Stmt *stmt, int value)
#endif
m_hasInsertedInclude = true;
- emitWarning(clazy::getLocStart(stmt), "make code more robust: use " + suggestion + " instead.", fixits);
+ emitWarning(stmt->getBeginLoc(), "make code more robust: use " + suggestion + " instead.", fixits);
}
static std::string functionName(CallExpr *callExpr)
diff --git a/src/checks/requiredresults.cpp b/src/checks/requiredresults.cpp
index b817b497..5ab0cd38 100644
--- a/src/checks/requiredresults.cpp
+++ b/src/checks/requiredresults.cpp
@@ -108,7 +108,7 @@ void RequiredResults::VisitStmt(clang::Stmt *stm)
if (!bailout) {
std::string error = std::string("Unused result of const member (") + methodName + ')';
- emitWarning(clazy::getLocStart(callExpr), error);
+ emitWarning(callExpr->getBeginLoc(), error);
}
}
}