]> granicus.if.org Git - clang/commitdiff
Modules: revert r280728.
authorManman Ren <manman.ren@gmail.com>
Fri, 9 Sep 2016 19:03:07 +0000 (19:03 +0000)
committerManman Ren <manman.ren@gmail.com>
Fri, 9 Sep 2016 19:03:07 +0000 (19:03 +0000)
In post-commit review, Richard suggested a better way to fix this.
rdar://27926200

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281078 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclBase.cpp
test/Modules/Inputs/lookup-assert/Base.h [deleted file]
test/Modules/Inputs/lookup-assert/Derive.h [deleted file]
test/Modules/Inputs/lookup-assert/H3.h [deleted file]
test/Modules/Inputs/lookup-assert/module.map [deleted file]
test/Modules/lookup-assert.m [deleted file]

index 4d4e725dbdd654dc710ab9073890b861ef48f354..cea511b5118f38a0092a1313fd518501db7d301c 100644 (file)
@@ -1413,6 +1413,10 @@ DeclContext::lookup(DeclarationName Name) const {
   assert(DeclKind != Decl::LinkageSpec && DeclKind != Decl::Export &&
          "should not perform lookups into transparent contexts");
 
+  const DeclContext *PrimaryContext = getPrimaryContext();
+  if (PrimaryContext != this)
+    return PrimaryContext->lookup(Name);
+
   // If we have an external source, ensure that any later redeclarations of this
   // context have been loaded, since they may add names to the result of this
   // lookup (or add external visible storage).
@@ -1420,12 +1424,6 @@ DeclContext::lookup(DeclarationName Name) const {
   if (Source)
     (void)cast<Decl>(this)->getMostRecentDecl();
 
-  // getMostRecentDecl can change the result of getPrimaryContext. Call
-  // getPrimaryContext afterwards.
-  const DeclContext *PrimaryContext = getPrimaryContext();
-  if (PrimaryContext != this)
-    return PrimaryContext->lookup(Name);
-
   if (hasExternalVisibleStorage()) {
     assert(Source && "external visible storage but no external source?");
 
diff --git a/test/Modules/Inputs/lookup-assert/Base.h b/test/Modules/Inputs/lookup-assert/Base.h
deleted file mode 100644 (file)
index 8d5e06b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-@interface BaseInterface
-- (void) test;
-@end
-
diff --git a/test/Modules/Inputs/lookup-assert/Derive.h b/test/Modules/Inputs/lookup-assert/Derive.h
deleted file mode 100644 (file)
index 313a961..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "Base.h"
-@interface DerivedInterface : BaseInterface
-@end
diff --git a/test/Modules/Inputs/lookup-assert/H3.h b/test/Modules/Inputs/lookup-assert/H3.h
deleted file mode 100644 (file)
index 3d8f878..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "Base.h"
diff --git a/test/Modules/Inputs/lookup-assert/module.map b/test/Modules/Inputs/lookup-assert/module.map
deleted file mode 100644 (file)
index e8a89eb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-module X {
-  header "H3.h"
-  export *
-}
diff --git a/test/Modules/lookup-assert.m b/test/Modules/lookup-assert.m
deleted file mode 100644 (file)
index 2697fb1..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/lookup-assert %s -verify
-// expected-no-diagnostics
-
-#include "Derive.h"
-#import <H3.h>
-@implementation DerivedInterface
-- (void)test {
-}
-@end