r228475 - [modules] Don't accidentally trigger deserialization from DeclContext::noload_lookup.

Richard Smith richard-llvm at metafoo.co.uk
Fri Feb 6 16:45:52 PST 2015


Author: rsmith
Date: Fri Feb  6 18:45:52 2015
New Revision: 228475

URL: http://llvm.org/viewvc/llvm-project?rev=228475&view=rev
Log:
[modules] Don't accidentally trigger deserialization from DeclContext::noload_lookup.

Added:
    cfe/trunk/test/Modules/Inputs/deferred-lookup/
    cfe/trunk/test/Modules/Inputs/deferred-lookup/a.h
    cfe/trunk/test/Modules/Inputs/deferred-lookup/b.h
    cfe/trunk/test/Modules/Inputs/deferred-lookup/module.modulemap
    cfe/trunk/test/Modules/deferred-lookup.cpp
Modified:
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=228475&r1=228474&r2=228475&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Feb  6 18:45:52 2015
@@ -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);

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=228475&r1=228474&r2=228475&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri Feb  6 18:45:52 2015
@@ -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(DeclCo
           (!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(DeclarationNa
     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::makeDeclVisibleInConte
     return;
   }
 
-  else if (DeclNameEntries.isNull()) {
+  if (DeclNameEntries.isNull()) {
     DeclNameEntries.setOnlyValue(D);
     return;
   }

Added: cfe/trunk/test/Modules/Inputs/deferred-lookup/a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/deferred-lookup/a.h?rev=228475&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/deferred-lookup/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/deferred-lookup/a.h Fri Feb  6 18:45:52 2015
@@ -0,0 +1 @@
+namespace N { int f(int); }

Added: cfe/trunk/test/Modules/Inputs/deferred-lookup/b.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/deferred-lookup/b.h?rev=228475&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/deferred-lookup/b.h (added)
+++ cfe/trunk/test/Modules/Inputs/deferred-lookup/b.h Fri Feb  6 18:45:52 2015
@@ -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>()); }

Added: cfe/trunk/test/Modules/Inputs/deferred-lookup/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/deferred-lookup/module.modulemap?rev=228475&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/deferred-lookup/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/deferred-lookup/module.modulemap Fri Feb  6 18:45:52 2015
@@ -0,0 +1,2 @@
+module a { header "a.h" export * }
+module b { header "b.h" export * }

Added: cfe/trunk/test/Modules/deferred-lookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/deferred-lookup.cpp?rev=228475&view=auto
==============================================================================
--- cfe/trunk/test/Modules/deferred-lookup.cpp (added)
+++ cfe/trunk/test/Modules/deferred-lookup.cpp Fri Feb  6 18:45:52 2015
@@ -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"





More information about the cfe-commits mailing list