Skip to content

[clang] Improve nested name specifier AST representation #147835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 9, 2025

Conversation

mizvekov
Copy link
Contributor

@mizvekov mizvekov commented Jul 9, 2025

This is a major change on how we represent nested name qualifications in the AST.

  • The nested name specifier itself and how it's stored is changed. The prefixes for types are handled within the type hierarchy, which makes canonicalization for them super cheap, no memory allocation required. Also translating a type into nested name specifier form becomes a no-op. An identifier is stored as a DependentNameType. The nested name specifier gains a lightweight handle class, to be used instead of passing around pointers, which is similar to what is implemented for TemplateName. There is still one free bit available, and this handle can be used within a PointerUnion and PointerIntPair, which should keep bit-packing aficionados happy.
  • The ElaboratedType node is removed, all type nodes in which it could previously apply to can now store the elaborated keyword and name qualifier, tail allocating when present.
  • TagTypes can now point to the exact declaration found when producing these, as opposed to the previous situation of there only existing one TagType per entity. This increases the amount of type sugar retained, and can have several applications, for example in tracking module ownership, and other tools which care about source file origins, such as IWYU. These TagTypes are lazily allocated, in order to limit the increase in AST size.

This patch offers a great performance benefit.

It greatly improves compilation time for stdexec. For one datapoint, for test_on2.cpp in that project, which is the slowest compiling test, this patch improves -c compilation time by about 7.2%, with the -fsyntax-only improvement being at ~12%.

This has great results on compile-time-tracker as well:
image

This patch also further enables other optimziations in the future, and will reduce the performance impact of template specialization resugaring when that lands.

It has some other miscelaneous drive-by fixes.

About the review: Yes the patch is huge, sorry about that. Part of the reason is that I started by the nested name specifier part, before the ElaboratedType part, but that had a huge performance downside, as ElaboratedType is a big performance hog. I didn't have the steam to go back and change the patch after the fact.

There is also a lot of internal API changes, and it made sense to remove ElaboratedType in one go, versus removing it from one type at a time, as that would present much more churn to the users. Also, the nested name specifier having a different API avoids missing changes related to how prefixes work now, which could make existing code compile but not work.

How to review: The important changes are all in clang/include/clang/AST and clang/lib/AST, with also important changes in clang/lib/Sema/TreeTransform.h.

The rest and bulk of the changes are mostly consequences of the changes in API.

PS: TagType::getDecl is renamed to getOriginalDecl in this patch, just for easier to rebasing. I plan to rename it back after this lands.

Fixes #136624
Fixes #43179
Fixes #68670
Fixes #92757

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 9, 2025

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-dbg-bootstrap-build running on libc-x86_64-debian while building clang-tools-extra,clang,libcxx,lldb at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/200/builds/14983

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[396/659] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ASTMerge.cpp.o
[397/659] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReaderStmt.cpp.o
[398/659] Linking CXX static library lib/libclangAnalysis.a
[399/659] Building CXX object tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/CommentToXML.cpp.o
[400/659] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CreateInvocationFromCommandLine.cpp.o
[401/659] Building CXX object tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/FileIndexRecord.cpp.o
[402/659] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterDecl.cpp.o
[403/659] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterStmt.cpp.o
[404/659] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/DependencyFile.cpp.o
[405/659] Building CXX object tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteObjC.cpp.o
FAILED: tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteObjC.cpp.o 
/usr/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/tools/clang/lib/Frontend/Rewrite -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/tools/clang/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/llvm/include -fPIC -fno-semantic-interposition -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 -fno-common -Woverloaded-virtual -Wno-nested-anon-types -g  -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteObjC.cpp.o -MF tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteObjC.cpp.o.d -o tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteObjC.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:2361:52: error: no member named 'getTagDeclType' in 'clang::ASTContext'
  QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
                                          ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:2404:52: error: no member named 'getTagDeclType' in 'clang::ASTContext'
  QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
                                          ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:2555:19: error: no member named 'getTagDeclType' in 'clang::ASTContext'
  return Context->getTagDeclType(SuperStructDecl);
         ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:2588:19: error: no member named 'getTagDeclType' in 'clang::ASTContext'
  return Context->getTagDeclType(ConstantStringDecl);
         ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:3753:56: error: no member named 'getTagDeclType' in 'clang::ASTContext'
  QualType PtrBlock = Context->getPointerType(Context->getTagDeclType(RD));
                                              ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:4471:57: error: no member named 'getTagDeclType' in 'clang::ASTContext'
      QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
                                               ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:4837:63: error: no member named 'getDecl' in 'clang::RecordType'
        RecordDecl *RD = VD->getType()->castAs<RecordType>()->getDecl();
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:5807:57: error: no member named 'getTagDeclType' in 'clang::ASTContext'
      QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
                                               ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:5848:57: error: no member named 'getTagDeclType' in 'clang::ASTContext'
      QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
                                               ~~~~~~~  ^
