Skip to content

Commit 431d7f9

Browse files
setup clang-tidy and fix errors to conform to style
1 parent aa2175d commit 431d7f9

36 files changed

+382
-376
lines changed

.clang-tidy

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Copyright (C) 2022 Satya Das and CppParser contributors
22
# SPDX-License-Identifier: MIT
33

4-
Checks: '-*,readability-identifier-naming'
4+
Checks: '-*,readability-identifier-naming,-readability-redundant-access-specifiers'
5+
WarningsAsErrors: '*'
56

67
CheckOptions:
78
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
8-
- { key: readability-identifier-naming.MethodCase, value: camelCase }
9+
- { key: readability-identifier-naming.MethodCase, value: camelBack }
10+
- { key: readability-identifier-naming.ClassMethodCase, value: CamelCase }
911
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
1012
- { key: readability-identifier-naming.GlobalFunctionCase, value: CamelCase }
1113
- { key: readability-identifier-naming.VariableCase, value: camelBack }

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ project(cppparser)
55

66
set(CMAKE_CXX_STANDARD 17)
77
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8+
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
9+
# set(CMAKE_CXX_CLANG_TIDY clang-tidy --config-file=${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy)
810

911
if(MSVC)
1012
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd\"4996\"")

cppast/include/cppast/cpp_asm_block.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CppAsmBlock : public CppEntity
3131
*
3232
* @return Entire asm block including keyword asm.
3333
*/
34-
const std::string& Code() const
34+
const std::string& code() const
3535
{
3636
return asm_;
3737
}

cppast/include/cppast/cpp_blob.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CppBlob : public CppEntity
2424
CppBlob(std::string blob);
2525

2626
public:
27-
const std::string& Blob() const
27+
const std::string& blob() const
2828
{
2929
return blob_;
3030
}

cppast/include/cppast/cpp_compound.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ class CppCompound : public CppEntity, public CppTemplatableEntity
103103
{
104104
return name_;
105105
}
106-
void name(std::string _name)
106+
void name(std::string nameArg)
107107
{
108-
name_ = std::move(_name);
108+
name_ = std::move(nameArg);
109109
}
110110

111111
const std::string& apidecor() const
@@ -121,19 +121,19 @@ class CppCompound : public CppEntity, public CppTemplatableEntity
121121
{
122122
return inheritanceList_;
123123
}
124-
void inheritanceList(std::list<CppInheritanceInfo> _inheritanceList)
124+
void inheritanceList(std::list<CppInheritanceInfo> inheritanceListArg)
125125
{
126-
inheritanceList_ = std::move(_inheritanceList);
126+
inheritanceList_ = std::move(inheritanceListArg);
127127
}
128128

129-
void addAttr(std::uint32_t _attr)
129+
void addAttr(std::uint32_t attrArg)
130130
{
131-
attr_ |= _attr;
131+
attr_ |= attrArg;
132132
}
133133

134-
bool hasAttr(std::uint32_t _attr) const
134+
bool hasAttr(std::uint32_t attrArg) const
135135
{
136-
return (attr_ & _attr) == _attr;
136+
return (attr_ & attrArg) == attrArg;
137137
}
138138

139139
private:

cppast/include/cppast/cpp_compound_info_accessor.h

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,31 @@
44
#ifndef EB6246DE_3216_42BA_AF41_B260CA71C4EE
55
#define EB6246DE_3216_42BA_AF41_B260CA71C4EE
66

7-
// TODO: This file needs to be at least conformed to new coding style
8-
// - Setup clang-tidy to achieve it.
9-
107
#include "cppast/cpp_compound.h"
118

