From: Richard Smith Date: Fri, 24 May 2019 23:26:07 +0000 (+0000) Subject: Fix crash deserializing a CUDAKernelCallExpr with a +Asserts binary. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6c8a1bb5f92d3b82365c19fbb8f8feda36bb446;p=clang Fix crash deserializing a CUDAKernelCallExpr with a +Asserts binary. The assertion in setConfig read from the (uninitialized) CONFIG expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361680 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 4a6aa9014c..551a677570 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -216,6 +216,8 @@ public: /// Represents a call to a CUDA kernel function. class CUDAKernelCallExpr final : public CallExpr { + friend class ASTStmtReader; + enum { CONFIG, END_PREARG }; // CUDAKernelCallExpr has some trailing objects belonging @@ -241,20 +243,6 @@ public: } CallExpr *getConfig() { return cast_or_null(getPreArg(CONFIG)); } - /// Sets the kernel configuration expression. - /// - /// Note that this method cannot be called if config has already been set to a - /// non-null value. - void setConfig(CallExpr *E) { - assert(!getConfig() && - "Cannot call setConfig if config is not null"); - setPreArg(CONFIG, E); - setInstantiationDependent(isInstantiationDependent() || - E->isInstantiationDependent()); - setContainsUnexpandedParameterPack(containsUnexpandedParameterPack() || - E->containsUnexpandedParameterPack()); - } - static bool classof(const Stmt *T) { return T->getStmtClass() == CUDAKernelCallExprClass; } diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index e0647fc6b8..4d879b46e1 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -1904,7 +1904,7 @@ void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) { void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) { VisitCallExpr(E); - E->setConfig(cast(Record.readSubExpr())); + E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr()); } //===----------------------------------------------------------------------===//