From: Benjamin Kramer Date: Sat, 15 Mar 2014 18:54:13 +0000 (+0000) Subject: Make some assertions on constant expressions static. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b746d24a20dd3dd173c72f2365b1307e9e355436;p=clang Make some assertions on constant expressions static. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204012 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h index 4d65350d27..d347be0955 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h @@ -986,7 +986,8 @@ public: template CallEventRef CallEvent::cloneWithState(ProgramStateRef NewState) const { assert(isa(*this) && "Cloning to unrelated type"); - assert(sizeof(T) == sizeof(CallEvent) && "Subclasses may not add fields"); + static_assert(sizeof(T) == sizeof(CallEvent), + "Subclasses may not add fields"); if (NewState == State) return cast(this); diff --git a/lib/AST/APValue.cpp b/lib/AST/APValue.cpp index 5cdeb00e85..049518e933 100644 --- a/lib/AST/APValue.cpp +++ b/lib/AST/APValue.cpp @@ -622,7 +622,7 @@ ArrayRef APValue::getMemberPointerPath() const { void APValue::MakeLValue() { assert(isUninit() && "Bad state change"); - assert(sizeof(LV) <= DataSize && "LV too big"); + static_assert(sizeof(LV) <= DataSize, "LV too big"); new ((void*)(char*)Data.buffer) LV(); Kind = LValue; } diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 038c7acb0f..a61af50c48 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -1613,8 +1613,10 @@ VarDecl::VarDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass SC) : DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc), Init() { - assert(sizeof(VarDeclBitfields) <= sizeof(unsigned)); - assert(sizeof(ParmVarDeclBitfields) <= sizeof(unsigned)); + static_assert(sizeof(VarDeclBitfields) <= sizeof(unsigned), + "VarDeclBitfields too large!"); + static_assert(sizeof(ParmVarDeclBitfields) <= sizeof(unsigned), + "ParmVarDeclBitfields too large!"); AllBits = 0; VarDeclBits.SClass = SC; // Everything else is implicitly initialized to false.