diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-05-15 20:05:43 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-05-15 20:05:43 +0000 |
commit | 42413141641e26462a0d0c95f62b09fea5df78e9 (patch) | |
tree | dfcc51b854345c51e563fdbb5f28c1e7cb24310a /clang/lib/AST/Decl.cpp | |
parent | e70f8103781f1c4749b0de99aab050637bb5bd67 (diff) | |
download | bcm5719-llvm-42413141641e26462a0d0c95f62b09fea5df78e9.tar.gz bcm5719-llvm-42413141641e26462a0d0c95f62b09fea5df78e9.zip |
[modules] Add local submodule visibility support for declarations.
With this change, enabling -fmodules-local-submodule-visibility results in name
visibility rules being applied to submodules of the current module in addition
to imported modules (that is, names no longer "leak" between submodules of the
same top-level module). This also makes it much safer to textually include a
non-modular library into a module: each submodule that textually includes that
library will get its own "copy" of that library, and so the library becomes
visible no matter which including submodule you import.
llvm-svn: 237473
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 550810367d9..4a8eaaf99ad 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -44,6 +44,12 @@ bool Decl::isOutOfLine() const { return !getLexicalDeclContext()->Equals(getDeclContext()); } +TranslationUnitDecl::TranslationUnitDecl(ASTContext &ctx) + : Decl(TranslationUnit, nullptr, SourceLocation()), + DeclContext(TranslationUnit), Ctx(ctx), AnonymousNamespace(nullptr) { + Hidden = Ctx.getLangOpts().ModulesLocalVisibility; +} + //===----------------------------------------------------------------------===// // NamedDecl Implementation //===----------------------------------------------------------------------===// @@ -3934,10 +3940,17 @@ TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC, void TypedefNameDecl::anchor() { } -TagDecl *TypedefNameDecl::getAnonDeclWithTypedefName() const { - if (auto *TT = getTypeSourceInfo()->getType()->getAs<TagType>()) - if (TT->getDecl()->getTypedefNameForAnonDecl() == this) +TagDecl *TypedefNameDecl::getAnonDeclWithTypedefName(bool AnyRedecl) const { + if (auto *TT = getTypeSourceInfo()->getType()->getAs<TagType>()) { + auto *OwningTypedef = TT->getDecl()->getTypedefNameForAnonDecl(); + auto *ThisTypedef = this; + if (AnyRedecl && OwningTypedef) { + OwningTypedef = OwningTypedef->getCanonicalDecl(); + ThisTypedef = ThisTypedef->getCanonicalDecl(); + } + if (OwningTypedef == ThisTypedef) return TT->getDecl(); + } return nullptr; } |