129
namespace cppast {
1310

14-
inline bool isNamespace(const CppCompound& compound)
11+
inline bool IsNamespace(const CppCompound& compound)
1512
{
1613
return compound.compoundType() == CppCompoundType::NAMESPACE;
1714
}
18-
inline bool isClass(const CppCompound& compound)
15+
inline bool IsClass(const CppCompound& compound)
1916
{
2017
return compound.compoundType() == CppCompoundType::CLASS;
2118
}
22-
inline bool isStruct(const CppCompound& compound)
19+
inline bool IsStruct(const CppCompound& compound)
2320
{
2421
return compound.compoundType() == CppCompoundType::STRUCT;
2522
}
26-
inline bool isUnion(const CppCompound& compound)
23+
inline bool IsUnion(const CppCompound& compound)
2724
{
2825
return compound.compoundType() == CppCompoundType::UNION;
2926
}
30-
inline bool isCppFile(const CppCompound& compound)
27+
inline bool IsCppFile(const CppCompound& compound)
3128
{
3229
return compound.compoundType() == CppCompoundType::FILE;
3330
}
34-
inline bool isBlock(const CppCompound& compound)
31+
inline bool IsBlock(const CppCompound& compound)
3532
{
3633
return compound.compoundType() == CppCompoundType::BLOCK;
3734
}

cppast/include/cppast/cpp_compound_utility.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ inline std::vector<const CppEntity*> GetAllOwnedEntities(const CppCompound& owne
5151
*/
5252
inline std::string FullName(const CppCompound& compound)
5353
{
54-
if (!isNamespaceLike(compound))
54+
if (!IsNamespaceLike(compound))
5555
return "";
56-
if (compound.owner() && isNamespaceLike(*compound.owner()))
56+
if (compound.owner() && IsNamespaceLike(*compound.owner()))
5757
return FullName(*compound.owner()) + "::" + compound.name();
5858
else
5959
return compound.name();

cppast/include/cppast/cpp_control_blocks.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class CppIfBlock : public CppControlBlockBase<CppEntityType::IF_BLOCK>
4949
public:
5050
CppIfBlock(std::unique_ptr<CppEntity> cond,
5151
std::unique_ptr<CppEntity> body,
52-
std::unique_ptr<CppEntity> _else = nullptr)
52+
std::unique_ptr<CppEntity> elseArg = nullptr)
5353
: CppControlBlockBase(std::move(cond), std::move(body))
54-
, else_(std::move(_else))
54+
, else_(std::move(elseArg))
5555
{
5656
}
5757

cppast/include/cppast/cpp_entity_info_accessor.h

+51-51
Original file line numberDiff line numberDiff line change
@@ -11,99 +11,99 @@
1111

1212
namespace cppast {
1313

14-
inline bool isFunction(const CppEntity& cppEntity)
14+
inline bool IsFunction(const CppEntity& cppEntity)
1515
{
1616
return cppEntity.entityType() == CppEntityType::FUNCTION;
1717
}
1818

19-
inline bool isFunction(const std::unique_ptr<CppEntity>& cppEntity)
19+
inline bool IsFunction(const std::unique_ptr<CppEntity>& cppEntity)
2020
{
21-
return isFunction(*cppEntity);
21+
return IsFunction(*cppEntity);
2222
}
2323

24-
inline bool isFunctionPtr(const CppEntity& cppEntity)
24+
inline bool IsFunctionPtr(const CppEntity& cppEntity)
2525
{
2626
return cppEntity.entityType() == CppEntityType::FUNCTION_PTR;
2727
}
2828

29-
inline bool isFunctionPtr(const std::unique_ptr<CppEntity>& cppEntity)
29+
inline bool IsFunctionPtr(const std::unique_ptr<CppEntity>& cppEntity)
3030
{
31-
return isFunctionPtr(*cppEntity);
31+
return IsFunctionPtr(*cppEntity);
3232
}
3333

34-
inline bool isFunctionLike(const CppEntity& cppEntity)
34+
inline bool IsFunctionLike(const CppEntity& cppEntity)
3535
{
3636
return cppEntity.entityType() == CppEntityType::FUNCTION || cppEntity.entityType() == CppEntityType::CONSTRUCTOR
3737
|| cppEntity.entityType() == CppEntityType::DESTRUCTOR
3838
|| cppEntity.entityType() == CppEntityType::TYPE_CONVERTER;
3939
}
4040

41-
inline bool isFunctionLike(const std::unique_ptr<CppEntity>& cppEntity)
41+
inline bool IsFunctionLike(const std::unique_ptr<CppEntity>& cppEntity)
4242
{
43-
return isFunctionLike(*cppEntity);
43+
return IsFunctionLike(*cppEntity);
4444
}
4545

46-
inline bool isDestructor(const CppEntity& cppEntity)
46+
inline bool IsDestructor(const CppEntity& cppEntity)
4747
{
4848
return cppEntity.entityType() == CppEntityType::DESTRUCTOR;
4949
}
5050

51-
inline bool isDestructor(const std::unique_ptr<CppEntity>& cppEntity)
51+
inline bool IsDestructor(const std::unique_ptr<CppEntity>& cppEntity)
5252
{
53-
return isDestructor(*cppEntity);
53+
return IsDestructor(*cppEntity);
5454
}
5555

56-
inline bool isEnum(const CppEntity& cppEntity)
56+
inline bool IsEnum(const CppEntity& cppEntity)
5757
{
5858
return cppEntity.entityType() == CppEntityType::ENUM;
5959
}
6060

61-
inline bool isEnum(const std::unique_ptr<CppEntity> cppEntity)
61+
inline bool IsEnum(const std::unique_ptr<CppEntity> cppEntity)
6262
{
63-
return isEnum(*cppEntity);
63+
return IsEnum(*cppEntity);
6464
}
6565

66-
inline bool isTypedefName(const CppEntity& cppEntity)
66+
inline bool IsTypedefName(const CppEntity& cppEntity)
6767
{
6868
return cppEntity.entityType() == CppEntityType::TYPEDEF_DECL;
6969
}
7070

71-
inline bool isTypedefName(const std::unique_ptr<CppEntity>& cppEntity)
71+
inline bool IsTypedefName(const std::unique_ptr<CppEntity>& cppEntity)
7272
{
73-
return isTypedefName(*cppEntity);
73+
return IsTypedefName(*cppEntity);
7474
}
7575

76-
inline bool isUsingDecl(const CppEntity& cppEntity)
76+
inline bool IsUsingDecl(const CppEntity& cppEntity)
7777
{
7878
return cppEntity.entityType() == CppEntityType::USING_DECL;
7979
}
8080

81-
inline bool isUsingDecl(const std::unique_ptr<CppEntity>& cppEntity)
81+
inline bool IsUsingDecl(const std::unique_ptr<CppEntity>& cppEntity)
8282
{
83-
return isUsingDecl(*cppEntity);
83+
return IsUsingDecl(*cppEntity);
8484
}
8585

86-
inline bool isCompound(const CppEntity& cppEntity)
86+
inline bool IsCompound(const CppEntity& cppEntity)
8787
{
8888
return cppEntity.entityType() == CppEntityType::COMPOUND;
8989
}
9090

91-
inline bool isCompound(const std::unique_ptr<CppEntity>& cppEntity)
91+
inline bool IsCompound(const std::unique_ptr<CppEntity>& cppEntity)
9292
{
93-
return isCompound(*cppEntity);
93+
return IsCompound(*cppEntity);
9494
}
9595

96-
inline bool isFwdClsDecl(const CppEntity& cppEntity)
96+
inline bool IsFwdClsDecl(const CppEntity& cppEntity)
9797
{
9898
return cppEntity.entityType() == CppEntityType::FORWARD_CLASS_DECL;
9999
}
100100

101-
inline bool isFwdClsDecl(const std::unique_ptr<CppEntity>& cppEntity)
101+
inline bool IsFwdClsDecl(const std::unique_ptr<CppEntity>& cppEntity)
102102
{
103-
return isFwdClsDecl(*cppEntity);
103+
return IsFwdClsDecl(*cppEntity);
104104
}
105105

106-
inline bool isNamespaceLike(const CppEntity& cppEntity)
106+
inline bool IsNamespaceLike(const CppEntity& cppEntity)
107107
{
108108
const helper::CppEntityPtr<const CppCompound> compound = &cppEntity;
109109
if (!compound)
@@ -115,74 +115,74 @@ inline bool isNamespaceLike(const CppEntity& cppEntity)
115115
&& (compound->compoundType() <= CppCompoundType::UNION);
116116
}
117117

118-
inline bool isNamespaceLike(const std::unique_ptr<CppEntity>& cppEntity)
118+
inline bool IsNamespaceLike(const std::unique_ptr<CppEntity>& cppEntity)
119119
{
120-
return isNamespaceLike(*cppEntity);
120+
return IsNamespaceLike(*cppEntity);
121121
}
122122

123-
bool isClassLike(const CppEntity& cppEntity);
123+
bool IsClassLike(const CppEntity& cppEntity);
124124

125-
inline bool isClassLike(const std::unique_ptr<CppEntity>& cppEntity)
125+
inline bool IsClassLike(const std::unique_ptr<CppEntity>& cppEntity)
126126
{
127-
return isClassLike(*cppEntity);
127+
return IsClassLike(*cppEntity);
128128
}
129129

130-
inline bool isTypedefLike(const CppEntity& cppEntity)
130+
inline bool IsTypedefLike(const CppEntity& cppEntity)
131131
{
132132
return (cppEntity.entityType() == CppEntityType::TYPEDEF_DECL)
133133
|| (cppEntity.entityType() == CppEntityType::USING_DECL);
134134
}
135135

136-
inline bool isTypedefLike(const std::unique_ptr<CppEntity>& cppEntity)
136+
inline bool IsTypedefLike(const std::unique_ptr<CppEntity>& cppEntity)
137137
{
138-
return isTypedefLike(*cppEntity);
138+
return IsTypedefLike(*cppEntity);
139139
}
140140

141-
inline bool isPreProcessorType(const CppEntity& cppEntity)
141+
inline bool IsPreProcessorType(const CppEntity& cppEntity)
142142
{
143143
return cppEntity.entityType() == CppEntityType::PREPROCESSOR;
144144
}
145145

146-
inline bool isPreProcessorType(const std::unique_ptr<CppEntity>& cppEntity)
146+
inline bool IsPreProcessorType(const std::unique_ptr<CppEntity>& cppEntity)
147147
{
148-
return isPreProcessorType(*cppEntity);
148+
return IsPreProcessorType(*cppEntity);
149149
}
150150

151-
inline bool isVar(const CppEntity& cppEntity)
151+
inline bool IsVar(const CppEntity& cppEntity)
152152
{
153153
return cppEntity.entityType() == CppEntityType::VAR;
154154
}
155155

156-
inline bool isVar(const std::unique_ptr<CppEntity>& cppEntity)
156+
inline bool IsVar(const std::unique_ptr<CppEntity>& cppEntity)
157157
{
158-
return isVar(*cppEntity);
158+
return IsVar(*cppEntity);
159159
}
160160

161-
inline bool isVarList(const CppEntity& cppEntity)
161+
inline bool IsVarList(const CppEntity& cppEntity)
162162
{
163163
return cppEntity.entityType() == CppEntityType::VAR_LIST;
164164
}
165165

166-
inline bool isVarList(const std::unique_ptr<CppEntity>& cppEntity)
166+
inline bool IsVarList(const std::unique_ptr<CppEntity>& cppEntity)
167167
{
168-
return isVarList(*cppEntity);
168+
return IsVarList(*cppEntity);
169169
}
170170

171-
inline bool isExpr(const CppEntity& cppEntity)
171+
inline bool IsExpr(const CppEntity& cppEntity)
172172
{
173173
return cppEntity.entityType() == CppEntityType::EXPRESSION;
174174
}
175175

176-
inline bool isExpr(const std::unique_ptr<CppEntity>& cppEntity)
176+
inline bool IsExpr(const std::unique_ptr<CppEntity>& cppEntity)
177177
{
178-
return isExpr(*cppEntity);
178+
return IsExpr(*cppEntity);
179179
}
180180

181-
inline CppCompound* root(const CppEntity& cppEntity)
181+
inline CppCompound* Root(const CppEntity& cppEntity)
182182
{
183183
if (cppEntity.owner() == nullptr)
184-
return isCompound(cppEntity) ? const_cast<CppCompound*>(static_cast<const CppCompound*>(&cppEntity)) : nullptr;
185-
return root(*cppEntity.owner());
184+
return IsCompound(cppEntity) ? const_cast<CppCompound*>(static_cast<const CppCompound*>(&cppEntity)) : nullptr;
185+
return Root(*cppEntity.owner());
186186
}
187187

188188
} // namespace cppast

cppast/include/cppast/cpp_forward_class_decl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ class CppForwardClassDecl : public CppEntity, public CppTemplatableEntity
5353
{
5454
return attr_;
5555
}
56-
void addAttr(std::uint32_t _attr)
56+
void addAttr(std::uint32_t attr)
5757
{
58-
attr_ |= _attr;
58+
attr_ |= attr;
5959
}
6060

6161
private:

0 commit comments

Comments
 (0)