mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
fix(tidy): Only emit diagnostic if source location is valid
This commit is contained in:
parent
f3385173b2
commit
adf743750f
|
@ -14,7 +14,6 @@
|
||||||
#include <clang/ASTMatchers/ASTMatchers.h>
|
#include <clang/ASTMatchers/ASTMatchers.h>
|
||||||
#include <clang/Basic/Diagnostic.h>
|
#include <clang/Basic/Diagnostic.h>
|
||||||
#include <llvm/Support/Casting.h>
|
#include <llvm/Support/Casting.h>
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
namespace fair::mq::tidy {
|
namespace fair::mq::tidy {
|
||||||
|
|
||||||
|
@ -44,20 +43,12 @@ struct ModernizeNonNamespacedTypes
|
||||||
if (auto const type_alias_decl = m.Nodes.getNodeAs<TypeAliasDecl>("decl")) {
|
if (auto const type_alias_decl = m.Nodes.getNodeAs<TypeAliasDecl>("decl")) {
|
||||||
auto const underlying_type(type_alias_decl->getUnderlyingType());
|
auto const underlying_type(type_alias_decl->getUnderlyingType());
|
||||||
|
|
||||||
// auto ldecl_ctx(type_loc->getType()getLexicalDeclContext());
|
|
||||||
// std::stringstream s;
|
|
||||||
// while (ldecl_ctx) {
|
|
||||||
// s << "." << ldecl_ctx->getDeclKindName();
|
|
||||||
// if (ldecl_ctx->isNamespace()) {
|
|
||||||
// s << dyn_cast<NamespaceDecl>(ldecl_ctx)->getNameAsString();
|
|
||||||
// }
|
|
||||||
// ldecl_ctx = ldecl_ctx->getLexicalParent();
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (underlying_type.getAsString().rfind("fair::mq::", 0) == 0) {
|
if (underlying_type.getAsString().rfind("fair::mq::", 0) == 0) {
|
||||||
auto& diag_engine(m.Context->getDiagnostics());
|
auto& diag_engine(m.Context->getDiagnostics());
|
||||||
auto builder(
|
auto const location(type_loc->getBeginLoc());
|
||||||
diag_engine.Report(type_loc->getBeginLoc(),
|
if (location.isValid()) {
|
||||||
|
auto builder(diag_engine.Report(
|
||||||
|
location,
|
||||||
diag_engine.getCustomDiagID(
|
diag_engine.getCustomDiagID(
|
||||||
DiagnosticsEngine::Warning,
|
DiagnosticsEngine::Warning,
|
||||||
"Modernize non-namespaced type %0 with %1. [%2]")));
|
"Modernize non-namespaced type %0 with %1. [%2]")));
|
||||||
|
@ -70,6 +61,7 @@ struct ModernizeNonNamespacedTypes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user