[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
This commit is contained in:
wangyihan 2022-03-29 11:38:29 -07:00 committed by Erich Keane
parent 7a94a032f0
commit de7cd3ccf5
2 changed files with 4 additions and 1 deletions

View File

@ -116,6 +116,7 @@ Non-comprehensive list of changes in this release
- Improve __builtin_dump_struct: - Improve __builtin_dump_struct:
- Support bitfields in struct and union. - Support bitfields in struct and union.
- Improve the dump format, dump both bitwidth(if its a bitfield) and field value. - Improve the dump format, dump both bitwidth(if its a bitfield) and field value.
- Remove anonymous tag locations.
New Compiler Flags New Compiler Flags
------------------ ------------------

View File

@ -2050,8 +2050,10 @@ static llvm::Value *dumpRecord(CodeGenFunction &CGF, QualType RType,
RecordDecl *RD = RType->castAs<RecordType>()->getDecl()->getDefinition(); RecordDecl *RD = RType->castAs<RecordType>()->getDecl()->getDefinition();
std::string Pad = std::string(Lvl * 4, ' '); std::string Pad = std::string(Lvl * 4, ' ');
PrintingPolicy Policy(Context.getLangOpts());
Policy.AnonymousTagLocations = false;
Value *GString = Value *GString =
CGF.Builder.CreateGlobalStringPtr(RType.getAsString() + " {\n"); CGF.Builder.CreateGlobalStringPtr(RType.getAsString(Policy) + " {\n");
Value *Res = CGF.Builder.CreateCall(Func, {GString}); Value *Res = CGF.Builder.CreateCall(Func, {GString});
static llvm::DenseMap<QualType, const char *> Types; static llvm::DenseMap<QualType, const char *> Types;