Skip to content

Commit

Permalink
aplly cpplint
Browse files Browse the repository at this point in the history
  • Loading branch information
IngeniariusSoftware committed Jul 11, 2022
1 parent 3aba856 commit 1ffdc71
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 21 deletions.
6 changes: 5 additions & 1 deletion project/src/transpiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ set(SOURCE_FILES
aliases.h
tracer.h
process_variables.h
enumdecl.h
enum_manager.h

# Sources
main.cpp
Expand All @@ -47,7 +49,9 @@ set(SOURCE_FILES
recorddecl.cpp
record_manager.cpp
tracer.cpp
process_variables.cpp)
process_variables.cpp
enumdecl.cpp
enum_manager.cpp)

# add_executable(recvisitor main.cpp)
add_executable(c2eo ${SOURCE_FILES})
Expand Down
2 changes: 1 addition & 1 deletion project/src/transpiler/analyzers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void EnumDeclAnalyzer::run(const MatchFinder::MatchResult &result) {
if (context == nullptr) {
context = result.Context;
}
const auto *ED = result.Nodes.getNodeAs<EnumDecl>("enumDecl");
const auto *ED = result.Nodes.getNodeAs<clang::EnumDecl>("enumDecl");
if (ED == nullptr) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions project/src/transpiler/analyzers.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class DeclBaseVarGlobalMemoryAnalyzer
const clang::ast_matchers::MatchFinder::MatchResult &result) override;
};

#endif // PROJECT_SRC_TRANSPILER_ANALYZERS_H_
class EnumDeclAnalyzer
: public clang::ast_matchers::MatchFinder::MatchCallback {
public:
Expand All @@ -85,4 +84,4 @@ class EnumDeclAnalyzer
const clang::ast_matchers::MatchFinder::MatchResult &result) override;
};

#endif // C2EO_SRC_TRANSPILER_ANALYZERS_H_
#endif // PROJECT_SRC_TRANSPILER_ANALYZERS_H_
26 changes: 25 additions & 1 deletion project/src/transpiler/enum_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
#include "enum_manager.h"
/*
* The MIT License (MIT)
*
* Copyright (c) 2021-2022 c2eo team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#include "src/transpiler/enum_manager.h"

EnumType EnumManager::Add(const clang::EnumDecl *id, std::string name,
size_t size,
Expand Down
35 changes: 30 additions & 5 deletions project/src/transpiler/enum_manager.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
#ifndef C2EO_ENUM_MANAGER_H
#define C2EO_ENUM_MANAGER_H
/*
* The MIT License (MIT)
*
* Copyright (c) 2021-2022 c2eo team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#ifndef PROJECT_SRC_TRANSPILER_ENUM_MANAGER_H_
#define PROJECT_SRC_TRANSPILER_ENUM_MANAGER_H_

#include <cstdint>
#include <string>
#include <utility>
#include <vector>

#include "clang/AST/Decl.h"
#include "eo_object.h"
#include "memory_manager.h"
#include "src/transpiler/eo_object.h"
#include "src/transpiler/memory_manager.h"

class EnumConstantType {
public:
Expand All @@ -34,4 +59,4 @@ class EnumManager {
std::vector<EnumType> enum_types;
};

#endif // C2EO_ENUM_MANAGER_H
#endif // PROJECT_SRC_TRANSPILER_ENUM_MANAGER_H_
34 changes: 30 additions & 4 deletions project/src/transpiler/enumdecl.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
#include "enumdecl.h"
/*
* The MIT License (MIT)
*
* Copyright (c) 2021-2022 c2eo team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#include "src/transpiler/enumdecl.h"

#include <algorithm>
#include <string>
#include <vector>

#include "transpile_helper.h"
#include "unit_transpiler.h"
#include "vardecl.h"
#include "src/transpiler/transpile_helper.h"
#include "src/transpiler/unit_transpiler.h"
#include "src/transpiler/vardecl.h"

EnumType ProcessEnumDecl(const clang::EnumDecl *ED) {
if (ED == nullptr) {
Expand Down
32 changes: 28 additions & 4 deletions project/src/transpiler/enumdecl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
#ifndef C2EO_ENUMDECL_H
#define C2EO_ENUMDECL_H
/*
* The MIT License (MIT)
*
* Copyright (c) 2021-2022 c2eo team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#ifndef PROJECT_SRC_TRANSPILER_ENUMDECL_H_
#define PROJECT_SRC_TRANSPILER_ENUMDECL_H_

#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
Expand All @@ -8,9 +32,9 @@
#include "clang/Frontend/FrontendActions.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
#include "enum_manager.h"
#include "llvm/Support/CommandLine.h"
#include "src/transpiler/enum_manager.h"

EnumType ProcessEnumDecl(const clang::EnumDecl *ED);

#endif // C2EO_ENUMDECL_H
#endif // PROJECT_SRC_TRANSPILER_ENUMDECL_H_
1 change: 1 addition & 0 deletions project/src/transpiler/matchers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "src/transpiler/matchers.h"

using clang::ast_matchers::DeclarationMatcher;
using clang::ast_matchers::enumDecl;
using clang::ast_matchers::functionDecl;
using clang::ast_matchers::MatchFinder;
using clang::ast_matchers::recordDecl;
Expand Down
5 changes: 2 additions & 3 deletions project/src/transpiler/transpile_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ using clang::DeclRefExpr;
using clang::DeclStmt;
using clang::DefaultStmt;
using clang::DoStmt;
using clang::EnumConstantDecl;
using clang::Expr;
using clang::FloatingLiteral;
using clang::ForStmt;
Expand Down Expand Up @@ -133,6 +134,7 @@ EOObject GetCaseCondEOObject(const vector<const Expr *> &all_cases,
const EOObject &switch_exp, size_t i);

extern UnitTranspiler transpiler;
extern ASTContext *context;

EOObject GetFunctionBody(const clang::FunctionDecl *FD) {
if (!FD->hasBody()) {
Expand Down Expand Up @@ -1203,7 +1205,6 @@ EOObject GetSeqForBodyEOObject(const Stmt *p_stmt) {
}

uint64_t GetTypeSize(QualType qual_type) {
extern ASTContext *context;
const clang::Type *type_ptr = qual_type.getTypePtr();
TypeInfo type_info = context->getTypeInfo(type_ptr);
uint64_t type_size = type_info.Width;
Expand All @@ -1219,7 +1220,6 @@ uint64_t GetTypeSize(QualType qual_type) {
}

std::string GetPostfix(QualType qual_type) {
extern ASTContext *context;
const clang::Type *type_ptr = qual_type.getTypePtr();
TypeInfo type_info = context->getTypeInfo(type_ptr);
uint64_t type_size = type_info.Width;
Expand Down Expand Up @@ -1255,7 +1255,6 @@ std::string GetPostfix(QualType qual_type) {
}

std::string GetTypeName(QualType qual_type) {
extern ASTContext *context;
const clang::Type *type_ptr = qual_type.getTypePtr();
TypeInfo type_info = context->getTypeInfo(type_ptr);
uint64_t type_size = type_info.Width;
Expand Down

0 comments on commit 1ffdc71

Please sign in to comment.