This is an archive of the discontinued LLVM Phabricator instance.

[include-cleaner] Handle files with unnamed buffers
ClosedPublic

Authored by kadircet on Aug 4 2023, 1:54 AM.

Details

Summary

Some tools can register virtual buffers without identifiers into the
filemanager. Make sure we can handle pragmas in such cases.

Diff Detail

Event Timeline

kadircet created this revision.Aug 4 2023, 1:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 1:54 AM
Herald added a subscriber: ChuanqiXu. · View Herald Transcript
kadircet requested review of this revision.Aug 4 2023, 1:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 1:54 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
hokein accepted this revision.Aug 4 2023, 2:08 AM
This revision is now accepted and ready to land.Aug 4 2023, 2:08 AM
This revision was automatically updated to reflect the committed changes.
lei added a subscriber: lei.Aug 4 2023, 3:04 PM

This is causing a ld.lld link failure in https://lab.llvm.org/buildbot/#/builders/57

FAILED: tools/clang/tools/extra/include-cleaner/unittests/ClangIncludeCleanerTests 
: && /home/buildbots/clang.15.0.4/bin/clang++ --gcc-toolchain=/usr -fPIC -fno-semantic-interposition -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 -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -Wl,--color-diagnostics     -Wl,--gc-sections tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/AnalysisTest.cpp.o tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/FindHeadersTest.cpp.o tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/IncludeSpellerTest.cpp.o tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/LocateSymbolTest.cpp.o tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/RecordTest.cpp.o tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/TypesTest.cpp.o tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/WalkASTTest.cpp.o -o tools/clang/tools/extra/include-cleaner/unittests/ClangIncludeCleanerTests  -Wl,-rpath,/home/buildbots/docker-RHEL84-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib  -lpthread  lib/libllvm_gtest_main.so.18git  -lpthread  lib/libclangIncludeCleaner.so.18git  lib/libclangTesting.so.18git  lib/libLLVMTestingAnnotations.so.18git  lib/libLLVMTestingSupport.so.18git  lib/libclangFormat.so.18git  lib/libclangToolingInclusionsStdlib.so.18git  lib/libllvm_gtest.so.18git  lib/libclangFrontend.so.18git  lib/libclangAST.so.18git  lib/libclangLex.so.18git  lib/libclangBasic.so.18git  lib/libLLVMSupport.so.18git  -Wl,-rpath-link,/home/buildbots/docker-RHEL84-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib && :
ld.lld: error: undefined symbol: clang::PCHContainerOperations::PCHContainerOperations()
>>> referenced by RecordTest.cpp
>>>               tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/RecordTest.cpp.o:(clang::include_cleaner::(anonymous namespace)::PragmaIncludeTest_ExportInUnnamedBuffer_Test::TestBody())
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)

Maybe a lib is needed?

Seeing the link error downstream. I think clangSerialization needs to be added to the link libraries.

RKSimon added a subscriber: RKSimon.Aug 5 2023, 9:41 AM

Seeing the link error downstream. I think clangSerialization needs to be added to the link libraries.

Should be fixed by 36daf3532d91bb

Seeing the link error downstream. I think clangSerialization needs to be added to the link libraries.

Should be fixed by 36daf3532d91bb

Perfect. Thanks for the quick fix.