[clang] [clang-tools-extra] [clang] AST: fix getAs canonicalization of leaf types (PR #155028)

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 28 06:00:44 PDT 2025


jyknight wrote:

Minimized test-case:
```
cat > test.h <<EOF
#ifndef TEST_H_
#define TEST_H_
template <class _Tp>
using __underlying_type_t = __underlying_type(_Tp);
enum __legacy_memory_order { __mo_relaxed };
using __memory_order_underlying_t = __underlying_type_t<__legacy_memory_order>;
enum class memory_order : __memory_order_underlying_t { relaxed = __mo_relaxed };
#endif
EOF
cat > test1.h <<EOF
#ifndef TEST1_H_
#define TEST1_H_
#include "test.h"
#endif
EOF
cat > test2.h <<EOF
#ifndef TEST2_H_
#define TEST2_H_
#include "test.h"
#endif
EOF
cat > test.cppmap <<EOF
module "test_module" {
  export *
  module "test1.h" {
    export *
    header "test1.h"
  }
  module "test2.h" {
    export *
    header "test2.h"
  }
  textual header "test.h"
}
EOF

$CLANG -xc++ -std=gnu++20 -fmodule-name=test_module -fmodule-map-file=test.cppmap -Xclang=-emit-module -fmodules -fno-implicit-modules -fno-implicit-module-maps -c test.cppmap -o /dev/null
```

With a debug build of Clang, this actually results in an assert fail
`clang: clang/lib/Sema/SemaType.cpp:9881: QualType GetEnumUnderlyingType(Sema &, QualType, SourceLocation): Assertion `!Underlying.isNull()' failed.`

https://github.com/llvm/llvm-project/pull/155028


More information about the cfe-commits mailing list