Skip to content

Commit

Permalink
clang-tidy for all targets
Browse files Browse the repository at this point in the history
  • Loading branch information
SatyaRanjanDas-tomtom committed Nov 12, 2024
1 parent 431d7f9 commit 62387c9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(cppparser)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
# set(CMAKE_CXX_CLANG_TIDY clang-tidy --config-file=${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy)
set(CLANG_TIDY_COMMAND "clang-tidy" "--config-file=${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy")

if(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd\"4996\"")
Expand Down
1 change: 1 addition & 0 deletions cppast/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ target_include_directories(cppast
PUBLIC
include
)
set_target_properties(cppast PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")

add_subdirectory(test)
1 change: 0 additions & 1 deletion cppparser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,4 @@ target_link_libraries(cppparser
cppparser_lex_and_yacc
)

set(CLANG_TIDY_COMMAND "clang-tidy" "--config-file=${CMAKE_CURRENT_SOURCE_DIR}/../.clang-tidy")
set_target_properties(cppparser PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
1 change: 1 addition & 0 deletions cppwriter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ target_link_libraries(cppwriter
PUBLIC
cppast
)
set_target_properties(cppwriter PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
10 changes: 5 additions & 5 deletions cppwriter/src/cppwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace cppcodegen {

namespace {

static void emitAttribute(std::uint32_t attr, std::ostream& stm)
static void EmitAttribute(std::uint32_t attr, std::ostream& stm)
{
if (attr & cppast::CppIdentifierAttrib::STATIC)
stm << "static ";
Expand All @@ -28,7 +28,7 @@ static void emitAttribute(std::uint32_t attr, std::ostream& stm)
stm << "mutable ";
}

static void emitTypeModifier(const cppast::CppTypeModifier& modifier, std::ostream& stm)
static void EmitTypeModifier(const cppast::CppTypeModifier& modifier, std::ostream& stm)
{
std::uint8_t constBit = 0;
for (constBit = 0; constBit < modifier.ptrLevel_; ++constBit)
Expand Down Expand Up @@ -297,15 +297,15 @@ void CppWriter::emitUsingNamespace(const cppast::CppUsingNamespaceDecl& usingNsO
void CppWriter::emitVarType(const cppast::CppVarType& varTypeObj, std::ostream& stm) const
{
const auto attr = varTypeObj.typeAttr() | (IsConst(varTypeObj) ? cppast::CppIdentifierAttrib::CONST : 0);
emitAttribute(attr, stm);
EmitAttribute(attr, stm);
if (varTypeObj.compound())
emit(*varTypeObj.compound(), stm, CppIndent(), true);
else
stm << varTypeObj.baseType();
const auto& origTypeModifier = varTypeObj.typeModifier();
const cppast::CppTypeModifier typeModifier {
origTypeModifier.refType_, origTypeModifier.ptrLevel_, origTypeModifier.constBits_ & ~1};
emitTypeModifier(typeModifier, stm);
EmitTypeModifier(typeModifier, stm);
if (varTypeObj.parameterPack())
stm << "...";
}
Expand Down Expand Up @@ -378,7 +378,7 @@ void CppWriter::emitVarList(const cppast::CppVarList& varListObj, std::ostream&
{
stm << ", ";
const auto& decl = varDeclList[i];
emitTypeModifier(decl, stm);
EmitTypeModifier(decl, stm);
emitVarDecl(stm, decl, false);
}

Expand Down

0 comments on commit 62387c9

Please sign in to comment.