Browse Source

Merge pull request #66 from sherief/Robustness

Hints for Clang's static analyzer - preventing false positives.
Alexander Gessler 12 years ago
parent
commit
5f0bd28b15
3 changed files with 9 additions and 3 deletions
  1. 2 2
      code/FBXDocumentUtil.h
  2. 1 1
      code/ValidateDataStructure.h
  3. 6 0
      include/assimp/defs.h

+ 2 - 2
code/FBXDocumentUtil.h

@@ -50,8 +50,8 @@ namespace Util {
 
 
 
 
 /* DOM/Parse error reporting - does not return */
 /* DOM/Parse error reporting - does not return */
-void DOMError(const std::string& message, const Token& token);
-void DOMError(const std::string& message, const Element* element = NULL);
+AI_WONT_RETURN void DOMError(const std::string& message, const Token& token) AI_WONT_RETURN_SUFFIX;
+AI_WONT_RETURN void DOMError(const std::string& message, const Element* element = NULL) AI_WONT_RETURN_SUFFIX;
 
 
 // does return
 // does return
 void DOMWarning(const std::string& message, const Token& token);
 void DOMWarning(const std::string& message, const Token& token);

+ 1 - 1
code/ValidateDataStructure.h

@@ -82,7 +82,7 @@ protected:
 	/** Report a validation error. This will throw an exception,
 	/** Report a validation error. This will throw an exception,
 	 *  control won't return.
 	 *  control won't return.
 	 * @param msg Format string for sprintf().*/
 	 * @param msg Format string for sprintf().*/
-	AI_WONT_RETURN void ReportError(const char* msg,...);
+	AI_WONT_RETURN void ReportError(const char* msg,...) AI_WONT_RETURN_SUFFIX;
 
 
 
 
 	// -------------------------------------------------------------------
 	// -------------------------------------------------------------------

+ 6 - 0
include/assimp/defs.h

@@ -162,6 +162,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #	define AI_FORCE_INLINE inline
 #	define AI_FORCE_INLINE inline
 #endif // (defined _MSC_VER)
 #endif // (defined _MSC_VER)
 
 
+#ifdef __clang__
+#	define AI_WONT_RETURN_SUFFIX  __attribute__((analyzer_noreturn))
+#else
+#	define AI_WONT_RETURN_SUFFIX
+#endif // (defined __clang__)
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 	/* No explicit 'struct' and 'enum' tags for C++, this keeps showing up
 	/* No explicit 'struct' and 'enum' tags for C++, this keeps showing up
 	 * in doxydocs.
 	 * in doxydocs.