mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-30 17:21:10 +00:00
[clang][AST] Add support for ShuffleVectorExpr to ASTImporter
Addresses https://bugs.llvm.org/show_bug.cgi?id=51902 Reviewed By: shafik, martong Differential Revision: https://reviews.llvm.org/D110052
This commit is contained in:
parent
0bd9162fd7
commit
66d9d1012b
@ -583,6 +583,7 @@ namespace clang {
|
||||
ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E);
|
||||
ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
|
||||
ExpectedStmt VisitChooseExpr(ChooseExpr *E);
|
||||
ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E);
|
||||
ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
|
||||
ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E);
|
||||
ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
|
||||
@ -6730,6 +6731,24 @@ ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
|
||||
ToRParenLoc, CondIsTrue);
|
||||
}
|
||||
|
||||
ExpectedStmt ASTNodeImporter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
|
||||
Error Err = Error::success();
|
||||
auto ToRParenLoc = importChecked(Err, E->getRParenLoc());
|
||||
auto ToBeginLoc = importChecked(Err, E->getBeginLoc());
|
||||
auto ToType = importChecked(Err, E->getType());
|
||||
const unsigned NumSubExprs = E->getNumSubExprs();
|
||||
|
||||
llvm::SmallVector<Expr *, 8> ToSubExprs;
|
||||
llvm::ArrayRef<Expr *> FromSubExprs(E->getSubExprs(), NumSubExprs);
|
||||
ToSubExprs.resize(NumSubExprs);
|
||||
|
||||
if ((Err = ImportContainerChecked(FromSubExprs, ToSubExprs)))
|
||||
return std::move(Err);
|
||||
|
||||
return new (Importer.getToContext()) ShuffleVectorExpr(
|
||||
Importer.getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
|
||||
}
|
||||
|
||||
ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
|
||||
ExpectedType TypeOrErr = import(E->getType());
|
||||
if (!TypeOrErr)
|
||||
|
@ -290,6 +290,25 @@ TEST_P(ImportExpr, ImportChooseExpr) {
|
||||
functionDecl(hasDescendant(chooseExpr())));
|
||||
}
|
||||
|
||||
const internal::VariadicDynCastAllOfMatcher<Stmt, ShuffleVectorExpr>
|
||||
shuffleVectorExpr;
|
||||
|
||||
TEST_P(ImportExpr, ImportShuffleVectorExpr) {
|
||||
MatchVerifier<Decl> Verifier;
|
||||
constexpr auto Code = R"code(
|
||||
typedef double vector4double __attribute__((__vector_size__(32)));
|
||||
vector4double declToImport(vector4double a, vector4double b) {
|
||||
return __builtin_shufflevector(a, b, 0, 1, 2, 3);
|
||||
}
|
||||
)code";
|
||||
const auto Pattern = functionDecl(hasDescendant(shuffleVectorExpr(
|
||||
allOf(has(declRefExpr(to(parmVarDecl(hasName("a"))))),
|
||||
has(declRefExpr(to(parmVarDecl(hasName("b"))))),
|
||||
has(integerLiteral(equals(0))), has(integerLiteral(equals(1))),
|
||||
has(integerLiteral(equals(2))), has(integerLiteral(equals(3)))))));
|
||||
testImport(Code, Lang_C99, "", Lang_C99, Verifier, Pattern);
|
||||
}
|
||||
|
||||
TEST_P(ImportExpr, ImportGNUNullExpr) {
|
||||
MatchVerifier<Decl> Verifier;
|
||||
testImport("void declToImport() { (void)__null; }", Lang_CXX03, "",
|
||||
|
Loading…
Reference in New Issue
Block a user