9 errors generated.
[406/659] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ModuleDependencyCollector.cpp.o
[407/659] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/InitPreprocessor.cpp.o
[408/659] Building CXX object tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteModernObjC.cpp.o
FAILED: tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteModernObjC.cpp.o 
/usr/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/tools/clang/lib/Frontend/Rewrite -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/tools/clang/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/llvm/include -fPIC -fno-semantic-interposition -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 -fno-common -Woverloaded-virtual -Wno-nested-anon-types -g  -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteModernObjC.cpp.o -MF tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteModernObjC.cpp.o.d -o tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteModernObjC.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:855:51: error: no member named 'getDecl' in 'clang::RecordType'
    RecordDecl *RD = IvarT->castAs<RecordType>()->getDecl();
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:868:65: error: no member named 'getTagDeclType' in 'clang::ASTContext'
Step 6 (build libc) failure: build libc (failure)
...
[396/659] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ASTMerge.cpp.o
[397/659] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReaderStmt.cpp.o
[398/659] Linking CXX static library lib/libclangAnalysis.a
[399/659] Building CXX object tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/CommentToXML.cpp.o
[400/659] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CreateInvocationFromCommandLine.cpp.o
[401/659] Building CXX object tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/FileIndexRecord.cpp.o
[402/659] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterDecl.cpp.o
[403/659] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterStmt.cpp.o
[404/659] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/DependencyFile.cpp.o
[405/659] Building CXX object tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteObjC.cpp.o
FAILED: tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteObjC.cpp.o 
/usr/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/tools/clang/lib/Frontend/Rewrite -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/tools/clang/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/llvm/include -fPIC -fno-semantic-interposition -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 -fno-common -Woverloaded-virtual -Wno-nested-anon-types -g  -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteObjC.cpp.o -MF tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteObjC.cpp.o.d -o tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteObjC.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:2361:52: error: no member named 'getTagDeclType' in 'clang::ASTContext'
  QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
                                          ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:2404:52: error: no member named 'getTagDeclType' in 'clang::ASTContext'
  QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
                                          ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:2555:19: error: no member named 'getTagDeclType' in 'clang::ASTContext'
  return Context->getTagDeclType(SuperStructDecl);
         ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:2588:19: error: no member named 'getTagDeclType' in 'clang::ASTContext'
  return Context->getTagDeclType(ConstantStringDecl);
         ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:3753:56: error: no member named 'getTagDeclType' in 'clang::ASTContext'
  QualType PtrBlock = Context->getPointerType(Context->getTagDeclType(RD));
                                              ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:4471:57: error: no member named 'getTagDeclType' in 'clang::ASTContext'
      QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
                                               ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:4837:63: error: no member named 'getDecl' in 'clang::RecordType'
        RecordDecl *RD = VD->getType()->castAs<RecordType>()->getDecl();
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:5807:57: error: no member named 'getTagDeclType' in 'clang::ASTContext'
      QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
                                               ~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp:5848:57: error: no member named 'getTagDeclType' in 'clang::ASTContext'
      QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
                                               ~~~~~~~  ^
9 errors generated.
[406/659] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ModuleDependencyCollector.cpp.o
[407/659] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/InitPreprocessor.cpp.o
[408/659] Building CXX object tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteModernObjC.cpp.o
FAILED: tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteModernObjC.cpp.o 
/usr/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/tools/clang/lib/Frontend/Rewrite -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/tools/clang/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/llvm/include -fPIC -fno-semantic-interposition -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 -fno-common -Woverloaded-virtual -Wno-nested-anon-types -g  -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteModernObjC.cpp.o -MF tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteModernObjC.cpp.o.d -o tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/RewriteModernObjC.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:855:51: error: no member named 'getDecl' in 'clang::RecordType'
    RecordDecl *RD = IvarT->castAs<RecordType>()->getDecl();
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:868:65: error: no member named 'getTagDeclType' in 'clang::ASTContext'

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 9, 2025

