[PATCH] D71301: [clang][IFS] Prevent Clang-IFS from Leaking symbols from inside a block.
Puyan Lotfi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 10 13:43:53 PST 2019
plotfi created this revision.
plotfi added reviewers: compnerd, cishida.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.
Built libdispatch with clang interface stubs. Ran into some block related issues. Basically VarDecl symbols can leak out because I wasn't checking the case where a VarDecl is contained inside a BlockDecl (versus a method or function).
This patch checks that a VarDecl is not a child decl of a BlockDecl.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D71301
Files:
clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
clang/test/InterfaceStubs/blocks.c
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,6 +52,11 @@
if (!isVisible(ND))
return true;
+ if (const VarDecl *VD = dyn_cast<VarDecl>(ND))
+ if (const auto *Parent = VD->getParentFunctionOrMethod())
+ if (const auto *BD = dyn_cast_or_null<BlockDecl>(Parent))
+ return true;
+
if (const VarDecl *VD = dyn_cast<VarDecl>(ND))
if ((VD->getStorageClass() == StorageClass::SC_Extern) ||
(VD->getStorageClass() == StorageClass::SC_Static &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71301.233187.patch
Type: text/x-patch
Size: 1203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191210/6411d4a3/attachment.bin>
More information about the cfe-commits
mailing list