From: Rafael Espindola Date: Tue, 20 Aug 2013 15:30:32 +0000 (+0000) Subject: Remove duplicated error checking. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ade7cd45d5bf510c8599b805691e6402edb0d203;p=clang Remove duplicated error checking. The driver validates its options, so we don't need to redo the work in "clang -cc1". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188806 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticCommonKinds.td b/include/clang/Basic/DiagnosticCommonKinds.td index cec938b180..c67b437ddf 100644 --- a/include/clang/Basic/DiagnosticCommonKinds.td +++ b/include/clang/Basic/DiagnosticCommonKinds.td @@ -115,7 +115,6 @@ def err_target_unknown_triple : Error< def err_target_unknown_cpu : Error<"unknown target CPU '%0'">; def err_target_unknown_abi : Error<"unknown target ABI '%0'">; def err_target_unknown_cxxabi : Error<"unknown C++ ABI '%0'">; -def err_target_invalid_feature : Error<"invalid target feature '%0'">; // Source manager def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal; diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index 60028365e9..821a469d61 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -672,12 +672,10 @@ public: /// \brief Enable or disable a specific target feature; /// the feature name must be valid. - /// - /// \return False on error (invalid feature name). - virtual bool setFeatureEnabled(llvm::StringMap &Features, + virtual void setFeatureEnabled(llvm::StringMap &Features, StringRef Name, bool Enabled) const { - return false; + Features[Name] = Enabled; } /// \brief Perform initialization based on the user configured diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 49531baa66..788579de7a 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -727,10 +727,6 @@ public: virtual void getDefaultFeatures(llvm::StringMap &Features) const; - virtual bool setFeatureEnabled(llvm::StringMap &Features, - StringRef Name, - bool Enabled) const; - virtual bool hasFeature(StringRef Feature) const; virtual void getGCCRegNames(const char * const *&Names, @@ -1021,18 +1017,6 @@ void PPCTargetInfo::getDefaultFeatures(llvm::StringMap &Features) const { Features["qpx"] = (CPU == "a2q"); } -bool PPCTargetInfo::setFeatureEnabled(llvm::StringMap &Features, - StringRef Name, - bool Enabled) const { - if (Name == "altivec" || Name == "fprnd" || Name == "mfocrf" || - Name == "popcntd" || Name == "qpx") { - Features[Name] = Enabled; - return true; - } - - return false; -} - bool PPCTargetInfo::hasFeature(StringRef Feature) const { return Feature == "powerpc"; } @@ -1772,7 +1756,7 @@ public: bool Enabled) const; void setXOPLevel(llvm::StringMap &Features, XOPEnum Level, bool Enabled) const; - virtual bool setFeatureEnabled(llvm::StringMap &Features, + virtual void setFeatureEnabled(llvm::StringMap &Features, StringRef Name, bool Enabled) const; virtual void getDefaultFeatures(llvm::StringMap &Features) const; @@ -1925,35 +1909,6 @@ public: }; void X86TargetInfo::getDefaultFeatures(llvm::StringMap &Features) const { - // FIXME: This should not be here. - Features["3dnow"] = false; - Features["3dnowa"] = false; - Features["mmx"] = false; - Features["sse"] = false; - Features["sse2"] = false; - Features["sse3"] = false; - Features["ssse3"] = false; - Features["sse41"] = false; - Features["sse42"] = false; - Features["sse4a"] = false; - Features["aes"] = false; - Features["pclmul"] = false; - Features["avx"] = false; - Features["avx2"] = false; - Features["avx-512"] = false; - Features["lzcnt"] = false; - Features["rdrand"] = false; - Features["bmi"] = false; - Features["bmi2"] = false; - Features["popcnt"] = false; - Features["rtm"] = false; - Features["prfchw"] = false; - Features["rdseed"] = false; - Features["fma4"] = false; - Features["fma"] = false; - Features["xop"] = false; - Features["f16c"] = false; - // FIXME: This *really* should not be here. // X86_64 always has SSE2. @@ -2223,7 +2178,7 @@ void X86TargetInfo::setXOPLevel(llvm::StringMap &Features, XOPEnum Level, } } -bool X86TargetInfo::setFeatureEnabled(llvm::StringMap &Features, +void X86TargetInfo::setFeatureEnabled(llvm::StringMap &Features, StringRef Name, bool Enabled) const { // FIXME: This *really* should not be here. We need some way of translating @@ -2234,8 +2189,6 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap &Features, Name = "sse41"; if (Name == "rdrnd") Name = "rdrand"; - if (!Features.count(Name)) - return false; Features[Name] = Enabled; @@ -2279,8 +2232,6 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap &Features, } else if (Name == "sse4a") { setXOPLevel(Features, SSE4A, Enabled); } - - return true; } /// HandleTargetOptions - Perform initialization based on the user @@ -3294,16 +3245,6 @@ public: return Feature == "aarch64" || (Feature == "neon" && FPU == NeonMode); } - virtual bool setFeatureEnabled(llvm::StringMap &Features, - StringRef Name, bool Enabled) const { - if (Name == "neon") { - Features[Name] = Enabled; - return true; - } - - return false; - } - virtual void HandleTargetFeatures(std::vector &Features) { FPU = FPUMode; for (unsigned i = 0, e = Features.size(); i != e; ++i) { @@ -3595,19 +3536,6 @@ public: } } - virtual bool setFeatureEnabled(llvm::StringMap &Features, - StringRef Name, - bool Enabled) const { - if (Name == "soft-float" || Name == "soft-float-abi" || - Name == "vfp2" || Name == "vfp3" || Name == "vfp4" || Name == "neon" || - Name == "d16" || Name == "neonfp" || Name == "v8fp") { - Features[Name] = Enabled; - } else - return false; - - return true; - } - virtual void HandleTargetFeatures(std::vector &Features) { FPU = 0; SoftFloat = SoftFloatABI = false; @@ -4107,16 +4035,6 @@ class SparcTargetInfo : public TargetInfo { public: SparcTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {} - virtual bool setFeatureEnabled(llvm::StringMap &Features, - StringRef Name, - bool Enabled) const { - if (Name == "soft-float") - Features[Name] = Enabled; - else - return false; - - return true; - } virtual void HandleTargetFeatures(std::vector &Features) { SoftFloat = false; for (unsigned i = 0, e = Features.size(); i != e; ++i) @@ -4689,26 +4607,14 @@ public: return ""; } - virtual bool setFeatureEnabled(llvm::StringMap &Features, + virtual void setFeatureEnabled(llvm::StringMap &Features, StringRef Name, bool Enabled) const { - if (Name == "soft-float" || Name == "single-float" || - Name == "o32" || Name == "n32" || Name == "n64" || Name == "eabi" || - Name == "mips32" || Name == "mips32r2" || - Name == "mips64" || Name == "mips64r2" || - Name == "mips16" || Name == "micromips" || - Name == "dsp" || Name == "dspr2" || - Name == "msa") { - Features[Name] = Enabled; - return true; - } else if (Name == "32") { - Features["o32"] = Enabled; - return true; - } else if (Name == "64") { - Features["n64"] = Enabled; - return true; - } - return false; + if (Name == "32") + Name = "o32"; + else if (Name == "64") + Name = "n64"; + Features[Name] = Enabled; } virtual void HandleTargetFeatures(std::vector &Features) { @@ -5574,10 +5480,7 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, continue; // Apply the feature via the target. - if (!Target->setFeatureEnabled(Features, Name + 1, true)) { - Diags.Report(diag::err_target_invalid_feature) << Name; - return 0; - } + Target->setFeatureEnabled(Features, Name + 1, true); } // Then the disables. @@ -5591,11 +5494,8 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, continue; // Apply the feature via the target. - if (Name[0] != '-' || - !Target->setFeatureEnabled(Features, Name + 1, false)) { - Diags.Report(diag::err_target_invalid_feature) << Name; - return 0; - } + assert(Name[0] == '-'); + Target->setFeatureEnabled(Features, Name + 1, false); } // Add the features to the compile options.