twoh updated this revision to Diff 164564.
twoh edited the summary of this revision.
twoh added a comment.
Herald added a subscriber: cfe-commits.

Addressing comments from @echristo. Reverted option name change, and added a 
test case. Sorry I haven't work on this code for a while so it took time to 
invent a test case.


Repository:
  rC Clang

https://reviews.llvm.org/D38061

Files:
  lib/AST/Expr.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Frontend/CompilerInstance.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
  test/CodeGenCXX/debug-info-anonymous.cpp
  test/Sema/assign.c
  test/Sema/enum.c
  test/Sema/switch.c
  test/SemaCXX/condition.cpp
  test/SemaCXX/enum.cpp
  test/SemaCXX/lambda-expressions.cpp
  test/SemaCXX/pass-object-size.cpp
  test/SemaCXX/warn-sign-conversion.cpp

Index: test/SemaCXX/warn-sign-conversion.cpp
===================================================================
--- test/SemaCXX/warn-sign-conversion.cpp
+++ test/SemaCXX/warn-sign-conversion.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -verify -fsyntax-only -Wsign-conversion %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -dwarf-column-info -verify -fsyntax-only -Wsign-conversion %s
 
 // NOTE: When a 'enumeral mismatch' warning is implemented then expect several
 // of the following cases to be impacted.
