diff options
author | Eric Christopher <echristo@gmail.com> | 2015-08-25 13:45:24 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2015-08-25 13:45:24 +0000 |
commit | 6b45437f6f69b99306bced83f9178705e75c8495 (patch) | |
tree | 0081feff42b7e741c17e7be6a272bde01ed1cfcd /clang | |
parent | af642c692726314ae0a6cbe6466c726ed17c10c1 (diff) | |
download | bcm5719-llvm-6b45437f6f69b99306bced83f9178705e75c8495.tar.gz bcm5719-llvm-6b45437f6f69b99306bced83f9178705e75c8495.zip |
Extract handling of user defined features into a function so we can
specialize it on the targets.
llvm-svn: 245935
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/TargetInfo.h | 16 | ||||
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 8 |
2 files changed, 18 insertions, 6 deletions
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index c804b2d0364..acb5f726eaf 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -797,6 +797,22 @@ public: Features[Name] = Enabled; } + /// \brief Add user defined features to the feature set while + /// possibly diagnosing incompatibilities. + /// + /// \return False on error. + virtual bool handleUserFeatures(llvm::StringMap<bool> &Features, + std::vector<std::string> &UserFeatures, + DiagnosticsEngine &Diags) { + for (const auto &F : UserFeatures) { + const char *Name = F.c_str(); + // Apply the feature via the target. + bool Enabled = Name[0] == '+'; + setFeatureEnabled(Features, Name + 1, Enabled); + } + return true; + } + /// \brief Perform initialization based on the user configured /// set of features (e.g., +sse4). /// diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index b78e2817f0e..5c4a016b554 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -7565,12 +7565,8 @@ TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, Target->initDefaultFeatures(Features); // Apply the user specified deltas. - for (const auto &F : Opts->FeaturesAsWritten) { - const char *Name = F.c_str(); - // Apply the feature via the target. - bool Enabled = Name[0] == '+'; - Target->setFeatureEnabled(Features, Name + 1, Enabled); - } + if (!Target->handleUserFeatures(Features, Opts->FeaturesAsWritten, Diags)) + return nullptr; // Add the features to the compile options. // |