plotfi updated this revision to Diff 237739. plotfi added a comment. using isa
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71301/new/ https://reviews.llvm.org/D71301 Files: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp clang/test/InterfaceStubs/blocks.c clang/test/InterfaceStubs/lambda.cpp Index: clang/test/InterfaceStubs/lambda.cpp =================================================================== --- /dev/null +++ clang/test/InterfaceStubs/lambda.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -emit-interface-stubs -o - %s | FileCheck %s + +// CHECK: --- !experimental-ifs-v1 +// CHECK-NEXT: IfsVersion: 1.0 +// CHECK-NEXT: Triple: +// CHECK-NEXT: ObjectFileFormat: ELF +// CHECK-NEXT: Symbols: +// CHECK-NEXT: "f" : { Type: Object, Size: 1 } +// CHECK-NEXT: ... +auto f = [](void* data) { int i; }; Index: clang/test/InterfaceStubs/blocks.c =================================================================== --- /dev/null +++ clang/test/InterfaceStubs/blocks.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -emit-interface-stubs -fblocks -o - %s | FileCheck %s + +// CHECK: --- !experimental-ifs-v1 +// CHECK-NEXT: IfsVersion: 1.0 +// CHECK-NEXT: Triple: +// CHECK-NEXT: ObjectFileFormat: ELF +// CHECK-NEXT: Symbols: +// CHECK-NEXT: ... +static void (^f)(void*) = ^(void* data) { int i; }; Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp =================================================================== --- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -52,11 +52,16 @@ if (!isVisible(ND)) return true; - if (const VarDecl *VD = dyn_cast<VarDecl>(ND)) + if (const VarDecl *VD = dyn_cast<VarDecl>(ND)) { + if (const auto *Parent = VD->getParentFunctionOrMethod()) + if (isa<BlockDecl>(Parent) || isa<CXXMethodDecl>(Parent)) + return true; + if ((VD->getStorageClass() == StorageClass::SC_Extern) || (VD->getStorageClass() == StorageClass::SC_Static && VD->getParentFunctionOrMethod() == nullptr)) return true; + } if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) { if (FD->isInlined() && !isa<CXXMethodDecl>(FD) &&
Index: clang/test/InterfaceStubs/lambda.cpp =================================================================== --- /dev/null +++ clang/test/InterfaceStubs/lambda.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -emit-interface-stubs -o - %s | FileCheck %s + +// CHECK: --- !experimental-ifs-v1 +// CHECK-NEXT: IfsVersion: 1.0 +// CHECK-NEXT: Triple: +// CHECK-NEXT: ObjectFileFormat: ELF +// CHECK-NEXT: Symbols: +// CHECK-NEXT: "f" : { Type: Object, Size: 1 } +// CHECK-NEXT: ... +auto f = [](void* data) { int i; }; Index: clang/test/InterfaceStubs/blocks.c =================================================================== --- /dev/null +++ clang/test/InterfaceStubs/blocks.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -emit-interface-stubs -fblocks -o - %s | FileCheck %s + +// CHECK: --- !experimental-ifs-v1 +// CHECK-NEXT: IfsVersion: 1.0 +// CHECK-NEXT: Triple: +// CHECK-NEXT: ObjectFileFormat: ELF +// CHECK-NEXT: Symbols: +// CHECK-NEXT: ... +static void (^f)(void*) = ^(void* data) { int i; }; Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp =================================================================== --- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -52,11 +52,16 @@ if (!isVisible(ND)) return true; - if (const VarDecl *VD = dyn_cast<VarDecl>(ND)) + if (const VarDecl *VD = dyn_cast<VarDecl>(ND)) { + if (const auto *Parent = VD->getParentFunctionOrMethod()) + if (isa<BlockDecl>(Parent) || isa<CXXMethodDecl>(Parent)) + return true; + if ((VD->getStorageClass() == StorageClass::SC_Extern) || (VD->getStorageClass() == StorageClass::SC_Static && VD->getParentFunctionOrMethod() == nullptr)) return true; + } if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) { if (FD->isInlined() && !isa<CXXMethodDecl>(FD) &&
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits