[all-commits] [llvm/llvm-project] ab187b: [clang][AST] Fix positioning of preserve cconv att...

Andreas C. Osowski via All-commits all-commits at lists.llvm.org
Wed Jul 9 05:53:17 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ab187bbd3a5c64451846aa3480f271a93dfba760
      https://github.com/llvm/llvm-project/commit/ab187bbd3a5c64451846aa3480f271a93dfba760
  Author: Andreas C. Osowski <andreas at osowski.de>
  Date:   2025-07-09 (Wed, 09 Jul 2025)

  Changed paths:
    M clang/lib/AST/TypePrinter.cpp
    A clang/test/AST/ast-print-cconv-preserve.cpp
    M clang/test/Sema/preserve-call-conv.c
    M clang/test/Sema/preserve-none-call-conv.c
    M clang/test/SemaCXX/lambda-attributes.cpp

  Log Message:
  -----------
  [clang][AST] Fix positioning of preserve cconv attributes in TypePrinter (#147285)

TypePrinter currently generates function pointer types that do not
compile when using the `preserve_.*` calling conventions as per
https://clang.llvm.org/docs/AttributeReference.html#preserve-all ff.

Running clang with `-Xclang -ast-print` on the following: 
```cc
using IN1 = void (__attribute__((preserve_most)) *)();
using IN2 = __attribute__((preserve_most)) void (*) ();
```

outputs:
```cc
using IN1 = void (*)() __attribute__((preserve_most));
using IN2 = void ((*))() __attribute__((preserve_most));
```

However, this does not compile:
```cc
<source>:3:23: error: expected ';' after alias declaration
    3 | using IN1 = void (*)() __attribute__((preserve_most));
```

This PR updates TypePrinter such that output is correct and compiles:
```cc
using IN1 = __attribute__((preserve_most)) void (*)();
using IN2 = __attribute__((preserve_most)) void ((*))();
```

I've verified via `-ast-dump` that the AST looks equivalent.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list