Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.14)
project(armor)
set(TOOL_VERSION "0.6.9")
set(TOOL_VERSION "0.7.1")
set(TOOL_DOCS_URL "https://github.com/qualcomm/armor/blob/main/README.md")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem /usr/include/c++/11 -isystem /usr/include/x86_64-linux-gnu/c++/11")

execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE DETECTED_GCC_VERSION
Expand Down Expand Up @@ -47,15 +49,16 @@ llvm_map_components_to_libnames(LLVM_LIBS
)

add_definitions(-DTOOL_VERSION="${TOOL_VERSION}")
add_definitions(-DTOOL_DOCS_URL="${TOOL_DOCS_URL}")

add_subdirectory(src/common)
add_subdirectory(src/alpha)
add_subdirectory(src/beta)
add_subdirectory(src/armor)

add_subdirectory(src/tests/alpha/src)
add_subdirectory(src/tests/beta/src)
add_subdirectory(src/tests/armor/src)
add_subdirectory(src/tests/alpha)
add_subdirectory(src/tests/beta)
add_subdirectory(src/tests/armor)
add_subdirectory(src/tests/common)


Expand Down
153 changes: 0 additions & 153 deletions src/alpha/include/ast_normalized_context.hpp

This file was deleted.

66 changes: 14 additions & 52 deletions src/alpha/include/astnormalizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,40 @@
#pragma once

#include "clang/AST/ASTContext.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Tooling/Tooling.h"

#include "node.hpp"
#include "ast_normalized_context.hpp"
#include "session.hpp"
#include "tree_builder.hpp"
#include "preprocesor.hpp"

namespace alpha{

class ASTNormalize : public clang::RecursiveASTVisitor<ASTNormalize> {
public:

alpha::APISession* session;
ASTNormalizedContext* context;
clang::ASTContext *clangContext;

alpha::TreeBuilder treeBuilder;

ASTNormalize(alpha::APISession* session, alpha::ASTNormalizedContext* context, clang::ASTContext* clangContext);

bool TraverseNamespaceDecl(clang::NamespaceDecl *Decl);
bool TraverseRecordDecl(clang::RecordDecl *Decl);
bool TraverseCXXRecordDecl(clang::CXXRecordDecl *Decl);
bool TraverseCXXConstructorDecl(clang::CXXConstructorDecl *Decl);
bool TraverseCXXMethodDecl(clang::CXXMethodDecl *Decl);
bool TraverseFunctionTemplateDecl(clang::FunctionTemplateDecl *Decl);
bool TraverseEnumDecl(clang::EnumDecl *Decl);
bool TraverseFunctionDecl(clang::FunctionDecl *Decl);
bool TraverseTypeAliasDecl(clang::TypeAliasDecl *Decl);
bool TraverseVarDecl(clang::VarDecl *Decl);
bool TraverseFieldDecl(clang::FieldDecl *Decl);
bool TraverseTypedefDecl(clang::TypedefDecl *Decl);
bool TraverseClassTemplateDecl(clang::ClassTemplateDecl *Decl);
bool TraverseClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl *Decl);
bool TraverseClassTemplatePartialSpecializationDecl(clang::ClassTemplatePartialSpecializationDecl *Decl);

bool VisitNamespaceDecl(clang::NamespaceDecl *Decl);
bool VisitRecordDecl(clang::RecordDecl *Decl);
bool VisitCXXRecordDecl(clang::CXXRecordDecl *Decl);
bool VisitEnumDecl(clang::EnumDecl *Decl);
bool VisitFieldDecl(clang::FieldDecl *Decl);
bool VisitFunctionDecl(clang::FunctionDecl *Decl);
bool VisitTypeAliasDecl(clang::TypeAliasDecl *Decl);
bool VisitVarDecl(clang::VarDecl *Decl);
bool VisitTypedefDecl(clang::TypedefDecl *Decl);
};
namespace armor { namespace alpha {

class ASTNormalizeConsumer : public clang::ASTConsumer {
public:
alpha::APISession* session;
alpha::ASTNormalizedContext* context;
ASTNormalize *visitor;
ASTNormalizeConsumer(alpha::APISession* session, alpha::ASTNormalizedContext* context);
armor::APISession* session;
armor::ASTNormalizedContext* context;
ASTNormalizeConsumer(armor::APISession* session, armor::ASTNormalizedContext* context);
void HandleTranslationUnit(clang::ASTContext &Context) override;
};


class NormalizeAction : public clang::ASTFrontendAction {
public:
alpha::APISession* session;
ASTNormalizedContext* context;
NormalizeAction(alpha::APISession* session, alpha::ASTNormalizedContext* context);
armor::APISession* session;
armor::ASTNormalizedContext* context;
NormalizeAction(armor::APISession* session, armor::ASTNormalizedContext* context);
std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &, clang::StringRef) override;
};

class NormalizeActionFactory : public clang::tooling::FrontendActionFactory {
public:
alpha::APISession* session;
armor::APISession* session;
const std::string& fileName;
explicit NormalizeActionFactory(alpha::APISession* session, const std::string& fileName);
explicit NormalizeActionFactory(armor::APISession* session, const std::string& fileName);
std::unique_ptr<clang::FrontendAction> create() override;
};

}
std::unique_ptr<clang::tooling::FrontendActionFactory>
createNormalizeActionFactory(armor::APISession* session, const std::string& fileName);

} } // namespace armor::alpha
12 changes: 8 additions & 4 deletions src/alpha/include/diffengine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
// SPDX-License-Identifier: BSD-3-Clause
#pragma once

