Eliminate the last trivial NDEBUG uses in clang headers
assert(sanity()) reads so much better than preprocessor conditional blocks. llvm-svn: 196657
This commit is contained in:
parent
3ffab05f54
commit
c108676822
|
@ -319,7 +319,7 @@ protected:
|
||||||
DeclContext *Parent, std::size_t Extra = 0);
|
DeclContext *Parent, std::size_t Extra = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CheckAccessDeclContext() const;
|
bool AccessDeclContextSanity() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -413,15 +413,11 @@ public:
|
||||||
|
|
||||||
void setAccess(AccessSpecifier AS) {
|
void setAccess(AccessSpecifier AS) {
|
||||||
Access = AS;
|
Access = AS;
|
||||||
#ifndef NDEBUG
|
assert(AccessDeclContextSanity());
|
||||||
CheckAccessDeclContext();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessSpecifier getAccess() const {
|
AccessSpecifier getAccess() const {
|
||||||
#ifndef NDEBUG
|
assert(AccessDeclContextSanity());
|
||||||
CheckAccessDeclContext();
|
|
||||||
#endif
|
|
||||||
return AccessSpecifier(Access);
|
return AccessSpecifier(Access);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2633,7 +2633,7 @@ public:
|
||||||
private:
|
private:
|
||||||
Stmt *Op;
|
Stmt *Op;
|
||||||
|
|
||||||
void CheckCastConsistency() const;
|
bool CastConsistency() const;
|
||||||
|
|
||||||
const CXXBaseSpecifier * const *path_buffer() const {
|
const CXXBaseSpecifier * const *path_buffer() const {
|
||||||
return const_cast<CastExpr*>(this)->path_buffer();
|
return const_cast<CastExpr*>(this)->path_buffer();
|
||||||
|
@ -2664,9 +2664,7 @@ protected:
|
||||||
assert(kind != CK_Invalid && "creating cast with invalid cast kind");
|
assert(kind != CK_Invalid && "creating cast with invalid cast kind");
|
||||||
CastExprBits.Kind = kind;
|
CastExprBits.Kind = kind;
|
||||||
setBasePathSize(BasePathSize);
|
setBasePathSize(BasePathSize);
|
||||||
#ifndef NDEBUG
|
assert(CastConsistency());
|
||||||
CheckCastConsistency();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Construct an empty cast.
|
/// \brief Construct an empty cast.
|
||||||
|
|
|
@ -259,7 +259,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
LookupResultKind getResultKind() const {
|
LookupResultKind getResultKind() const {
|
||||||
sanity();
|
assert(sanity());
|
||||||
return ResultKind;
|
return ResultKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,13 +637,7 @@ private:
|
||||||
void configure();
|
void configure();
|
||||||
|
|
||||||
// Sanity checks.
|
// Sanity checks.
|
||||||
void sanityImpl() const;
|
bool sanity() const;
|
||||||
|
|
||||||
void sanity() const {
|
|
||||||
#ifndef NDEBUG
|
|
||||||
sanityImpl();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool sanityCheckUnresolved() const {
|
bool sanityCheckUnresolved() const {
|
||||||
for (iterator I = begin(), E = end(); I != E; ++I)
|
for (iterator I = begin(), E = end(); I != E; ++I)
|
||||||
|
|
|
@ -667,7 +667,7 @@ SourceLocation Decl::getBodyRBrace() const {
|
||||||
return SourceLocation();
|
return SourceLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Decl::CheckAccessDeclContext() const {
|
bool Decl::AccessDeclContextSanity() const {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// Suppress this check if any of the following hold:
|
// Suppress this check if any of the following hold:
|
||||||
// 1. this is the translation unit (and thus has no parent)
|
// 1. this is the translation unit (and thus has no parent)
|
||||||
|
@ -689,11 +689,12 @@ void Decl::CheckAccessDeclContext() const {
|
||||||
// AS_none as access specifier.
|
// AS_none as access specifier.
|
||||||
isa<CXXRecordDecl>(this) ||
|
isa<CXXRecordDecl>(this) ||
|
||||||
isa<ClassScopeFunctionSpecializationDecl>(this))
|
isa<ClassScopeFunctionSpecializationDecl>(this))
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
assert(Access != AS_none &&
|
assert(Access != AS_none &&
|
||||||
"Access specifier is AS_none inside a record decl");
|
"Access specifier is AS_none inside a record decl");
|
||||||
#endif
|
#endif
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Decl::Kind getKind(const Decl *D) { return D->getKind(); }
|
static Decl::Kind getKind(const Decl *D) { return D->getKind(); }
|
||||||
|
|
|
@ -1421,7 +1421,7 @@ SourceLocation MemberExpr::getLocEnd() const {
|
||||||
return EndLoc;
|
return EndLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CastExpr::CheckCastConsistency() const {
|
bool CastExpr::CastConsistency() const {
|
||||||
switch (getCastKind()) {
|
switch (getCastKind()) {
|
||||||
case CK_DerivedToBase:
|
case CK_DerivedToBase:
|
||||||
case CK_UncheckedDerivedToBase:
|
case CK_UncheckedDerivedToBase:
|
||||||
|
@ -1524,6 +1524,7 @@ void CastExpr::CheckCastConsistency() const {
|
||||||
assert(path_empty() && "Cast kind should not have a base path!");
|
assert(path_empty() && "Cast kind should not have a base path!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CastExpr::getCastKindName() const {
|
const char *CastExpr::getCastKindName() const {
|
||||||
|
|
|
@ -315,7 +315,7 @@ void LookupResult::configure() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LookupResult::sanityImpl() const {
|
bool LookupResult::sanity() const {
|
||||||
// Note that this function is never called by NDEBUG builds. See
|
// Note that this function is never called by NDEBUG builds. See
|
||||||
// LookupResult::sanity().
|
// LookupResult::sanity().
|
||||||
assert(ResultKind != NotFound || Decls.size() == 0);
|
assert(ResultKind != NotFound || Decls.size() == 0);
|
||||||
|
@ -330,6 +330,7 @@ void LookupResult::sanityImpl() const {
|
||||||
assert((Paths != NULL) == (ResultKind == Ambiguous &&
|
assert((Paths != NULL) == (ResultKind == Ambiguous &&
|
||||||
(Ambiguity == AmbiguousBaseSubobjectTypes ||
|
(Ambiguity == AmbiguousBaseSubobjectTypes ||
|
||||||
Ambiguity == AmbiguousBaseSubobjects)));
|
Ambiguity == AmbiguousBaseSubobjects)));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Necessary because CXXBasePaths is not complete in Sema.h
|
// Necessary because CXXBasePaths is not complete in Sema.h
|
||||||
|
|
Loading…
Reference in New Issue