unterumarmung wrote:

Could please add AI assistance message to your PR message? Also, I reviewed 
this locally with Codex and it suggested to add these test cases for better 
coverage and avoiding possible regressions:
```cpp
#define NULL_CONSTANT 0

using IntPointer = int *;

struct PointerAlias {
  PointerAlias(IntPointer);
};

struct PointerReference {
  PointerReference(int *const &);
};

struct FunctionPointer {
  FunctionPointer(void (*)());
};

struct WithMethod {
  void method();
};

struct MemberFunctionPointer {
  MemberFunctionPointer(void (WithMethod::*)());
};

void testAdditionalNullPointerCases() {
  std::vector<Base> values;
  values.push_back(Base(42, NULL_CONSTANT));

  values.push_back(Base(42, static_cast<int *>(0)));
  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use emplace_back instead of 
push_back
  // CHECK-FIXES: values.emplace_back(42, static_cast<int *>(0));

  values.push_back(Base(42, (int *)0));
  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use emplace_back instead of 
push_back
  // CHECK-FIXES: values.emplace_back(42, (int *)0);

  values.emplace_back(Base(42, 0));

  values.emplace_back(Base(42, nullptr));
  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: unnecessary temporary object 
created while calling emplace_back
  // CHECK-FIXES: values.emplace_back(42, nullptr);

  std::vector<PointerAlias> aliases;
  aliases.push_back(PointerAlias(0));

  std::vector<PointerReference> references;
  references.push_back(PointerReference(0));

  std::vector<FunctionPointer> functions;
  functions.push_back(FunctionPointer(0));

  functions.push_back(FunctionPointer(nullptr));
  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use emplace_back instead of 
push_back
  // CHECK-FIXES: functions.emplace_back(nullptr);

  std::vector<MemberFunctionPointer> members;
  members.push_back(MemberFunctionPointer(0));

  members.push_back(MemberFunctionPointer(nullptr));
  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use emplace_back instead of 
push_back
  // CHECK-FIXES: members.emplace_back(nullptr);
}
``` 

https://github.com/llvm/llvm-project/pull/237770
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to