Skip to content

Commit

Permalink
setup clang-tidy and fix errors to conform to style
Browse files Browse the repository at this point in the history
  • Loading branch information
SatyaRanjanDas-tomtom committed Nov 12, 2024
1 parent aa2175d commit 431d7f9
Show file tree
Hide file tree
Showing 36 changed files with 382 additions and 376 deletions.
6 changes: 4 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Copyright (C) 2022 Satya Das and CppParser contributors
# SPDX-License-Identifier: MIT

Checks: '-*,readability-identifier-naming'
Checks: '-*,readability-identifier-naming,-readability-redundant-access-specifiers'
WarningsAsErrors: '*'

CheckOptions:
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.MethodCase, value: camelCase }
- { key: readability-identifier-naming.MethodCase, value: camelBack }
- { key: readability-identifier-naming.ClassMethodCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
- { key: readability-identifier-naming.GlobalFunctionCase, value: CamelCase }
- { key: readability-identifier-naming.VariableCase, value: camelBack }
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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)

if(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd\"4996\"")
Expand Down
2 changes: 1 addition & 1 deletion cppast/include/cppast/cpp_asm_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CppAsmBlock : public CppEntity
*
* @return Entire asm block including keyword asm.
*/
const std::string& Code() const
const std::string& code() const
{
return asm_;
}
Expand Down
2 changes: 1 addition & 1 deletion cppast/include/cppast/cpp_blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CppBlob : public CppEntity
CppBlob(std::string blob);

public:
const std::string& Blob() const
const std::string& blob() const
{
return blob_;
}
Expand Down
16 changes: 8 additions & 8 deletions cppast/include/cppast/cpp_compound.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class CppCompound : public CppEntity, public CppTemplatableEntity
{
return name_;
}
void name(std::string _name)
void name(std::string nameArg)
{
name_ = std::move(_name);
name_ = std::move(nameArg);
}

const std::string& apidecor() const
Expand All @@ -121,19 +121,19 @@ class CppCompound : public CppEntity, public CppTemplatableEntity
{
return inheritanceList_;
}
void inheritanceList(std::list<CppInheritanceInfo> _inheritanceList)
void inheritanceList(std::list<CppInheritanceInfo> inheritanceListArg)
{
inheritanceList_ = std::move(_inheritanceList);
inheritanceList_ = std::move(inheritanceListArg);
}

void addAttr(std::uint32_t _attr)
void addAttr(std::uint32_t attrArg)
{
attr_ |= _attr;
attr_ |= attrArg;
}

bool hasAttr(std::uint32_t _attr) const
bool hasAttr(std::uint32_t attrArg) const
{
return (attr_ & _attr) == _attr;
return (attr_ & attrArg) == attrArg;
}

private:
Expand Down
15 changes: 6 additions & 9 deletions cppast/include/cppast/cpp_compound_info_accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,31 @@
#ifndef EB6246DE_3216_42BA_AF41_B260CA71C4EE
#define EB6246DE_3216_42BA_AF41_B260CA71C4EE

// TODO: This file needs to be at least conformed to new coding style
// - Setup clang-tidy to achieve it.

#include "cppast/cpp_compound.h"

