diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-02-07 00:45:52 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-02-07 00:45:52 +0000 |
| commit | a3271c139058c7d98a0147df5e17164141d8e699 (patch) | |
| tree | bdfb1d85c7f1fef6a8a29dc97a2177244e01e1da /clang | |
| parent | e7e2abe6a2783be04cb07a82ef0be2565c42cf9d (diff) | |
| download | bcm5719-llvm-a3271c139058c7d98a0147df5e17164141d8e699.tar.gz bcm5719-llvm-a3271c139058c7d98a0147df5e17164141d8e699.zip | |
[modules] Don't accidentally trigger deserialization from DeclContext::noload_lookup.
llvm-svn: 228475
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/AST/DeclBase.h | 2 | ||||
| -rw-r--r-- | clang/lib/AST/DeclBase.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/deferred-lookup/a.h | 1 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/deferred-lookup/b.h | 6 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/deferred-lookup/module.modulemap | 2 | ||||
| -rw-r--r-- | clang/test/Modules/deferred-lookup.cpp | 6 |
6 files changed, 22 insertions, 7 deletions
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 984ab13df42..93f6a6fa0f8 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -1672,7 +1672,7 @@ private: template<decl_iterator (DeclContext::*Begin)() const, decl_iterator (DeclContext::*End)() const> - void buildLookupImpl(DeclContext *DCtx); + void buildLookupImpl(DeclContext *DCtx, bool Internal); void makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal, bool Rediscoverable); void makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal); diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index a46787fb0e8..8862f9f5c62 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1251,7 +1251,7 @@ StoredDeclsMap *DeclContext::buildLookup() { collectAllContexts(Contexts); for (unsigned I = 0, N = Contexts.size(); I != N; ++I) buildLookupImpl<&DeclContext::decls_begin, - &DeclContext::decls_end>(Contexts[I]); + &DeclContext::decls_end>(Contexts[I], false); // We no longer have any lazy decls. LookupPtr.setInt(false); @@ -1264,7 +1264,7 @@ StoredDeclsMap *DeclContext::buildLookup() { /// nested within it. template<DeclContext::decl_iterator (DeclContext::*Begin)() const, DeclContext::decl_iterator (DeclContext::*End)() const> -void DeclContext::buildLookupImpl(DeclContext *DCtx) { +void DeclContext::buildLookupImpl(DeclContext *DCtx, bool Internal) { for (decl_iterator I = (DCtx->*Begin)(), E = (DCtx->*End)(); I != E; ++I) { Decl *D = *I; @@ -1282,14 +1282,14 @@ void DeclContext::buildLookupImpl(DeclContext *DCtx) { (!ND->isFromASTFile() || (isTranslationUnit() && !getParentASTContext().getLangOpts().CPlusPlus))) - makeDeclVisibleInContextImpl(ND, false); + makeDeclVisibleInContextImpl(ND, Internal); // If this declaration is itself a transparent declaration context // or inline namespace, add the members of this declaration of that // context (recursively). if (DeclContext *InnerCtx = dyn_cast<DeclContext>(D)) if (InnerCtx->isTransparentContext() || InnerCtx->isInlineNamespace()) - buildLookupImpl<Begin, End>(InnerCtx); + buildLookupImpl<Begin, End>(InnerCtx, Internal); } } @@ -1369,7 +1369,7 @@ DeclContext::noload_lookup(DeclarationName Name) { collectAllContexts(Contexts); for (unsigned I = 0, N = Contexts.size(); I != N; ++I) buildLookupImpl<&DeclContext::noload_decls_begin, - &DeclContext::noload_decls_end>(Contexts[I]); + &DeclContext::noload_decls_end>(Contexts[I], true); // We no longer have any lazy decls. LookupPtr.setInt(false); @@ -1555,7 +1555,7 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal) { return; } - else if (DeclNameEntries.isNull()) { + if (DeclNameEntries.isNull()) { DeclNameEntries.setOnlyValue(D); return; } diff --git a/clang/test/Modules/Inputs/deferred-lookup/a.h b/clang/test/Modules/Inputs/deferred-lookup/a.h new file mode 100644 index 00000000000..751aae01496 --- /dev/null +++ b/clang/test/Modules/Inputs/deferred-lookup/a.h @@ -0,0 +1 @@ +namespace N { int f(int); } diff --git a/clang/test/Modules/Inputs/deferred-lookup/b.h b/clang/test/Modules/Inputs/deferred-lookup/b.h new file mode 100644 index 00000000000..23925e2e93c --- /dev/null +++ b/clang/test/Modules/Inputs/deferred-lookup/b.h @@ -0,0 +1,6 @@ +namespace N { template<typename T> struct A { friend int f(A); }; } +namespace N { int f(int); } +namespace N { int f(int); } +#include "a.h" +namespace N { int f(int); } +inline int g() { return f(N::A<int>()); } diff --git a/clang/test/Modules/Inputs/deferred-lookup/module.modulemap b/clang/test/Modules/Inputs/deferred-lookup/module.modulemap new file mode 100644 index 00000000000..61578a1865a --- /dev/null +++ b/clang/test/Modules/Inputs/deferred-lookup/module.modulemap @@ -0,0 +1,2 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } diff --git a/clang/test/Modules/deferred-lookup.cpp b/clang/test/Modules/deferred-lookup.cpp new file mode 100644 index 00000000000..aaac389da0d --- /dev/null +++ b/clang/test/Modules/deferred-lookup.cpp @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/deferred-lookup -verify %s +// expected-no-diagnostics + +namespace N { int f(int); } +#include "b.h" |

