Skip to content

Commit

Permalink
Merge pull request #651 from andreasfertig/codeHygiene
Browse files Browse the repository at this point in the history
Various cleanups for better code hygiene.
  • Loading branch information
andreasfertig committed Jun 28, 2024
2 parents bc598a4 + cbb9bae commit 617af1c
Show file tree
Hide file tree
Showing 24 changed files with 208 additions and 514 deletions.
6 changes: 0 additions & 6 deletions ASTHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ UnaryOperator* Not(const Expr* stmt)
}
//-----------------------------------------------------------------------------

UnaryOperator* Not(const VarDecl* stmt)
{
return mkUnaryOperator(mkDeclRefExpr(stmt), UO_LNot, stmt->getType());
}
//-----------------------------------------------------------------------------

static UnaryOperator* mkReference(Expr* e, QualType t)
{
return mkUnaryOperator(e, UO_AddrOf, t);
Expand Down
1 change: 0 additions & 1 deletion ASTHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ BreakStmt* Break();
LabelStmt* Label(std::string_view name);
GotoStmt* Goto(std::string_view labelName);
UnaryOperator* Not(const Expr* stmt);
UnaryOperator* Not(const VarDecl* stmt);
UnaryOperator* Ref(const Expr* e);
UnaryOperator* Ref(const ValueDecl* d);
UnaryOperator* Dref(const Expr* stmt);
Expand Down
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,9 @@ if(INSIGHTS_COVERAGE)
endif()

else() # Clang
find_program(LCOV_BIN llvm-cov)
find_program(PROFDATA_BIN llvm-profdata)
llvm_config(LLVM_BINDIR "--bindir")
find_program(LCOV_BIN llvm-cov PATHS ${LLVM_BINDIR})
find_program(PROFDATA_BIN llvm-profdata PATHS ${LLVM_BINDIR})
# find_package_handle_standard_args(llvm-lcov
# REQUIRED_VARS LCOV_BIN PROFDATA_BIN
# )
Expand All @@ -806,13 +807,15 @@ if(INSIGHTS_COVERAGE)

# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
add_custom_target(coverage
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/llvm-coverage.py --insights ${CMAKE_CURRENT_BINARY_DIR}/insights --llvm-prof-dir=${CMAKE_CURRENT_BINARY_DIR}/llvmprof/ --format=text --output=${CMAKE_CURRENT_BINARY_DIR}/filtered.info
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/llvm-coverage.py --insights ${CMAKE_CURRENT_BINARY_DIR}/insights --llvm-prof-dir=${CMAKE_CURRENT_BINARY_DIR}/llvmprof/ --format=text --output=${CMAKE_CURRENT_BINARY_DIR}/filtered.info --llvm-cov ${LCOV_BIN} --llvm-prof ${PROFDATA_BIN}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/insights ${CMAKE_CURRENT_SOURCE_DIR}/tests/runTest.py
COMMENT "Running code coverage analysis" VERBATIM
)

add_custom_target(coverage-html
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/llvm-coverage.py --insights ${CMAKE_CURRENT_BINARY_DIR}/insights --llvm-prof-dir=${CMAKE_CURRENT_BINARY_DIR}/llvmprof/ --format=html --output=${CMAKE_CURRENT_BINARY_DIR}/filtered.html
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/llvm-coverage.py --insights
${CMAKE_CURRENT_BINARY_DIR}/insights --llvm-prof-dir=${CMAKE_CURRENT_BINARY_DIR}/llvmprof/ --format=lcov --output=${CMAKE_CURRENT_BINARY_DIR}/filtered.lcov --llvm-cov ${LCOV_BIN} --llvm-prof ${PROFDATA_BIN}
COMMAND genhtml ${CMAKE_CURRENT_BINARY_DIR}/filtered.lcov --demangle-cpp --output-directory ${CMAKE_CURRENT_BINARY_DIR}/out --keep-going
COMMENT "Generating code coverage HTML" VERBATIM
)

Expand Down
3 changes: 1 addition & 2 deletions CfrontCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,7 @@ void CfrontCodeGenerator::InsertArg(const CXXRecordDecl* stmt)
// CodeGenerator::InsertArg(typedefDecl);

// insert member functions except for the special member functions and classes defined inside this class
OnceTrue firstRecordDecl{};
for(const auto* d : stmt->decls()) {
for(OnceTrue firstRecordDecl{}; const auto* d : stmt->decls()) {
if((isa<CXXRecordDecl>(d) and firstRecordDecl) // skip the first record decl which are ourselves
or (stmt->isLambda() and isa<CXXDestructorDecl>(d)) // skip dtor for lambdas
or isa<FieldDecl>(d) // skip fields
Expand Down
9 changes: 0 additions & 9 deletions ClangCompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#define IS_CLANG_NEWER_THAN(major) (CLANG_VERSION_MAJOR > (major))
//-----------------------------------------------------------------------------

#include "clang/AST/ExprCXX.h"
//-----------------------------------------------------------------------------

namespace clang::insights {

template<unsigned int MAJOR>
Expand All @@ -32,12 +29,6 @@ struct IsClangNewerThan
// inline constexpr bool IsClangNewerThan8 = IsClangNewerThan<8>::value;
//-----------------------------------------------------------------------------

inline auto* GetTemporary(const MaterializeTemporaryExpr* stmt)
{
return stmt->getSubExpr();
}
//-----------------------------------------------------------------------------

} // namespace clang::insights

#endif /* INSIGHTS_CLANG_COMPAT_H */
Loading

0 comments on commit 617af1c

Please sign in to comment.