Skip to content

Commit

Permalink
Merge pull request #876 from mull-project/namespace
Browse files Browse the repository at this point in the history
cxx-frontend: namespace everything under mull::cxx
  • Loading branch information
stanislaw committed Jun 8, 2021
2 parents 78ffb4a + 90c7f24 commit dce12ab
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 5 deletions.
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ASTInstrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

#include <sstream>

namespace mull {
namespace cxx {

void ASTInstrumentation::instrumentTranslationUnit() {
/// Create an external getenv() declaration within extern "C" {} block.
clang::LinkageSpecDecl *cLinkageSpecDecl =
Expand Down Expand Up @@ -115,3 +118,6 @@ clang::FunctionDecl *ASTInstrumentation::createGetEnvFuncDecl(clang::DeclContext

return getEnvFuncDecl;
}

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ASTInstrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class FunctionDecl;
class Sema;
} // namespace clang

namespace mull {
namespace cxx {

class ASTNodeFactory;

class ASTInstrumentation {
Expand All @@ -27,3 +30,6 @@ class ASTInstrumentation {
private:
clang::FunctionDecl *createGetEnvFuncDecl(clang::DeclContext *declContext);
};

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ASTMutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include <clang/AST/Expr.h>

namespace mull {
namespace cxx {

class ASTMutation {
public:
virtual void performMutation(ASTMutationPoint &mutation, ASTMutator &mutator) = 0;
Expand Down Expand Up @@ -93,3 +96,6 @@ class ReplaceNumericInitAssignmentMutation : public ASTMutation {
mutator.performReplaceNumericInitAssignmentMutation(mutation, *this);
}
};

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ASTMutationPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include <sstream>

namespace mull {
namespace cxx {

ASTMutationPoint::ASTMutationPoint(std::unique_ptr<ASTMutation> mutation,
mull::MutatorKind mutationType, std::string mutationIdentifier,
clang::Stmt *toBeMutatedStmt, std::string sourceFilePath,
Expand All @@ -25,3 +28,6 @@ ASTMutationPoint::ASTMutationPoint(std::unique_ptr<ASTMutation> mutation,
void ASTMutationPoint::performMutation(ASTMutator &mutator) {
mutation->performMutation(*this, mutator);
}

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ASTMutationPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace clang {
class Stmt;
}

namespace mull {
namespace cxx {

class ASTMutationPoint {
public:
std::unique_ptr<ASTMutation> mutation;
Expand All @@ -27,3 +30,6 @@ class ASTMutationPoint {

void performMutation(ASTMutator &mutator);
};

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ASTMutationsSearchVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <clang/Basic/SourceManager.h>
#include <clang/Lex/Lexer.h>

namespace mull {
namespace cxx {

std::vector<std::unique_ptr<ASTMutationPoint>> &ASTMutationsSearchVisitor::getAstMutations() {
return astMutations;
}
Expand Down Expand Up @@ -271,3 +274,6 @@ ASTMutationsSearchVisitor::getBeginEndMutationLocation(clang::Stmt *stmt,

return std::make_pair(updatedMutationLocation, sourceLocationEndActual);
}

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ASTMutationsSearchVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include <clang/AST/RecursiveASTVisitor.h>

namespace mull {
namespace cxx {

class MutationMap;

class ASTMutationsSearchVisitor : public clang::RecursiveASTVisitor<ASTMutationsSearchVisitor> {
Expand Down Expand Up @@ -34,3 +37,6 @@ class ASTMutationsSearchVisitor : public clang::RecursiveASTVisitor<ASTMutations
getBeginEndMutationLocation(clang::Stmt *stmt, clang::SourceLocation mutationLocation,
bool locationIsExpression);
};

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ASTMutator.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

namespace mull {
namespace cxx {

class ASTMutationPoint;
class BinaryMutation;
class RemoveVoidMutation;
Expand Down Expand Up @@ -34,3 +37,6 @@ class ASTMutator {
ASTMutationPoint &mutation,
ReplaceNumericInitAssignmentMutation &replaceNumericInitAssignmentMutation) = 0;
};

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ASTNodeFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <clang/AST/ASTContext.h>
#include <clang/AST/Attr.h>

namespace mull {
namespace cxx {

const clang::SourceLocation NULL_LOCATION;

clang::FunctionDecl *ASTNodeFactory::createFunctionDecl(std::string name,
Expand Down Expand Up @@ -230,3 +233,6 @@ clang::QualType ASTNodeFactory::getConstantArrayType(clang::QualType type, unsig
type, llvm::APInt(32, size + 1), clang::ArrayType::Normal, /*IndexTypeQuals*/ 0);
#endif
}

} // namespace cxx
} // namespace mull
10 changes: 8 additions & 2 deletions tools/mull-cxx-frontend/src/ASTNodeFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
#include <clang/AST/Type.h>
#include <clang/Basic/Specifiers.h>

extern const clang::SourceLocation NULL_LOCATION;

namespace clang {
class SectionAttr;
}

namespace mull {
namespace cxx {

extern const clang::SourceLocation NULL_LOCATION;

class ASTNodeFactory {
clang::ASTContext &context;

Expand Down Expand Up @@ -55,3 +58,6 @@ class ASTNodeFactory {
clang::QualType getStringLiteralArrayType(clang::QualType type, unsigned size);
clang::QualType getConstantArrayType(clang::QualType type, unsigned size);
};

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ClangASTMutator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <clang/Basic/SourceLocation.h>
#include <llvm/Support/Casting.h>

namespace mull {
namespace cxx {

void ClangASTMutator::replaceExpression(clang::Expr *oldExpr, clang::Expr *newExpr,
std::string identifier) {
clang::ConditionalOperator *conditionalExpr =
Expand Down Expand Up @@ -151,3 +154,6 @@ clang::CallExpr *ClangASTMutator::createGetenvCallExpr(std::string identifier) {

return callExpr;
}

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/ClangASTMutator.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class IfStmt;
class Stmt;
} // namespace clang

namespace mull {
namespace cxx {

class ASTInstrumentation;
class ASTNodeFactory;

Expand All @@ -34,3 +37,6 @@ class ClangASTMutator {
std::string identifier);
clang::CallExpr *createGetenvCallExpr(std::string identifier);
};

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/MullASTMutator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <clang/AST/ASTContext.h>
#include <clang/AST/Expr.h>

namespace mull {
namespace cxx {

void MullASTMutator::instrumentTranslationUnit() {
instrumentation.instrumentTranslationUnit();
}
Expand Down Expand Up @@ -155,3 +158,6 @@ void MullASTMutator::performReplaceNumericInitAssignmentMutation(
mutation.beginLine,
mutation.beginColumn);
}

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/MullASTMutator.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class ASTContext;
class FunctionDecl;
} // namespace clang

namespace mull {
namespace cxx {

class MullASTMutator : public ASTMutator {
public:
MullASTMutator(clang::ASTContext &context, clang::Sema &sema)
Expand Down Expand Up @@ -41,3 +44,6 @@ class MullASTMutator : public ASTMutator {
ASTInstrumentation instrumentation;
ClangASTMutator clangAstMutator;
};

} // namespace cxx
} // namespace mull
9 changes: 6 additions & 3 deletions tools/mull-cxx-frontend/src/MullClangPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
using namespace clang;
using namespace llvm;

namespace {
namespace mull {
namespace cxx {

class MullASTConsumer : public ASTConsumer {
CompilerInstance &instance;
Expand Down Expand Up @@ -127,6 +128,8 @@ class MullAction : public PluginASTAction {
}
};

} // namespace
} // namespace cxx
} // namespace mull

static FrontendPluginRegistry::Add<MullAction> X("mull-cxx-frontend", "Mull: Prepare mutations");
static FrontendPluginRegistry::Add<mull::cxx::MullAction> X("mull-cxx-frontend",
"Mull: Prepare mutations");
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/MutationMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include <cassert>

namespace mull {
namespace cxx {

static const std::vector<MutationIdentifier> MUTATIONS_MAP({
{ "cxx_add_to_sub", mull::MutatorKind::CXX_AddToSub },
{ "cxx_sub_to_add", mull::MutatorKind::CXX_SubToAdd },
Expand Down Expand Up @@ -77,3 +80,6 @@ void MutationMap::setDefaultMutationsIfNotSpecified() {
usedMutatorSet.insert(mutationIdentifier.mutatorKind);
}
}

} // namespace cxx
} // namespace mull
6 changes: 6 additions & 0 deletions tools/mull-cxx-frontend/src/MutationMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include <unordered_map>

namespace mull {
namespace cxx {

struct MutationIdentifier {
std::string identifier;
mull::MutatorKind mutatorKind;
Expand All @@ -23,3 +26,6 @@ class MutationMap {
void addMutation(std::string identifier);
void setDefaultMutationsIfNotSpecified();
};

} // namespace cxx
} // namespace mull

0 comments on commit dce12ab

Please sign in to comment.