From: Eric Christopher Date: Tue, 25 Aug 2015 13:45:24 +0000 (+0000) Subject: Extract handling of user defined features into a function so we can X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a2e2011c10aceb86a5a63e1b36327373c9a662de;p=clang Extract handling of user defined features into a function so we can specialize it on the targets. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245935 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index c804b2d036..acb5f726ea 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/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 &Features, + std::vector &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/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index b78e2817f0..5c4a016b55 100644 --- a/lib/Basic/Targets.cpp +++ b/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. //