[PATCH] D23492: Make function local tags visible.
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 14 13:59:49 PDT 2016
v.g.vassilev created this revision.
v.g.vassilev added a reviewer: rsmith.
v.g.vassilev added a subscriber: cfe-commits.
v.g.vassilev set the repository for this revision to rL LLVM.
Upon instantiating function decls, we should mark visible any tag decl in the function's body.
Repository:
rL LLVM
https://reviews.llvm.org/D23492
Files:
lib/Sema/SemaLookup.cpp
test/Modules/Inputs/PR28794/LibAHeader.h
test/Modules/Inputs/PR28794/Subdir/Empty.h
test/Modules/Inputs/PR28794/Subdir/LibBHeader.h
test/Modules/Inputs/PR28794/module.modulemap
test/Modules/pr28794.cpp
Index: test/Modules/pr28794.cpp
===================================================================
--- /dev/null
+++ test/Modules/pr28794.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR28794 -verify %s
+// RUN: %clang_cc1 -std=c++11 -fmodules -fmodule-map-file=%S/Inputs/PR28794/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28794/ -verify %s
+
+#include "Subdir/Empty.h"
+#include "LibAHeader.h"
+
+BumpPtrAllocatorImpl<> &getPreprocessorAllocator();
+class B {
+ struct ModuleMacroInfo {
+ ModuleMacroInfo *getModuleInfo() {
+ return new (getPreprocessorAllocator()) ModuleMacroInfo();
+ }
+ };
+};
+
+// expected-no-diagnostics
Index: test/Modules/Inputs/PR28794/module.modulemap
===================================================================
--- /dev/null
+++ test/Modules/Inputs/PR28794/module.modulemap
@@ -0,0 +1,3 @@
+module M {
+ umbrella "Subdir" module * {export *}
+}
Index: test/Modules/Inputs/PR28794/Subdir/LibBHeader.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/PR28794/Subdir/LibBHeader.h
@@ -0,0 +1,12 @@
+#ifndef LIB_B_HEADER
+#define LIB_B_HEADER
+
+#include "LibAHeader.h"
+
+template <typename T, size_t SlabSize, size_t SizeThreshold>
+void *operator new(size_t, BumpPtrAllocatorImpl<T, SlabSize, SizeThreshold> &) {
+ struct S {};
+ return (void*)0xdead;
+}
+
+#endif // LIB_B_HEADER
Index: test/Modules/Inputs/PR28794/Subdir/Empty.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/PR28794/Subdir/Empty.h
@@ -0,0 +1 @@
+
Index: test/Modules/Inputs/PR28794/LibAHeader.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/PR28794/LibAHeader.h
@@ -0,0 +1,12 @@
+#ifndef LIB_A_HEADER
+#define LIB_A_HEADER
+
+typedef __SIZE_TYPE__ size_t;
+
+template <typename = int, size_t SlabSize = 4096, size_t = SlabSize>
+class BumpPtrAllocatorImpl;
+
+template <typename T, size_t SlabSize, size_t SizeThreshold>
+void * operator new(size_t, BumpPtrAllocatorImpl<T, SlabSize, SizeThreshold> &);
+
+#endif // LIB_A_HEADER
Index: lib/Sema/SemaLookup.cpp
===================================================================
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -1535,9 +1535,13 @@
return true;
}
+ DeclContext *DC = D->getLexicalDeclContext();
+ // If this declaration is a tag in a function decl it should be visible.
+ if (isa<TagDecl>(D) && DC && DC->isFunctionOrMethod())
+ return true;
+
// If this declaration is not at namespace scope nor module-private,
// then it is visible if its lexical parent has a visible definition.
- DeclContext *DC = D->getLexicalDeclContext();
if (!D->isModulePrivate() &&
DC && !DC->isFileContext() && !isa<LinkageSpecDecl>(DC)) {
// For a parameter, check whether our current template declaration's
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23492.67988.patch
Type: text/x-patch
Size: 2951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160814/c74d0441/attachment.bin>
More information about the cfe-commits
mailing list