Skip to content

Commit

Permalink
[CIR][CIRGen] Add suppport for local typedefs (llvm#451)
Browse files Browse the repository at this point in the history
The change is taken from original codegen.
  • Loading branch information
YazZz1k authored and lanza committed Apr 17, 2024
1 parent 5bf8c1f commit a41ddd1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 831,12 @@ void CIRGenFunction::buildDecl(const Decl &D) {

case Decl::Typedef: // typedef int X;
case Decl::TypeAlias: { // using X = int; [C 0x]
assert(0 && "Not implemented");
QualType Ty = cast<TypedefNameDecl>(D).getUnderlyingType();
if (auto *DI = getDebugInfo())
assert(!UnimplementedFeature::generateDebugInfo());
if (Ty->isVariablyModifiedType())
buildVariablyModifiedType(Ty);
return;
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions clang/test/CIR/CodeGen/typedef.c
Original file line number Diff line number Diff line change
@@ -0,0 1,10 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir-enable -emit-cir %s -o - | FileCheck %s

void local_typedef() {
typedef struct {int a;} Struct;
Struct s;
}

//CHECK: cir.func no_proto @local_typedef()
//CHECK: {{.*}} = cir.alloca !ty_22Struct22, cir.ptr <!ty_22Struct22>, ["s"] {alignment = 4 : i64}
//CHECK: cir.return

0 comments on commit a41ddd1

Please sign in to comment.