aboutsummaryrefslogtreecommitdiffstats
path: root/mutator-lvl0.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mutator-lvl0.cpp')
-rw-r--r--mutator-lvl0.cpp129
1 files changed, 122 insertions, 7 deletions
diff --git a/mutator-lvl0.cpp b/mutator-lvl0.cpp
index 53a137c..3240baa 100644
--- a/mutator-lvl0.cpp
+++ b/mutator-lvl0.cpp
@@ -1484,11 +1484,28 @@ public:
QualType RQT = RHS->getType();
QualType LQT = LHS->getType();
+ ASTContext *const ASTC = MR.Context;
+
const clang::Type* RTP [[maybe_unused]] = RQT.getTypePtr();
- const clang::Type* LTP [[maybe_unused]] = LQT.getTypePtr();
+ const clang::Type* LTP = LQT.getTypePtr();
+
+ const clang::Type* CanonType = ASTC->getCanonicalType(LTP);
+
+ uint64_t LHSSize = ASTC->getTypeSize(CanonType);
+
+ llvm::APSInt Result;
+
+ if (RHS->isIntegerConstantExpr(Result, *ASTC, nullptr, true))
+ {
+ if ((Result >= (LHSSize - 1U)) || (Result <= 0))
+ {
+ std::cout << "12.8 : " << "shift size should be between zero and one less than the size of the LHS operand: " << std::endl;
+ std::cout << SL.printToString(*MR.SourceManager) << "\n" << std::endl;
+
+ XMLDocOut.XMLAddNode(MR.Context, SL, "12.8", "shift size should be between zero and one less than the size of the LHS operand: ");
+ }
+ }
- /*i need to know the size of underlying types on the target so i cant do much about that.*/
- /*llvm::DataLayout lets you do that but then you need llvm::Module.*/
}
}
@@ -3028,7 +3045,8 @@ public:
std::cout << "8.7 : " << "Object (" + iter.ObjNameStr + ") is only being used in one block (" + iter.FirstDaddyName + ") but is not defined inside that block: " << std::endl;
std::cout << iter.ObjSLStr << "\n" << std::endl;
- XMLDocOut.XMLAddNode(iter.ObjFSL, iter.ObjSL, "8.7", "Object (" + iter.ObjNameStr + ") is only being used in one block (" + iter.FirstDaddyName + ") but is not defined inside that block: ");
+ XMLDocOut.XMLAddNode(iter.ObjFSL, iter.ObjSL, "8.7", \
+ "Object (" + iter.ObjNameStr + ") is only being used in one block (" + iter.FirstDaddyName + ") but is not defined inside that block: ");
}
}
}
@@ -3037,7 +3055,8 @@ public:
private:
struct MaybeLocalObjInfo
{
- MaybeLocalObjInfo(SourceLocation iObjSL, FullSourceLoc iObjFSL, std::string iObjSLStr, std::string iObjNameStr, std::string iFirstDaddyName, bool iHasMoreThanOneDaddy = false)
+ MaybeLocalObjInfo(SourceLocation iObjSL, FullSourceLoc iObjFSL, std::string iObjSLStr, \
+ std::string iObjNameStr, std::string iFirstDaddyName, bool iHasMoreThanOneDaddy = false)
{
ObjSL = iObjSL;
ObjFSL = iObjFSL;
@@ -3062,6 +3081,98 @@ private:
Rewriter &Rewrite;
};
/**********************************************************************************************************************/
+class MCDCDF88 : public MatchFinder::MatchCallback
+{
+public:
+ MCDCDF88 (Rewriter &Rewrite) : Rewrite(Rewrite) {}
+
+ virtual void run(const MatchFinder::MatchResult &MR)
+ {
+ /*underdev*/
+ if (MR.Nodes.getNodeAs<clang::NamedDecl>("mcdcdf88") != nullptr)
+ {
+ IsNewEntry = true;
+
+ const NamedDecl* ND = MR.Nodes.getNodeAs<clang::NamedDecl>("mcdcdf88");
+
+ SourceLocation SL = ND->getLocStart();
+ SL = Devi::SourceLocationHasMacro(SL, Rewrite, "start");
+
+ ASTContext* const ASTC = MR.Context;
+
+ std::string NDNameString = ND->getNameAsString();
+
+ FullSourceLoc FSL = ASTC->getFullLoc(SL);
+
+ for (auto &iter : ExternObjInfoProto)
+ {
+ if (iter.XObjNameStr == NDNameString)
+ {
+ IsNewEntry = false;
+
+ if (iter.XObjFID != FSL.getFileID())
+ {
+ iter.HasMoreThanOneDefinition = true;
+ }
+ }
+ }
+
+ if (IsNewEntry)
+ {
+ ExternObjInfo Temp = {SL, SL.printToString(*MR.SourceManager), FSL, NDNameString, FSL.getFileID(), false};
+ ExternObjInfoProto.push_back(Temp);
+ }
+ }
+ }
+
+ virtual void onEndOfTranslationUnit()
+ {
+ for (auto &iter : ExternObjInfoProto)
+ {
+ if (iter.HasMoreThanOneDefinition)
+ {
+#if 0
+ std::cout << "8.8 : " << "External function or object (" + iter.XObjNameStr + ") is defined in more than one file: " << std::endl;
+ std::cout << iter.XObjSLStr << "\n" << std::endl;
+
+ XMLDocOut.XMLAddNode(iter.XObjFSL, iter.XObjSL, "8.8", "External function or object (" + iter.XObjNameStr + ") is defined in more than one file: ");
+#endif
+ }
+ }
+ }
+
+private:
+ struct ExternObjInfo
+ {
+ ExternObjInfo(SourceLocation iXObjSL, std::string iXObjSLStr, FullSourceLoc iXObjFSL, std::string iXObjNameStr, FileID iXObjFID , bool iHasMoreThanOneDefinition)
+ {
+ XObjSL = iXObjSL;
+ XObjSLStr = iXObjSLStr;
+ XObjFSL = iXObjFSL;
+ XObjNameStr = iXObjNameStr;
+ XObjFID = iXObjFID;
+ HasMoreThanOneDefinition = iHasMoreThanOneDefinition;
+ }
+
+ SourceLocation XObjSL;
+ std::string XObjSLStr;
+ FullSourceLoc XObjFSL;
+ std::string XObjNameStr;
+ FileID XObjFID;
+ bool HasMoreThanOneDefinition;
+ };
+
+ std::vector<ExternObjInfo> ExternObjInfoProto;
+
+ bool IsNewEntry;
+
+ Rewriter &Rewrite;
+};
+/**********************************************************************************************************************/
+/**********************************************************************************************************************/
+/**********************************************************************************************************************/
+/**********************************************************************************************************************/
+/**********************************************************************************************************************/
/**********************************************************************************************************************/
/**********************************************************************************************************************/
/**********************************************************************************************************************/
@@ -3577,7 +3688,7 @@ public:
HandlerForCF145(R), HandlerForCF146(R), HandlerForCF147(R), HandlerForCF148(R), HandlerForSwitch154(R), HandlerForPTC111(R), \
HandlerForCSE137(R), HandlerForDCDF810(R), HandlerForFunction165(R), HandlerForFunction1652(R), HandlerForPointer171(R), \
HandlerForPointer1723(R), HandlerForPointer174(R), HandlerForPointer175(R), HandlerForTypes61(R), HandlerForSU181(R), \
- HandlerForMCPTCCSTYLE(R), HandlerForATC101(R), HandlerForIdent5(R), HandlerForDCDF87(R) {
+ HandlerForMCPTCCSTYLE(R), HandlerForATC101(R), HandlerForIdent5(R), HandlerForDCDF87(R), HandlerForDCDF88(R) {
/*forstmts whithout a compound statement.*/
Matcher.addMatcher(forStmt(unless(hasDescendant(compoundStmt()))).bind("mcfor"), &HandlerForCmpless);
@@ -3762,7 +3873,10 @@ public:
Matcher.addMatcher(recordDecl().bind("ident5record"), &HandlerForIdent5);
- Matcher.addMatcher(declRefExpr(allOf(hasAncestor(functionDecl().bind("mcdcdf87daddy")), to(varDecl(unless(hasAncestor(functionDecl()))).bind("mcdcdf87origin")))).bind("mcdcdfobj"), &HandlerForDCDF87);
+ Matcher.addMatcher(declRefExpr(allOf(hasAncestor(functionDecl().bind("mcdcdf87daddy")), \
+ to(varDecl(unless(hasAncestor(functionDecl()))).bind("mcdcdf87origin")))).bind("mcdcdfobj"), &HandlerForDCDF87);
+
+ Matcher.addMatcher(namedDecl(hasExternalFormalLinkage()).bind("mcdcdf88"), &HandlerForDCDF88);
}
void HandleTranslationUnit(ASTContext &Context) override {
@@ -3828,6 +3942,7 @@ private:
MCATC101 HandlerForATC101;
MCIdent5 HandlerForIdent5;
MCDCDF87 HandlerForDCDF87;
+ MCDCDF88 HandlerForDCDF88;
MatchFinder Matcher;
};
/**********************************************************************************************************************/