summaryrefslogtreecommitdiffstats
path: root/include/clang/AST
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-05-18 02:29:20 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-05-18 02:29:20 +0000
commitaaaa0b61427c26fec9adc47951a39d0367ce65e1 (patch)
tree28a290a9eb5547cf42c709bf7501db090e65b8fa /include/clang/AST
parentd665e952bdf8d103e4d1765d80d81e28369617d3 (diff)
[modules] Switch from inferring owning modules based on source location to
inferring based on the current module at the point of creation. This should result in no functional change except when building a preprocessed module (or more generally when using #pragma clang module begin/end to switch module in the middle of a file), in which case it allows us to correctly track the owning module for declarations. We can't map from FileID to module in the preprocessed module case, since all modules would have the same FileID. There are still a couple of remaining places that try to infer a module from a source location; I'll clean those up in follow-up changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303322 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST')
-rw-r--r--include/clang/AST/ASTContext.h2
-rw-r--r--include/clang/AST/DeclBase.h19
2 files changed, 12 insertions, 9 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 474cf2c0e3..2221d6f9fc 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -935,7 +935,7 @@ public:
/// \brief Get the additional modules in which the definition \p Def has
/// been merged.
- ArrayRef<Module*> getModulesWithMergedDefinition(NamedDecl *Def) {
+ ArrayRef<Module*> getModulesWithMergedDefinition(const NamedDecl *Def) {
auto MergedIt = MergedDefModules.find(Def);
if (MergedIt == MergedDefModules.end())
return None;
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 08879b36cc..29889fde96 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -332,15 +332,15 @@ private:
bool AccessDeclContextSanity() const;
protected:
-
Decl(Kind DK, DeclContext *DC, SourceLocation L)
- : NextInContextAndBits(), DeclCtx(DC),
- Loc(L), DeclKind(DK), InvalidDecl(0),
- HasAttrs(false), Implicit(false), Used(false), Referenced(false),
- Access(AS_none), FromASTFile(0), Hidden(DC && cast<Decl>(DC)->Hidden),
- IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
- CacheValidAndLinkage(0)
- {
+ : NextInContextAndBits(), DeclCtx(DC), Loc(L), DeclKind(DK),
+ InvalidDecl(0), HasAttrs(false), Implicit(false), Used(false),
+ Referenced(false), Access(AS_none), FromASTFile(0),
+ Hidden(DC && cast<Decl>(DC)->Hidden &&
+ (!cast<Decl>(DC)->isFromASTFile() ||
+ hasLocalOwningModuleStorage())),
+ IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
+ CacheValidAndLinkage(0) {
if (StatisticsEnabled) add(DK);
}
@@ -698,6 +698,9 @@ public:
Module *getLocalOwningModule() const {
if (isFromASTFile() || !Hidden)
return nullptr;
+
+ assert(hasLocalOwningModuleStorage() &&
+ "hidden local decl but no local module storage");
return reinterpret_cast<Module *const *>(this)[-1];
}
void setLocalOwningModule(Module *M) {