[clang] de7cd3c - [Clang][CodeGen]Remove anonymous tag locations

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 29 11:39:15 PDT 2022


Author: wangyihan
Date: 2022-03-29T11:38:29-07:00
New Revision: de7cd3ccf563847a24e04fb920cd0e3c310ba5bd

URL: https://github.com/llvm/llvm-project/commit/de7cd3ccf563847a24e04fb920cd0e3c310ba5bd
DIFF: https://github.com/llvm/llvm-project/commit/de7cd3ccf563847a24e04fb920cd0e3c310ba5bd.diff

LOG: [Clang][CodeGen]Remove anonymous tag locations

Remove anonymous tag locations, powered by 'PrintingPolicy',
@aaron.ballman once suggested removing this extra information in
https://reviews.llvm.org/D122248
struct:

  struct S {
    int a;
    struct /* Anonymous*/ {
      int x;
    } b;
    int c;
  };

Before:

  struct S {
    int a = 0
      struct S::(unnamed at ./builtin_dump_struct.c:20:3) {
        int x = 0
      }
    int c = 0
  }

After:

struct S {
  int a = 0
    struct S::(unnamed) {
      int x = 0
    }
  int c = 0
}

Differntial Revision: https://reviews.llvm.org/D122670

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/lib/CodeGen/CGBuiltin.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e893f5b4627c7..69806fa4407dc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -116,6 +116,7 @@ Non-comprehensive list of changes in this release
 - Improve __builtin_dump_struct:
   - Support bitfields in struct and union.
   - Improve the dump format, dump both bitwidth(if its a bitfield) and field value.
+  - Remove anonymous tag locations.
 
 New Compiler Flags
 ------------------

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index b0df0b147fc52..2159dd7139101 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2050,8 +2050,10 @@ static llvm::Value *dumpRecord(CodeGenFunction &CGF, QualType RType,
   RecordDecl *RD = RType->castAs<RecordType>()->getDecl()->getDefinition();
   std::string Pad = std::string(Lvl * 4, ' ');
 
+  PrintingPolicy Policy(Context.getLangOpts());
+  Policy.AnonymousTagLocations = false;
   Value *GString =
-      CGF.Builder.CreateGlobalStringPtr(RType.getAsString() + " {\n");
+      CGF.Builder.CreateGlobalStringPtr(RType.getAsString(Policy) + " {\n");
   Value *Res = CGF.Builder.CreateCall(Func, {GString});
 
   static llvm::DenseMap<QualType, const char *> Types;


        


More information about the cfe-commits mailing list