LLVM Buildbot has detected a new failure on builder lldb-x86_64-debian running on lldb-x86_64-debian while building clang-tools-extra,clang,libcxx,lldb at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/28595

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteAuxvSupport.py (50 of 3137)
PASS: lldb-api :: python_api/find_in_memory/TestFindRangesInMemory.py (51 of 3137)
PASS: lldb-api :: tools/lldb-dap/completions/TestDAP_completions.py (52 of 3137)
PASS: lldb-api :: tools/lldb-server/qSupported/TestGdbRemote_qSupported.py (53 of 3137)
PASS: lldb-api :: functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py (54 of 3137)
PASS: lldb-api :: tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py (55 of 3137)
PASS: lldb-api :: commands/settings/TestSettings.py (56 of 3137)
PASS: lldb-api :: functionalities/thread/state/TestThreadStates.py (57 of 3137)
PASS: lldb-api :: tools/lldb-dap/server/TestDAP_server.py (58 of 3137)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/vector/TestDataFormatterStdVector.py (59 of 3137)
FAIL: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py (60 of 3137)
******************** TEST 'lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py' FAILED ********************
Script:
--
/usr/bin/python3 /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 --build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex --lldb-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./lib --cmake-build-type Release -t /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string -p TestDataFormatterStdString.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision 91cdd35008e9ab32dffb7e401cdd7313b3461892)
  clang revision 91cdd35008e9ab32dffb7e401cdd7313b3461892
  llvm revision 91cdd35008e9ab32dffb7e401cdd7313b3461892
Skipping the following test categories: ['libc++', 'msvcstl', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
Change dir to: /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string
UNSUPPORTED: LLDB (/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang-x86_64) :: test_embedded_null_libcxx_dsym (TestDataFormatterStdString.StdStringDataFormatterTestCase.test_embedded_null_libcxx_dsym) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang-x86_64) :: test_embedded_null_libcxx_dwarf (TestDataFormatterStdString.StdStringDataFormatterTestCase.test_embedded_null_libcxx_dwarf) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang-x86_64) :: test_embedded_null_libcxx_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase.test_embedded_null_libcxx_dwo) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang-x86_64) :: test_embedded_null_libstdcxx_dsym (TestDataFormatterStdString.StdStringDataFormatterTestCase.test_embedded_null_libstdcxx_dsym) (test case does not fall in any category of interest for this run) 
runCmd: settings clear --all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 

runCmd: settings set target.disable-aslr false

output: 


@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 9, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building clang-tools-extra,clang,libcxx,lldb at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/22354

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/u8string_view/TestDataFormatterStdU8StringView.py (413 of 2304)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/valarray/TestDataFormatterStdValarray.py (414 of 2304)
PASS: lldb-api :: functionalities/completion/TestCompletion.py (415 of 2304)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py (416 of 2304)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterStdVBool.py (417 of 2304)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libcxx-simulators/optional/TestDataFormatterLibcxxOptionalSimulator.py (418 of 2304)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/TestDataFormatterStdUniquePtr.py (419 of 2304)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxInvalidString.py (420 of 2304)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/TestDataFormatterLibcxxUniquePtrSimulator.py (421 of 2304)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/invalid-variant/TestDataFormatterInvalidStdVariant.py (422 of 2304)
FAIL: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py (423 of 2304)
******************** TEST 'lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --cmake-build-type Release /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string -p TestDataFormatterStdString.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision 91cdd35008e9ab32dffb7e401cdd7313b3461892)
  clang revision 91cdd35008e9ab32dffb7e401cdd7313b3461892
  llvm revision 91cdd35008e9ab32dffb7e401cdd7313b3461892
Skipping the following test categories: ['libc++', 'msvcstl', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_embedded_null_libcxx_dsym (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_embedded_null_libcxx_dwarf (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_embedded_null_libcxx_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_embedded_null_libstdcxx_dsym (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
XFAIL: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_embedded_null_libstdcxx_dwarf (TestDataFormatterStdString.StdStringDataFormatterTestCase)
XFAIL: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_embedded_null_libstdcxx_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase)
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_embedded_null_msvc_dsym (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_embedded_null_msvc_dwarf (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_embedded_null_msvc_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_libcxx_dsym (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_libcxx_dwarf (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_libcxx_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_libstdcxx_dsym (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_libstdcxx_dwarf (TestDataFormatterStdString.StdStringDataFormatterTestCase)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_libstdcxx_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase)
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_msvc_dsym (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_msvc_dwarf (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_msvc_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_multibyte_libcxx_dsym (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_multibyte_libcxx_dwarf (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_multibyte_libcxx_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase) (test case does not fall in any category of interest for this run) 

mizvekov added a commit that referenced this pull request Aug 9, 2025
This completes #147835
by adapting the changes in the API to the rewriter.

Fixes build failures such as reported here: #147835 (comment)

We previously missed this because it was not tested in pre-commit CI.
This patch also addresses that problem.
mizvekov added a commit that referenced this pull request Aug 9, 2025
This completes #147835
by adapting the changes in the API to the rewriter.

Fixes build failures such as reported here: #147835 (comment)

We previously missed this because it was not tested in pre-commit CI.
mizvekov added a commit that referenced this pull request Aug 9, 2025
This completes #147835 by
adapting the changes in the API to the rewriter.

Fixes build failures such as reported here:
#147835 (comment)

We previously missed this because it was not tested in pre-commit CI.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Aug 9, 2025
This completes llvm/llvm-project#147835 by
adapting the changes in the API to the rewriter.

Fixes build failures such as reported here:
llvm/llvm-project#147835 (comment)

We previously missed this because it was not tested in pre-commit CI.
searlmc1 pushed a commit to ROCm/llvm-project that referenced this pull request Aug 10, 2025
…m#147835)"

needs dependent PR
  [clang][CGRecordLayout] Remove dependency on isZeroSize (llvm#96422)

This reverts commit 91cdd35.
@DavidSpickett
Copy link
Collaborator

This has changed the output of lldb's std::string formatter when it's not a valid std::string object:

******************** TEST 'lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --cmake-build-type Release /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string -p TestDataFormatterStdString.py
--
Exit Code: 1
<...>
--
Command Output (stderr):
--
<...>
======================================================================
FAIL: test_unavailable_summary_libstdcxx_dwarf (TestDataFormatterStdString.StdStringDataFormatterTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1805, in test_method
    return attrvalue(self)
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py", line 223, in test_unavailable_summary_libstdcxx
    self.do_test_summary_unavailable()
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py", line 213, in do_test_summary_unavailable
    self.assertEqual(summary, "Summary Unavailable", "No summary for bad value")
AssertionError: '(null)' != 'Summary Unavailable'
- (null)
+ Summary Unavailable
 : No summary for bad value
Config=aarch64-/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang
======================================================================
FAIL: test_unavailable_summary_libstdcxx_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1805, in test_method
    return attrvalue(self)
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py", line 223, in test_unavailable_summary_libstdcxx
    self.do_test_summary_unavailable()
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py", line 213, in do_test_summary_unavailable
    self.assertEqual(summary, "Summary Unavailable", "No summary for bad value")
AssertionError: '(null)' != 'Summary Unavailable'
- (null)
+ Summary Unavailable
 : No summary for bad value
Config=aarch64-/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang
----------------------------------------------------------------------
Ran 54 tests in 6.052s

We create the (not a) std::string like this:

std::string *not_a_string = (std::string *)0x0;

So in some sense, (null) is accurate, but users probably expect to see no summary at all.

This is from Linaro's bot where we only run libstdcxx tests. Libcxx testing seems fine (https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-matrix/). This could be because the formatter has different behaviour for the two standard libraries.

@Michael137 might know where to look for this problem, in the meantime, I'll do my own digging.

DavidSpickett added a commit to DavidSpickett/llvm-project that referenced this pull request Aug 11, 2025
llvm#147835 made changes that
caused libstdc++ std::string tests to fail:
```
======================================================================
FAIL: test_unavailable_summary_libstdcxx_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1805, in test_method
    return attrvalue(self)
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py", line 223, in test_unavailable_summary_libstdcxx
    self.do_test_summary_unavailable()
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py", line 213, in do_test_summary_unavailable
    self.assertEqual(summary, "Summary Unavailable", "No summary for bad value")
AssertionError: '(null)' != 'Summary Unavailable'
- (null)
+ Summary Unavailable
 : No summary for bad value
Config=aarch64-/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang
----------------------------------------------------------------------
```

This test constructs an invalid std::string by starting with a null pointer.

Somehow this improvement in Clang uncovered a bug in the formatter. The formatter
tries to access `_M_p` and checked whether the resulting ValueObjectSP was null,
but not that it did not contain an error value.

I think that error value can be there if you are able to access one part
of the path, `_M_dataplus`, but another part fails. Since the layout looks like this:
```
      struct _Alloc_hider :
      {
	      pointer _M_p; // The actual data.
      };

      _Alloc_hider	_M_dataplus;

      void
      _M_data(pointer __p)
      { _M_dataplus._M_p = __p; }
```
So I think we were able to read `_M_dataplus` just by offset, but
then failed because it contains, or points to something containing
nulls or a null pointer.

Or perhaps an error value means we know what the class member is,
but could not read from it.

I found this by comparing with the libcxx formatter, so I've copied
the same handling from there to fix the issue.
@DavidSpickett
Copy link
Collaborator

#152993 fixes this.

Pretty sure there's no problem with this PR, it uncovered an existing problem in the formatter itself.

DavidSpickett added a commit that referenced this pull request Aug 11, 2025
#147835 made changes that
caused libstdc++ std::string tests to fail:
```
======================================================================
FAIL: test_unavailable_summary_libstdcxx_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1805, in test_method
    return attrvalue(self)
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py", line 223, in test_unavailable_summary_libstdcxx
    self.do_test_summary_unavailable()
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py", line 213, in do_test_summary_unavailable
    self.assertEqual(summary, "Summary Unavailable", "No summary for bad value")
AssertionError: '(null)' != 'Summary Unavailable'
- (null)
+ Summary Unavailable
 : No summary for bad value
Config=aarch64-/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang
----------------------------------------------------------------------
```

This test constructs an invalid std::string by starting with a null
pointer.

Somehow this improvement in Clang uncovered a bug in the formatter.
Perhaps because we now know the type of the field we tried to access is
char *, so fall back to a C string formatter that produces `(null)`.

The formatter tries to access `_M_p` and checked whether the resulting
ValueObjectSP was null, but not that it did not contain an error value.
I think that error value can be there if you are able to access one part
of the path, `_M_dataplus`, but another part fails. Since the layout
looks like this:
```
      struct _Alloc_hider :
      {
	      pointer _M_p; // The actual data.
      };

      _Alloc_hider	_M_dataplus;

      void
      _M_data(pointer __p)
      { _M_dataplus._M_p = __p; }
```
So I think we were able to read `_M_dataplus` just by offset, but then
failed because it contains, or points to something containing nulls or a
null pointer.

Or perhaps an error value means we know what the class member is, but
could not read from it.

I found this by comparing with the libcxx formatter, so I've copied the
same handling from there to fix the issue.
@ckandeler
Copy link
Member

Observation using clangd: In the following construct

namespace N { struct Foo{}; }
void f()
{
    using namespace N;
    Foo foo;
}

The "arcana" field of the AST node of "Foo" inside the function reports the "QualType" as "Foo", whereas before it was "N::Foo". Is that expected?

llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Aug 11, 2025
…#152993)

llvm/llvm-project#147835 made changes that
caused libstdc++ std::string tests to fail:
```
======================================================================
FAIL: test_unavailable_summary_libstdcxx_dwo (TestDataFormatterStdString.StdStringDataFormatterTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1805, in test_method
    return attrvalue(self)
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py", line 223, in test_unavailable_summary_libstdcxx
    self.do_test_summary_unavailable()
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py", line 213, in do_test_summary_unavailable
    self.assertEqual(summary, "Summary Unavailable", "No summary for bad value")
AssertionError: '(null)' != 'Summary Unavailable'
- (null)
+ Summary Unavailable
 : No summary for bad value
Config=aarch64-/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang
----------------------------------------------------------------------
```

This test constructs an invalid std::string by starting with a null
pointer.

Somehow this improvement in Clang uncovered a bug in the formatter.
Perhaps because we now know the type of the field we tried to access is
char *, so fall back to a C string formatter that produces `(null)`.

The formatter tries to access `_M_p` and checked whether the resulting
ValueObjectSP was null, but not that it did not contain an error value.
I think that error value can be there if you are able to access one part
of the path, `_M_dataplus`, but another part fails. Since the layout
looks like this:
```
      struct _Alloc_hider :
      {
	      pointer _M_p; // The actual data.
      };

      _Alloc_hider	_M_dataplus;

      void
      _M_data(pointer __p)
      { _M_dataplus._M_p = __p; }
```
So I think we were able to read `_M_dataplus` just by offset, but then
failed because it contains, or points to something containing nulls or a
null pointer.

Or perhaps an error value means we know what the class member is, but
could not read from it.

I found this by comparing with the libcxx formatter, so I've copied the
same handling from there to fix the issue.
@kimgr
Copy link
Contributor

kimgr commented Aug 11, 2025

Did this PR intentionally break the RecursiveASTVisitor API? The new TraverseQualifier argument through the whole Traverse.*Type hierarchy makes all CRTP overrides not be called, unless I'm missing something.

It's a bit hard to test, because the NNS changes also break a lot of code in IWYU, so it's tricky to play with things in isolation.

@bolshakov-a
Copy link
Contributor

@kimgr, I've just succeeded in building IWYU against this and getting the tests green. However, I want to spend some time on self-review, probably writing additional tests, and so on.

AmrDeveloper added a commit that referenced this pull request Aug 11, 2025
…epresentation (#152846)

After AST representation, new modifications landed in
(#147835). ClangIR requires
some changes in how we use Clang AST to be compatible with the new
changes
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Aug 11, 2025
…ifier AST representation (#152846)

After AST representation, new modifications landed in
(llvm/llvm-project#147835). ClangIR requires
some changes in how we use Clang AST to be compatible with the new
changes
@mizvekov
Copy link
Contributor Author

mizvekov commented Aug 11, 2025

Did this PR intentionally break the RecursiveASTVisitor API? The new TraverseQualifier argument through the whole Traverse.*Type hierarchy makes all CRTP overrides not be called, unless I'm missing something.

Yeah, the change in API helps in that we keep the same order of traversal as before, which makes it easier to keep existing code working.

@mizvekov
Copy link
Contributor Author

Observation using clangd: In the following construct
...
The "arcana" field of the AST node of "Foo" inside the function reports the "QualType" as "Foo", whereas before it was "N::Foo". Is that expected?

It looks correct in that this is the as-written type.

Now I am not sure clangd wants to present the type that way, maybe they want to fully qualify it for printing instead?
@kadircet @hokein

@mysterymath
Copy link
Contributor

We are seeing an assertion failure in one of Fuchsia's builders due to this:

[38296/176952](67) CXX user.basic_x64-shared/obj/sdk/lib/ld/libld-startup.zircon-startup.cc.o
FAILED: [code=1] user.basic_x64-shared/obj/sdk/lib/ld/libld-startup.zircon-startup.cc.o
../../prebuilt/third_party/clang/custom/bin/clang++ -MD -MF user.basic_x64-shared/obj/sdk/lib/ld/libld-startup.zircon-startup.cc.o.d -o user.basic_x64-shared/obj/sdk/lib/ld/libld-startup.zircon-startup.cc.o -DWITH_FRAME_POINTERS=1 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 -DZX_ASSERT_LEVEL=2 -D_ALL_SOURCE -DHAVE_LLVM_PROFDATA=0 -I../../zircon/system/p...
clang++: clang/lib/AST/TemplateBase.cpp:610: clang::TemplateArgumentLoc::TemplateArgumentLoc(ASTContext &, const TemplateArgument &, SourceLocation, NestedNameSpecifierLoc, SourceLocation, SourceLocation): Assertion `QualifierLoc.getNestedNameSpecifier() == Argument.getAsTemplateOrTemplatePattern().getQualifier()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: ../../prebuilt/third_party/clang/custom/bin/clang++ -MD -MF user.basic_x64-shared/obj/sdk/lib/ld/libld-startup.zircon-startup.cc.o.d -o user.basic_x64-shared/obj/sdk/lib/ld/libld-startup.zircon-startup.cc.o -DWITH_FRAME_POINTERS=1 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 -DZX_ASSERT_LEVEL=2 -D_ALL_SOURCE -DHAVE_LLVM_PROFDATA=0 -...
1.	<eof> parser at end of file
2.	../../sdk/lib/ld/startup-load.h:183:15: instantiating function definition 'ld::StartupLoadModule<elfldltl::LocalVmarLoader>::LinkModules<trivial_allocator::BasicLeakyAllocator<trivial_allocator::OwningAllocateFunction<trivial_allocator::PageAllocator<trivial_allocator::ZirconVmar>>>, InitialExecAllocator, (lambda at ../../sdk/lib/ld/zircon-startup.cc:210:23) &, zx::vmar &>'
3.	../../sdk/lib/ld/startup-load.h:289:15: instantiating function definition 'ld::StartupLoadModule<elfldltl::LocalVmarLoader>::LoadDeps<trivial_allocator::BasicLeakyAllocator<trivial_allocator::OwningAllocateFunction<trivial_allocator::PageAllocator<trivial_allocator::ZirconVmar>>>, InitialExecAllocator, (lambda at ../../sdk/lib/ld/zircon-startup.cc:210:23) &, zx::vmar &>'
4.	../../sdk/lib/ld/startup-load.h:269:8: instantiating function definition 'ld::StartupLoadModule<elfldltl::LocalVmarLoader>::EnqueueDeps<trivial_allocator::BasicLeakyAllocator<trivial_allocator::OwningAllocateFunction<trivial_allocator::PageAllocator<trivial_allocator::ZirconVmar>>>, zx::vmar &>'
#0 0x000055b727798b48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../prebuilt/third_party/clang/custom/bin/clang+++0x9396b48)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Fuchsia clang version 22.0.0git (https://llvm.googlesource.com/llvm-project 10e146a7161065429629a13f99c179a61ffe7721)
Target: x86_64-unknown-fuchsia
Thread model: posix
InstalledDir: ../../prebuilt/third_party/clang/cu...

Can you revert or fix forward? I've no idea whether this helps with debugging at all, but this is the source file that produced the assertion failure in clang: https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/lib/ld/zircon-startup.cc?q=zircon-startup.cc&ss=fuchsia

@mizvekov
Copy link
Contributor Author

We are seeing an assertion failure in one of Fuchsia's builders due to this:

Can you please attach the crash reproducer which clang should have generated? Thanks.

@stbergmann
Copy link
Collaborator

After this commit, the comment in clang/include/clang/AST/Decl.h for clang::TypeDecl::getTypeForDecl,

  // Low-level accessor. If you just want the type defined by this node,
  // check out ASTContext::getTypeDeclType or one of
  // ASTContext::getTypedefType, ASTContext::getRecordType, etc. if you
  // already know the specific kind of node this is.

isn't accurate any more, there's no more ASTContext::getRecordType.

@kadircet
Copy link
Member

Observation using clangd: In the following construct
...
The "arcana" field of the AST node of "Foo" inside the function reports the "QualType" as "Foo", whereas before it was "N::Foo". Is that expected?

It looks correct in that this is the as-written type.

Now I am not sure clangd wants to present the type that way, maybe they want to fully qualify it for printing instead? @kadircet @hokein

clangd doesn't really have a preference here, we just surface -ast-dump in a editor friendly format, for debugging purposes.

one can repro the situation with clang -xc++ -fsyntax-only -Xclang=-ast-dump a.cc

where a.cc is:

namespace N {
struct Foo {};
}  // namespace N
void f() {
  using namespace N;
  Foo foo;
  N::Foo x;
}

pre this change output looks like:

`-FunctionDecl 0x5621625282a0 <line:4:1, line:8:1> line:4:6 f 'void ()'
  `-CompoundStmt 0x562162528d10 <col:10, line:8:1>
    |-DeclStmt 0x5621625283e8 <line:5:3, col:20>
    | `-UsingDirectiveDecl 0x562162528390 <col:3, col:19> col:19 Namespace 0x562162528018 'N'
    |-DeclStmt 0x562162528b88 <line:6:3, col:10>
    | `-VarDecl 0x562162528440 <col:3, col:7> col:7 foo 'Foo':'N::Foo' callinit
    |   `-CXXConstructExpr 0x562162528b60 <col:7> 'Foo':'N::Foo' 'void () noexcept'
    `-DeclStmt 0x562162528cf8 <line:7:3, col:11>
      `-VarDecl 0x562162528c38 <col:3, col:10> col:10 x 'N::Foo' callinit
        `-CXXConstructExpr 0x562162528cd0 <col:10> 'N::Foo' 'void () noexcept'

emphasis on -VarDecl 0x562162528440 <col:3, col:7> col:7 foo 'Foo':'N::Foo' callinit

after thins change this is now reported as VarDecl 0x5652a7615860 <col:3, col:7> col:7 foo 'Foo' callinit

this was handled by https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/TextNodeDumper.cpp#L909-L926, I am not sure if change is intended (i think we should still be able to detect & desugar)

@bolshakov-a
Copy link
Contributor

The new TraverseQualifier argument through the whole Traverse.*Type hierarchy ...

@mizvekov, anyway, it would be good to know if TraverseQualifier is a customization point for users who implement their own RecursiveASTVisitor subclasses, or the default argument value should always be true? There is an assertion inside TraverseQualifiedTypeLoc:

assert(TraverseQualifier &&

However, I don't see where in the world QualifiedTypeLoc is created...

@mizvekov
Copy link
Contributor Author

After this commit, the comment in clang/include/clang/AST/Decl.h for clang::TypeDecl::getTypeForDecl,
isn't accurate any more, there's no more ASTContext::getRecordType.

Thanks for reporting, I'll fix in a follow up patch.

Observation using clangd: In the following construct
this was handled by https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/TextNodeDumper.cpp#L909-L926, I am not sure if change is intended (i think we should still be able to detect & desugar)

Right, the difference here is that before this patch, if you print a fully desugared tag type (that's what the 'aka' in the diagnostic does), the type is printed fully qualified. That's because the name qualifiers were carried in the 'ElaboratedType' sugar node, and we used to handle this situation specially: we assumed a bare tag type only occurred because of canonicalization.

With this patch the tag types themselves carry the name qualifier, so just removing the top level sugar doesn't make them lose name qualifier information.

We still fully qualify canonical tag types when printing them though, but that now happens because a canonical tag type is a special value which is not identical to any other tag type for the same declaration.

We may still want to fully qualify types for the 'aka' diagnostic, but I deferred that for a follow up patch in order to limit the amount of test churn.

For clangd, I assume the same thing is happening here, for this arcana" field, you are fully desugaring the type before printing it.

@mizvekov, anyway, it would be good to know if TraverseQualifier is a customization point for users who implement their own RecursiveASTVisitor subclasses, or the default argument value should always be true?

The TraverseQualifier flag means, 'should I traverse NestedNameSpecifiers?'

If you are simply customizing one of the Traverse* methods which take it, but still delegating to the base class Traverse method, you should just forward that flag along to the base method.

If you are implementing your own Traverse method for a type from scratch, then if this flag is false, you should not traverse the nested name specifier for that type.

There is an assertion inside TraverseQualifiedTypeLoc:

assert(TraverseQualifier &&

However, I don't see where in the world QualifiedTypeLoc is created...

QualifiedTypeLoc is created implicitly for QualTypes which have top level qualifiers, and they represent the source locations for type qualifiers (not name qualifiers, different thing.)

This assert here means that a top level type qualifier can't appear within a nested name specifier (but it could appear for example in the underlying type for a typedef).

The C++ grammar doesn't allow you to write const / volatile in a way which applies to an entity in the name qualifier itself.

While such a NestedNameSpecifier could still be produced as part of template argument deduction, we simply remove the top level qualifiers in that case, as the NestedNameSpecifier AST node itself still can't represent it.

@mysterymath
Copy link
Contributor

We are seeing an assertion failure in one of Fuchsia's builders due to this:

Can you please attach the crash reproducer which clang should have generated? Thanks.

https://storage.googleapis.com/fuchsia-artifacts/builds/8707018386865583409/build-debug/clang-crashreports/zircon-startup-bad996.tar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AArch64 backend:AMDGPU backend:ARC backend:ARM backend:CSKY backend:Hexagon backend:Lanai backend:loongarch backend:MIPS backend:PowerPC backend:RISC-V backend:Sparc backend:SystemZ backend:WebAssembly backend:X86 clang:analysis clang:as-a-library libclang and C++ API clang:bytecode Issues for the clang bytecode constexpr interpreter clang:codegen IR generation bugs: mangling, exceptions, etc. clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules clang:openmp OpenMP related changes to Clang clang:static analyzer clang Clang issues not falling into any other category clang-tidy clang-tools-extra clangd coroutines C++20 coroutines debuginfo HLSL HLSL Language Support libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. lldb
Projects
None yet