]> granicus.if.org Git - clang/commitdiff
Fix crash deserializing a CUDAKernelCallExpr with a +Asserts binary.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 24 May 2019 23:26:07 +0000 (23:26 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 24 May 2019 23:26:07 +0000 (23:26 +0000)
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

include/clang/AST/ExprCXX.h
lib/Serialization/ASTReaderStmt.cpp

index 4a6aa9014c9ec57fb6c840578dabf3aa7ef29441..551a677570ff96b7e8ca65034d206609a0c89c27 100644 (file)
@@ -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<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;
   }
index e0647fc6b82bd72cdcc64bb31e01c53b9b543d09..4d879b46e1a4ac06b87ab154f9a5007867e45df3 100644 (file)
@@ -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());
 }
 
 //===----------------------------------------------------------------------===//