diff options
author | Ben Langmuir <blangmuir@apple.com> | 2015-02-02 21:56:15 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2015-02-02 21:56:15 +0000 |
commit | 532d2104cedf624924309ecd53a3b9216147ac0d (patch) | |
tree | 6ad9e93df232710f00e55d51e93e25ee903cc0d0 /clang/lib/Basic/Module.cpp | |
parent | e4716e65b3498968cfdb236c478e2f6211e8b276 (diff) | |
download | llvm-532d2104cedf624924309ecd53a3b9216147ac0d.zip llvm-532d2104cedf624924309ecd53a3b9216147ac0d.tar.gz llvm-532d2104cedf624924309ecd53a3b9216147ac0d.tar.bz2 |
Add cc1 option '-fmodule-feature' to add custom values for 'requires' decls
This allows clang-based tools to specify custom features that can be
tested by the 'requires' declaration in a module map file.
llvm-svn: 227868
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r-- | clang/lib/Basic/Module.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 03f9bd3..e7e37ce 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -58,16 +58,21 @@ Module::~Module() { /// language options has the given feature. static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target) { - return llvm::StringSwitch<bool>(Feature) - .Case("altivec", LangOpts.AltiVec) - .Case("blocks", LangOpts.Blocks) - .Case("cplusplus", LangOpts.CPlusPlus) - .Case("cplusplus11", LangOpts.CPlusPlus11) - .Case("objc", LangOpts.ObjC1) - .Case("objc_arc", LangOpts.ObjCAutoRefCount) - .Case("opencl", LangOpts.OpenCL) - .Case("tls", Target.isTLSSupported()) - .Default(Target.hasFeature(Feature)); + bool HasFeature = llvm::StringSwitch<bool>(Feature) + .Case("altivec", LangOpts.AltiVec) + .Case("blocks", LangOpts.Blocks) + .Case("cplusplus", LangOpts.CPlusPlus) + .Case("cplusplus11", LangOpts.CPlusPlus11) + .Case("objc", LangOpts.ObjC1) + .Case("objc_arc", LangOpts.ObjCAutoRefCount) + .Case("opencl", LangOpts.OpenCL) + .Case("tls", Target.isTLSSupported()) + .Default(Target.hasFeature(Feature)); + if (!HasFeature) + HasFeature = std::find(LangOpts.ModuleFeatures.begin(), + LangOpts.ModuleFeatures.end(), + Feature) != LangOpts.ModuleFeatures.end(); + return HasFeature; } bool Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target, |