[lld] r193487 - Rather than rendering an argument to a std::string (which is primarily
Chandler Carruth
chandlerc at gmail.com
Sat Oct 26 17:10:44 PDT 2013
Author: chandlerc
Date: Sat Oct 26 19:10:43 2013
New Revision: 193487
URL: http://llvm.org/viewvc/llvm-project?rev=193487&view=rev
Log:
Rather than rendering an argument to a std::string (which is primarily
intended for debugging and diagnostic output), just inspect the spelling
to check for specific prefixes in drectve section flags.
In addition to being significantly cheaper and not relying on
a debugging interface, this also avoids creating a temporary string and
binding it to StringRef variable. We then went on to access it after the
memory had been deallocated.
This bug too was caught by ASan. I love ASan so much. =]
Modified:
lld/trunk/lib/Driver/WinLinkDriver.cpp
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=193487&r1=193486&r2=193487&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Sat Oct 26 19:10:43 2013
@@ -474,7 +474,7 @@ parseArgs(int argc, const char *argv[],
// new linker option to an object file while keeping backward compatibility.
for (auto it = parsedArgs->filtered_begin(OPT_UNKNOWN),
ie = parsedArgs->filtered_end(); it != ie; ++it) {
- StringRef arg = (*it)->getAsString(*parsedArgs);
+ StringRef arg = (*it)->getSpelling();
if (isReadingDirectiveSection && arg.startswith("-?"))
continue;
diagnostics << "warning: ignoring unknown argument: " << arg << "\n";
More information about the llvm-commits
mailing list