This is an archive of the discontinued LLVM Phabricator instance.

[pseudo] Key guards by RuleID, add guards to literals (and 0).
ClosedPublic

Authored by sammccall on Jul 19 2022, 1:55 AM.

Details

Summary

After this, NUMERIC_CONSTANT and strings should parse only one way.

There are 8 types of literals, and 24 valid (literal, TokenKind) pairs.
This means adding 8 new named guards (or 24, if we want to assert the token).

It seems fairly clear to me at this point that the guard names are unneccesary
indirection: the guards are in fact coupled to the rule signature.

(Also add the zero guard I forgot in the previous patch.)

Diff Detail

Event Timeline

sammccall created this revision.Jul 19 2022, 1:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 1:55 AM
sammccall requested review of this revision.Jul 19 2022, 1:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 1:55 AM
sammccall updated this revision to Diff 445760.Jul 19 2022, 3:16 AM

reorder a bit

rebase on function-declarator guards

hokein accepted this revision.Jul 20 2022, 4:42 AM

it looks good.

clang-tools-extra/pseudo/gen/Main.cpp
102 ↗(On Diff #446061)

I think this invariant is still true even in this patch, ExtensionID for empty attribute value is 0, and we start from 1 in the loop.

clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
31

nit: update the stale comment.

clang-tools-extra/pseudo/lib/cxx/CXX.cpp
31–91

nit: not sure the abbreviation of UD is a clearer, took me a while to understand it is for UserDefined, add a comment?

159–169

we might probably to consider to split it out from the CXX.cpp at some point in the future. I think currently it is fine.

174

nit: add a blank line, I think function-declarator guard is different than the contextual-sensitive guard.

clang-tools-extra/pseudo/tool/ClangPseudo.cpp
48

I like this flag -- I have been wanted for several times.

This revision is now accepted and ready to land.Jul 20 2022, 4:42 AM
This revision was automatically updated to reflect the committed changes.
sammccall marked 6 inline comments as done.
sammccall added inline comments.Jul 21 2022, 1:42 PM
clang-tools-extra/pseudo/gen/Main.cpp
102 ↗(On Diff #446061)

Hmm, the assert was firing...

Ah I see what was going on: we were inserting "" at 0 but were inserting it *again* if it was in UniqueAttributeValues, so we had two copies. Fixed.

clang-tools-extra/pseudo/lib/cxx/CXX.cpp
159–169

Yeah, I'd like to keep this all lumped together with no public interfaces for now until the patterns are stable - I wouldn't be surprised if we have to refactor these macros a few more times.

174

Yeah, good call.

amyk added a subscriber: amyk.Jul 21 2022, 9:38 PM

Hi!

It appears that this patch is causing a build failure on a couple PPC bots that build with shared libraries:
https://lab.llvm.org/buildbot/#/builders/57/builds/20179
https://lab.llvm.org/buildbot/#/builders/121/builds/21678

The specific error that occurs looks like this:

2.485 [936/22/19] Linking CXX shared library lib/libclangPseudoCXX.so.15git
FAILED: lib/libclangPseudoCXX.so.15git 
: && /home/buildbots/clang.11.0.0/bin/clang++ --gcc-toolchain=/opt/rh/devtoolset-7/root/usr -fPIC -fPIC -fvisibility-inlines-hidden -Werror -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 -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/buildbots/docker-RHEL-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libclangPseudoCXX.so.15git -o lib/libclangPseudoCXX.so.15git tools/clang/tools/extra/pseudo/lib/cxx/CMakeFiles/obj.clangPseudoCXX.dir/CXX.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libclangPseudo.so.15git  lib/libclangPseudoGrammar.so.15git  lib/libLLVMSupport.so.15git  -Wl,-rpath-link,/home/buildbots/docker-RHEL-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib && :
tools/clang/tools/extra/pseudo/lib/cxx/CMakeFiles/obj.clangPseudoCXX.dir/CXX.cpp.o:(.toc+0x10): undefined reference to `clang::charinfo::InfoTable'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Would you be able to take a look at this issue (or revert the patch if this requires more time to resolve)? Thank you in advance.

Hi!

It appears that this patch is causing a build failure on a couple PPC bots that build with shared libraries:
https://lab.llvm.org/buildbot/#/builders/57/builds/20179
https://lab.llvm.org/buildbot/#/builders/121/builds/21678

The specific error that occurs looks like this:

2.485 [936/22/19] Linking CXX shared library lib/libclangPseudoCXX.so.15git
FAILED: lib/libclangPseudoCXX.so.15git 
: && /home/buildbots/clang.11.0.0/bin/clang++ --gcc-toolchain=/opt/rh/devtoolset-7/root/usr -fPIC -fPIC -fvisibility-inlines-hidden -Werror -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 -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/buildbots/docker-RHEL-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libclangPseudoCXX.so.15git -o lib/libclangPseudoCXX.so.15git tools/clang/tools/extra/pseudo/lib/cxx/CMakeFiles/obj.clangPseudoCXX.dir/CXX.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libclangPseudo.so.15git  lib/libclangPseudoGrammar.so.15git  lib/libLLVMSupport.so.15git  -Wl,-rpath-link,/home/buildbots/docker-RHEL-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib && :
tools/clang/tools/extra/pseudo/lib/cxx/CMakeFiles/obj.clangPseudoCXX.dir/CXX.cpp.o:(.toc+0x10): undefined reference to `clang::charinfo::InfoTable'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Would you be able to take a look at this issue (or revert the patch if this requires more time to resolve)? Thank you in advance.

Sorry about that. d26ee284ded30aff46 links in clangBasic for this dep.
(I think it wasn't showing up in the non-shared builds because these functions were always inlined)

amyk added a comment.Jul 22 2022, 6:23 AM

Hi!

It appears that this patch is causing a build failure on a couple PPC bots that build with shared libraries:
https://lab.llvm.org/buildbot/#/builders/57/builds/20179
https://lab.llvm.org/buildbot/#/builders/121/builds/21678

The specific error that occurs looks like this:

2.485 [936/22/19] Linking CXX shared library lib/libclangPseudoCXX.so.15git
FAILED: lib/libclangPseudoCXX.so.15git 
: && /home/buildbots/clang.11.0.0/bin/clang++ --gcc-toolchain=/opt/rh/devtoolset-7/root/usr -fPIC -fPIC -fvisibility-inlines-hidden -Werror -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 -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/buildbots/docker-RHEL-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libclangPseudoCXX.so.15git -o lib/libclangPseudoCXX.so.15git tools/clang/tools/extra/pseudo/lib/cxx/CMakeFiles/obj.clangPseudoCXX.dir/CXX.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libclangPseudo.so.15git  lib/libclangPseudoGrammar.so.15git  lib/libLLVMSupport.so.15git  -Wl,-rpath-link,/home/buildbots/docker-RHEL-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib && :
tools/clang/tools/extra/pseudo/lib/cxx/CMakeFiles/obj.clangPseudoCXX.dir/CXX.cpp.o:(.toc+0x10): undefined reference to `clang::charinfo::InfoTable'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Would you be able to take a look at this issue (or revert the patch if this requires more time to resolve)? Thank you in advance.

Sorry about that. d26ee284ded30aff46 links in clangBasic for this dep.
(I think it wasn't showing up in the non-shared builds because these functions were always inlined)

Thank you for fixing the build failures, @sammccall, I appreciate it! The bots are back to green now. :-)