Index: test/SemaCXX/pass-object-size.cpp
===================================================================
--- test/SemaCXX/pass-object-size.cpp
+++ test/SemaCXX/pass-object-size.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -verify %s -std=c++11
 
 namespace simple {
 int Foo(void *const p __attribute__((pass_object_size(0))));
Index: test/SemaCXX/lambda-expressions.cpp
===================================================================
--- test/SemaCXX/lambda-expressions.cpp
+++ test/SemaCXX/lambda-expressions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -dwarf-column-info -fsyntax-only -verify -fblocks %s
 
 namespace std { class type_info; };
 
Index: test/SemaCXX/enum.cpp
===================================================================
--- test/SemaCXX/enum.cpp
+++ test/SemaCXX/enum.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s
-// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s
+// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s
+// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s
 enum E { // expected-note{{previous definition is here}}
   Val1,
   Val2
Index: test/SemaCXX/condition.cpp
===================================================================
--- test/SemaCXX/condition.cpp
+++ test/SemaCXX/condition.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 
+// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -verify -std=c++11 %s
 
 void test() {
   int x;
Index: test/Sema/switch.c
===================================================================
--- test/Sema/switch.c
+++ test/Sema/switch.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default -triple x86_64-linux-gnu %s
-void f (int z) { 
-  while (z) { 
+// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default -triple x86_64-linux-gnu %s
+void f (int z) {
+  while (z) {
     default: z--;            // expected-error {{statement not in switch}}
-  } 
+  }
 }
 
 void foo(int X) {
@@ -22,7 +22,7 @@
   }
 }
 
-void test3(void) { 
+void test3(void) {
   // empty switch;
   switch (0); // expected-warning {{no case matching constant switch condition '0'}} \
               // expected-warning {{switch statement has empty body}} \
@@ -45,33 +45,33 @@
   case 0 ... g(): // expected-error {{expression is not an integer constant expression}}
     break;
   }
-  
+
   switch (cond) {
   case 0 && g() ... 1 || g():
     break;
   }
-  
+
   switch (cond) {
   case g() // expected-error {{expression is not an integer constant expression}}
       && 0:
     break;
   }
-  
+
   switch (cond) {
   case 0 ...
       g() // expected-error {{expression is not an integer constant expression}}
       || 1:
     break;
   }
 }
 
-void test5(int z) { 
+void test5(int z) {
   switch(z) {
     default:  // expected-note {{previous case defined here}}
     default:  // expected-error {{multiple default labels in one switch}}
       break;
   }
-} 
+}
 
 void test6() {
   char ch = 'a';
@@ -187,7 +187,7 @@
     case 0 ...  //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
 	    1:  //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
     case 2 ... 4:
-    case 5 ...  //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}	
+    case 5 ...  //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
 	      9:  //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
     case 10 ... 12:
     case 13 ...  //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
@@ -212,7 +212,7 @@
     case B:
     case C:
       break;
-      
+
     default:
       break;
   }
@@ -308,13 +308,13 @@
 typedef enum {
         kOne = 1,
 } Ints;
-        
+
 void rdar110822110(Ints i)
 {
         switch (i) {
                 case kOne:
                         break;
-                case 2: 	// expected-warning {{case value not in enumerated type 'Ints'}}          
+                case 2: 	// expected-warning {{case value not in enumerated type 'Ints'}}
                         break;
                 default:	// expected-warning {{default label in switch which covers all enumeration values}}
                         break;
Index: test/Sema/enum.c
===================================================================
--- test/Sema/enum.c
+++ test/Sema/enum.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple %s -fsyntax-only -verify -pedantic
-enum e {A, 
+// RUN: %clang_cc1 -triple %itanium_abi_triple %s -dwarf-column-info -fsyntax-only -verify -pedantic
+enum e {A,
         B = 42LL << 32,        // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
       C = -4, D = 12456 };
 
@@ -11,7 +11,7 @@
 enum h { e = -2147483648, // too pos
    f = 2147483648,           // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
   i = 0xFFFF0000 // expected-warning {{too large}}
-}; 
+};
 
 // minll maxull
 enum x                      // expected-warning {{enumeration values exceed range of largest integer}}
Index: test/Sema/assign.c
===================================================================
--- test/Sema/assign.c
+++ test/Sema/assign.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -verify %s
 
 void *test1(void) { return 0; }
 
Index: test/CodeGenCXX/debug-info-anonymous.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/debug-info-anonymous.cpp
@@ -0,0 +1,22 @@
+template <class T> int foo(const T v) {
+  return v;
+}
+
+int foo(int v) { return foo<int>(v); }
+
+class X {
+public:
+  enum { A };
+  int x() { return foo(A); }
+};
+
+int test() {
+  X x;
+  return x.x();
+}
+
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone %s -o - | FileCheck --check-prefix=NOLOC %s
+// RUN: %clang_cc1 -emit-llvm -dwarf-column-info -debug-info-kind=standalone %s -o - | FileCheck --check-prefix=LOC %s
+
+// NOLOC: X::(anonymous)
+// LOC: X::(anonymous enum at {{.*}}:9:3)
Index: test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
===================================================================
--- test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -std=c++11 %s -verify
 
 void defargs() {
   auto l1 = [](int i, int j = 17, int k = 18) { return i + j + k; };
Index: lib/Frontend/CompilerInstance.cpp
===================================================================
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -488,6 +488,10 @@
                                  PP.getIdentifierTable(), PP.getSelectorTable(),
                                  PP.getBuiltinInfo());
   Context->InitBuiltinTypes(getTarget(), getAuxTarget());
+  PrintingPolicy Policy = Context->getPrintingPolicy();
+  if (!getCodeGenOpts().DebugColumnInfo)
+    Policy.AnonymousTagLocations = false;
+  Context->setPrintingPolicy(Policy);
   setASTContext(Context);
 }
 
Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -234,6 +234,9 @@
   if (CGM.getCodeGenOpts().EmitCodeView)
     PP.MSVCFormatting = true;
 
+  if (!CGM.getCodeGenOpts().DebugColumnInfo)
+    PP.AnonymousTagLocations = false;
+
   return PP;
 }
 
Index: lib/AST/Expr.cpp
===================================================================
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -552,7 +552,7 @@
         Out << "static ";
     }
 
-    PrintingPolicy Policy(Context.getLangOpts());
+    PrintingPolicy Policy(Context.getPrintingPolicy());
     std::string Proto;
     llvm::raw_string_ostream POut(Proto);
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D38061: Set AnonymousTa... Taewook Oh via Phabricator via cfe-commits

Reply via email to