This is an archive of the discontinued LLVM Phabricator instance.

[clang] fix error detection in consteval calls
ClosedPublic

Authored by Tyker on Feb 11 2020, 8:50 AM.

Details

Summary

code like:

consteval int f() {
  int *A = new int(0);
  return *A;
}

int i1 = f();

currently doesn't generate any error.

maybe a better solution is to make CheckMemoryLeaks return false when there is memory leaks.

Diff Detail

Event Timeline

Tyker created this revision.Feb 11 2020, 8:50 AM
rsmith accepted this revision.Feb 25 2020, 10:48 AM

Given the comment at the start of lib/AST/ExprConstant.cpp, this seems reasonable to me. I do wonder if it'd be better to return an enum constant/not-constant-but-foldable/not-foldable from the evaluator, rather than just a bool. But not as part of this patch :)

This revision is now accepted and ready to land.Feb 25 2020, 10:48 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 26 2020, 12:10 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript