aboutsummaryrefslogtreecommitdiffstats
path: root/mutator_aux.cpp
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2016-12-17 18:08:10 +0000
committerbloodstalker <thabogre@gmail.com>2016-12-17 18:08:10 +0000
commitab8e46106036adf77c36b43a390ed9ccb902e5df (patch)
tree6b79abbbf7c0301e61ef58b9a5666c30e90a0540 /mutator_aux.cpp
parentadded coverage options, the g++ build mode is no longer broken (diff)
downloadmutator-ab8e46106036adf77c36b43a390ed9ccb902e5df.tar.gz
mutator-ab8e46106036adf77c36b43a390ed9ccb902e5df.zip
added asserts for sourcelocation
Diffstat (limited to '')
-rw-r--r--mutator_aux.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/mutator_aux.cpp b/mutator_aux.cpp
index 9d0e4f3..37a7b3e 100644
--- a/mutator_aux.cpp
+++ b/mutator_aux.cpp
@@ -4,6 +4,7 @@
/*inclusion directives*/
#include "mutator_aux.h"
#include <string>
+#include <cassert>
#include <iostream>
#include "clang/AST/AST.h"
#include "clang/Basic/SourceManager.h"
@@ -58,10 +59,12 @@ void XMLReport::XMLCreateReport()
XMLReportDoc.InsertFirstChild(RootPointer);
}
-/*it is the caller's responsibility to make sure the sourcelocation passed to this member function and its overload
-contain only the spelling location.*/
+/*it is the caller's responsibility to make sure the sourcelocation passed to this overload of the member function
+contains only the spelling location.*/
void XMLReport::XMLAddNode(ASTContext* ASTC, SourceLocation SL, std::string MisraRule, std::string Description)
{
+ assert(SL.isValid() && "SourceLocation passed as function parameter in an overload(1) of XMLAddNode is not valid.");
+
FullSourceLoc FSL = ASTC->getFullLoc(SL);
unsigned LineNumber = FSL.getSpellingLineNumber();
@@ -81,6 +84,8 @@ void XMLReport::XMLAddNode(ASTContext* ASTC, SourceLocation SL, std::string Misr
void XMLReport::XMLAddNode(FullSourceLoc FullSrcLoc, SourceLocation SL, std::string MisraRule, std::string Description)
{
+ assert(SL.isValid() && "SourceLocation passed as function parameter in an overload(2) of XMLAddNode is not valid.");
+
unsigned LineNumber = FullSrcLoc.getSpellingLineNumber();
unsigned ColumnNumber = FullSrcLoc.getSpellingColumnNumber();
@@ -100,6 +105,8 @@ void XMLReport::XMLAddNode(const SourceManager &SM, SourceLocation SL, std::stri
{
SL = SM.getSpellingLoc(SL);
+ assert(SL.isValid() && "SourceLocation Acquired by SourceManager in an overload(3) of XMLAddNode is not valid.");
+
unsigned LineNumber = SM.getSpellingLineNumber(SL);
unsigned ColumnNumber = SM.getSpellingColumnNumber(SL);