diff options
Diffstat (limited to 'compilerplugins/clang/indentation.cxx')
-rw-r--r-- | compilerplugins/clang/indentation.cxx | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/compilerplugins/clang/indentation.cxx b/compilerplugins/clang/indentation.cxx index 2dda32f8174c..cf2512d1d25d 100644 --- a/compilerplugins/clang/indentation.cxx +++ b/compilerplugins/clang/indentation.cxx @@ -16,6 +16,7 @@ #include <fstream> #include <set> #include <unordered_set> +#include "config_clang.h" #include "plugin.hxx" /* @@ -50,6 +51,7 @@ public: return false; // the QEMIT macros if (loplugin::hasPathnamePrefix(fn, SRCDIR "/vcl/qt5/") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/vcl/qt6/") || loplugin::isSamePathname(fn, SRCDIR "/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx")) return false; return true; @@ -118,7 +120,7 @@ bool Indentation::VisitCompoundStmt(CompoundStmt const* compoundStmt) { auto stmt = *i; auto const actualPrevEnd = prevEnd; - prevEnd = compat::getEndLoc(stmt); // compute early, before below `continue`s + prevEnd = stmt->getEndLoc(); // compute early, before below `continue`s // these show up in macro expansions, not interesting if (isa<NullStmt>(stmt)) @@ -126,28 +128,8 @@ bool Indentation::VisitCompoundStmt(CompoundStmt const* compoundStmt) // these are always weirdly indented if (isa<LabelStmt>(stmt)) continue; -#if CLANG_VERSION < 100000 - // Before - // <https://github.com/llvm/llvm-project/commit/dc3957ec215dd17b8d293461f18696566637a6cd> - // "Include leading attributes in DeclStmt's SourceRange", getBeginLoc of a VarDecl DeclStmt - // with an UnusedAttr pointed after the attr (and getLocation of the attr pointed at - // "maybe_unused", not at the leading "[["), so just ignore those in old compiler versions: - if (auto const declStmt = dyn_cast<DeclStmt>(stmt)) - { - if (declStmt->decl_begin() != declStmt->decl_end()) - { - if (auto const decl = dyn_cast<VarDecl>(*declStmt->decl_begin())) - { - if (decl->hasAttr<UnusedAttr>()) - { - continue; - } - } - } - } -#endif - auto stmtLoc = compat::getBeginLoc(stmt); + auto stmtLoc = stmt->getBeginLoc(); StringRef macroName; bool partOfMacro = false; @@ -165,11 +147,7 @@ bool Indentation::VisitCompoundStmt(CompoundStmt const* compoundStmt) // similar thing in forms/ if (macroName == "DECL_IFACE_PROP_IMPL" || macroName == "DECL_BOOL_PROP_IMPL") continue; -#if CLANG_VERSION >= 70000 stmtLoc = SM.getExpansionRange(stmtLoc).getBegin(); -#else - stmtLoc = SM.getExpansionRange(stmtLoc).first; -#endif } // check for comment to the left of the statement @@ -211,13 +189,12 @@ bool Indentation::VisitCompoundStmt(CompoundStmt const* compoundStmt) { if (containsPreprocessingConditionalInclusion(SourceRange( locationAfterToken(compiler.getSourceManager().getExpansionLoc(actualPrevEnd)), - compiler.getSourceManager().getExpansionLoc(compat::getBeginLoc(stmt))))) + compiler.getSourceManager().getExpansionLoc(stmt->getBeginLoc())))) continue; report(DiagnosticsEngine::Warning, "statement mis-aligned compared to neighbours %0", stmtLoc) << macroName; - report(DiagnosticsEngine::Note, "measured against this one", - compat::getBeginLoc(firstStmt)); + report(DiagnosticsEngine::Note, "measured against this one", firstStmt->getBeginLoc()); //getParentStmt(compoundStmt)->dump(); //stmt->dump(); } @@ -228,7 +205,7 @@ bool Indentation::VisitCompoundStmt(CompoundStmt const* compoundStmt) auto bodyStmt = ifStmt->getThen(); if (bodyStmt && !isa<CompoundStmt>(bodyStmt)) { - stmtLoc = compat::getBeginLoc(bodyStmt); + stmtLoc = bodyStmt->getBeginLoc(); invalid1 = false; invalid2 = false; unsigned bodyColumn = SM.getPresumedColumnNumber(stmtLoc, &invalid1); @@ -243,7 +220,7 @@ bool Indentation::VisitCompoundStmt(CompoundStmt const* compoundStmt) auto elseStmt = ifStmt->getElse(); if (elseStmt && !isa<CompoundStmt>(elseStmt) && !isa<IfStmt>(elseStmt)) { - stmtLoc = compat::getBeginLoc(elseStmt); + stmtLoc = elseStmt->getBeginLoc(); invalid1 = false; invalid2 = false; unsigned elseColumn = SM.getPresumedColumnNumber(stmtLoc, &invalid1); @@ -340,7 +317,7 @@ void Indentation::checkCompoundStmtBraces(const Stmt* parentStmt, const Compound bool invalid1 = false; bool invalid2 = false; - auto parentBeginLoc = compat::getBeginLoc(parentStmt); + auto parentBeginLoc = parentStmt->getBeginLoc(); unsigned parentColumn = SM.getPresumedColumnNumber(parentBeginLoc, &invalid1); if (invalid1) return; @@ -405,7 +382,7 @@ void Indentation::checkCompoundStmtBraces(const Stmt* parentStmt, const Compound auto firstStmt = compoundStmt->body_front(); if (isa<LabelStmt>(firstStmt)) return; - auto firstStmtLoc = compat::getBeginLoc(firstStmt); + auto firstStmtLoc = firstStmt->getBeginLoc(); unsigned firstStmtBeginColumn = SM.getPresumedColumnNumber(firstStmtLoc, &invalid1); if (invalid1) return; @@ -440,7 +417,7 @@ bool Indentation::VisitSwitchStmt(SwitchStmt const* switchStmt) if (!caseStmt) continue; - auto stmtLoc = compat::getBeginLoc(caseStmt); + auto stmtLoc = caseStmt->getBeginLoc(); bool invalid1 = false; bool invalid2 = false; @@ -466,7 +443,7 @@ bool Indentation::VisitSwitchStmt(SwitchStmt const* switchStmt) // report(DiagnosticsEngine::Warning, "statement mis-aligned compared to neighbours", // stmtLoc); // report(DiagnosticsEngine::Note, "measured against this one", - // compat::getBeginLoc(firstStmt)); + // firstStmt->getBeginLoc()); //getParentStmt(compoundStmt)->dump(); //stmt->dump(); } |