[llvm-commits] [hlvm] r38072 - in /hlvm/trunk/hlvm: AST/Bundle.cpp AST/ContainerType.cpp AST/Function.cpp AST/Node.cpp AST/Node.h AST/Type.cpp Base/Assert.h Base/Memory.cpp Reader/XML/XMLReader.cpp Writer/XML/XMLWriter.cpp
Reid Spencer
reid at x10sys.com
Sat Jul 7 16:59:34 PDT 2007
Author: reid
Date: Sat Jul 7 18:59:34 2007
New Revision: 38072
URL: http://llvm.org/viewvc/llvm-project?rev=38072&view=rev
Log:
Convert to using HLVM style assertion mechanisms. This does two things for us:
1. We can control assertions on/off without relying on NDEBUG
2. We can design additional conditions (dead code, not implemented, etc.) and
take different actions based on the kind of condition.
Added:
hlvm/trunk/hlvm/Base/Assert.h
Modified:
hlvm/trunk/hlvm/AST/Bundle.cpp
hlvm/trunk/hlvm/AST/ContainerType.cpp
hlvm/trunk/hlvm/AST/Function.cpp
hlvm/trunk/hlvm/AST/Node.cpp
hlvm/trunk/hlvm/AST/Node.h
hlvm/trunk/hlvm/AST/Type.cpp
hlvm/trunk/hlvm/Base/Memory.cpp
hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp
Modified: hlvm/trunk/hlvm/AST/Bundle.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Bundle.cpp?rev=38072&r1=38071&r2=38072&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.cpp (original)
+++ hlvm/trunk/hlvm/AST/Bundle.cpp Sat Jul 7 18:59:34 2007
@@ -29,6 +29,7 @@
#include <hlvm/AST/Bundle.h>
#include <hlvm/AST/LinkageItem.h>
+#include <hlvm/Base/Assert.h>
using namespace llvm;
@@ -50,19 +51,19 @@
void
Bundle::insertChild(Node* kid)
{
- assert(isa<LinkageItem>(kid) && "Can't insert that here");
+ hlvmAssert(isa<LinkageItem>(kid) && "Can't insert that here");
kids.push_back(cast<LinkageItem>(kid));
}
void
Bundle::removeChild(Node* kid)
{
- assert(isa<LinkageItem>(kid) && "Can't remove that here");
+ hlvmAssert(isa<LinkageItem>(kid) && "Can't remove that here");
// This is sucky slow, but we probably won't be removing nodes that much.
for (iterator I = begin(), E = end(); I != E; ++I ) {
if (*I == kid) { kids.erase(I); return; }
}
- assert(!"That node isn't my child");
+ hlvmAssert(!"That node isn't my child");
}
}
Modified: hlvm/trunk/hlvm/AST/ContainerType.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/ContainerType.cpp?rev=38072&r1=38071&r2=38072&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/ContainerType.cpp (original)
+++ hlvm/trunk/hlvm/AST/ContainerType.cpp Sat Jul 7 18:59:34 2007
@@ -28,6 +28,7 @@
//===----------------------------------------------------------------------===//
#include <hlvm/AST/ContainerType.h>
+#include <hlvm/Base/Assert.h>
using namespace llvm;
@@ -40,19 +41,19 @@
void
ContainerType::insertChild(Node* n)
{
- assert(isa<Type>(n) && "Can't insert those here");
+ hlvmAssert(isa<Type>(n) && "Can't insert those here");
types.push_back(cast<Type>(n));
}
void
ContainerType::removeChild(Node* n)
{
- assert(isa<Type>(n) && "Can't remove those here");
+ hlvmAssert(isa<Type>(n) && "Can't remove those here");
// This is sucky slow, but we probably won't be removing nodes that much.
for (iterator I = begin(), E = end(); I != E; ++I ) {
if (*I == n) { types.erase(I); break; }
}
- assert(!"That node isn't my child");
+ hlvmAssert(!"That node isn't my child");
}
const char*
@@ -68,7 +69,7 @@
void
StructureType::insertChild(Node* n)
{
- assert(isa<AliasType>(n) && "Can't insert those here");
+ hlvmAssert(isa<AliasType>(n) && "Can't insert those here");
types.push_back(cast<AliasType>(n));
}
@@ -79,7 +80,7 @@
void
SignatureType::insertChild(Node* n)
{
- assert(isa<AliasType>(n) && "Can't insert those here");
+ hlvmAssert(isa<AliasType>(n) && "Can't insert those here");
types.push_back(cast<AliasType>(n));
}
Modified: hlvm/trunk/hlvm/AST/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Function.cpp?rev=38072&r1=38071&r2=38072&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Function.cpp (original)
+++ hlvm/trunk/hlvm/AST/Function.cpp Sat Jul 7 18:59:34 2007
@@ -28,6 +28,7 @@
//===----------------------------------------------------------------------===//
#include <hlvm/AST/Function.h>
+#include <hlvm/Base/Assert.h>
using namespace llvm;
@@ -49,7 +50,7 @@
block->setParent(0);
block = cast<Block>(kid);
} else {
- assert(!"Can't insert one of those here");
+ hlvmAssert(!"Can't insert one of those here");
}
}
@@ -59,7 +60,7 @@
if (isa<SignatureType>(kid)) {
} else if (isa<Block>(kid)) {
} else {
- assert(!"Can't insert one of those here");
+ hlvmAssert(!"Can't insert one of those here");
}
}
Modified: hlvm/trunk/hlvm/AST/Node.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.cpp?rev=38072&r1=38071&r2=38072&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Node.cpp (original)
+++ hlvm/trunk/hlvm/AST/Node.cpp Sat Jul 7 18:59:34 2007
@@ -28,6 +28,7 @@
//===----------------------------------------------------------------------===//
#include <hlvm/AST/Node.h>
+#include <hlvm/Base/Assert.h>
namespace hlvm {
@@ -51,13 +52,20 @@
void
Node::insertChild(Node* child)
{
- assert(!"This node doesn't accept child nodes");
+ hlvmNotImplemented("Node::insertChild");
}
void
Node::removeChild(Node* child)
{
- assert(!"This node doesn't have child nodes");
+ hlvmNotImplemented("Node::insertChild");
+}
+
+void
+Node::setFlags(unsigned f)
+{
+ hlvmAssert(f < 1 << 24 && "Flags out of range");
+ flags = f;
}
void
Modified: hlvm/trunk/hlvm/AST/Node.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.h?rev=38072&r1=38071&r2=38072&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul 7 18:59:34 2007
@@ -266,10 +266,7 @@
/// @{
public:
void setLocator(const Locator& l) { loc = l; }
- void setFlags(unsigned f) {
- assert(f < 1 << 24 && "Flags out of range");
- flags = f;
- }
+ void setFlags(unsigned f);
virtual void setParent(Node* parent);
protected:
Modified: hlvm/trunk/hlvm/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Type.cpp?rev=38072&r1=38071&r2=38072&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Type.cpp (original)
+++ hlvm/trunk/hlvm/AST/Type.cpp Sat Jul 7 18:59:34 2007
@@ -28,6 +28,7 @@
//===----------------------------------------------------------------------===//
#include <hlvm/AST/Type.h>
+#include <hlvm/Base/Assert.h>
namespace hlvm {
@@ -38,7 +39,7 @@
void
Type::insertChild(Node* n)
{
- assert(!"This type doesn't accept children!");
+ hlvmAssert(!"This type doesn't accept children!");
}
const char*
@@ -110,7 +111,7 @@
else
return "u8";
}
- assert(!"Can't get here");
+ hlvmDeadCode("Primitive Name");
}
OctetType::~OctetType()
Added: hlvm/trunk/hlvm/Base/Assert.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Assert.h?rev=38072&view=auto
==============================================================================
--- hlvm/trunk/hlvm/Base/Assert.h (added)
+++ hlvm/trunk/hlvm/Base/Assert.h Sat Jul 7 18:59:34 2007
@@ -0,0 +1,113 @@
+//===-- Various CPP Macros For Doing Assertions -----------------*- C++ -*-===//
+//
+// High Level Virtual Machine (HLVM)
+//
+// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
+//
+// This software is free software; you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation; either version 2.1 of the License, or (at
+// your option) any later version.
+//
+// This software is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+// more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library in the file named LICENSE.txt; if not, write to the
+// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301 USA
+//
+//===----------------------------------------------------------------------===//
+/// @file hlvm/Base/Assert.h
+/// @author Reid Spencer <rspencer at reidspencer.com>
+/// @date 2006/05/20
+/// @since 0.1
+/// @brief Assertion and error checking macros.
+///
+/// This file provides various preprocessor macros that can be used to assist
+/// the programmer to check assertions, handle dead code locations, do range
+/// checking, etc. These are intended to be used to check class invariants,
+/// function arguments, and other points in the logic where an assertion
+/// can be made to ensure the program is operating within its parameters.
+/// Note that if an assertion macro is triggered, it results in an
+/// exception being thrown. Make sure that your code can exit cleanly in
+/// the face of the assertion being thrown. Generally this means that
+/// you should place all your assertions at the beginning of a function
+/// so that you don't attempt to operate on the parameters or objects
+/// that are outside of the specified limits. Also note that these macros
+/// can be turned off with the HLVM_ASSERT configuration variable. Ensure
+/// that no needed side effects are encapsulated in the arguments to these
+/// macros as those side effects will disappear when building without the
+/// HLVM_ASSERT configuration. Assertions should only be used to check
+/// validity of logic that should always be true (such as parameter ranges)
+/// but not for end user error messages.
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef HLVM_BASE_ASSERT_H
+#define HLVM_BASE_ASSERT_H
+
+#ifdef HLVM_ASSERT
+#include <cassert>
+#endif
+/// This macro enforces any expression that the programmer cares to
+/// assert at the point in the program where the macro is used. The argument
+/// can be any valid logical expression that can be used with the ! operator.
+/// Note that the exception thrown will contain the text of the expression so
+/// that it will be easier to identify which condition failed. Watch out for
+/// side effects of the expression! Do all assignments before the assertion!
+/// @param expr Any logic expression to be tested. The macro throws if the expression evaluates to false.
+/// @brief Check an arbitrary expression for truth.
+#ifdef HLVM_ASSERT
+#define hlvmAssert( expr ) assert(expr)
+#else
+#define hlvmAssert( expr ) {}
+#endif
+
+/// The DEAD_CODE macro is intended to be used to signify locations in the
+/// code that should never be reached. It serves as a sentinel in the software
+/// and will \em always throw an exception when it is encountered. Use this to
+/// place some code in the \p default label of a switch statement that should
+/// not be reached or at the end of a function that should normally return
+/// through some other execution path.
+/// @param msg Provides a message that will become part of the exception
+/// object thrown.
+/// @brief Identify locations in the code that should not be reached.
+#ifdef HLVM_ASSERT
+#define hlvmDeadCode( msg ) assert(! "Dead Code:" msg)
+#else
+#define hlvmDeadCode( msg ) {}
+#endif
+
+/// This macro can be utilized to state that a function is not implemented. It
+/// throws a "Not Implemented" exception that indicates the name of the function
+/// that has not been implemented. This can be used as the sole content of any
+/// to ensure that unimplemented functionality is recognized. You should use
+/// this macro in every function when you are doing rapid prototyping.
+/// @param msg Provides a message that will become part of the exception
+/// object thrown.
+/// @brief Identify unimplemented functionality
+#ifdef HLVM_ASSERT
+#define hlvmNotImplemented( msg ) assert(! "Not Implemented:" msg)
+#else
+#define hlvmNotImplemented(msg) {}
+#endif
+
+/// This macro allows the programmer to make a range assertion about the
+/// \p value argument when compared with the \p min and \p max arguments. The
+/// \p value can be anything that is compatible with the \c < and \c >
+/// operators. Note that the range being checked is inclusive of both \p min
+/// and \p max.
+/// @param value The value checked against the \p min and \p max parameters.
+/// @param min The (inclusive) minimum value to be checked.
+/// @param max The (inclusive) maximum value to be checked.
+/// @brief Check numerical range of a value.
+#ifdef HLVM_ASSERT
+#define hlvmRangeCheck( value, min, max ) \
+ assert(((value)>=(min) || (value)<=(max)) && "Range Error!")
+#else
+#define hlvmRangeCheck(value,min,max) {}
+#endif
+
+#endif
Modified: hlvm/trunk/hlvm/Base/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Memory.cpp?rev=38072&r1=38071&r2=38072&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Base/Memory.cpp (original)
+++ hlvm/trunk/hlvm/Base/Memory.cpp Sat Jul 7 18:59:34 2007
@@ -28,11 +28,11 @@
//===----------------------------------------------------------------------===//
#include <hlvm/Base/Memory.h>
+#include <hlvm/Base/Assert.h>
#include <llvm/System/Signals.h>
#include <memory>
#include <new>
#include <iostream>
-#include <cassert>
namespace hlvm { namespace Base {
@@ -54,20 +54,20 @@
}
else
{
- assert( _memory_reserve != 0 && "No memory!");
+ hlvmAssert( _memory_reserve != 0 && "No memory!");
}
}
static void
the_unexpected_handler( void )
{
- assert(!"Unexpected Handler.");
+ hlvmNotImplemented("Unexpected Handler");
}
static void
the_terminate_handler( void )
{
- assert(!"Terminate Handler.");
+ hlvmNotImplemented("Terminate Handler");
}
static void
@@ -109,11 +109,11 @@
// Initialize APR
if (APR_SUCCESS != apr_initialize())
- assert(!"Can't initialize APR");
+ hlvmAssert(!"Can't initialize APR");
// Allocate the master pool
if (APR_SUCCESS != apr_pool_create(&POOL,0))
- assert(!"Can't allocate the master pool");
+ hlvmAssert(!"Can't allocate the master pool");
#ifdef XPS_DEBUG
// Make sure we print stack trace if we get bad signals
@@ -123,11 +123,11 @@
}
catch ( ... )
{
- assert(!"Unexpected exception during initialization.");
+ hlvmAssert(!"Unexpected exception during initialization.");
}
if (0 != atexit(terminate))
- assert(!"Can't register termination at exit");
+ hlvmAssert(!"Can't register termination at exit");
// We've made it through initialization .. indicate that.
initialized = true;
Modified: hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp?rev=38072&r1=38071&r2=38072&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp Sat Jul 7 18:59:34 2007
@@ -38,6 +38,7 @@
#include <hlvm/AST/Function.h>
#include <hlvm/AST/Import.h>
#include <hlvm/AST/Variable.h>
+#include <hlvm/Base/Assert.h>
#include <libxml/parser.h>
#include <libxml/relaxng.h>
#include <vector>
@@ -181,7 +182,7 @@
case '1': if (str == "1") return true; break;
default: break;
}
- assert(!"Invalid boolean value");
+ hlvmDeadCode("Invalid boolean value");
}
inline const char*
@@ -190,7 +191,7 @@
const char* result = reinterpret_cast<const char*>(
xmlGetNoNsProp(cur,reinterpret_cast<const xmlChar*>(name)));
if (!result && required) {
- assert(!"Missing Attribute");
+ hlvmAssert(!"Missing Attribute");
}
return result;
}
@@ -245,7 +246,7 @@
Function*
XMLReaderImpl::parseFunction(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_function);
+ hlvmAssert(getToken(cur->name)==TKN_function);
Locator loc(cur->line,0,&ast->getSystemID());
std::string name, type;
getNameType(cur, name, type);
@@ -257,7 +258,7 @@
Import*
XMLReaderImpl::parseImport(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_import);
+ hlvmAssert(getToken(cur->name)==TKN_import);
Locator loc(cur->line,0,&ast->getSystemID());
std::string pfx = getAttribute(cur,"prefix");
Import* imp = ast->new_Import(loc,pfx);
@@ -268,7 +269,7 @@
AliasType*
XMLReaderImpl::parseAlias(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_alias);
+ hlvmAssert(getToken(cur->name)==TKN_alias);
Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
std::string type = getAttribute(cur,"renames");
@@ -280,7 +281,7 @@
Type*
XMLReaderImpl::parseAtom(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_atom);
+ hlvmAssert(getToken(cur->name)==TKN_atom);
Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
xmlNodePtr child = cur->children;
@@ -293,7 +294,7 @@
case TKN_intrinsic: {
const char* is = getAttribute(child,"is");
if (!is)
- assert(!"intrinsic element requires 'is' attribute");
+ hlvmAssert(!"intrinsic element requires 'is' attribute");
int typeTkn = getToken(reinterpret_cast<const xmlChar*>(is));
switch (typeTkn) {
case TKN_any: result=ast->new_AnyType(loc,name); break;
@@ -317,7 +318,7 @@
case TKN_u8: result=ast->new_u8(loc,name); break;
case TKN_void: result=ast->new_VoidType(loc,name); break;
default:
- assert(!"Invalid intrinsic kind");
+ hlvmDeadCode("Invalid intrinsic kind");
}
break;
}
@@ -328,7 +329,7 @@
result = ast->new_IntegerType(loc,name,numBits,/*signed=*/true);
break;
}
- assert(!"Missing 'bits' attribute");
+ hlvmAssert(!"Missing 'bits' attribute");
break;
}
case TKN_unsigned: {
@@ -338,7 +339,7 @@
result = ast->new_IntegerType(loc,name,numBits,/*signed=*/false);
break;
}
- assert(!"Missing 'bits' attribute");
+ hlvmAssert(!"Missing 'bits' attribute");
break;
}
case TKN_range: {
@@ -350,7 +351,7 @@
result = ast->new_RangeType(loc,name,minVal,maxVal);
break;
}
- assert(!"Missing 'min' or 'max' attribute");
+ hlvmAssert(!"Missing 'min' or 'max' attribute");
break;
}
case TKN_real: {
@@ -364,7 +365,7 @@
break;
}
default:
- assert(!"Invalid content for atom");
+ hlvmAssert(!"Invalid content for atom");
break;
}
if (result) {
@@ -373,19 +374,19 @@
return result;
}
}
- assert(!"Atom definition element expected");
+ hlvmAssert(!"Atom definition element expected");
}
Type*
XMLReaderImpl::parseEnumeration(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_enumeration);
+ hlvmAssert(getToken(cur->name)==TKN_enumeration);
Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
EnumerationType* en = ast->new_EnumerationType(loc,name);
xmlNodePtr child = checkDoc(cur,en);
while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
- assert(getToken(child->name) == TKN_enumerator);
+ hlvmAssert(getToken(child->name) == TKN_enumerator);
std::string id = getAttribute(child,"id");
en->addEnumerator(id);
child = child->next;
@@ -396,7 +397,7 @@
Type*
XMLReaderImpl::parsePointer(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_pointer);
+ hlvmAssert(getToken(cur->name)==TKN_pointer);
Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
std::string type = getAttribute(cur,"to");
@@ -409,7 +410,7 @@
Type*
XMLReaderImpl::parseArray(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_array);
+ hlvmAssert(getToken(cur->name)==TKN_array);
Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
std::string type = getAttribute(cur,"of");
@@ -423,7 +424,7 @@
Type*
XMLReaderImpl::parseVector(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_vector);
+ hlvmAssert(getToken(cur->name)==TKN_vector);
Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
std::string type = getAttribute(cur,"of");
@@ -438,13 +439,14 @@
Type*
XMLReaderImpl::parseStructure(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_structure);
+ hlvmAssert(getToken(cur->name)==TKN_structure);
Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
StructureType* struc = ast->new_StructureType(loc,name);
xmlNodePtr child = checkDoc(cur,struc);
while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
- assert(getToken(child->name) == TKN_field && "Structure only has fields");
+ hlvmAssert(getToken(child->name) == TKN_field &&
+ "Structure only has fields");
std::string name = getAttribute(child,"name");
std::string type = getAttribute(child,"type");
AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
@@ -458,7 +460,7 @@
Type*
XMLReaderImpl::parseSignature(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_signature);
+ hlvmAssert(getToken(cur->name)==TKN_signature);
Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
std::string result = getAttribute(cur,"result");
@@ -469,7 +471,7 @@
sig->setIsVarArgs(recognize_boolean(varargs));
xmlNodePtr child = checkDoc(cur,sig);
while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
- assert(getToken(child->name) == TKN_arg && "Signature only has args");
+ hlvmAssert(getToken(child->name) == TKN_arg && "Signature only has args");
std::string name = getAttribute(child,"name");
std::string type = getAttribute(child,"type");
AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
@@ -483,7 +485,7 @@
Variable*
XMLReaderImpl::parseVariable(xmlNodePtr& cur)
{
- assert(getToken(cur->name)==TKN_var);
+ hlvmAssert(getToken(cur->name)==TKN_var);
Locator loc(cur->line,0,&ast->getSystemID());
std::string name, type;
getNameType(cur, name, type);
@@ -496,7 +498,7 @@
Bundle*
XMLReaderImpl::parseBundle(xmlNodePtr& cur)
{
- assert(getToken(cur->name) == TKN_bundle && "Expecting bundle element");
+ hlvmAssert(getToken(cur->name) == TKN_bundle && "Expecting bundle element");
std::string pubid(getAttribute(cur, "pubid"));
Locator loc(cur->line,0,&ast->getSystemID());
Bundle* bundle = ast->new_Bundle(loc,pubid);
@@ -524,7 +526,7 @@
case TKN_signature: n = parseSignature(child); break;
case TKN_var : n = parseVariable(child); break;
default:
- assert(!"Invalid content for bundle");
+ hlvmDeadCode("Invalid content for bundle");
break;
}
if (n)
@@ -543,7 +545,7 @@
return;
}
int tkn = getToken(cur->name);
- assert(tkn == TKN_hlvm && "Expecting hlvm element");
+ hlvmAssert(tkn == TKN_hlvm && "Expecting hlvm element");
cur = cur->children;
if (skipBlanks(cur)) {
Bundle* bundle = parseBundle(cur);
Modified: hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp?rev=38072&r1=38071&r2=38072&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp (original)
+++ hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp Sat Jul 7 18:59:34 2007
@@ -35,10 +35,10 @@
#include <hlvm/AST/Import.h>
#include <hlvm/AST/ContainerType.h>
#include <hlvm/AST/Variable.h>
+#include <hlvm/Base/Assert.h>
#include <llvm/ADT/StringExtras.h>
#include <libxml/xmlwriter.h>
#include <iostream>
-#include <cassert>
using namespace hlvm;
using namespace llvm;
@@ -53,7 +53,7 @@
: writer(0), node(0)
{
writer = xmlNewTextWriterFilename(fname,0);
- assert(writer && "Can't allocate writer");
+ hlvmAssert(writer && "Can't allocate writer");
xmlTextWriterSetIndent(writer,1);
xmlTextWriterSetIndentString(writer,reinterpret_cast<const xmlChar*>(" "));
}
@@ -396,7 +396,7 @@
case StructureTypeID: put(cast<StructureType>(*I)); break;
case SignatureTypeID: put(cast<SignatureType>(*I)); break;
default:
- assert(!"Invalid bundle content");
+ hlvmDeadCode("Invalid bundle content");
}
}
endElement();
More information about the llvm-commits
mailing list