#include "node.hpp"
#include "ast_normalized_context.hpp"
#include <nlohmann/json.hpp>

namespace armor { namespace alpha {

nlohmann::json diffTrees(
const alpha::ASTNormalizedContext* context1,
const alpha::ASTNormalizedContext* context2
);
const armor::ASTNormalizedContext* context1,
const armor::ASTNormalizedContext* context2
);

} } // namespace armor::alpha
4 changes: 4 additions & 0 deletions src/alpha/include/header_processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "comm_def.hpp"
#include "session.hpp"

namespace armor { namespace alpha {

PARSING_STATUS processHeaderPairAlpha(const std::string& projectRoot1,
const std::string& file1,
const std::string& projectRoot2,
Expand All @@ -15,3 +17,5 @@ PARSING_STATUS processHeaderPairAlpha(const std::string& projectRoot1,
const std::vector<std::string>& IncludePaths,
const std::vector<std::string>& macroFlags,
const LANG_OPTIONS lang);

} } // namespace armor::alpha
32 changes: 0 additions & 32 deletions src/alpha/include/node.hpp

This file was deleted.

15 changes: 7 additions & 8 deletions src/alpha/include/preprocesor.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
// SPDX-License-Identifier: BSD-3-Clause
#include "clang/AST/ASTContext.h"
#pragma once

#include "clang/Basic/SourceManager.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/PPCallbacks.h"

#include "node.hpp"
#include "ast_normalized_context.hpp"

namespace alpha {
namespace armor { namespace alpha {

class ASTNormalizerPreprocessor : public clang::PPCallbacks {

public:

ASTNormalizerPreprocessor(clang::SourceManager* SM, ASTNormalizedContext* context);
ASTNormalizerPreprocessor(clang::SourceManager* SM, armor::ASTNormalizedContext* context);

void InclusionDirective(
clang::SourceLocation HashLoc,
Expand All @@ -27,11 +26,11 @@ class ASTNormalizerPreprocessor : public clang::PPCallbacks {
clang::StringRef RelativePath,
const clang::Module *Imported,
clang::SrcMgr::CharacteristicKind FileType);

private:

clang::SourceManager* SM;
ASTNormalizedContext* context;
armor::ASTNormalizedContext* context;
};

}
} } // namespace armor::alpha
Loading
Loading