forked from OSchip/llvm-project
[SyntaxTree] Ignore implicit `CXXFunctionalCastExpr` wrapping constructor
Differential Revision: https://reviews.llvm.org/D87229
This commit is contained in:
parent
46f4439dc9
commit
134455a07c
|
@ -14,6 +14,7 @@
|
|||
#include "clang/AST/Expr.h"
|
||||
#include "clang/AST/ExprCXX.h"
|
||||
#include "clang/AST/IgnoreExpr.h"
|
||||
#include "clang/AST/OperationKinds.h"
|
||||
#include "clang/AST/RecursiveASTVisitor.h"
|
||||
#include "clang/AST/Stmt.h"
|
||||
#include "clang/AST/TypeLoc.h"
|
||||
|
@ -60,9 +61,25 @@ static Expr *IgnoreImplicitConstructorSingleStep(Expr *E) {
|
|||
return E;
|
||||
}
|
||||
|
||||
// In:
|
||||
// struct X {
|
||||
// X(int)
|
||||
// };
|
||||
// X x = X(1);
|
||||
// Ignores the implicit `CXXFunctionalCastExpr` that wraps
|
||||
// `CXXConstructExpr X(1)`.
|
||||
static Expr *IgnoreCXXFunctionalCastExprWrappingConstructor(Expr *E) {
|
||||
if (auto *F = dyn_cast<CXXFunctionalCastExpr>(E)) {
|
||||
if (F->getCastKind() == CK_ConstructorConversion)
|
||||
return F->getSubExpr();
|
||||
}
|
||||
return E;
|
||||
}
|
||||
|
||||
static Expr *IgnoreImplicit(Expr *E) {
|
||||
return IgnoreExprNodes(E, IgnoreImplicitSingleStep,
|
||||
IgnoreImplicitConstructorSingleStep);
|
||||
IgnoreImplicitConstructorSingleStep,
|
||||
IgnoreCXXFunctionalCastExprWrappingConstructor);
|
||||
}
|
||||
|
||||
LLVM_ATTRIBUTE_UNUSED
|
||||
|
|
|
@ -4069,7 +4069,6 @@ struct X {
|
|||
X(int);
|
||||
};
|
||||
X test() {
|
||||
// FIXME: Remove `UnknownExpression` due to implicit `CXXFunctionalCastExpr`
|
||||
[[return X(1);]]
|
||||
}
|
||||
)cpp",
|
||||
|
@ -4077,12 +4076,11 @@ X test() {
|
|||
ReturnStatement Statement
|
||||
|-'return' IntroducerKeyword
|
||||
|-UnknownExpression ReturnValue
|
||||
| `-UnknownExpression
|
||||
| |-'X'
|
||||
| |-'('
|
||||
| |-IntegerLiteralExpression
|
||||
| | `-'1' LiteralToken
|
||||
| `-')'
|
||||
| |-'X'
|
||||
| |-'('
|
||||
| |-IntegerLiteralExpression
|
||||
| | `-'1' LiteralToken
|
||||
| `-')'
|
||||
`-';'
|
||||
)txt"}));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue