Skip to content
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

[clang] [C23] Fix crash with _BitInt running clang-tidy #65889

Merged
merged 1 commit into from
Sep 20, 2023

Commits on Sep 19, 2023

  1. [clang] [C23] Fix crash with _BitInt running clang-tidy

    This crash was exposed recently in our randomized testing. _BitInts were
    not being handled properly during IntegerLiteral visitation. This patch
    addresses the problem for now.
    
    The BitIntType has no getKind() method, so the FoldingSetID is taken
    from the APInt value representing the _BitInt(), similar to other
    methods in StmtProfile.cpp. Seems also the const qualifier was missing
    on the nonstatic profile method of the BitIntType class.
    
    Crash seen (summary form):
    
    clang-tidy: <src-root>/llvm/include/llvm/Support/Casting.h:566:
    decltype(auto) llvm::cast(const From&) [with To = clang::BuiltinType;
    From = clang::QualType]: Assertion `isa<To>(Val) && "cast<Ty>() argument
    of incompatible type!"' failed
    
    ...
      llvm#9 <address> decltype(auto) llvm::cast<clang::BuiltinType,
           clang::QualType>(clang::QualType const&)
           <src-root>/llvm/include/llvm/Support/Casting.h:566:3
     llvm#10 <address> clang::BuiltinType const* clang::Type::castAs<clang::BuiltinType>() const
           <bin-root>/tools/clang/include/clang/AST/TypeNodes.inc:86:1
     llvm#11 <address> (anonymous namespace)::StmtProfiler::VisitIntegerLiteral(
           clang::IntegerLiteral const*)
           <src-root>/clang/lib/AST/StmtProfile.cpp:1362:64
     llvm#12 <address> clang::StmtVisitorBase<llvm::make_const_ptr,
           (anonymous namespace)::StmtProfiler, void>::Visit(clang::Stmt const*)
           <src-root>/clang/include/clang/AST/StmtNodes.inc:1225:1
    ...
    
    Reviewed By: donat.nagy
    vabridgers authored and einvbri committed Sep 19, 2023
    Configuration menu
    Copy the full SHA
    79e1ab6 View commit details
    Browse the repository at this point in the history