This is an archive of the discontinued LLVM Phabricator instance.

Store OptTable::Info::Name as a StringRef
ClosedPublic

Authored by serge-sans-paille on Dec 4 2022, 9:41 AM.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2022, 9:41 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
serge-sans-paille requested review of this revision.Dec 4 2022, 9:41 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 4 2022, 9:41 AM
nikic added a comment.Dec 5 2022, 2:32 AM

Build failure in pre-merge checks:

FAILED: lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildkite-agent/builds/llvm-project/build/lib/Option -I/var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option -I/var/lib/buildkite-agent/builds/llvm-project/build/include -I/var/lib/buildkite-agent/builds/llvm-project/llvm/include -gmlt -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG  -fno-exceptions -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o -MF lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o.d -o lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o -c /var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option/OptTable.cpp
/var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option/OptTable.cpp:70:15: error: no matching function for call to 'StrCmpOptionName'
  if (int N = StrCmpOptionName(A.Name, B.Name))
              ^~~~~~~~~~~~~~~~
/var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option/OptTable.cpp:60:12: note: candidate function not viable: no known conversion from 'const llvm::StringRef' to 'const char *' for 1st argument
static int StrCmpOptionName(const char *A, const char *B) {
           ^
1 error generated.

fix test / compile errors

nikic added inline comments.Dec 6 2022, 12:53 AM
llvm/lib/Option/OptTable.cpp
38–39

The code in this function (and also StrCmpOptionName) depends on the terminating null byte, while a StringRef is not guaranteed to by directly followed by one. I think these two functions would have to be adjusted to operate on StringRef rather than pointers as well.

Also simplify StrCmpOptionNameIgnoreCase implementation thanks to the move to StringRef

serge-sans-paille marked an inline comment as done.Dec 6 2022, 3:28 AM
nikic accepted this revision.Dec 6 2022, 3:48 AM

LG

llvm/lib/Option/OptTable.cpp
41

res -> Res

This revision is now accepted and ready to land.Dec 6 2022, 3:48 AM
This revision was landed with ongoing or failed builds.Dec 6 2022, 5:13 AM
This revision was automatically updated to reflect the committed changes.
thakis added a comment.Dec 6 2022, 5:44 AM

Reverted in de4b6a1bc64db33643f001ad45fae7b92b4a4688 for now. (Note that there was a follow-up fix in e50a60d7349de151bd2b06d85a79201ebc372d8a that I reverted in 13e061e73e1b067589d3bd680fc29297d7e4ec8d. When you reland, you'll likely want to cherry-pick that into your reland.)

Reverted in de4b6a1bc64db33643f001ad45fae7b92b4a4688 for now. (Note that there was a follow-up fix in e50a60d7349de151bd2b06d85a79201ebc372d8a that I reverted in 13e061e73e1b067589d3bd680fc29297d7e4ec8d. When you reland, you'll likely want to cherry-pick that into your reland.)

You've been quicker than I am. Thanks for the revert.

dyung added a subscriber: dyung.Dec 6 2022, 2:50 PM

@serge-sans-paille Your change is causing 24 test failures on the Linux PS4 bot, mostly with an assertion failure it seems. Can you take a look?

https://lab.llvm.org/buildbot/#/builders/139/builds/32263