From 59c397de1a18d0368c003ceae0794f4168a26f3c Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Mon, 5 May 2014 23:26:59 +0000 Subject: [PATCH] Walk back commits for unused function parameters - they're still being used via dragonegg for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208016 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/SubtargetFeature.h | 2 +- lib/MC/SubtargetFeature.cpp | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/llvm/MC/SubtargetFeature.h b/include/llvm/MC/SubtargetFeature.h index d9bea4b917b..d0735ccd9fa 100644 --- a/include/llvm/MC/SubtargetFeature.h +++ b/include/llvm/MC/SubtargetFeature.h @@ -78,7 +78,7 @@ public: std::string getString() const; /// Adding Features. - void AddFeature(const StringRef String); + void AddFeature(const StringRef String, bool IsEnabled = true); /// ToggleFeature - Toggle a feature and returns the newly updated feature /// bits. diff --git a/lib/MC/SubtargetFeature.cpp b/lib/MC/SubtargetFeature.cpp index dd69b0fe8c0..6af92c74a42 100644 --- a/lib/MC/SubtargetFeature.cpp +++ b/lib/MC/SubtargetFeature.cpp @@ -51,6 +51,18 @@ static inline bool isEnabled(const StringRef Feature) { return Ch == '+'; } +/// PrependFlag - Return a string with a prepended flag; '+' or '-'. +/// +static inline std::string PrependFlag(const StringRef Feature, + bool IsEnabled) { + assert(!Feature.empty() && "Empty string"); + if (hasFlag(Feature)) + return Feature; + std::string Prefix = IsEnabled ? "+" : "-"; + Prefix += Feature; + return Prefix; +} + /// Split - Splits a string of comma separated items in to a vector of strings. /// static void Split(std::vector &V, const StringRef S) { @@ -97,11 +109,13 @@ static std::string Join(const std::vector &V) { } /// Adding features. -void SubtargetFeatures::AddFeature(const StringRef String) { - // Don't add empty features or features we already have. - if (!String.empty()) - // Convert to lowercase, prepend flag if we don't already have a flag. - Features.push_back(hasFlag(String) ? String.str() : "+" + String.lower()); +void SubtargetFeatures::AddFeature(const StringRef String, + bool IsEnabled) { + // Don't add empty features + if (!String.empty()) { + // Convert to lowercase, prepend flag and add to vector + Features.push_back(PrependFlag(String.lower(), IsEnabled)); + } } /// Find KV in array using binary search. -- 2.11.0