summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2016-09-06 18:16:54 +0000
committerManman Ren <manman.ren@gmail.com>2016-09-06 18:16:54 +0000
commitc748359c14956ae6453435a7fa7659af0b46916b (patch)
treedb4eba535c7f2a223ef2f8340c56fc5a05331266 /clang/lib/AST/DeclBase.cpp
parent4e463b4a2c34c9a98cdf408b3f57ea661209cf70 (diff)
downloadbcm5719-llvm-c748359c14956ae6453435a7fa7659af0b46916b.tar.gz
bcm5719-llvm-c748359c14956ae6453435a7fa7659af0b46916b.zip
Modules: Fix an assertion in DeclContext::buildLookup.
When calling getMostRecentDecl, we can pull in more definitions from a module. We call getPrimaryContext afterwards to make sure that we buildLookup on a primary context. rdar://27926200 llvm-svn: 280728
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 8342c0f2e39..4586d4bd2aa 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name) const {
assert(DeclKind != Decl::LinkageSpec &&
"Should not perform lookups into linkage specs!");
- 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).
@@ -1422,6 +1418,12 @@ 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?");
OpenPOWER on IntegriCloud