From 6fd26424af4a012c851af4cc8da81bbc09ffd796 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 24 Oct 2012 20:21:25 +0000 Subject: [PATCH] Don't print scope qualifiers for references to a type defined locally in a function. Patch by Grzegorz Jablonski. llvm-svn: 166617 --- clang/lib/AST/TypePrinter.cpp | 1 + clang/test/SemaCXX/ast-print.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index 4cf4b1847f42..90b2ca9cce15 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -799,6 +799,7 @@ void TypePrinter::printAtomicAfter(const AtomicType *T, raw_ostream &OS) { } /// Appends the given scope to the end of a string. void TypePrinter::AppendScope(DeclContext *DC, raw_ostream &OS) { if (DC->isTranslationUnit()) return; + if (DC->isFunctionOrMethod()) return; AppendScope(DC->getParent(), OS); if (NamespaceDecl *NS = dyn_cast(DC)) { diff --git a/clang/test/SemaCXX/ast-print.cpp b/clang/test/SemaCXX/ast-print.cpp index 0dad623d47d9..aeb4039d597d 100644 --- a/clang/test/SemaCXX/ast-print.cpp +++ b/clang/test/SemaCXX/ast-print.cpp @@ -64,3 +64,20 @@ template void test7() // CHECK: t.~T(); template void test8(T t) { t.~T(); } + + +// CHECK: enum E { +// CHECK-NEXT: A, +// CHECK-NEXT: B, +// CHECK-NEXT: C +// CHECK-NEXT: }; +// CHECK-NEXT: {{^[ ]+}}E a = A; + +struct test9 +{ + void f() + { + enum E { A, B, C }; + E a = A; + } +}; -- GitLab