Skip to content

Commit

Permalink
Fix crash deserializing a CUDAKernelCallExpr with a +Asserts binary.
Browse files Browse the repository at this point in the history
The assertion in setConfig read from the (uninitialized) CONFIG
expression.

llvm-svn: 361680
  • Loading branch information
zygoloid committed May 24, 2019
1 parent 97d668d commit fd42079
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
16 changes: 2 additions & 14 deletions clang/include/clang/AST/ExprCXX.h
Expand Up @@ -216,6 +216,8 @@ class CXXMemberCallExpr final : public CallExpr {

/// 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
Expand All @@ -241,20 +243,6 @@ class CUDAKernelCallExpr final : public CallExpr {
}
CallExpr *getConfig() { return cast_or_null<CallExpr>(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;
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Serialization/ASTReaderStmt.cpp
Expand Up @@ -1904,7 +1904,7 @@ void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {

void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
VisitCallExpr(E);
E->setConfig(cast<CallExpr>(Record.readSubExpr()));
E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
}

//===----------------------------------------------------------------------===//
Expand Down

0 comments on commit fd42079

Please sign in to comment.