This is an archive of the discontinued LLVM Phabricator instance.

Fix a couple of incorrect format strings
ClosedPublic

Authored by ldrumm on Dec 21 2016, 12:30 PM.

Details

Summary

This patch fixes use of incorrect %zi to format a plain int, and switches from using "%llu" to format a uint64_t to using the exact width specifier PRIu64 from inttypes.h

Diff Detail

Event Timeline

ldrumm updated this revision to Diff 82256.Dec 21 2016, 12:30 PM
ldrumm retitled this revision from to Fix a couple of incorrect format strings.
ldrumm updated this object.
ldrumm added reviewers: zturner, clayborg.
ldrumm added a subscriber: Restricted Project.
zturner edited edge metadata.Dec 21 2016, 12:52 PM

How about re-writing these to use llvm::formatv() since the whole point of it is to eliminate this problem entirely and clayborg@ has agreed that it looks good going forward?

Individual call-site suggestions inlined.

source/Interpreter/Args.cpp
216–217

s.Format("{0}[{1}]=\"{2}\"\n", label_name, i++, entry.ref);

219

s.Format("{0}[{1}]=NULL\n", label_name, i);

source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
517–519
log->Format("Encountered an Object-C constant string with unusual "
            "element size {0}", string_array->getElementByteSize());
clayborg requested changes to this revision.Dec 21 2016, 1:42 PM
clayborg edited edge metadata.

Please swift to using the new formatv stuff as this is the main reason Zach made those changes.

source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
41

Not needed if you use formatv.

This revision now requires changes to proceed.Dec 21 2016, 1:42 PM
ldrumm updated this revision to Diff 82334.Dec 22 2016, 5:22 AM
ldrumm edited edge metadata.

switched to the new llvm::Format API

clayborg accepted this revision.Dec 22 2016, 8:09 AM
clayborg edited edge metadata.
This revision is now accepted and ready to land.Dec 22 2016, 8:09 AM
This revision was automatically updated to reflect the committed changes.