[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
Mon Jan 13 11:31:54 PST 2020


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) &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71301.237739.patch
Type: text/x-patch
Size: 1938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200113/5ab72b13/attachment-0001.bin>


More information about the cfe-commits mailing list