r310706 - [modules] Set the lexical DC for dummy tag decls that refer to hidden

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 11 05:06:52 PDT 2017


Author: arphaman
Date: Fri Aug 11 05:06:52 2017
New Revision: 310706

URL: http://llvm.org/viewvc/llvm-project?rev=310706&view=rev
Log:
[modules] Set the lexical DC for dummy tag decls that refer to hidden
declarations that are made visible after the dummy is parsed and ODR verified

Prior to this commit the
"(getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one."),"
assertion failure was triggered during semantic analysis of the dummy
tag declaration that was declared in another tag declaration because its
lexical context did not point to the outer tag decl.

rdar://32292196

Added:
    cfe/trunk/test/Modules/Inputs/innerstructredef.h
    cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Modules/Inputs/module.map

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=310706&r1=310705&r2=310706&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 11 05:06:52 2017
@@ -13722,6 +13722,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
                   // comparison.
                   SkipBody->CheckSameAsPrevious = true;
                   SkipBody->New = createTagFromNewDecl();
+                  SkipBody->New->setLexicalDeclContext(CurContext);
                   SkipBody->Previous = Hidden;
                 } else {
                   SkipBody->ShouldSkip = true;

Added: cfe/trunk/test/Modules/Inputs/innerstructredef.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/innerstructredef.h?rev=310706&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/innerstructredef.h (added)
+++ cfe/trunk/test/Modules/Inputs/innerstructredef.h Fri Aug 11 05:06:52 2017
@@ -0,0 +1,6 @@
+struct Outer {
+// This definition is actually hidden since only submodule 'one' is imported.
+struct Inner {
+  int x;
+} field;
+};

Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=310706&r1=310705&r2=310706&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Fri Aug 11 05:06:52 2017
@@ -451,3 +451,12 @@ module DebugNestedB {
 module objcAtKeywordMissingEnd {
   header "objcAtKeywordMissingEnd.h"
 }
+
+module innerstructredef {
+  module one {
+    header "empty.h"
+  }
+  module two {
+   header "innerstructredef.h"
+  }
+}

Added: cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/inner-struct-redefines-invisible.m?rev=310706&view=auto
==============================================================================
--- cfe/trunk/test/Modules/inner-struct-redefines-invisible.m (added)
+++ cfe/trunk/test/Modules/inner-struct-redefines-invisible.m Fri Aug 11 05:06:52 2017
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -verify %s
+// expected-no-diagnostics
+
+ at import innerstructredef.one;
+
+struct Outer {
+// Should set lexical context when parsing 'Inner' here, otherwise there's a crash:
+struct Inner {
+  int x;
+} field;
+};




More information about the cfe-commits mailing list