summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-01-05 17:25:10 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-01-05 17:25:51 +0100
commitf569c4197c8e3d63ddd0e8c1f71cc5a6161b2fe5 (patch)
treeeabf34dcf53d2b5ad99d9e91bdf66ef6aa0992ba /compilerplugins
parentf627c122461de4dd4e75a995145e8838b1d9bf34 (diff)
Improve loplugin:revisibility
(for non-Windows--only code, as MSVC would complain about such cases anyway) Change-Id: Id6daf61b79bd31529bdaeb7c6df4f354731ae7d7
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/store/revisibility.cxx20
1 files changed, 19 insertions, 1 deletions
diff --git a/compilerplugins/clang/store/revisibility.cxx b/compilerplugins/clang/store/revisibility.cxx
index 11e3cc89ee5e..fec8ff7f7e61 100644
--- a/compilerplugins/clang/store/revisibility.cxx
+++ b/compilerplugins/clang/store/revisibility.cxx
@@ -41,11 +41,13 @@ bool ReVisibility::VisitFunctionDecl(FunctionDecl const * decl) {
if (!ignoreLocation(decl) && hasExplicitVisibilityAttr(decl)
&& !isFriendDecl(decl))
{
+ Decl const * first = nullptr;
for (Decl const * p = decl;;) {
p = p->getPreviousDecl();
if (p == nullptr) {
break;
}
+ first = p;
if (hasExplicitVisibilityAttr(p) && !isFriendDecl(p)) {
report(
DiagnosticsEngine::Warning,
@@ -57,9 +59,25 @@ bool ReVisibility::VisitFunctionDecl(FunctionDecl const * decl) {
"Previous visibility declaration is here",
p->getAttr<VisibilityAttr>()->getLocation())
<< p->getAttr<VisibilityAttr>()->getRange();
- break;
+ return true;
}
}
+ if (decl->isThisDeclarationADefinition() && first != nullptr
+ && !(compiler.getSourceManager().getFilename(
+ compiler.getSourceManager().getSpellingLoc(
+ decl->getLocation()))
+ .startswith(SRCDIR "/libreofficekit/")))
+ {
+ report(
+ DiagnosticsEngine::Warning,
+ "Visibility declaration on definition, not first declaration",
+ decl->getAttr<VisibilityAttr>()->getLocation())
+ << decl->getAttr<VisibilityAttr>()->getRange();
+ report(
+ DiagnosticsEngine::Note, "First declaration is here",
+ first->getLocation())
+ << first->getSourceRange();
+ }
}
return true;
}