]> granicus.if.org Git - clang/commitdiff
Make some assertions on constant expressions static.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 15 Mar 2014 18:54:13 +0000 (18:54 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 15 Mar 2014 18:54:13 +0000 (18:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204012 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
lib/AST/APValue.cpp
lib/AST/Decl.cpp

index 4d65350d27e16bcb39a965f8e6e47932a59be5dd..d347be09551623535067b849226186cbca1a1327 100644 (file)
@@ -986,7 +986,8 @@ public:
 template <typename T>
 CallEventRef<T> CallEvent::cloneWithState(ProgramStateRef NewState) const {
   assert(isa<T>(*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<T>(this);
index 5cdeb00e8529e2787bf51100bee47752c2a908ed..049518e933f78e5c64138e5dab086a2fc5838fba 100644 (file)
@@ -622,7 +622,7 @@ ArrayRef<const CXXRecordDecl*> 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;
 }
index 038c7acb0f8b1db2ebd2e13f8ecf30eb0674192f..a61af50c480e4bcb14068a001c0072a680d71a1c 100644 (file)
@@ -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.