[opengtl-commits] [429] don't crash when accessing a non initialized global value |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 429
Author: cyrille
Date: 2008-10-06 15:47:19 +0200 (Mon, 06 Oct 2008)
Log Message:
-----------
don't crash when accessing a non initialized global value
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/AST/Tree.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Type.h
trunk/OpenGTL/OpenShiva/tests/imagegenerators/raytracer.shiva
Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Tree.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Tree.cpp 2008-10-06 12:52:52 UTC (rev 428)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Tree.cpp 2008-10-06 13:47:19 UTC (rev 429)
@@ -24,6 +24,7 @@
#include "FunctionDeclaration.h"
+#include "GTLCore/Debug.h"
#include "GTLCore/CodeGenerator_p.h"
#include "GTLCore/ExpressionResult_p.h"
#include "GTLCore/Type.h"
@@ -56,8 +57,9 @@
if( m_initialiser )
{
value = _codeGenerator->convertConstantTo( m_initialiser->generateValue( gc, 0 ).constant(), m_initialiser->type() , m_type );
+ GTL_ASSERT( value );
}
- llvm::Value* pointer = new llvm::GlobalVariable( value->getType(), true, llvm::GlobalValue::InternalLinkage, value, "", _module->llvmModule() );
+ llvm::Value* pointer = new llvm::GlobalVariable( value ? value->getType() : m_type->d->type() , true, llvm::GlobalValue::InternalLinkage, value, "", _module->llvmModule() );
m_variable->initialise( gc, 0, pointer);
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.h 2008-10-06 12:52:52 UTC (rev 428)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.h 2008-10-06 13:47:19 UTC (rev 429)
@@ -47,6 +47,7 @@
class ConstantCoumpoundExpression;
class FunctionCallExpression;
class FunctionDeclaration;
+ class GlobalConstantDeclaration;
}
/**
* This class holds information about a type.
@@ -59,6 +60,7 @@
friend class AST::CoumpoundExpression;
friend class AST::FunctionCallExpression;
friend class AST::FunctionDeclaration;
+ friend class AST::GlobalConstantDeclaration;
friend class OpenCTL::Compiler;
friend class OpenCTL::Program;
friend class CodeGenerator;
Modified: trunk/OpenGTL/OpenShiva/tests/imagegenerators/raytracer.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/imagegenerators/raytracer.shiva 2008-10-06 12:52:52 UTC (rev 428)
+++ trunk/OpenGTL/OpenShiva/tests/imagegenerators/raytracer.shiva 2008-10-06 13:47:19 UTC (rev 429)
@@ -108,7 +108,7 @@
}
float length( float3 v)
{
- return v;
+ return 0.0;
}
float mod( float v, float v2)
{