This is an archive of the discontinued LLVM Phabricator instance.

[clang][CGExprConstant] handle unary negation on integrals
ClosedPublic

Authored by nickdesaulniers on Jul 26 2023, 3:08 PM.

Details

Summary

Consider the statement:

int x = -1;

And the following AST:

`-VarDecl 0x55c4823a7670 <x.c:2:1, col:10> col:5 x 'int' cinit
  `-UnaryOperator 0x55c4823a7740 <col:9, col:10> 'int' prefix '-'
    `-IntegerLiteral 0x55c4823a7720 <col:10> 'int' 1

Return the evaluation of the subexpression negated.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2023, 3:08 PM
nickdesaulniers requested review of this revision.Jul 26 2023, 3:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2023, 3:08 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
  • fix oneline class
efriedma added inline comments.Aug 2 2023, 3:51 PM
clang/lib/CodeGen/CGExprConstant.cpp
1366

StmtVisitor supports defining a function "VisitUnaryMinus", so you don't have to switch() over the opcode.

nickdesaulniers marked an inline comment as done.
This revision is now accepted and ready to land.Aug 4 2023, 10:03 AM