summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Gehre <M.Gehre@gmx.de>2019-05-14 18:23:10 +0000
committerMatthias Gehre <M.Gehre@gmx.de>2019-05-14 18:23:10 +0000
commit094584cd522b119444a05019189f2065ad1d215c (patch)
tree497bdbd96c247c0f6e6982b381e55751b9a47519
parent80c6e79602f396f9f7b6ce6117e868230b17aca0 (diff)
downloadbcm5719-llvm-094584cd522b119444a05019189f2065ad1d215c.tar.gz
bcm5719-llvm-094584cd522b119444a05019189f2065ad1d215c.zip
[clang-tidy] Fix invalid fixit for readability-static-accessed-through-instance (bug 40544)
Summary: Fixed https://bugs.llvm.org/show_bug.cgi?id=40544 Before, we would generate a fixit like `(anonymous namespace)::Foo::fun();` for the added test case. Reviewers: aaron.ballman, alexfh, xazax.hun Subscribers: rnkovacs, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D61874 llvm-svn: 360698
-rw-r--r--clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp1
-rw-r--r--clang-tools-extra/test/clang-tidy/readability-static-accessed-through-instance.cpp28
2 files changed, 29 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp b/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
index 8458fe3c2f0..e7d70f06bdb 100644
--- a/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
@@ -67,6 +67,7 @@ void StaticAccessedThroughInstanceCheck::check(
const ASTContext *AstContext = Result.Context;
PrintingPolicy PrintingPolicyWithSupressedTag(AstContext->getLangOpts());
PrintingPolicyWithSupressedTag.SuppressTagKeyword = true;
+ PrintingPolicyWithSupressedTag.SuppressUnwrittenScope = true;
std::string BaseTypeName =
BaseType.getAsString(PrintingPolicyWithSupressedTag);
diff --git a/clang-tools-extra/test/clang-tidy/readability-static-accessed-through-instance.cpp b/clang-tools-extra/test/clang-tidy/readability-static-accessed-through-instance.cpp
index fc42a1d191a..9de96ae3a9d 100644
--- a/clang-tools-extra/test/clang-tidy/readability-static-accessed-through-instance.cpp
+++ b/clang-tools-extra/test/clang-tidy/readability-static-accessed-through-instance.cpp
@@ -220,3 +220,31 @@ int func(Qptr qp) {
qp->y = 10; // OK, the overloaded operator might have side-effects.
qp->K = 10; //
}
+
+namespace {
+ struct Anonymous {
+ static int I;
+ };
+}
+
+void use_anonymous() {
+ Anonymous Anon;
+ Anon.I;
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+ // CHECK-FIXES: {{^}} Anonymous::I;{{$}}
+}
+
+namespace Outer {
+ inline namespace Inline {
+ struct S {
+ static int I;
+ };
+ }
+}
+
+void use_inline() {
+ Outer::S V;
+ V.I;
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+ // CHECK-FIXES: {{^}} Outer::S::I;{{$}}
+}
OpenPOWER on IntegriCloud