This is an archive of the discontinued LLVM Phabricator instance.

Fix call sites with spurious .c_str() calls from explicit StringRef conversion (NFC)
AbandonedPublic

Authored by mehdi_amini on Oct 16 2016, 11:07 PM.

Details

Reviewers
zturner
Summary

This update all call-sites where .c_str() is spuriously called
during conversion to StringRef(). This is a follow up to D25639,
now that the conversion are explicit and easy to spot.

Was generated by running the following over the codebase:

sed -i '' 's/llvm::StringRef(\(.*\)->c_str())/*\1/' $file; done
sed -i '' 's/StringRef(\(.*\)->c_str())/*\1/' $file; done
sed -i '' 's/llvm::StringRef(\(.*\).c_str())/\1/' $file; done
sed -i '' 's/StringRef(\(.*\).c_str())/\1/' $file; done

Event Timeline

mehdi_amini retitled this revision from to Fix call sites with spurious .c_str() calls from explicit StringRef conversion (NFC).
mehdi_amini updated this object.
mehdi_amini added a reviewer: zturner.
mehdi_amini added a subscriber: llvm-commits.
malcolm.parsons added inline comments.
clang/lib/Driver/Job.cpp
183

.str() looks redundant.

196

.str() looks redundant.

lldb/source/Interpreter/OptionValueArray.cpp
75

.str() looks redundant.

lldb/source/Interpreter/OptionValueDictionary.cpp
201

.str() looks redundant.

lldb/source/Interpreter/OptionValueFileSpec.cpp
83

.str() looks redundant.

lldb/source/Interpreter/OptionValueFileSpecLIst.cpp
44

.str() looks redundant.

lldb/source/Interpreter/OptionValuePathMappings.cpp
46

.str() looks redundant.

lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
1024

.str() looks redundant.

llvm/lib/MC/ELFObjectWriter.cpp
869

sed didn't do what you wanted here.

Thanks, will update!

clang/lib/Driver/Job.cpp
183

Good point, one more sed line to add :)

llvm/lib/MC/ELFObjectWriter.cpp
869

Nice pattern, interestingly it is still compiling: double redundant StringRef()!

mehdi_amini abandoned this revision.Oct 27 2016, 2:18 PM

Closing since D25639 went dead.