[PATCH] D125272: [clang] Add -fcheck-new support

Pedro Falcato via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 26 23:14:29 PDT 2023


heatd added inline comments.


================
Comment at: clang/test/CodeGenCXX/fcheck-new.cpp:2
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -fcheck-new -triple x86_64-linux-gnu -S -disable-O0-optnone \
+// RUN: -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s
----------------
MaskRay wrote:
> In this test, if I remove `-fcheck-new` , nothing will change. So this isn't a good test.
> 
> I think we need something like:
> ```
> struct A { A(); };
> void *test0() { return A; }
> ```
It will change (the attributes of _Znwm).

>From the test (with -fcheck-new):
```
[[CALL:%.*]] = call noalias noundef ptr @_Znwm(i64 noundef 4) #[[ATTR2:[0-9]+]]
```
The same test (but without -fcheck-new, tested locally):

```
  %1 = tail call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4) #2
```

As you'll see, the non-fcheck-new has nonnull attached to _Znwm, while -fcheck-new doesn't. This is exactly the behavior we want to test for.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125272/new/

https://reviews.llvm.org/D125272



More information about the cfe-commits mailing list