From c2bd73bba5316aa294187995e8c37b4f0f224179 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 8 Mar 2012 01:43:06 +0000 Subject: [PATCH] Sema: Don't emit a gajillion calls to sanity() -- an empty function -- in NDEBUG builds. Sheesh. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152279 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Lookup.h | 8 +++++++- lib/Sema/SemaLookup.cpp | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h index 1c24d20ee8..e7a6f15c0e 100644 --- a/include/clang/Sema/Lookup.h +++ b/include/clang/Sema/Lookup.h @@ -600,7 +600,13 @@ private: void configure(); // Sanity checks. - void sanity() const; + void sanityImpl() const; + + void sanity() const { +#ifndef NDEBUG + sanityImpl(); +#endif + } bool sanityCheckUnresolved() const { for (iterator I = begin(), E = end(); I != E; ++I) diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index b8901e2063..40774e135c 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -302,7 +302,9 @@ void LookupResult::configure() { } } -void LookupResult::sanity() const { +void LookupResult::sanityImpl() const { + // Note that this function is never called by NDEBUG builds. See + // LookupResult::sanity(). assert(ResultKind != NotFound || Decls.size() == 0); assert(ResultKind != Found || Decls.size() == 1); assert(ResultKind != FoundOverloaded || Decls.size() > 1 || -- 2.40.0