Author: echristo Date: Tue Aug 25 08:45:24 2015 New Revision: 245935 URL: http://llvm.org/viewvc/llvm-project?rev=245935&view=rev Log: Extract handling of user defined features into a function so we can specialize it on the targets.
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/lib/Basic/Targets.cpp Modified: cfe/trunk/include/clang/Basic/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=245935&r1=245934&r2=245935&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/TargetInfo.h (original) +++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Aug 25 08:45:24 2015 @@ -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). /// Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=245935&r1=245934&r2=245935&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Tue Aug 25 08:45:24 2015 @@ -7565,12 +7565,8 @@ TargetInfo::CreateTargetInfo(Diagnostics 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. // _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits