r201437 - Consistently print anonymous namespace names as "<anonymous namespace>"

David Blaikie dblaikie at gmail.com
Fri Feb 14 14:22:24 PST 2014


On Fri, Feb 14, 2014 at 2:12 PM, David Blaikie <dblaikie at gmail.com> wrote:

> Author: dblaikie
> Date: Fri Feb 14 16:12:54 2014
> New Revision: 201437
>
> URL: http://llvm.org/viewvc/llvm-project?rev=201437&view=rev
> Log:
> Consistently print anonymous namespace names as "<anonymous namespace>"
>
> For some reason we have two bits of code handling this printing:
>
> lib/AST/Decl.cpp:        OS << "<anonymous namespace>";
> lib/AST/TypePrinter.cpp:      OS << "<anonymous namespace>::";
>
> it would be nice if we only had one...
>

Sorry - forgot to squash this and the previous commit (r201436 to
TypePrinter.cpp) into one before committing.


>
> Modified:
>     cfe/trunk/test/Modules/namespaces.cpp
>     cfe/trunk/test/SemaCXX/undefined-internal.cpp
>     cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
>
> Modified: cfe/trunk/test/Modules/namespaces.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/namespaces.cpp?rev=201437&r1=201436&r2=201437&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Modules/namespaces.cpp (original)
> +++ cfe/trunk/test/Modules/namespaces.cpp Fri Feb 14 16:12:54 2014
> @@ -69,8 +69,8 @@ void testMergedMerged() {
>  // Test merging when using anonymous namespaces, which does not
>  // actually perform any merging.
>  void testAnonymousNotMerged() {
> -  N11::consumeFoo(N11::getFoo()); // expected-error{{cannot initialize a
> parameter of type 'N11::<anonymous>::Foo *' with an rvalue of type
> 'N11::<anonymous>::Foo *'}}
> -  N12::consumeFoo(N12::getFoo()); // expected-error{{cannot initialize a
> parameter of type 'N12::<anonymous>::Foo *' with an rvalue of type
> 'N12::<anonymous>::Foo *'}}
> +  N11::consumeFoo(N11::getFoo()); // expected-error{{cannot initialize a
> parameter of type 'N11::<anonymous namespace>::Foo *' with an rvalue of
> type 'N11::<anonymous namespace>::Foo *'}}
> +  N12::consumeFoo(N12::getFoo()); // expected-error{{cannot initialize a
> parameter of type 'N12::<anonymous namespace>::Foo *' with an rvalue of
> type 'N12::<anonymous namespace>::Foo *'}}
>  }
>
>  // expected-note at Inputs/namespaces-right.h:60 {{passing argument to
> parameter here}}
>
> Modified: cfe/trunk/test/SemaCXX/undefined-internal.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/undefined-internal.cpp?rev=201437&r1=201436&r2=201437&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/undefined-internal.cpp (original)
> +++ cfe/trunk/test/SemaCXX/undefined-internal.cpp Fri Feb 14 16:12:54 2014
> @@ -78,8 +78,8 @@ namespace test5 {
>    }
>
>    template <class N> struct B {
> -    static int var; // expected-warning {{variable
> 'test5::B<test5::<anonymous>::A>::var' has internal linkage but is not
> defined}}
> -    static void foo(); // expected-warning {{function
> 'test5::B<test5::<anonymous>::A>::foo' has internal linkage but is not
> defined}}
> +    static int var; // expected-warning {{variable
> 'test5::B<test5::<anonymous namespace>::A>::var' has internal linkage but
> is not defined}}
> +    static void foo(); // expected-warning {{function
> 'test5::B<test5::<anonymous namespace>::A>::foo' has internal linkage but
> is not defined}}
>    };
>
>    void test() {
>
> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=201437&r1=201436&r2=201437&view=diff
>
> ==============================================================================
> --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
> +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Fri Feb 14
> 16:12:54 2014
> @@ -1038,7 +1038,7 @@ TEST(HasType, MatchesAsString) {
>    EXPECT_TRUE(matches("namespace ns { struct A {}; }  struct B { ns::A a;
> };",
>        fieldDecl(hasType(asString("ns::A")))));
>    EXPECT_TRUE(matches("namespace { struct A {}; }  struct B { A a; };",
> -      fieldDecl(hasType(asString("struct <anonymous>::A")))));
> +      fieldDecl(hasType(asString("struct <anonymous namespace>::A")))));
>  }
>
>  TEST(Matcher, OverloadedOperatorCall) {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140214/8d3d3a5a/attachment.html>


More information about the cfe-commits mailing list