Issue 182737
Summary Segmentation fault when dumping AST of wrong C doxygen comment
Labels new issue
Assignees
Reporter cybernetlab
    Originally I tried to parse headers of [ESP Zigbee library](https://github.com/espressif/esp-zigbee-sdk) and clang crashes on [this file (line104)](https://github.com/espressif/esp-zigbee-sdk/blob/main/components/esp-zigbee-lib/include/platform/esp_zigbee_platform.h#L104). After some investigation I found that if I remove both `@param` lines from doxygen comment before that line everything is fine. I see that actually this comment is invalid cause it describes typedef for function but not an actual function declaration and `@param` shouldn't be used there. Anyway I believe that AST parser shouldn't crash with segfault on such mistakes and should generate warn or error instead.

## Reproduce

test file `test.h`:

```c
/**
 * @brief A callback
 *
 * @param[in] a param1
 * @return
 *      - true: ok
 *      - false: failure
 */
typedef bool (*func_t)(uint8_t a);
```

command:

```sh
clang -Xclang -ast-dump -fsyntax-only -fno-color-diagnostics test.h
```

<details>
<summary>output</summary>
```
platform/test.h:9:16: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
    9 | typedef bool (*func_t)(uint8_t a);
      |                ^
      | int
platform/test.h:9:24: error: unknown type name 'uint8_t'
    9 | typedef bool (*func_t)(uint8_t a);
      | ^
platform/test.h:9:9: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
    9 | typedef bool (*func_t)(uint8_t a);
      | ~~~~~~~ ^
      | int
platform/test.h:9:14: error: function cannot return function type 'int (int)'
    9 | typedef bool (*func_t)(uint8_t a);
      | ^
TranslationUnitDecl 0xcbf156008 <<invalid sloc>> <invalid sloc>
|-TypedefDecl 0xcbf1f2088 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
| `-BuiltinType 0xcbf1565d0 '__int128'
|-TypedefDecl 0xcbf1f20f8 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
| `-BuiltinType 0xcbf1565f0 'unsigned __int128'
|-TypedefDecl 0xcbf1f2400 <<invalid sloc>> <invalid sloc> implicit __NSConstantString 'struct __NSConstantString_tag'
| `-RecordType 0xcbf1f21d0 'struct __NSConstantString_tag'
|   `-Record 0xcbf1f2150 '__NSConstantString_tag'
|-TypedefDecl 0xcbf1f24a8 <<invalid sloc>> <invalid sloc> implicit __Int8x8_t '__attribute__((neon_vector_type(8))) signed char'
| `-VectorType 0xcbf1f2460 '__attribute__((neon_vector_type(8))) signed char' neon 8
|   `-BuiltinType 0xcbf1560d0 'signed char'
|-TypedefDecl 0xcbf1f2548 <<invalid sloc>> <invalid sloc> implicit __Int16x4_t '__attribute__((neon_vector_type(4))) short'
| `-VectorType 0xcbf1f2500 '__attribute__((neon_vector_type(4))) short' neon 4
| `-BuiltinType 0xcbf1560f0 'short'
|-TypedefDecl 0xcbf1f25e8 <<invalid sloc>> <invalid sloc> implicit __Int32x2_t '__attribute__((neon_vector_type(2))) int'
| `-VectorType 0xcbf1f25a0 '__attribute__((neon_vector_type(2))) int' neon 2
|   `-BuiltinType 0xcbf156110 'int'
|-TypedefDecl 0xcbf1f2688 <<invalid sloc>> <invalid sloc> implicit __Uint8x8_t '__attribute__((neon_vector_type(8))) unsigned char'
| `-VectorType 0xcbf1f2640 '__attribute__((neon_vector_type(8))) unsigned char' neon 8
| `-BuiltinType 0xcbf156170 'unsigned char'
|-TypedefDecl 0xcbf1f2728 <<invalid sloc>> <invalid sloc> implicit __Uint16x4_t '__attribute__((neon_vector_type(4))) unsigned short'
| `-VectorType 0xcbf1f26e0 '__attribute__((neon_vector_type(4))) unsigned short' neon 4
| `-BuiltinType 0xcbf156190 'unsigned short'
|-TypedefDecl 0xcbf1f27c8 <<invalid sloc>> <invalid sloc> implicit __Uint32x2_t '__attribute__((neon_vector_type(2))) unsigned int'
| `-VectorType 0xcbf1f2780 '__attribute__((neon_vector_type(2))) unsigned int' neon 2
| `-BuiltinType 0xcbf1561b0 'unsigned int'
|-TypedefDecl 0xcbf1f2868 <<invalid sloc>> <invalid sloc> implicit __Float16x4_t '__attribute__((neon_vector_type(4))) __fp16'
| `-VectorType 0xcbf1f2820 '__attribute__((neon_vector_type(4))) __fp16' neon 4
|   `-BuiltinType 0xcbf156f20 '__fp16'
|-TypedefDecl 0xcbf1f2908 <<invalid sloc>> <invalid sloc> implicit __Float32x2_t '__attribute__((neon_vector_type(2))) float'
| `-VectorType 0xcbf1f28c0 '__attribute__((neon_vector_type(2))) float' neon 2
|   `-BuiltinType 0xcbf156210 'float'
|-TypedefDecl 0xcbf1f29a8 <<invalid sloc>> <invalid sloc> implicit __Poly8x8_t '__attribute__((neon_polyvector_type(8))) unsigned char'
| `-VectorType 0xcbf1f2960 '__attribute__((neon_polyvector_type(8))) unsigned char' neon poly 8
|   `-BuiltinType 0xcbf156170 'unsigned char'
|-TypedefDecl 0xcbf1f2a48 <<invalid sloc>> <invalid sloc> implicit __Poly16x4_t '__attribute__((neon_polyvector_type(4))) unsigned short'
| `-VectorType 0xcbf1f2a00 '__attribute__((neon_polyvector_type(4))) unsigned short' neon poly 4
|   `-BuiltinType 0xcbf156190 'unsigned short'
|-TypedefDecl 0xcbf1f2ae8 <<invalid sloc>> <invalid sloc> implicit __Bfloat16x4_t '__attribute__((neon_vector_type(4))) __bf16'
| `-VectorType 0xcbf1f2aa0 '__attribute__((neon_vector_type(4))) __bf16' neon 4
|   `-BuiltinType 0xcbf156f40 '__bf16'
|-TypedefDecl 0xcbf1f2b88 <<invalid sloc>> <invalid sloc> implicit __Int8x16_t '__attribute__((neon_vector_type(16))) signed char'
| `-VectorType 0xcbf1f2b40 '__attribute__((neon_vector_type(16))) signed char' neon 16
|   `-BuiltinType 0xcbf1560d0 'signed char'
|-TypedefDecl 0xcbf1f2c28 <<invalid sloc>> <invalid sloc> implicit __Int16x8_t '__attribute__((neon_vector_type(8))) short'
| `-VectorType 0xcbf1f2be0 '__attribute__((neon_vector_type(8))) short' neon 8
| `-BuiltinType 0xcbf1560f0 'short'
|-TypedefDecl 0xcbf1f2cc8 <<invalid sloc>> <invalid sloc> implicit __Int32x4_t '__attribute__((neon_vector_type(4))) int'
| `-VectorType 0xcbf1f2c80 '__attribute__((neon_vector_type(4))) int' neon 4
|   `-BuiltinType 0xcbf156110 'int'
|-TypedefDecl 0xcbf1f2d68 <<invalid sloc>> <invalid sloc> implicit __Int64x2_t '__attribute__((neon_vector_type(2))) long'
| `-VectorType 0xcbf1f2d20 '__attribute__((neon_vector_type(2))) long' neon 2
|   `-BuiltinType 0xcbf156130 'long'
|-TypedefDecl 0xcbf1f2e08 <<invalid sloc>> <invalid sloc> implicit __Uint8x16_t '__attribute__((neon_vector_type(16))) unsigned char'
| `-VectorType 0xcbf1f2dc0 '__attribute__((neon_vector_type(16))) unsigned char' neon 16
|   `-BuiltinType 0xcbf156170 'unsigned char'
|-TypedefDecl 0xcbf1f2ea8 <<invalid sloc>> <invalid sloc> implicit __Uint16x8_t '__attribute__((neon_vector_type(8))) unsigned short'
| `-VectorType 0xcbf1f2e60 '__attribute__((neon_vector_type(8))) unsigned short' neon 8
|   `-BuiltinType 0xcbf156190 'unsigned short'
|-TypedefDecl 0xcbf1f2f48 <<invalid sloc>> <invalid sloc> implicit __Uint32x4_t '__attribute__((neon_vector_type(4))) unsigned int'
| `-VectorType 0xcbf1f2f00 '__attribute__((neon_vector_type(4))) unsigned int' neon 4
| `-BuiltinType 0xcbf1561b0 'unsigned int'
|-TypedefDecl 0xcbf1f3000 <<invalid sloc>> <invalid sloc> implicit __Uint64x2_t '__attribute__((neon_vector_type(2))) unsigned long'
| `-VectorType 0xcbf1f2fa0 '__attribute__((neon_vector_type(2))) unsigned long' neon 2
| `-BuiltinType 0xcbf1561d0 'unsigned long'
|-TypedefDecl 0xcbf1f30a8 <<invalid sloc>> <invalid sloc> implicit __Float16x8_t '__attribute__((neon_vector_type(8))) __fp16'
| `-VectorType 0xcbf1f3060 '__attribute__((neon_vector_type(8))) __fp16' neon 8
|   `-BuiltinType 0xcbf156f20 '__fp16'
|-TypedefDecl 0xcbf1f3148 <<invalid sloc>> <invalid sloc> implicit __Float32x4_t '__attribute__((neon_vector_type(4))) float'
| `-VectorType 0xcbf1f3100 '__attribute__((neon_vector_type(4))) float' neon 4
|   `-BuiltinType 0xcbf156210 'float'
|-TypedefDecl 0xcbf1f31e8 <<invalid sloc>> <invalid sloc> implicit __Float64x2_t '__attribute__((neon_vector_type(2))) double'
| `-VectorType 0xcbf1f31a0 '__attribute__((neon_vector_type(2))) double' neon 2
|   `-BuiltinType 0xcbf156230 'double'
|-TypedefDecl 0xcbf1f3288 <<invalid sloc>> <invalid sloc> implicit __Poly8x16_t '__attribute__((neon_polyvector_type(16))) unsigned char'
| `-VectorType 0xcbf1f3240 '__attribute__((neon_polyvector_type(16))) unsigned char' neon poly 16
| `-BuiltinType 0xcbf156170 'unsigned char'
|-TypedefDecl 0xcbf1f3328 <<invalid sloc>> <invalid sloc> implicit __Poly16x8_t '__attribute__((neon_polyvector_type(8))) unsigned short'
| `-VectorType 0xcbf1f32e0 '__attribute__((neon_polyvector_type(8))) unsigned short' neon poly 8
|   `-BuiltinType 0xcbf156190 'unsigned short'
|-TypedefDecl 0xcbf1f33c8 <<invalid sloc>> <invalid sloc> implicit __Poly64x2_t '__attribute__((neon_polyvector_type(2))) unsigned long'
| `-VectorType 0xcbf1f3380 '__attribute__((neon_polyvector_type(2))) unsigned long' neon poly 2
|   `-BuiltinType 0xcbf1561d0 'unsigned long'
|-TypedefDecl 0xcbf1f3468 <<invalid sloc>> <invalid sloc> implicit __Bfloat16x8_t '__attribute__((neon_vector_type(8))) __bf16'
| `-VectorType 0xcbf1f3420 '__attribute__((neon_vector_type(8))) __bf16' neon 8
|   `-BuiltinType 0xcbf156f40 '__bf16'
|-TypedefDecl 0xcbf1f3508 <<invalid sloc>> <invalid sloc> implicit __Mfloat8x8_t '__attribute__((neon_vector_type(8))) __mfp8'
| `-VectorType 0xcbf1f34c0 '__attribute__((neon_vector_type(8))) __mfp8' neon 8
|   `-BuiltinType 0xcbf156eb0 '__mfp8'
|-TypedefDecl 0xcbf1f35a8 <<invalid sloc>> <invalid sloc> implicit __Mfloat8x16_t '__attribute__((neon_vector_type(16))) __mfp8'
| `-VectorType 0xcbf1f3560 '__attribute__((neon_vector_type(16))) __mfp8' neon 16
|   `-BuiltinType 0xcbf156eb0 '__mfp8'
|-TypedefDecl 0xcbf1f3610 <<invalid sloc>> <invalid sloc> implicit __SVInt8_t '__SVInt8_t'
| `-BuiltinType 0xcbf1567b0 '__SVInt8_t'
|-TypedefDecl 0xcbf1f3678 <<invalid sloc>> <invalid sloc> implicit __SVInt16_t '__SVInt16_t'
| `-BuiltinType 0xcbf1567d0 '__SVInt16_t'
|-TypedefDecl 0xcbf1f36e0 <<invalid sloc>> <invalid sloc> implicit __SVInt32_t '__SVInt32_t'
| `-BuiltinType 0xcbf1567f0 '__SVInt32_t'
|-TypedefDecl 0xcbf1f3748 <<invalid sloc>> <invalid sloc> implicit __SVInt64_t '__SVInt64_t'
| `-BuiltinType 0xcbf156810 '__SVInt64_t'
|-TypedefDecl 0xcbf1f37b0 <<invalid sloc>> <invalid sloc> implicit __SVUint8_t '__SVUint8_t'
| `-BuiltinType 0xcbf156830 '__SVUint8_t'
|-TypedefDecl 0xcbf1f3818 <<invalid sloc>> <invalid sloc> implicit __SVUint16_t '__SVUint16_t'
| `-BuiltinType 0xcbf156850 '__SVUint16_t'
|-TypedefDecl 0xcbf1f3880 <<invalid sloc>> <invalid sloc> implicit __SVUint32_t '__SVUint32_t'
| `-BuiltinType 0xcbf156870 '__SVUint32_t'
|-TypedefDecl 0xcbf1f38e8 <<invalid sloc>> <invalid sloc> implicit __SVUint64_t '__SVUint64_t'
| `-BuiltinType 0xcbf156890 '__SVUint64_t'
|-TypedefDecl 0xcbf1f3950 <<invalid sloc>> <invalid sloc> implicit __SVFloat16_t '__SVFloat16_t'
| `-BuiltinType 0xcbf1568b0 '__SVFloat16_t'
|-TypedefDecl 0xcbf1f39b8 <<invalid sloc>> <invalid sloc> implicit __SVFloat32_t '__SVFloat32_t'
| `-BuiltinType 0xcbf1568d0 '__SVFloat32_t'
|-TypedefDecl 0xcbf1f3a20 <<invalid sloc>> <invalid sloc> implicit __SVFloat64_t '__SVFloat64_t'
| `-BuiltinType 0xcbf1568f0 '__SVFloat64_t'
|-TypedefDecl 0xcbf1f3a88 <<invalid sloc>> <invalid sloc> implicit __SVBfloat16_t '__SVBfloat16_t'
| `-BuiltinType 0xcbf156910 '__SVBfloat16_t'
|-TypedefDecl 0xcbf1f3af0 <<invalid sloc>> <invalid sloc> implicit __SVMfloat8_t '__SVMfloat8_t'
| `-BuiltinType 0xcbf156930 '__SVMfloat8_t'
|-TypedefDecl 0xcbf1f3b58 <<invalid sloc>> <invalid sloc> implicit __clang_svint8x2_t '__clang_svint8x2_t'
| `-BuiltinType 0xcbf156950 '__clang_svint8x2_t'
|-TypedefDecl 0xcbf1f3bc0 <<invalid sloc>> <invalid sloc> implicit __clang_svint16x2_t '__clang_svint16x2_t'
| `-BuiltinType 0xcbf156970 '__clang_svint16x2_t'
|-TypedefDecl 0xcbf1f3c28 <<invalid sloc>> <invalid sloc> implicit __clang_svint32x2_t '__clang_svint32x2_t'
| `-BuiltinType 0xcbf156990 '__clang_svint32x2_t'
|-TypedefDecl 0xcbf1f3c90 <<invalid sloc>> <invalid sloc> implicit __clang_svint64x2_t '__clang_svint64x2_t'
| `-BuiltinType 0xcbf1569b0 '__clang_svint64x2_t'
|-TypedefDecl 0xcbf1f3cf8 <<invalid sloc>> <invalid sloc> implicit __clang_svuint8x2_t '__clang_svuint8x2_t'
| `-BuiltinType 0xcbf1569d0 '__clang_svuint8x2_t'
|-TypedefDecl 0xcbf1f3d60 <<invalid sloc>> <invalid sloc> implicit __clang_svuint16x2_t '__clang_svuint16x2_t'
| `-BuiltinType 0xcbf1569f0 '__clang_svuint16x2_t'
|-TypedefDecl 0xcbf1f3dc8 <<invalid sloc>> <invalid sloc> implicit __clang_svuint32x2_t '__clang_svuint32x2_t'
| `-BuiltinType 0xcbf156a10 '__clang_svuint32x2_t'
|-TypedefDecl 0xcbf1f3e30 <<invalid sloc>> <invalid sloc> implicit __clang_svuint64x2_t '__clang_svuint64x2_t'
| `-BuiltinType 0xcbf156a30 '__clang_svuint64x2_t'
|-TypedefDecl 0xcbf1f3e98 <<invalid sloc>> <invalid sloc> implicit __clang_svfloat16x2_t '__clang_svfloat16x2_t'
| `-BuiltinType 0xcbf156a50 '__clang_svfloat16x2_t'
|-TypedefDecl 0xcbf1f3f00 <<invalid sloc>> <invalid sloc> implicit __clang_svfloat32x2_t '__clang_svfloat32x2_t'
| `-BuiltinType 0xcbf156a70 '__clang_svfloat32x2_t'
|-TypedefDecl 0xcbf1f3f68 <<invalid sloc>> <invalid sloc> implicit __clang_svfloat64x2_t '__clang_svfloat64x2_t'
| `-BuiltinType 0xcbf156a90 '__clang_svfloat64x2_t'
|-TypedefDecl 0xcbf274000 <<invalid sloc>> <invalid sloc> implicit __clang_svbfloat16x2_t '__clang_svbfloat16x2_t'
| `-BuiltinType 0xcbf156ab0 '__clang_svbfloat16x2_t'
|-TypedefDecl 0xcbf274068 <<invalid sloc>> <invalid sloc> implicit __clang_svmfloat8x2_t '__clang_svmfloat8x2_t'
| `-BuiltinType 0xcbf156ad0 '__clang_svmfloat8x2_t'
|-TypedefDecl 0xcbf2740d0 <<invalid sloc>> <invalid sloc> implicit __clang_svint8x3_t '__clang_svint8x3_t'
| `-BuiltinType 0xcbf156af0 '__clang_svint8x3_t'
|-TypedefDecl 0xcbf274138 <<invalid sloc>> <invalid sloc> implicit __clang_svint16x3_t '__clang_svint16x3_t'
| `-BuiltinType 0xcbf156b10 '__clang_svint16x3_t'
|-TypedefDecl 0xcbf2741a0 <<invalid sloc>> <invalid sloc> implicit __clang_svint32x3_t '__clang_svint32x3_t'
| `-BuiltinType 0xcbf156b30 '__clang_svint32x3_t'
|-TypedefDecl 0xcbf274208 <<invalid sloc>> <invalid sloc> implicit __clang_svint64x3_t '__clang_svint64x3_t'
| `-BuiltinType 0xcbf156b50 '__clang_svint64x3_t'
|-TypedefDecl 0xcbf274270 <<invalid sloc>> <invalid sloc> implicit __clang_svuint8x3_t '__clang_svuint8x3_t'
| `-BuiltinType 0xcbf156b70 '__clang_svuint8x3_t'
|-TypedefDecl 0xcbf2742d8 <<invalid sloc>> <invalid sloc> implicit __clang_svuint16x3_t '__clang_svuint16x3_t'
| `-BuiltinType 0xcbf156b90 '__clang_svuint16x3_t'
|-TypedefDecl 0xcbf274340 <<invalid sloc>> <invalid sloc> implicit __clang_svuint32x3_t '__clang_svuint32x3_t'
| `-BuiltinType 0xcbf156bb0 '__clang_svuint32x3_t'
|-TypedefDecl 0xcbf2743a8 <<invalid sloc>> <invalid sloc> implicit __clang_svuint64x3_t '__clang_svuint64x3_t'
| `-BuiltinType 0xcbf156bd0 '__clang_svuint64x3_t'
|-TypedefDecl 0xcbf274410 <<invalid sloc>> <invalid sloc> implicit __clang_svfloat16x3_t '__clang_svfloat16x3_t'
| `-BuiltinType 0xcbf156bf0 '__clang_svfloat16x3_t'
|-TypedefDecl 0xcbf274478 <<invalid sloc>> <invalid sloc> implicit __clang_svfloat32x3_t '__clang_svfloat32x3_t'
| `-BuiltinType 0xcbf156c10 '__clang_svfloat32x3_t'
|-TypedefDecl 0x<truncated>Please see the issue for the entire body.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to