[PATCH] D33366: Fix that global delete operator get's assigned to a submodule.

Raphael Isemann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 8 03:33:07 PDT 2017


teemperor updated this revision to Diff 101877.
teemperor added a comment.

- Just unconditionally calling `setHidden` now.

IIRC I had to put the conditions for the module builds because setLocalOwningModule did trigger some tests/asserts, otherwise  but the setHidden works fine like this.


https://reviews.llvm.org/D33366

Files:
  lib/Sema/SemaExprCXX.cpp
  test/Modules/Inputs/local-submodule-globaldelete/a.h
  test/Modules/Inputs/local-submodule-globaldelete/b.h
  test/Modules/Inputs/local-submodule-globaldelete/c.h
  test/Modules/Inputs/local-submodule-globaldelete/module.modulemap
  test/Modules/local-submodule-globaldelete.cpp


Index: test/Modules/local-submodule-globaldelete.cpp
===================================================================
--- /dev/null
+++ test/Modules/local-submodule-globaldelete.cpp
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp -r %S/Inputs/local-submodule-globaldelete %t/local-submodule-globaldelete
+// RUN: cd %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -verify -fmodules-cache-path=%t  -fimplicit-module-maps -I local-submodule-globaldelete %s -H
+
+// expected-no-diagnostics
+
+// This tests that the global delete operator is not by accident assigned
+// to a submodule in local-submodule-visibility mode. This could happen
+// when the operator is created on demand when we discover a virtual destructor
+// inside a module.
+
+// Build a module with submodules that each need the global delete operator.
+#include "a.h"
+// Build another module with another global delete operator to check that
+// we didn't introduced ambiguity in the lookup.
+#include "c.h"
+
+// Require a lookup of the global delete operator.
+class T {
+  virtual ~T() {}
+};
Index: test/Modules/Inputs/local-submodule-globaldelete/module.modulemap
===================================================================
--- /dev/null
+++ test/Modules/Inputs/local-submodule-globaldelete/module.modulemap
@@ -0,0 +1,7 @@
+module M {
+  module a { header "a.h" export * }
+  module b { header "b.h" export * }
+}
+module Other {
+  module c { header "c.h" export * }
+}
Index: test/Modules/Inputs/local-submodule-globaldelete/c.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/local-submodule-globaldelete/c.h
@@ -0,0 +1,6 @@
+#ifndef C_H
+#define C_H
+class C {
+  virtual ~C(){};
+};
+#endif
Index: test/Modules/Inputs/local-submodule-globaldelete/b.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/local-submodule-globaldelete/b.h
@@ -0,0 +1,6 @@
+#ifndef B_H
+#define B_H
+class B {
+  virtual ~B(){};
+};
+#endif
Index: test/Modules/Inputs/local-submodule-globaldelete/a.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/local-submodule-globaldelete/a.h
@@ -0,0 +1,6 @@
+#ifndef A_H
+#define A_H
+class A {
+  virtual ~A(){};
+};
+#endif
Index: lib/Sema/SemaExprCXX.cpp
===================================================================
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -2658,6 +2658,8 @@
         Context, GlobalCtx, SourceLocation(), SourceLocation(), Name,
         FnType, /*TInfo=*/nullptr, SC_None, false, true);
     Alloc->setImplicit();
+    // Global allocation functions should always be visible.
+    Alloc->setHidden(false);
 
     // Implicit sized deallocation functions always have default visibility.
     Alloc->addAttr(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33366.101877.patch
Type: text/x-patch
Size: 2876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170608/75436c1b/attachment.bin>


More information about the cfe-commits mailing list