Author: mgehre Date: Tue May 14 11:23:10 2019 New Revision: 360698 URL: http://llvm.org/viewvc/llvm-project?rev=360698&view=rev Log: [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 Modified: clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp?rev=360698&r1=360697&r2=360698&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp Tue May 14 11:23:10 2019 @@ -67,6 +67,7 @@ void StaticAccessedThroughInstanceCheck: const ASTContext *AstContext = Result.Context; PrintingPolicy PrintingPolicyWithSupressedTag(AstContext->getLangOpts()); PrintingPolicyWithSupressedTag.SuppressTagKeyword = true; + PrintingPolicyWithSupressedTag.SuppressUnwrittenScope = true; std::string BaseTypeName = BaseType.getAsString(PrintingPolicyWithSupressedTag); Modified: clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp?rev=360698&r1=360697&r2=360698&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp Tue May 14 11:23:10 2019 @@ -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;{{$}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits