[llvm-commits] [llvm] r89793 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DIE.h lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h
Daniel Dunbar
daniel at zuster.org
Wed Nov 25 11:43:18 PST 2009
Hi Devang,
On Tue, Nov 24, 2009 at 11:42 AM, Devang Patel <dpatel at apple.com> wrote:
> Author: dpatel
> Date: Tue Nov 24 13:42:17 2009
> New Revision: 89793
>
> URL: http://llvm.org/viewvc/llvm-project?rev=89793&view=rev
> Log:
> Use StringRef instead of std::string in DIEString.
Thanks!
> Modified:
> llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
> llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
>
> Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=89793&r1=89792&r2=89793&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Tue Nov 24 13:42:17 2009
> @@ -297,7 +297,7 @@
> /// EmitString - Emit a string with quotes and a null terminator.
> /// Special characters are emitted properly.
> /// @verbatim (Eg. '\t') @endverbatim
> - void EmitString(const std::string &String) const;
> + void EmitString(const StringRef String) const;
> void EmitString(const char *String, unsigned Size) const;
>
> /// EmitFile - Emit a .file directive.
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=89793&r1=89792&r2=89793&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Nov 24 13:42:17 2009
> @@ -728,7 +728,7 @@
> /// EmitString - Emit a string with quotes and a null terminator.
> /// Special characters are emitted properly.
> /// \literal (Eg. '\t') \endliteral
> -void AsmPrinter::EmitString(const std::string &String) const {
> +void AsmPrinter::EmitString(const StringRef String) const {
> EmitString(String.data(), String.size());
> }
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=89793&r1=89792&r2=89793&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Tue Nov 24 13:42:17 2009
> @@ -277,9 +277,9 @@
> /// DIEString - A string value DIE.
> ///
> class DIEString : public DIEValue {
> - const std::string Str;
> + const StringRef Str;
This particular change might not be a good idea. A StringRef is just a
reference, so whether this is safe or not depends on whether clients
are disallowed from passing in strings whose lifetime will not extend
pass that of the DIEString. I suspect this should remain std::string.
For example, this will fail:
--
addString(die, attr, form, std::string("foo") + "bar");
--
- Daniel
> public:
> - explicit DIEString(const std::string &S) : DIEValue(isString), Str(S) {}
> + explicit DIEString(const StringRef S) : DIEValue(isString), Str(S) {}
>
> /// EmitValue - Emit string value.
> ///
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=89793&r1=89792&r2=89793&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Nov 24 13:42:17 2009
> @@ -333,7 +333,7 @@
> /// addString - Add a string attribute data and value.
> ///
> void DwarfDebug::addString(DIE *Die, unsigned Attribute, unsigned Form,
> - const std::string &String) {
> + const StringRef String) {
> DIEValue *Value = new DIEString(String);
> DIEValues.push_back(Value);
> Die->addValue(Attribute, Form, Value);
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=89793&r1=89792&r2=89793&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Nov 24 13:42:17 2009
> @@ -244,7 +244,7 @@
> /// addString - Add a string attribute data and value.
> ///
> void addString(DIE *Die, unsigned Attribute, unsigned Form,
> - const std::string &String);
> + const StringRef Str);
>
> /// addLabel - Add a Dwarf label attribute data and value.
> ///
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list