[llvm-commits] [llvm] r134219 - in /llvm/trunk: include/llvm/MC/SubtargetFeature.h lib/MC/SubtargetFeature.cpp
Eli Friedman
eli.friedman at gmail.com
Thu Jun 30 17:59:25 PDT 2011
On Thu, Jun 30, 2011 at 5:23 PM, Evan Cheng <evan.cheng at apple.com> wrote:
> Author: evancheng
> Date: Thu Jun 30 19:23:10 2011
> New Revision: 134219
>
> URL: http://llvm.org/viewvc/llvm-project?rev=134219&view=rev
> Log:
> Switch SubtargetFeatures from std::string to StringRef.
>
> Modified:
> llvm/trunk/include/llvm/MC/SubtargetFeature.h
> llvm/trunk/lib/MC/SubtargetFeature.cpp
>
[...]
> @@ -53,16 +53,19 @@
>
> /// PrependFlag - Return a string with a prepended flag; '+' or '-'.
> ///
> -static inline std::string PrependFlag(const std::string &Feature,
> - bool IsEnabled) {
> +static inline StringRef PrependFlag(const StringRef Feature,
> + bool IsEnabled) {
> assert(!Feature.empty() && "Empty string");
> - if (hasFlag(Feature)) return Feature;
> - return std::string(IsEnabled ? "+" : "-") + Feature;
> + if (hasFlag(Feature))
> + return Feature;
> + std::string Prefix = IsEnabled ? "+" : "-";
> + Prefix += Feature;
> + return StringRef(Prefix);
> }
Use-after-free.
> -std::string SubtargetFeatures::getString() const {
> +StringRef SubtargetFeatures::getString() const {
> return Join(Features);
> }
Same.
-Eli
More information about the llvm-commits
mailing list