aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/ModuleMap.cpp
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2015-01-13 17:47:44 +0000
committerBen Langmuir <blangmuir@apple.com>2015-01-13 17:47:44 +0000
commitc1d88ea5a751e7e42fc01d297e25eda9e790fea1 (patch)
tree8de8042fcca0cf1478204a9e7cd5dc0156141ab9 /clang/lib/Lex/ModuleMap.cpp
parent7615f00e5188e50180f9e2f62c24d50191038bdd (diff)
downloadllvm-c1d88ea5a751e7e42fc01d297e25eda9e790fea1.zip
llvm-c1d88ea5a751e7e42fc01d297e25eda9e790fea1.tar.gz
llvm-c1d88ea5a751e7e42fc01d297e25eda9e790fea1.tar.bz2
Inherit attributes when infering a framework module
If a module map contains framework module * [extern_c] {} We will now infer [extern_c] on the inferred framework modules (we already inferred [system] as a special case). llvm-svn: 225803
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r--clang/lib/Lex/ModuleMap.cpp47
1 files changed, 23 insertions, 24 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 132bd62b..ef322d8 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -585,6 +585,15 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName,
const DirectoryEntry *FrameworkDir,
bool IsSystem,
Module *Parent) {
+ Attributes Attrs;
+ Attrs.IsSystem = IsSystem;
+ return inferFrameworkModule(ModuleName, FrameworkDir, Attrs, Parent);
+}
+
+Module *ModuleMap::inferFrameworkModule(StringRef ModuleName,
+ const DirectoryEntry *FrameworkDir,
+ Attributes Attrs, Module *Parent) {
+
// Check whether we've already found this module.
if (Module *Mod = lookupModuleQualified(ModuleName, Parent))
return Mod;
@@ -625,7 +634,7 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName,
bool IsFrameworkDir = Parent.endswith(".framework");
if (const FileEntry *ModMapFile =
HeaderInfo.lookupModuleMapFile(ParentDir, IsFrameworkDir)) {
- parseModuleMapFile(ModMapFile, IsSystem, ParentDir);
+ parseModuleMapFile(ModMapFile, Attrs.IsSystem, ParentDir);
inferred = InferredDirectories.find(ParentDir);
}
@@ -642,8 +651,9 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName,
inferred->second.ExcludedModules.end(),
Name) == inferred->second.ExcludedModules.end();
- if (inferred->second.InferSystemModules)
- IsSystem = true;
+ Attrs.IsSystem |= inferred->second.Attrs.IsSystem;
+ Attrs.IsExternC |= inferred->second.Attrs.IsExternC;
+ Attrs.IsExhaustive |= inferred->second.Attrs.IsExhaustive;
ModuleMapFile = inferred->second.ModuleMapFile;
}
}
@@ -675,9 +685,11 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName,
SourceModule = Result;
SourceModuleName = ModuleName;
}
- if (IsSystem)
- Result->IsSystem = IsSystem;
-
+
+ Result->IsSystem |= Attrs.IsSystem;
+ Result->IsExternC |= Attrs.IsExternC;
+ Result->ConfigMacrosExhaustive |= Attrs.IsExhaustive;
+
if (!Parent)
Modules[ModuleName] = Result;
@@ -732,8 +744,8 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName,
// FIXME: Do we want to warn about subframeworks without umbrella headers?
SmallString<32> NameBuf;
inferFrameworkModule(sanitizeFilenameAsIdentifier(
- llvm::sys::path::stem(Dir->path()), NameBuf),
- SubframeworkDir, IsSystem, Result);
+ llvm::sys::path::stem(Dir->path()), NameBuf),
+ SubframeworkDir, Attrs, Result);
}
}
@@ -972,21 +984,6 @@ namespace clang {
}
};
- /// \brief The set of attributes that can be attached to a module.
- struct Attributes {
- Attributes() : IsSystem(), IsExternC(), IsExhaustive() { }
-
- /// \brief Whether this is a system module.
- unsigned IsSystem : 1;
-
- /// \brief Whether this is an extern "C" module.
- unsigned IsExternC : 1;
-
- /// \brief Whether this is an exhaustive set of configuration macros.
- unsigned IsExhaustive : 1;
- };
-
-
class ModuleMapParser {
Lexer &L;
SourceManager &SourceMgr;
@@ -1045,6 +1042,8 @@ namespace clang {
void parseConfigMacros();
void parseConflict();
void parseInferredModuleDecl(bool Framework, bool Explicit);
+
+ typedef ModuleMap::Attributes Attributes;
bool parseOptionalAttributes(Attributes &Attrs);
public:
@@ -2117,7 +2116,7 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
} else {
// We'll be inferring framework modules for this directory.
Map.InferredDirectories[Directory].InferModules = true;
- Map.InferredDirectories[Directory].InferSystemModules = Attrs.IsSystem;
+ Map.InferredDirectories[Directory].Attrs = Attrs;
Map.InferredDirectories[Directory].ModuleMapFile = ModuleMapFile;
// FIXME: Handle the 'framework' keyword.
}