[modules] When creating a declaration, cache its owning module immediately
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 17 May 2017 00:24:14 +0000 (00:24 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 17 May 2017 00:24:14 +0000 (00:24 +0000)
commit26342f915bd615900c652afd3c807a4fc195ac9f
tree1893d297ea1cf44fa0484cc6481b9a5d75da1667
parent9c99faa8563c11895b44d8e59c1a96216dfb17f7
[modules] When creating a declaration, cache its owning module immediately
rather than waiting until it's queried.

Currently this is only applied to local submodule visibility mode, as we don't
yet allocate storage for the owning module in non-local-visibility modules
compilations.

This reinstates r302965, reverted in r303037, with a fix for the reported
crash, which occurred when reparenting a local declaration to be a child of
a hidden imported declaration (specifically during template instantiation).

llvm-svn: 303224
13 files changed:
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTDumper.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaLookup.cpp
clang/test/Modules/Inputs/submodule-visibility/b.h
clang/test/Modules/Inputs/submodule-visibility/other.h
clang/test/Modules/submodule-visibility.cpp