namespace cppast {

inline bool isNamespace(const CppCompound& compound)
inline bool IsNamespace(const CppCompound& compound)
{
return compound.compoundType() == CppCompoundType::NAMESPACE;
}
inline bool isClass(const CppCompound& compound)
inline bool IsClass(const CppCompound& compound)
{
return compound.compoundType() == CppCompoundType::CLASS;
}
inline bool isStruct(const CppCompound& compound)
inline bool IsStruct(const CppCompound& compound)
{
return compound.compoundType() == CppCompoundType::STRUCT;
}
inline bool isUnion(const CppCompound& compound)
inline bool IsUnion(const CppCompound& compound)
{
return compound.compoundType() == CppCompoundType::UNION;
}
inline bool isCppFile(const CppCompound& compound)
inline bool IsCppFile(const CppCompound& compound)
{
return compound.compoundType() == CppCompoundType::FILE;
}
inline bool isBlock(const CppCompound& compound)
inline bool IsBlock(const CppCompound& compound)
{
return compound.compoundType() == CppCompoundType::BLOCK;
}
Expand Down
4 changes: 2 additions & 2 deletions cppast/include/cppast/cpp_compound_utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ inline std::vector<const CppEntity*> GetAllOwnedEntities(const CppCompound& owne
*/
inline std::string FullName(const CppCompound& compound)
{
if (!isNamespaceLike(compound))
if (!IsNamespaceLike(compound))
return "";
if (compound.owner() && isNamespaceLike(*compound.owner()))
if (compound.owner() && IsNamespaceLike(*compound.owner()))
return FullName(*compound.owner()) + "::" + compound.name();
else
return compound.name();
Expand Down
4 changes: 2 additions & 2 deletions cppast/include/cppast/cpp_control_blocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class CppIfBlock : public CppControlBlockBase<CppEntityType::IF_BLOCK>
public:
CppIfBlock(std::unique_ptr<CppEntity> cond,
std::unique_ptr<CppEntity> body,
std::unique_ptr<CppEntity> _else = nullptr)
std::unique_ptr<CppEntity> elseArg = nullptr)
: CppControlBlockBase(std::move(cond), std::move(body))
, else_(std::move(_else))
, else_(std::move(elseArg))
{
}

Expand Down
102 changes: 51 additions & 51 deletions cppast/include/cppast/cpp_entity_info_accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,99 +11,99 @@

namespace cppast {

inline bool isFunction(const CppEntity& cppEntity)
inline bool IsFunction(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::FUNCTION;
}

inline bool isFunction(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsFunction(const std::unique_ptr<CppEntity>& cppEntity)
{
return isFunction(*cppEntity);
return IsFunction(*cppEntity);
}

inline bool isFunctionPtr(const CppEntity& cppEntity)
inline bool IsFunctionPtr(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::FUNCTION_PTR;
}

inline bool isFunctionPtr(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsFunctionPtr(const std::unique_ptr<CppEntity>& cppEntity)
{
return isFunctionPtr(*cppEntity);
return IsFunctionPtr(*cppEntity);
}

inline bool isFunctionLike(const CppEntity& cppEntity)
inline bool IsFunctionLike(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::FUNCTION || cppEntity.entityType() == CppEntityType::CONSTRUCTOR
|| cppEntity.entityType() == CppEntityType::DESTRUCTOR
|| cppEntity.entityType() == CppEntityType::TYPE_CONVERTER;
}

inline bool isFunctionLike(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsFunctionLike(const std::unique_ptr<CppEntity>& cppEntity)
{
return isFunctionLike(*cppEntity);
return IsFunctionLike(*cppEntity);
}

inline bool isDestructor(const CppEntity& cppEntity)
inline bool IsDestructor(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::DESTRUCTOR;
}

inline bool isDestructor(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsDestructor(const std::unique_ptr<CppEntity>& cppEntity)
{
return isDestructor(*cppEntity);
return IsDestructor(*cppEntity);
}

inline bool isEnum(const CppEntity& cppEntity)
inline bool IsEnum(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::ENUM;
}

inline bool isEnum(const std::unique_ptr<CppEntity> cppEntity)
inline bool IsEnum(const std::unique_ptr<CppEntity> cppEntity)
{
return isEnum(*cppEntity);
return IsEnum(*cppEntity);
}

inline bool isTypedefName(const CppEntity& cppEntity)
inline bool IsTypedefName(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::TYPEDEF_DECL;
}

inline bool isTypedefName(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsTypedefName(const std::unique_ptr<CppEntity>& cppEntity)
{
return isTypedefName(*cppEntity);
return IsTypedefName(*cppEntity);
}

inline bool isUsingDecl(const CppEntity& cppEntity)
inline bool IsUsingDecl(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::USING_DECL;
}

inline bool isUsingDecl(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsUsingDecl(const std::unique_ptr<CppEntity>& cppEntity)
{
return isUsingDecl(*cppEntity);
return IsUsingDecl(*cppEntity);
}

inline bool isCompound(const CppEntity& cppEntity)
inline bool IsCompound(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::COMPOUND;
}

inline bool isCompound(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsCompound(const std::unique_ptr<CppEntity>& cppEntity)
{
return isCompound(*cppEntity);
return IsCompound(*cppEntity);
}

inline bool isFwdClsDecl(const CppEntity& cppEntity)
inline bool IsFwdClsDecl(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::FORWARD_CLASS_DECL;
}

inline bool isFwdClsDecl(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsFwdClsDecl(const std::unique_ptr<CppEntity>& cppEntity)
{
return isFwdClsDecl(*cppEntity);
return IsFwdClsDecl(*cppEntity);
}

inline bool isNamespaceLike(const CppEntity& cppEntity)
inline bool IsNamespaceLike(const CppEntity& cppEntity)
{
const helper::CppEntityPtr<const CppCompound> compound = &cppEntity;
if (!compound)
Expand All @@ -115,74 +115,74 @@ inline bool isNamespaceLike(const CppEntity& cppEntity)
&& (compound->compoundType() <= CppCompoundType::UNION);
}

inline bool isNamespaceLike(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsNamespaceLike(const std::unique_ptr<CppEntity>& cppEntity)
{
return isNamespaceLike(*cppEntity);
return IsNamespaceLike(*cppEntity);
}

bool isClassLike(const CppEntity& cppEntity);
bool IsClassLike(const CppEntity& cppEntity);

inline bool isClassLike(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsClassLike(const std::unique_ptr<CppEntity>& cppEntity)
{
return isClassLike(*cppEntity);
return IsClassLike(*cppEntity);
}

inline bool isTypedefLike(const CppEntity& cppEntity)
inline bool IsTypedefLike(const CppEntity& cppEntity)
{
return (cppEntity.entityType() == CppEntityType::TYPEDEF_DECL)
|| (cppEntity.entityType() == CppEntityType::USING_DECL);
}

inline bool isTypedefLike(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsTypedefLike(const std::unique_ptr<CppEntity>& cppEntity)
{
return isTypedefLike(*cppEntity);
return IsTypedefLike(*cppEntity);
}

inline bool isPreProcessorType(const CppEntity& cppEntity)
inline bool IsPreProcessorType(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::PREPROCESSOR;
}

inline bool isPreProcessorType(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsPreProcessorType(const std::unique_ptr<CppEntity>& cppEntity)
{
return isPreProcessorType(*cppEntity);
return IsPreProcessorType(*cppEntity);
}

inline bool isVar(const CppEntity& cppEntity)
inline bool IsVar(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::VAR;
}

inline bool isVar(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsVar(const std::unique_ptr<CppEntity>& cppEntity)
{
return isVar(*cppEntity);
return IsVar(*cppEntity);
}

inline bool isVarList(const CppEntity& cppEntity)
inline bool IsVarList(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::VAR_LIST;
}

inline bool isVarList(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsVarList(const std::unique_ptr<CppEntity>& cppEntity)
{
return isVarList(*cppEntity);
return IsVarList(*cppEntity);
}

inline bool isExpr(const CppEntity& cppEntity)
inline bool IsExpr(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::EXPRESSION;
}

inline bool isExpr(const std::unique_ptr<CppEntity>& cppEntity)
inline bool IsExpr(const std::unique_ptr<CppEntity>& cppEntity)
{
return isExpr(*cppEntity);
return IsExpr(*cppEntity);
}

inline CppCompound* root(const CppEntity& cppEntity)
inline CppCompound* Root(const CppEntity& cppEntity)
{
if (cppEntity.owner() == nullptr)
return isCompound(cppEntity) ? const_cast<CppCompound*>(static_cast<const CppCompound*>(&cppEntity)) : nullptr;
return root(*cppEntity.owner());
return IsCompound(cppEntity) ? const_cast<CppCompound*>(static_cast<const CppCompound*>(&cppEntity)) : nullptr;
return Root(*cppEntity.owner());
}

} // namespace cppast
Expand Down
4 changes: 2 additions & 2 deletions cppast/include/cppast/cpp_forward_class_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class CppForwardClassDecl : public CppEntity, public CppTemplatableEntity
{
return attr_;
}
void addAttr(std::uint32_t _attr)
void addAttr(std::uint32_t attr)
{
attr_ |= _attr;
attr_ |= attr;
}

private:
Expand Down
Loading

0 comments on commit 431d7f9

Please sign in to comment.