[llvm-dev] BinaryOperator vs. CXXOperatorCallExpr in template code

Stephan Bergmann via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 4 00:54:25 PDT 2021


Ever since 
<https://github.com/llvm/llvm-project/commit/d2b7ef6ecea967b70bdeb8a1fd8004c5aef3e415> 
"Improve the representation of operator expressions like "x + y" within 
C++ templates", the documentation of BinaryOperator 
(clang/include/clang/AST/Expr.h) and CXXOperatorCallExpr 
(clang/include/clang/AST/ExprCXX.h) claim that if any of an operator's 
arguments are type-dependent, it is represented with 
CXXOperatorCallExpr.  However,

> template<typename T> void f(T x) {
>     int n;
>     x + n;
>     x += n;
> }
> #pragma clang __debug dump f

shows both + and += to use BinaryOperator (derived 
CompoundAssignOperator for +=).

Anything I'm missing?



More information about the llvm-dev mailing list