]> granicus.if.org Git - clang/commitdiff
Extract handling of user defined features into a function so we can
authorEric Christopher <echristo@gmail.com>
Tue, 25 Aug 2015 13:45:24 +0000 (13:45 +0000)
committerEric Christopher <echristo@gmail.com>
Tue, 25 Aug 2015 13:45:24 +0000 (13:45 +0000)
specialize it on the targets.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245935 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/TargetInfo.h
lib/Basic/Targets.cpp

index c804b2d0364d87228adc5bfd8d7620c28dd20fc3..acb5f726eaf23bcb77933ae2794b7fd398b672ed 100644 (file)
@@ -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).
   ///
index b78e2817f0e00f3c3da30bf309dffc7219b43484..5c4a016b55492e38abb2b18b8e3c3494f7d16cdc 100644 (file)
@@ -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.
   //