r281286 - Fix interaction between serialization and c++1z feature.

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 12 18:20:40 PDT 2016


Author: rtrieu
Date: Mon Sep 12 20:20:40 2016
New Revision: 281286

URL: http://llvm.org/viewvc/llvm-project?rev=281286&view=rev
Log:
Fix interaction between serialization and c++1z feature.

In c++1z, static_assert is not required to have a StringLiteral message, where
previously it was required.  Update the AST Reader to be able to handle a
null StringLiteral.

Added:
    cfe/trunk/test/Modules/Inputs/static_assert/
    cfe/trunk/test/Modules/Inputs/static_assert/a.h
    cfe/trunk/test/Modules/Inputs/static_assert/module.modulemap
    cfe/trunk/test/Modules/static_assert.cpp
Modified:
    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=281286&r1=281285&r2=281286&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Sep 12 20:20:40 2016
@@ -2239,7 +2239,7 @@ void ASTDeclReader::VisitStaticAssertDec
   VisitDecl(D);
   D->AssertExprAndFailed.setPointer(Reader.ReadExpr(F));
   D->AssertExprAndFailed.setInt(Record[Idx++]);
-  D->Message = cast<StringLiteral>(Reader.ReadExpr(F));
+  D->Message = cast_or_null<StringLiteral>(Reader.ReadExpr(F));
   D->RParenLoc = ReadSourceLocation(Record, Idx);
 }
 

Added: cfe/trunk/test/Modules/Inputs/static_assert/a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/static_assert/a.h?rev=281286&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/static_assert/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/static_assert/a.h Mon Sep 12 20:20:40 2016
@@ -0,0 +1,3 @@
+class S {
+  static_assert(4 == 4);
+};

Added: cfe/trunk/test/Modules/Inputs/static_assert/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/static_assert/module.modulemap?rev=281286&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/static_assert/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/static_assert/module.modulemap Mon Sep 12 20:20:40 2016
@@ -0,0 +1 @@
+module a { header "a.h" }

Added: cfe/trunk/test/Modules/static_assert.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/static_assert.cpp?rev=281286&view=auto
==============================================================================
--- cfe/trunk/test/Modules/static_assert.cpp (added)
+++ cfe/trunk/test/Modules/static_assert.cpp Mon Sep 12 20:20:40 2016
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps \
+// RUN:            -I%S/Inputs/static_assert -std=c++1z -verify %s
+// expected-no-diagnostics
+
+#include "a.h"
+
+S s;




More information about the cfe-commits mailing list