diff --git a/.clang-tidy b/.clang-tidy index 05204a417..cf18b5e4a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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 } diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e8cfa29a..ad29e1a27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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\"") diff --git a/cppast/include/cppast/cpp_asm_block.h b/cppast/include/cppast/cpp_asm_block.h index 006f58b06..2a2e521c3 100644 --- a/cppast/include/cppast/cpp_asm_block.h +++ b/cppast/include/cppast/cpp_asm_block.h @@ -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_; } diff --git a/cppast/include/cppast/cpp_blob.h b/cppast/include/cppast/cpp_blob.h index 8209bf76a..23b03296b 100644 --- a/cppast/include/cppast/cpp_blob.h +++ b/cppast/include/cppast/cpp_blob.h @@ -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_; } diff --git a/cppast/include/cppast/cpp_compound.h b/cppast/include/cppast/cpp_compound.h index 015f0c152..eb256ce63 100644 --- a/cppast/include/cppast/cpp_compound.h +++ b/cppast/include/cppast/cpp_compound.h @@ -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 @@ -121,19 +121,19 @@ class CppCompound : public CppEntity, public CppTemplatableEntity { return inheritanceList_; } - void inheritanceList(std::list _inheritanceList) + void inheritanceList(std::list 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: diff --git a/cppast/include/cppast/cpp_compound_info_accessor.h b/cppast/include/cppast/cpp_compound_info_accessor.h index 4891319b8..ff0fd0cae 100644 --- a/cppast/include/cppast/cpp_compound_info_accessor.h +++ b/cppast/include/cppast/cpp_compound_info_accessor.h @@ -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; } diff --git a/cppast/include/cppast/cpp_compound_utility.h b/cppast/include/cppast/cpp_compound_utility.h index 7216f7812..311f20285 100644 --- a/cppast/include/cppast/cpp_compound_utility.h +++ b/cppast/include/cppast/cpp_compound_utility.h @@ -51,9 +51,9 @@ inline std::vector 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(); diff --git a/cppast/include/cppast/cpp_control_blocks.h b/cppast/include/cppast/cpp_control_blocks.h index 8a042566b..cde56f67e 100644 --- a/cppast/include/cppast/cpp_control_blocks.h +++ b/cppast/include/cppast/cpp_control_blocks.h @@ -49,9 +49,9 @@ class CppIfBlock : public CppControlBlockBase public: CppIfBlock(std::unique_ptr cond, std::unique_ptr body, - std::unique_ptr _else = nullptr) + std::unique_ptr elseArg = nullptr) : CppControlBlockBase(std::move(cond), std::move(body)) - , else_(std::move(_else)) + , else_(std::move(elseArg)) { } diff --git a/cppast/include/cppast/cpp_entity_info_accessor.h b/cppast/include/cppast/cpp_entity_info_accessor.h index 38abf6a84..0be8e3f5c 100644 --- a/cppast/include/cppast/cpp_entity_info_accessor.h +++ b/cppast/include/cppast/cpp_entity_info_accessor.h @@ -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) +inline bool IsFunction(const std::unique_ptr& 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) +inline bool IsFunctionPtr(const std::unique_ptr& 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) +inline bool IsFunctionLike(const std::unique_ptr& 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) +inline bool IsDestructor(const std::unique_ptr& 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) +inline bool IsEnum(const std::unique_ptr 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) +inline bool IsTypedefName(const std::unique_ptr& 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) +inline bool IsUsingDecl(const std::unique_ptr& 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) +inline bool IsCompound(const std::unique_ptr& 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) +inline bool IsFwdClsDecl(const std::unique_ptr& cppEntity) { - return isFwdClsDecl(*cppEntity); + return IsFwdClsDecl(*cppEntity); } -inline bool isNamespaceLike(const CppEntity& cppEntity) +inline bool IsNamespaceLike(const CppEntity& cppEntity) { const helper::CppEntityPtr compound = &cppEntity; if (!compound) @@ -115,74 +115,74 @@ inline bool isNamespaceLike(const CppEntity& cppEntity) && (compound->compoundType() <= CppCompoundType::UNION); } -inline bool isNamespaceLike(const std::unique_ptr& cppEntity) +inline bool IsNamespaceLike(const std::unique_ptr& 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) +inline bool IsClassLike(const std::unique_ptr& 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) +inline bool IsTypedefLike(const std::unique_ptr& 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) +inline bool IsPreProcessorType(const std::unique_ptr& 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) +inline bool IsVar(const std::unique_ptr& 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) +inline bool IsVarList(const std::unique_ptr& 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) +inline bool IsExpr(const std::unique_ptr& 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(static_cast(&cppEntity)) : nullptr; - return root(*cppEntity.owner()); + return IsCompound(cppEntity) ? const_cast(static_cast(&cppEntity)) : nullptr; + return Root(*cppEntity.owner()); } } // namespace cppast diff --git a/cppast/include/cppast/cpp_forward_class_decl.h b/cppast/include/cppast/cpp_forward_class_decl.h index 92cc8d98a..5f476acaf 100644 --- a/cppast/include/cppast/cpp_forward_class_decl.h +++ b/cppast/include/cppast/cpp_forward_class_decl.h @@ -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: diff --git a/cppast/include/cppast/cpp_function.h b/cppast/include/cppast/cpp_function.h index 600e3e77b..cac288173 100644 --- a/cppast/include/cppast/cpp_function.h +++ b/cppast/include/cppast/cpp_function.h @@ -26,18 +26,18 @@ class CppFuncLikeBase : public CppEntity { return throwSpec_; } - void throwSpec(std::vector _throwSpec) + void throwSpec(std::vector throwSpecArg) { - throwSpec_ = std::move(_throwSpec); + throwSpec_ = std::move(throwSpecArg); } const CppCompound* defn() const { return defn_.get(); } - void defn(std::unique_ptr _defn) + void defn(std::unique_ptr defnArg) { - defn_ = std::move(_defn); + defn_ = std::move(defnArg); } protected: @@ -63,31 +63,31 @@ class CppFunctionBase : public CppFuncLikeBase, public CppTemplatableEntity { return attr_; } - 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); } const std::string& decor1() const { return decor1_; } - void decor1(std::string _decor) + void decor1(std::string decorArg) { - decor1_ = std::move(_decor); + decor1_ = std::move(decorArg); } const std::string& decor2() const { return decor2_; } - void decor2(std::string _decor) + void decor2(std::string decorArg) { - decor2_ = std::move(_decor); + decor2_ = std::move(decorArg); } protected: diff --git a/cppast/include/cppast/cpp_function_info_accessor.h b/cppast/include/cppast/cpp_function_info_accessor.h index f1ade7a5f..5babcc3c8 100644 --- a/cppast/include/cppast/cpp_function_info_accessor.h +++ b/cppast/include/cppast/cpp_function_info_accessor.h @@ -12,35 +12,35 @@ namespace cppast { -inline bool isConst(const CppFunctionBase& func) +inline bool IsConst(const CppFunctionBase& func) { return (func.attr() & CONST) == CONST; } -inline bool isVirtual(const CppFunctionBase& func) +inline bool IsVirtual(const CppFunctionBase& func) { return (func.attr() & (VIRTUAL | OVERRIDE)) == VIRTUAL; } -inline bool isPureVirtual(const CppFunctionBase& func) +inline bool IsPureVirtual(const CppFunctionBase& func) { return (func.attr() & PURE_VIRTUAL) == PURE_VIRTUAL; } -inline bool isStatic(const CppFunctionBase& func) +inline bool IsStatic(const CppFunctionBase& func) { return (func.attr() & STATIC) == STATIC; } -inline bool isInline(const CppFunctionBase& func) +inline bool IsInline(const CppFunctionBase& func) { return (func.attr() & INLINE) == INLINE; } -inline bool isOverride(const CppFunctionBase& func) +inline bool IsOverride(const CppFunctionBase& func) { return (func.attr() & OVERRIDE) == OVERRIDE; } -inline bool isDeleted(const CppFunctionBase& func) +inline bool IsDeleted(const CppFunctionBase& func) { return (func.attr() & DELETE) == DELETE; } -inline bool isFinal(const CppFunctionBase& func) +inline bool IsFinal(const CppFunctionBase& func) { return (func.attr() & FINAL) == FINAL; } diff --git a/cppast/include/cppast/cpp_var.h b/cppast/include/cppast/cpp_var.h index c561e0593..d04246106 100644 --- a/cppast/include/cppast/cpp_var.h +++ b/cppast/include/cppast/cpp_var.h @@ -99,9 +99,9 @@ class CppVar : public CppEntity, public CppTemplatableEntity { return varDecl_.bitField(); } - void bitField(std::unique_ptr _bitField) + void bitField(std::unique_ptr bitFieldArg) { - varDecl_.bitField(std::move(_bitField)); + varDecl_.bitField(std::move(bitFieldArg)); } const CppArraySizes& arraySizes() const @@ -117,9 +117,9 @@ class CppVar : public CppEntity, public CppTemplatableEntity { return apidecor_; } - void apidecor(std::string _apidecor) + void apidecor(std::string apidecorArg) { - apidecor_ = std::move(_apidecor); + apidecor_ = std::move(apidecorArg); } private: diff --git a/cppast/include/cppast/cpp_var_decl.h b/cppast/include/cppast/cpp_var_decl.h index 194deb6d0..7cb18722f 100644 --- a/cppast/include/cppast/cpp_var_decl.h +++ b/cppast/include/cppast/cpp_var_decl.h @@ -115,9 +115,9 @@ class CppVarDecl { return bitField_.get(); } - void bitField(std::unique_ptr _bitField) + void bitField(std::unique_ptr bitFieldArg) { - bitField_ = std::move(_bitField); + bitField_ = std::move(bitFieldArg); } const CppArraySizes& arraySizes() const diff --git a/cppast/include/cppast/cpp_var_info_accessor.h b/cppast/include/cppast/cpp_var_info_accessor.h index 9ef82b499..7e52d3289 100644 --- a/cppast/include/cppast/cpp_var_info_accessor.h +++ b/cppast/include/cppast/cpp_var_info_accessor.h @@ -11,30 +11,30 @@ namespace cppast { -inline std::uint8_t ptrLevel(const CppVarType& varType) +inline std::uint8_t PtrLevel(const CppVarType& varType) { return varType.typeModifier().ptrLevel_; } -inline std::uint8_t ptrLevel(const std::unique_ptr& varType) +inline std::uint8_t PtrLevel(const std::unique_ptr& varType) { - return ptrLevel(*varType); + return PtrLevel(*varType); } -inline CppRefType refType(const CppVarType& varType) +inline CppRefType RefType(const CppVarType& varType) { return varType.typeModifier().refType_; } -inline CppRefType refType(const std::unique_ptr& varType) +inline CppRefType RefType(const std::unique_ptr& varType) { - return refType(*varType); + return RefType(*varType); } -inline std::uint8_t effectivePtrLevel(const CppVarType& varType) +inline std::uint8_t EffectivePtrLevel(const CppVarType& varType) { - return ptrLevel(varType) + [&varType]() { - switch (refType(varType)) + return PtrLevel(varType) + [&varType]() { + switch (RefType(varType)) { case CppRefType::BY_REF: case CppRefType::RVAL_REF: @@ -46,156 +46,156 @@ inline std::uint8_t effectivePtrLevel(const CppVarType& varType) }(); } -inline const std::string& baseType(const CppVarType& varType) +inline const std::string& BaseType(const CppVarType& varType) { return varType.baseType(); } -inline const std::string& baseType(const std::unique_ptr& varType) +inline const std::string& BaseType(const std::unique_ptr& varType) { - return baseType(*varType); + return BaseType(*varType); } -inline bool usesTemplateType(const std::string& varTypeName) +inline bool UsesTemplateType(const std::string& varTypeName) { return varTypeName.find('<') != varTypeName.npos; } -inline bool isVoid(const CppVarType& varType) +inline bool IsVoid(const CppVarType& varType) { if (varType.typeModifier().ptrLevel_ != 0 || varType.typeModifier().refType_ != CppRefType::NO_REF) return false; - // return (varType.baseType().compare("void") == 0); + // return (varType.BaseType().compare("void") == 0); // Above simple check fails to detect cases like usage of GrGLvoid if (varType.baseType().length() < 4) return false; return (std::strncmp(varType.baseType().c_str() + varType.baseType().length() - 4, "void", 4) == 0); } -inline bool isVoid(const std::unique_ptr& varType) +inline bool IsVoid(const std::unique_ptr& varType) { - return isVoid(*varType); + return IsVoid(*varType); } -inline bool isByRef(const CppVarType& varType) +inline bool IsByRef(const CppVarType& varType) { return varType.typeModifier().refType_ == CppRefType::BY_REF; } -inline bool isByRef(const std::unique_ptr& varType) +inline bool IsByRef(const std::unique_ptr& varType) { - return isByRef(*varType); + return IsByRef(*varType); } -inline bool isByRValueRef(const CppVarType& varType) +inline bool IsByRValueRef(const CppVarType& varType) { return varType.typeModifier().refType_ == CppRefType::RVAL_REF; } -inline bool isByRValueRef(const std::unique_ptr& varType) +inline bool IsByRValueRef(const std::unique_ptr& varType) { - return isByRValueRef(*varType); + return IsByRValueRef(*varType); } -inline bool isConst(const CppVarType& varType) +inline bool IsConst(const CppVarType& varType) { return ((varType.typeAttr() & CONST) == CONST) || (varType.typeModifier().constBits_ & 1); } -inline bool isConst(const std::unique_ptr& varType) +inline bool IsConst(const std::unique_ptr& varType) { - return isConst(*varType); + return IsConst(*varType); } -inline bool isByValue(const CppVarType& varType) +inline bool IsByValue(const CppVarType& varType) { - return !isVoid(varType) && (varType.typeModifier().refType_ == CppRefType::NO_REF) + return !IsVoid(varType) && (varType.typeModifier().refType_ == CppRefType::NO_REF) && (varType.typeModifier().ptrLevel_ == 0); } -inline bool isByValue(const std::unique_ptr& varType) +inline bool IsByValue(const std::unique_ptr& varType) { - return isByValue(*varType); + return IsByValue(*varType); } -inline const std::string& baseType(const CppVar& var) +inline const std::string& BaseType(const CppVar& var) { - return baseType(var.varType()); + return BaseType(var.varType()); } -inline const std::string& baseType(const std::unique_ptr& var) +inline const std::string& BaseType(const std::unique_ptr& var) { - return baseType(*var); + return BaseType(*var); } -inline std::uint8_t ptrLevel(const CppVar& var) +inline std::uint8_t PtrLevel(const CppVar& var) { - return ptrLevel(var.varType()); + return PtrLevel(var.varType()); } -inline std::uint8_t ptrLevel(const std::unique_ptr& var) +inline std::uint8_t PtrLevel(const std::unique_ptr& var) { - return ptrLevel(*var); + return PtrLevel(*var); } -inline CppRefType refType(const CppVar& var) +inline CppRefType RefType(const CppVar& var) { - return refType(var.varType()); + return RefType(var.varType()); } -inline CppRefType refType(const std::unique_ptr& var) +inline CppRefType RefType(const std::unique_ptr& var) { - return refType(*var); + return RefType(*var); } -inline const std::string& name(const CppVar& var) +inline const std::string& Name(const CppVar& var) { return var.varDecl().name(); } -inline const std::string& name(const std::unique_ptr& var) +inline const std::string& Name(const std::unique_ptr& var) { - return name(*var); + return Name(*var); } -inline bool isByRef(const CppVar& var) +inline bool IsByRef(const CppVar& var) { - return isByRef(var.varType()); + return IsByRef(var.varType()); } -inline bool isByRef(const std::unique_ptr& var) +inline bool IsByRef(const std::unique_ptr& var) { - return isByRef(*var); + return IsByRef(*var); } -inline bool isByRValueRef(const CppVar& var) +inline bool IsByRValueRef(const CppVar& var) { - return isByRValueRef(var.varType()); + return IsByRValueRef(var.varType()); } -inline bool isByRValueRef(const std::unique_ptr& var) +inline bool IsByRValueRef(const std::unique_ptr& var) { - return isByRValueRef(*var); + return IsByRValueRef(*var); } -inline bool isConst(const CppVar& var) +inline bool IsConst(const CppVar& var) { - return isConst(var.varType()); + return IsConst(var.varType()); } -inline bool isConst(const std::unique_ptr& var) +inline bool IsConst(const std::unique_ptr& var) { - return isConst(*var); + return IsConst(*var); } -inline bool isByValue(const CppVar& var) +inline bool IsByValue(const CppVar& var) { - return isByValue(var.varType()); + return IsByValue(var.varType()); } -inline bool isByValue(const std::unique_ptr& var) +inline bool IsByValue(const std::unique_ptr& var) { - return isByValue(*var); + return IsByValue(*var); } } // namespace cppast diff --git a/cppast/include/cppast/cpp_var_type.h b/cppast/include/cppast/cpp_var_type.h index 54b4fbfb4..4b67736b2 100644 --- a/cppast/include/cppast/cpp_var_type.h +++ b/cppast/include/cppast/cpp_var_type.h @@ -43,9 +43,9 @@ class CppVarType : public CppEntity { return baseType_; } - void baseType(std::string _baseType) + void baseType(std::string baseTypeArg) { - baseType_ = std::move(_baseType); + baseType_ = std::move(baseTypeArg); } const CppEntity* compound() const { diff --git a/cppast/include/cppast/cpputil.h b/cppast/include/cppast/cpputil.h index e3f3ddaa5..65efa2caf 100644 --- a/cppast/include/cppast/cpputil.h +++ b/cppast/include/cppast/cpputil.h @@ -12,14 +12,14 @@ namespace cppast { -inline CppAccessType defaultAccessType(CppCompoundType type) +inline CppAccessType DefaultAccessType(CppCompoundType type) { return (type == CppCompoundType::CLASS) ? CppAccessType::PRIVATE : CppAccessType::PUBLIC; } -inline CppAccessType resolveInheritanceType(const std::optional& inheritanceType, CppCompoundType type) +inline CppAccessType ResolveInheritanceType(const std::optional& inheritanceType, CppCompoundType type) { - return (inheritanceType.has_value()) ? inheritanceType.value() : defaultAccessType(type); + return (inheritanceType.has_value()) ? inheritanceType.value() : DefaultAccessType(type); } } // namespace cppast diff --git a/cppast/src/cpp_blob.cpp b/cppast/src/cpp_blob.cpp index f729022f8..ba8c4f4d4 100644 --- a/cppast/src/cpp_blob.cpp +++ b/cppast/src/cpp_blob.cpp @@ -10,7 +10,7 @@ namespace { /** * @brief Trims traling spaces and leading empty lines. */ -std::string& trimBlob(std::string& s) +std::string& TrimBlob(std::string& s) { auto len = s.size(); @@ -39,7 +39,7 @@ std::string& trimBlob(std::string& s) CppBlob::CppBlob(std::string blob) : CppEntity(EntityType()) - , blob_(std::move(trimBlob(blob))) + , blob_(std::move(TrimBlob(blob))) { } diff --git a/cppast/src/cpp_entity_info_accessor.cpp b/cppast/src/cpp_entity_info_accessor.cpp index 226fc0345..218491418 100644 --- a/cppast/src/cpp_entity_info_accessor.cpp +++ b/cppast/src/cpp_entity_info_accessor.cpp @@ -5,9 +5,9 @@ namespace cppast { -bool isClassLike(const CppEntity& cppEntity) +bool IsClassLike(const CppEntity& cppEntity) { - if (!isCompound(cppEntity)) + if (!IsCompound(cppEntity)) return false; const auto& compound = static_cast(cppEntity); return (compound.compoundType() >= CppCompoundType::CLASS) && (compound.compoundType() <= CppCompoundType::UNION); diff --git a/cppparser/CMakeLists.txt b/cppparser/CMakeLists.txt index db7e0659a..b414784cf 100644 --- a/cppparser/CMakeLists.txt +++ b/cppparser/CMakeLists.txt @@ -48,24 +48,17 @@ add_custom_command( DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/parser.l ${CMAKE_CURRENT_SOURCE_DIR}/src/parser.tab.h ) -set(CPPPARSER_SOURCES - src/cpp_program.cpp - src/cppparser.cpp - src/lexer-helper.cpp +add_library(cppparser_lex_and_yacc OBJECT src/parser.l src/parser.y src/parser.lex.cpp src/parser.tab.cpp - src/utils.cpp ) - -add_library(cppparser STATIC ${CPPPARSER_SOURCES}) -add_dependencies(cppparser btyacc) -target_link_libraries(cppparser +target_link_libraries(cppparser_lex_and_yacc PUBLIC cppast ) -target_include_directories(cppparser +target_include_directories(cppparser_lex_and_yacc PUBLIC include src @@ -73,7 +66,25 @@ target_include_directories(cppparser PRIVATE src/win_hack ) -target_compile_definitions(cppparser +target_compile_definitions(cppparser_lex_and_yacc PRIVATE YY_NO_UNPUT ) + +set(CPPPARSER_SOURCES + src/cpp_program.cpp + src/cppparser.cpp + src/lexer-helper.cpp + src/utils.cpp +) + +add_library(cppparser STATIC ${CPPPARSER_SOURCES}) +add_dependencies(cppparser btyacc) +target_link_libraries(cppparser + PUBLIC + cppast + 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}") diff --git a/cppparser/include/cppparser/string-utils.h b/cppparser/include/cppparser/string-utils.h index 0688bce1d..7ab78e37d 100644 --- a/cppparser/include/cppparser/string-utils.h +++ b/cppparser/include/cppparser/string-utils.h @@ -8,19 +8,19 @@ #include #include -inline size_t stripChar(char* s, size_t len, char c) +inline size_t StripChar(char* s, size_t len, char c) { auto* end = std::remove(s, s + len, c); return end - s; } -inline void stripChar(std::string& s, char c) +inline void StripChar(std::string& s, char c) { - auto len = stripChar(&s[0], s.length(), c); + auto len = StripChar(&s[0], s.length(), c); s.resize(len); } -inline std::string& trimBlob(std::string& s) +inline std::string& TrimBlob(std::string& s) { auto len = s.size(); @@ -46,9 +46,9 @@ inline std::string& trimBlob(std::string& s) } //! strips new-line char and collapses multiple white chars. -inline std::string& cleanseIdentifier(std::string& id) +inline std::string& CleanseIdentifier(std::string& id) { - stripChar(id, '\n'); + StripChar(id, '\n'); auto end = std::unique(id.begin(), id.end(), [](char c1, char c2) { return ((c1 == ' ' && c2 == ' ') || (c1 == '\t' && c2 == '\t') || (c1 == ' ' && c2 == '\t') || (c1 == '\t' && c2 == ' ')); diff --git a/cppparser/src/cpp_program.cpp b/cppparser/src/cpp_program.cpp index 9435b851c..18dbcf40f 100644 --- a/cppparser/src/cpp_program.cpp +++ b/cppparser/src/cpp_program.cpp @@ -44,24 +44,24 @@ void CppProgram::addCompound(const cppast::CppCompound& compound, const cppast:: void CppProgram::loadType(const cppast::CppCompound& cppCompound, CppTypeTreeNode& typeNode) { - if (isCppFile(cppCompound)) // Type node for file object should be the root itself. + if (IsCppFile(cppCompound)) // Type node for file object should be the root itself. { cppEntityToTypeNode_[&cppCompound] = &typeNode; typeNode.cppEntitySet.insert(&cppCompound); } cppCompound.visitAll([&](const cppast::CppEntity& mem) { - if (isCompound(mem)) + if (IsCompound(mem)) { addCompound(*static_cast(&mem), typeNode); } - else if (isEnum(mem)) + else if (IsEnum(mem)) { CppTypeTreeNode& childNode = typeNode.children[((cppast::CppEnum&) mem).name()]; childNode.cppEntitySet.insert(&mem); childNode.parent = &typeNode; cppEntityToTypeNode_[&mem] = &childNode; } - else if (isTypedefName(mem)) + else if (IsTypedefName(mem)) { const auto& typedefName = static_cast(mem); CppTypeTreeNode& childNode = typeNode.children[typedefName.var()->name()]; @@ -69,7 +69,7 @@ void CppProgram::loadType(const cppast::CppCompound& cppCompound, CppTypeTreeNod childNode.parent = &typeNode; cppEntityToTypeNode_[&mem] = &childNode; } - else if (isUsingDecl(mem)) + else if (IsUsingDecl(mem)) { const auto& usingDecl = static_cast(mem); CppTypeTreeNode& childNode = typeNode.children[usingDecl.name()]; @@ -77,14 +77,14 @@ void CppProgram::loadType(const cppast::CppCompound& cppCompound, CppTypeTreeNod childNode.parent = &typeNode; cppEntityToTypeNode_[&mem] = &childNode; } - else if (isFunctionPtr(mem)) + else if (IsFunctionPtr(mem)) { CppTypeTreeNode& childNode = typeNode.children[((const cppast::CppFunctionPointer&) mem).name()]; childNode.cppEntitySet.insert(&mem); childNode.parent = &typeNode; cppEntityToTypeNode_[&mem] = &childNode; } - else if (isFwdClsDecl(mem)) + else if (IsFwdClsDecl(mem)) { const auto& fwdCls = static_cast(mem); if (!(fwdCls.attr() & cppast::CppIdentifierAttrib::FRIEND)) diff --git a/cppparser/src/cppparser.cpp b/cppparser/src/cppparser.cpp index a3520012f..79a44c490 100644 --- a/cppparser/src/cppparser.cpp +++ b/cppparser/src/cppparser.cpp @@ -9,9 +9,9 @@ #include #include #include +#include #include #include -#include // Unfortunately parser is not reentrant and has no way as of now to inject parameters. // So, we need globals. @@ -102,8 +102,8 @@ void CppParser::parseFunctionBodyAsBlob(bool asBlob) std::unique_ptr CppParser::parseFile(const std::string& filename) { - auto stm = readFile(filename); - auto cppCompound = parseStream(stm.data(), stm.size()); + auto stm = ReadFile(filename); + auto cppCompound = ParseStream(stm.data(), stm.size()); if (!cppCompound) return cppCompound; cppCompound->name(filename); @@ -114,17 +114,17 @@ std::unique_ptr CppParser::parseStream(char* stm, size_t st { if ((stm == nullptr) || (stmSize < 2) || (stm[stmSize - 1] != '\0') || (stm[stmSize - 2] != '\0')) throw std::invalid_argument("Stream must be valid and it must terminate with double null characters"); - return ::parseStream(stm, stmSize); + return ::ParseStream(stm, stmSize); } void CppParser::setErrorHandler(ErrorHandler errorHandler) { - ::setErrorHandler(errorHandler); + ::SetErrorHandler(errorHandler); } void CppParser::resetErrorHandler() { - ::resetErrorHandler(); + ::ResetErrorHandler(); } } // namespace cppparser diff --git a/cppparser/src/cpptoken.h b/cppparser/src/cpptoken.h index 126c41599..2b0e661af 100644 --- a/cppparser/src/cpptoken.h +++ b/cppparser/src/cpptoken.h @@ -45,24 +45,24 @@ struct CppToken /** * Since CppToken cannot have ctor (because it is intended to be used inside union). */ -inline CppToken makeCppToken(const char* sz, size_t len) +inline CppToken MakeCppToken(const char* sz, size_t len) { CppToken tkn = {sz, len}; return tkn; } -inline CppToken makeCppToken(const char* beg, const char* end) +inline CppToken MakeCppToken(const char* beg, const char* end) { - return makeCppToken(beg, end - beg); + return MakeCppToken(beg, end - beg); } -inline CppToken mergeCppToken(const CppToken& token1, const CppToken& token2) +inline CppToken MergeCppToken(const CppToken& token1, const CppToken& token2) { if (token1.sz == nullptr) return token2; else if (token2.sz == nullptr) return token1; - return makeCppToken(token1.sz, token2.sz + token2.len - token1.sz); + return MakeCppToken(token1.sz, token2.sz + token2.len - token1.sz); } template diff --git a/cppparser/src/lexer-helper.cpp b/cppparser/src/lexer-helper.cpp index fb8f51d40..70c6d645b 100644 --- a/cppparser/src/lexer-helper.cpp +++ b/cppparser/src/lexer-helper.cpp @@ -11,7 +11,7 @@ extern std::set gUndefinedNames; extern std::set gIgnorableMacroNames; extern std::map gRenamedKeywords; -MacroDefineInfo getMacroDefineInfo(const std::string& id) +MacroDefineInfo GetMacroDefineInfo(const std::string& id) { if (gUndefinedNames.count(id)) return MacroDefineInfo::kUndefined; @@ -22,7 +22,7 @@ MacroDefineInfo getMacroDefineInfo(const std::string& id) return MacroDefineInfo::kNoInfo; } -std::optional getIdValue(const std::string& id) +std::optional GetIdValue(const std::string& id) { if (gUndefinedNames.count(id)) return std::nullopt; diff --git a/cppparser/src/lexer-helper.h b/cppparser/src/lexer-helper.h index 084c87d1a..af2809dfe 100644 --- a/cppparser/src/lexer-helper.h +++ b/cppparser/src/lexer-helper.h @@ -7,7 +7,7 @@ #include "parser.l.h" -inline MacroDependentCodeEnablement invert(MacroDependentCodeEnablement enabledCodeDecision) +inline MacroDependentCodeEnablement Invert(MacroDependentCodeEnablement enabledCodeDecision) { switch (enabledCodeDecision) { @@ -23,8 +23,8 @@ inline MacroDependentCodeEnablement invert(MacroDependentCodeEnablement enabledC return MacroDependentCodeEnablement::kNoInfo; } -MacroDefineInfo getMacroDefineInfo(const std::string& id); +MacroDefineInfo GetMacroDefineInfo(const std::string& id); -std::optional getIdValue(const std::string& id); +std::optional GetIdValue(const std::string& id); #endif /* EF4ACF9B_9D2E_4947_A8CD_17D2F1A6B363 */ diff --git a/cppparser/src/memory_util.h b/cppparser/src/memory_util.h index 2dcd7c52b..db751de85 100644 --- a/cppparser/src/memory_util.h +++ b/cppparser/src/memory_util.h @@ -24,7 +24,7 @@ class ToObjHelper { } - T ToObj() + T toObj() { if (p_ == nullptr) throw std::runtime_error("nullptr cannot be converted to an object"); @@ -44,7 +44,7 @@ class ToObjHelper>> { } - T ToObj() + T toObj() { if (p_ == nullptr) return T(); @@ -55,7 +55,7 @@ class ToObjHelper>> template auto Obj(T* p) { - return ToObjHelper(p).ToObj(); + return ToObjHelper(p).toObj(); } #endif /* B1A7BAF0_1D5C_4F41_9DF8_07895208C0BC */ diff --git a/cppparser/src/optional.h b/cppparser/src/optional.h index ddbe7c570..185f45650 100644 --- a/cppparser/src/optional.h +++ b/cppparser/src/optional.h @@ -17,7 +17,7 @@ class Optional public: static_assert(std::is_trivially_constructible_v); - bool has_value() const + bool hasValue() const { return initialized_; } diff --git a/cppparser/src/parser.h b/cppparser/src/parser.h index 856ac1b3d..23cfdd1fb 100644 --- a/cppparser/src/parser.h +++ b/cppparser/src/parser.h @@ -15,9 +15,9 @@ using ErrorHandler = std::function; -void setErrorHandler(ErrorHandler errorHandler); -void resetErrorHandler(); +void SetErrorHandler(ErrorHandler errorHandler); +void ResetErrorHandler(); -std::unique_ptr parseStream(char* stm, size_t stmSize); +std::unique_ptr ParseStream(char* stm, size_t stmSize); #endif /* BD166B6E_821D_49A3_9593_70C58C59558D */ diff --git a/cppparser/src/parser.l b/cppparser/src/parser.l index 6d4b8d4bb..ed011e7b9 100644 --- a/cppparser/src/parser.l +++ b/cppparser/src/parser.l @@ -123,7 +123,7 @@ static void setupToken(const char* text, size_t len, TokenSetupFlag flag = Token { extern char* yyposn; yyposn = const_cast(text); - yylval.str = makeCppToken(text, len); + yylval.str = MakeCppToken(text, len); setCommentTokenizationState(flag); } @@ -957,7 +957,7 @@ This context starts after #if, #elif, and #pragma to capture everyting till a ne std::string id(yyleng, '\0'); sscanf(yytext, " # if %[a-zA-Z0-9_]", id.data()); id.resize(strlen(id.data())); - const auto idVal = getIdValue(id); + const auto idVal = GetIdValue(id); if (!idVal.has_value()) { REJECT; } @@ -980,7 +980,7 @@ This context starts after #if, #elif, and #pragma to capture everyting till a ne int n=0; sscanf(yytext, " # if %[a-zA-Z0-9_] >= %d", id.data(), &n); id.resize(strlen(id.data())); - const auto idVal = getIdValue(id); + const auto idVal = GetIdValue(id); if (!idVal.has_value()) { REJECT; } @@ -1001,7 +1001,7 @@ This context starts after #if, #elif, and #pragma to capture everyting till a ne std::string id(yyleng, '\0'); sscanf(yytext, " # if ! %[a-zA-Z0-9_]", id.data()); id.resize(strlen(id.data())); - const auto idVal = getIdValue(id); + const auto idVal = GetIdValue(id); if (!idVal.has_value()) { REJECT; @@ -1025,7 +1025,7 @@ This context starts after #if, #elif, and #pragma to capture everyting till a ne sscanf(yytext, " # ifdef %[a-zA-Z0-9_]", id.data()); id.resize(strlen(id.data())); - const auto macroDefineInfo = getMacroDefineInfo(id); + const auto macroDefineInfo = GetMacroDefineInfo(id); if (macroDefineInfo == MacroDefineInfo::kNoInfo) { REJECT; } @@ -1048,7 +1048,7 @@ This context starts after #if, #elif, and #pragma to capture everyting till a ne sscanf(yytext, " # if defined( %[a-zA-Z0-9_])", id.data()); id.resize(strlen(id.data())); - const auto macroDefineInfo = getMacroDefineInfo(id); + const auto macroDefineInfo = GetMacroDefineInfo(id); if (macroDefineInfo == MacroDefineInfo::kNoInfo) { REJECT; } @@ -1071,7 +1071,7 @@ This context starts after #if, #elif, and #pragma to capture everyting till a ne sscanf(yytext, " # ifndef %[a-zA-Z0-9_]", id.data()); id.resize(strlen(id.data())); - const auto macroDefineInfo = getMacroDefineInfo(id); + const auto macroDefineInfo = GetMacroDefineInfo(id); if (macroDefineInfo == MacroDefineInfo::kNoInfo) { REJECT; } @@ -1096,7 +1096,7 @@ This context starts after #if, #elif, and #pragma to capture everyting till a ne LOG(); if (g.currentCodeEnablementInfo.numHashIfInMacroDependentCode == 0) { - g.currentCodeEnablementInfo.macroDependentCodeEnablement = invert(g.currentCodeEnablementInfo.macroDependentCodeEnablement); + g.currentCodeEnablementInfo.macroDependentCodeEnablement = Invert(g.currentCodeEnablementInfo.macroDependentCodeEnablement); if (g.currentCodeEnablementInfo.macroDependentCodeEnablement == MacroDependentCodeEnablement::kDisabled) { BEGINCONTEXT(ctxDisabledCode); } else { diff --git a/cppparser/src/parser.y b/cppparser/src/parser.y index 225defadc..8193a0249 100644 --- a/cppparser/src/parser.y +++ b/cppparser/src/parser.y @@ -465,8 +465,8 @@ stmt | usingnamespacedecl [ZZLOG;] { $$ = $1; } | namespacealias [ZZLOG;] { $$ = $1; } | macrocall [ZZLOG;] { $$ = new cppast::CppMacroCall($1); } - | macrocall ';' [ZZLOG;] { $$ = new cppast::CppMacroCall(mergeCppToken($1, $2)); } - | apidecortokensq macrocall [ZZLOG;] { $$ = new cppast::CppMacroCall(mergeCppToken($1, $2)); } + | macrocall ';' [ZZLOG;] { $$ = new cppast::CppMacroCall(MergeCppToken($1, $2)); } + | apidecortokensq macrocall [ZZLOG;] { $$ = new cppast::CppMacroCall(MergeCppToken($1, $2)); } | ';' [ZZLOG;] { $$ = nullptr; } /* blank statement */ | asmblock [ZZLOG;] { $$ = $1; } | blob [ZZLOG;] { $$ = $1; } @@ -498,10 +498,10 @@ asmblock macrocall : tknMacro [ZZLOG; $$ = $1;] {} - | macrocall '(' ')' [ZZLOG; $$ = mergeCppToken($1, $3); ] {} + | macrocall '(' ')' [ZZLOG; $$ = MergeCppToken($1, $3); ] {} | macrocall '(' expr ')' [ ZZLOG; - $$ = mergeCppToken($1, $4); + $$ = MergeCppToken($1, $4); delete $3; ] {} ; @@ -665,12 +665,12 @@ hashif hasherror : tknPreProHash tknHashError [ZZLOG;] { $$ = new cppast::CppPreprocessorError($2); } - | tknPreProHash tknHashError strlit [ZZLOG;] { $$ = new cppast::CppPreprocessorError(mergeCppToken($2, $3)); } + | tknPreProHash tknHashError strlit [ZZLOG;] { $$ = new cppast::CppPreprocessorError(MergeCppToken($2, $3)); } ; hashwarning : tknPreProHash tknHashWarning [ZZLOG;] { $$ = new cppast::CppPreprocessorWarning($2); } - | tknPreProHash tknHashWarning strlit [ZZLOG;] { $$ = new cppast::CppPreprocessorWarning(mergeCppToken($2, $3)); } + | tknPreProHash tknHashWarning strlit [ZZLOG;] { $$ = new cppast::CppPreprocessorWarning(MergeCppToken($2, $3)); } ; pragma @@ -689,17 +689,17 @@ optdoccommentstr doccommentstr : tknFreeStandingBlockComment [ZZLOG;] { $$ = $1; } | tknFreeStandingLineComment [ZZLOG;] { $$ = $1; } - | doccommentstr tknFreeStandingBlockComment [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | doccommentstr tknFreeStandingLineComment [ZZLOG;] { $$ = mergeCppToken($1, $2); } + | doccommentstr tknFreeStandingBlockComment [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | doccommentstr tknFreeStandingLineComment [ZZLOG;] { $$ = MergeCppToken($1, $2); } ; identifier : name [ZZLOG; $$ = $1; ] {} - | identifier tknScopeResOp identifier [ZZLOG; $$ = mergeCppToken($1, $3); ] {} + | identifier tknScopeResOp identifier [ZZLOG; $$ = MergeCppToken($1, $3); ] {} | id [ZZLOG; $$ = $1; ] {} | templidentifier [ZZLOG; $$ = $1; ] {} | tknOverride [ZZLOG; $$ = $1;] { /* override is not a reserved keyword */ } - | identifier tknEllipsis [ZZLOG; $$ = mergeCppToken($1, $2); ] {} + | identifier tknEllipsis [ZZLOG; $$ = MergeCppToken($1, $2); ] {} | macrocall [ZZLOG; $$ = $1; ] {} | templqualifiedid [ZZLOG; $$ = $1; ] {} ; @@ -710,44 +710,44 @@ numbertype | tknDouble [ZZLOG;] { $$ = $1; } | tknChar [ZZLOG;] { $$ = $1; } | tknNumSignSpec [ZZLOG;] { $$ = $1; } - | tknNumSignSpec numbertype [ZZLOG;] { $$ = mergeCppToken($1, $2); } + | tknNumSignSpec numbertype [ZZLOG;] { $$ = MergeCppToken($1, $2); } ; typeidentifier : identifier [ZZLOG;] { $$ = $1; } - | tknScopeResOp identifier %prec GLOBAL [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | typeidentifier tknScopeResOp typeidentifier [ZZLOG;] { $$ = mergeCppToken($1, $3); } + | tknScopeResOp identifier %prec GLOBAL [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | typeidentifier tknScopeResOp typeidentifier [ZZLOG;] { $$ = MergeCppToken($1, $3); } | numbertype [ZZLOG;] { $$ = $1; } - | typeidentifier '[' ']' [ZZLOG;] { $$ = mergeCppToken($1, $3); } + | typeidentifier '[' ']' [ZZLOG;] { $$ = MergeCppToken($1, $3); } | tknAuto [ZZLOG;] { $$ = $1; } | tknVoid [ZZLOG;] { $$ = $1; } - | tknEnum identifier [ZZLOG;] { $$ = mergeCppToken($1, $2); } + | tknEnum identifier [ZZLOG;] { $$ = MergeCppToken($1, $2); } | tknTypename identifier [ if (gTemplateParamStart == $1.sz) ZZERROR; else ZZLOG; - ] [ZZLOG;] { $$ = mergeCppToken($1, $2); } + ] [ZZLOG;] { $$ = MergeCppToken($1, $2); } | tknEllipsis [ZZLOG;] { $$ = $1; } - | tknTypename tknEllipsis [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknClass tknEllipsis [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | typeidentifier tknEllipsis [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknDecltype '(' expr ')' [ZZLOG;] { $$ = mergeCppToken($1, $4); delete $3; } + | tknTypename tknEllipsis [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknClass tknEllipsis [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | typeidentifier tknEllipsis [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknDecltype '(' expr ')' [ZZLOG;] { $$ = MergeCppToken($1, $4); delete $3; } ; templidentifier - : identifier tknLT templatearglist tknGT [ZZLOG; $$ = mergeCppToken($1, $4); ] {} + : identifier tknLT templatearglist tknGT [ZZLOG; $$ = MergeCppToken($1, $4); ] {} // The following rule is needed to parse an ambiguous input as template identifier, // see the test "vardecl-or-expr-ambiguity". - | identifier tknLT expr tknNotEq expr tknGT [ZZLOG; $$ = mergeCppToken($1, $6); ] {} + | identifier tknLT expr tknNotEq expr tknGT [ZZLOG; $$ = MergeCppToken($1, $6); ] {} // The following rule is needed to parse a template identifier which otherwise fails to parse // because of higher precedence of tknLT and tknGT, // see the test "C x;". - | identifier tknLT templatearglist ',' expr tknNotEq expr tknGT [ZZLOG; $$ = mergeCppToken($1, $8); ] {} + | identifier tknLT templatearglist ',' expr tknNotEq expr tknGT [ZZLOG; $$ = MergeCppToken($1, $8); ] {} ; templqualifiedid - : tknTemplate templidentifier [ZZLOG; $$ = mergeCppToken($1, $2); ] {} + : tknTemplate templidentifier [ZZLOG; $$ = MergeCppToken($1, $2); ] {} ; name @@ -755,7 +755,7 @@ name ; designatedname - : '.' name [ZZLOG;] {$$ = mergeCppToken($1, $2);} + : '.' name [ZZLOG;] {$$ = MergeCppToken($1, $2);} ; id @@ -763,11 +763,11 @@ id ; optname - : [ZZLOG;] { $$ = makeCppToken(nullptr, nullptr); } + : [ZZLOG;] { $$ = MakeCppToken(nullptr, nullptr); } | name [ZZLOG;] { $$ = $1; } optidentifier - : [ZZLOG;] { $$ = makeCppToken(nullptr, nullptr); } + : [ZZLOG;] { $$ = MakeCppToken(nullptr, nullptr); } | identifier [ZZLOG;] { $$ = $1; } ; @@ -1027,16 +1027,16 @@ vartype else ZZLOG; ] { - $$ = new cppast::CppVarType(mergeCppToken($1, $2), $3); + $$ = new cppast::CppVarType(MergeCppToken($1, $2), $3); } | tknClass optapidecor identifier opttypemodifier [ZZLOG;] { - $$ = new cppast::CppVarType(mergeCppToken($1, $3), $4); + $$ = new cppast::CppVarType(MergeCppToken($1, $3), $4); } | tknStruct optapidecor identifier opttypemodifier [ZZLOG;] { - $$ = new cppast::CppVarType(mergeCppToken($1, $3), $4); + $$ = new cppast::CppVarType(MergeCppToken($1, $3), $4); } | tknUnion identifier opttypemodifier [ZZLOG;] { - $$ = new cppast::CppVarType(mergeCppToken($1, $2), $3); + $$ = new cppast::CppVarType(MergeCppToken($1, $2), $3); } | functionptrtype [ZZLOG;] { $$ = new cppast::CppVarType($1, CppTypeModifier()); @@ -1064,16 +1064,16 @@ vartype | typeidentifier typeidentifier tknScopeResOp typemodifier [ZZLOG;] { // reference to member declrations. E.g.: // int GrCCStrokeGeometry::InstanceTallies::* InstanceType - $$ = new cppast::CppVarType(mergeCppToken($1, $3), $4); + $$ = new cppast::CppVarType(MergeCppToken($1, $3), $4); } ; varidentifier : identifier [ZZLOG;] { $$ = $1; } | tknFinal [ZZLOG;] { $$ = $1; /* final is not a reserved keyword */ } - | '(' '&' name ')' [ZZLOG;] { $$ = mergeCppToken($1, $4); } - | '(' '*' name ')' [ZZLOG;] { $$ = mergeCppToken($1, $4); } - | '(' '*' '*' name ')' [ZZLOG;] { $$ = mergeCppToken($1, $5); } + | '(' '&' name ')' [ZZLOG;] { $$ = MergeCppToken($1, $4); } + | '(' '*' name ')' [ZZLOG;] { $$ = MergeCppToken($1, $4); } + | '(' '*' '*' name ')' [ZZLOG;] { $$ = MergeCppToken($1, $5); } ; opttypemodifier @@ -1133,10 +1133,10 @@ varattrib typeconverter : tknOperator vartype '(' optvoid ')' [ZZLOG;] { - $$ = new cppast::CppTypeConverter($2, makeCppToken($1.sz, $3.sz)); + $$ = new cppast::CppTypeConverter($2, MakeCppToken($1.sz, $3.sz)); } | identifier tknScopeResOp tknOperator vartype '(' optvoid ')' [ZZLOG;] { - $$ = new cppast::CppTypeConverter($4, makeCppToken($1.sz, $5.sz)); + $$ = new cppast::CppTypeConverter($4, MakeCppToken($1.sz, $5.sz)); } | functype typeconverter [ZZLOG;] { $$ = $2; @@ -1193,11 +1193,11 @@ lambdaparams funcptrortype : functype vartype '(' optapidecor identifier tknScopeResOp '*' optname ')' '(' paramlist ')' [ZZVALID;] { - $$ = new cppast::CppFunctionPointer($8, Ptr($2), Obj($11), $1, mergeCppToken($5, $6)); + $$ = new cppast::CppFunctionPointer($8, Ptr($2), Obj($11), $1, MergeCppToken($5, $6)); $$->decor2($4); } | vartype '(' optapidecor identifier tknScopeResOp '*' optname ')' '(' paramlist ')' [ZZVALID;] { - $$ = new cppast::CppFunctionPointer($7, Ptr($1), Obj($10), 0, mergeCppToken($4, $5)); + $$ = new cppast::CppFunctionPointer($7, Ptr($1), Obj($10), 0, MergeCppToken($4, $5)); $$->decor2($3); } | functype vartype '(' optapidecor '*' optname ')' '(' paramlist ')' [ZZVALID;] { @@ -1311,77 +1311,77 @@ funcdecl funcobjstr : typeidentifier optapidecor '(' paramlist ')' [ZZLOG;] { delete $4; - $$ = mergeCppToken($1, $5); + $$ = MergeCppToken($1, $5); } ; funcname : operfuncname [ZZLOG;] { $$ = $1; } | typeidentifier [ZZLOG;] { $$ = $1; } - | tknScopeResOp operfuncname [ZZLOG;] { $$ = mergeCppToken($1, $2); } + | tknScopeResOp operfuncname [ZZLOG;] { $$ = MergeCppToken($1, $2); } /* final can be a function name too, see SkOpSpan.h :| */ | tknFinal [ZZLOG;] { $$ = $1; } ; rshift - : tknGT tknGT %prec RSHIFT [ if ($2.sz != ($1.sz + 1)) ZZERROR; ] { $$ = mergeCppToken($1, $2); } + : tknGT tknGT %prec RSHIFT [ if ($2.sz != ($1.sz + 1)) ZZERROR; ] { $$ = MergeCppToken($1, $2); } ; operfuncname - : tknOperator '+' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '-' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '*' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '/' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '%' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '^' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '&' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '|' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '~' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '!' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '=' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknLT [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknGT [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknPlusEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknMinusEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknMulEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknDivEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknPerEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknXorEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknAndEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknOrEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknLShift [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknRShift [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknLShiftEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknRShiftEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknCmpEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknNotEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknLessEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknGreaterEq [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tkn3WayCmp [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknAnd [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknOr [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknInc [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknDec [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator ',' [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknArrow [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknArrowStar [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator '(' ')' [ZZLOG;] { $$ = mergeCppToken($1, $3); } - | tknOperator '[' ']' [ZZLOG;] { $$ = mergeCppToken($1, $3); } - | tknOperator tknNew [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknNew '[' ']' [ZZLOG;] { $$ = mergeCppToken($1, $4); } - | tknOperator tknDelete [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator tknDelete '[' ']' [ZZLOG;] { $$ = mergeCppToken($1, $4); } - | tknOperator typeidentifier [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknOperator typeidentifier '*' [ZZLOG;] { $$ = mergeCppToken($1, $3); } - | identifier tknScopeResOp operfuncname [ZZLOG;] { $$ = mergeCppToken($1, $3); } + : tknOperator '+' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '-' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '*' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '/' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '%' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '^' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '&' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '|' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '~' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '!' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '=' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknLT [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknGT [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknPlusEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknMinusEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknMulEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknDivEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknPerEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknXorEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknAndEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknOrEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknLShift [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknRShift [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknLShiftEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknRShiftEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknCmpEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknNotEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknLessEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknGreaterEq [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tkn3WayCmp [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknAnd [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknOr [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknInc [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknDec [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator ',' [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknArrow [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknArrowStar [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator '(' ')' [ZZLOG;] { $$ = MergeCppToken($1, $3); } + | tknOperator '[' ']' [ZZLOG;] { $$ = MergeCppToken($1, $3); } + | tknOperator tknNew [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknNew '[' ']' [ZZLOG;] { $$ = MergeCppToken($1, $4); } + | tknOperator tknDelete [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator tknDelete '[' ']' [ZZLOG;] { $$ = MergeCppToken($1, $4); } + | tknOperator typeidentifier [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknOperator typeidentifier '*' [ZZLOG;] { $$ = MergeCppToken($1, $3); } + | identifier tknScopeResOp operfuncname [ZZLOG;] { $$ = MergeCppToken($1, $3); } /* see https://en.cppreference.com/w/cpp/language/user_literal */ - | tknOperator tknStrLit name [ZZLOG;] { $$ = mergeCppToken($1, $3); } + | tknOperator tknStrLit name [ZZLOG;] { $$ = MergeCppToken($1, $3); } /* To fix something like: friend void* operator new(size_t, GrTAllocator*); */ - | operfuncname tknLT templatearglist tknGT [ZZLOG;] { $$ = mergeCppToken($1, $4); } + | operfuncname tknLT templatearglist tknGT [ZZLOG;] { $$ = MergeCppToken($1, $4); } ; paramlist @@ -1429,16 +1429,16 @@ param ; templatearg - : [ZZLOG; $$ = nullptr;] { /*$$ = makeCppToken(nullptr, nullptr);*/ } - | vartype [ZZLOG; $$ = nullptr;] { /*$$ = mergeCppToken($1, $2);*/ } + : [ZZLOG; $$ = nullptr;] { /*$$ = MakeCppToken(nullptr, nullptr);*/ } + | vartype [ZZLOG; $$ = nullptr;] { /*$$ = MergeCppToken($1, $2);*/ } | funcobjstr [ZZLOG; $$ = nullptr;] { /*$$ = $1;*/ } | expr [ZZLOG; $$ = nullptr;] {} ; templatearglist : templatearg [ZZLOG; $$ = $1; ] {} - | templatearglist ',' templatearg [ZZLOG; $$ = $1;] { /*$$ = mergeCppToken($1, $3);*/ } - | templatearglist ',' doccomment templatearg [ZZLOG; $$ = $1;] { /*$$ = mergeCppToken($1, $3);*/ } + | templatearglist ',' templatearg [ZZLOG; $$ = $1;] { /*$$ = MergeCppToken($1, $3);*/ } + | templatearglist ',' doccomment templatearg [ZZLOG; $$ = $1;] { /*$$ = MergeCppToken($1, $3);*/ } ; functype @@ -1512,21 +1512,21 @@ ctordefn | name tknScopeResOp name [if($1 != $3) ZZERROR; else ZZVALID;] '(' paramlist ')' optfuncthrowspec meminitlist block [ZZVALID;] { - $$ = new cppast::CppConstructor(mergeCppToken($1, $3), Obj($6), Obj($9), 0); + $$ = new cppast::CppConstructor(MergeCppToken($1, $3), Obj($6), Obj($9), 0); $$->defn(Ptr($10)); $$->throwSpec(Obj($8)); } | identifier tknScopeResOp name tknScopeResOp name [if($3 != $5) ZZERROR; else ZZVALID;] '(' paramlist ')' optfuncthrowspec meminitlist block [ZZVALID;] { - $$ = new cppast::CppConstructor(mergeCppToken($1, $5), Obj($8), Obj($11), 0); + $$ = new cppast::CppConstructor(MergeCppToken($1, $5), Obj($8), Obj($11), 0); $$->defn(Ptr($12)); $$->throwSpec(Obj($10)); } | name tknLT templatearglist tknGT tknScopeResOp name [if($1 != $6) ZZERROR; else ZZVALID;] '(' paramlist ')' optfuncthrowspec meminitlist block [ZZVALID;] { - $$ = new cppast::CppConstructor(mergeCppToken($1, $6), Obj($9), Obj($12), 0); + $$ = new cppast::CppConstructor(MergeCppToken($1, $6), Obj($9), Obj($12), 0); $$->defn(Ptr($13)); $$->throwSpec(Obj($11)); } @@ -1545,7 +1545,7 @@ ctordecl [ if(gCompoundStack.empty()) ZZERROR; - if((gCompoundStack.top() != $1) && (classNameFromIdentifier(gCompoundStack.top()) != $1)) + if((gCompoundStack.top() != $1) && (ClassNameFromIdentifier(gCompoundStack.top()) != $1)) ZZERROR; else ZZVALID; @@ -1617,17 +1617,17 @@ dtordefn } | name tknScopeResOp '~' name [if($1 != $4) ZZERROR; else ZZVALID;] '(' ')' block { - $$ = new cppast::CppDestructor(mergeCppToken($1, $4), 0); + $$ = new cppast::CppDestructor(MergeCppToken($1, $4), 0); $$->defn(Ptr($8 ? $8 : new cppast::CppCompound(CppCompoundType::BLOCK))); } | identifier tknScopeResOp name tknScopeResOp '~' name [if($3 != $6) ZZERROR; else ZZVALID;] '(' ')' block { - $$ = new cppast::CppDestructor(mergeCppToken($1, $6), 0); + $$ = new cppast::CppDestructor(MergeCppToken($1, $6), 0); $$->defn(Ptr($10 ? $10 : new cppast::CppCompound(CppCompoundType::BLOCK))); } | name tknLT templatearglist tknGT tknScopeResOp '~' name [if($1 != $7) ZZERROR; else ZZVALID;] '(' ')' block { - $$ = new cppast::CppDestructor(mergeCppToken($1, $7), 0); + $$ = new cppast::CppDestructor(MergeCppToken($1, $7), 0); $$->defn(Ptr($11 ? $11 : new cppast::CppCompound(CppCompoundType::BLOCK))); } | templatespecifier dtordefn [ZZLOG;] { @@ -1645,7 +1645,7 @@ dtordecl [ if(gCompoundStack.empty()) ZZERROR; - if(classNameFromIdentifier(gCompoundStack.top()) != $2) + if(ClassNameFromIdentifier(gCompoundStack.top()) != $2) ZZERROR; else ZZVALID; @@ -1653,7 +1653,7 @@ dtordecl { const char* tildaStartPos = $2.sz-1; while(*tildaStartPos != '~') --tildaStartPos; - $$ = new cppast::CppDestructor(makeCppToken(tildaStartPos, $2.sz+$2.len-tildaStartPos), 0); + $$ = new cppast::CppDestructor(MakeCppToken(tildaStartPos, $2.sz+$2.len-tildaStartPos), 0); } | apidecor dtordecl [ZZLOG;] { $$ = $2; @@ -1743,7 +1743,7 @@ classdefn $$->compoundType($1); $$->apidecor($2); $$->attribSpecifierSequence(Obj($3)); - $$->name(pruneClassName($4)); + $$->name(PruneClassName($4)); $$->inheritanceList(Obj($6)); $$->addAttr($5); } @@ -1768,7 +1768,7 @@ namespacedefn : tknNamespace optidentifier '{' [ ZZVALID; - gCompoundStack.push(classNameFromIdentifier($2)); + gCompoundStack.push(ClassNameFromIdentifier($2)); ] optstmtlist '}' [ @@ -1917,21 +1917,21 @@ templateparam ; optapidecor - : [ZZLOG;] { $$ = makeCppToken(nullptr, nullptr); } + : [ZZLOG;] { $$ = MakeCppToken(nullptr, nullptr); } | apidecor [ZZLOG;] { $$ = $1; } ; apidecor : apidecortokensq [ZZLOG;] { $$ = $1; } - | apidecortokensq '(' name ')' [ZZLOG;] { $$ = mergeCppToken($1, $4); } - | apidecortokensq '(' tknNumber ')' [ZZLOG;] { $$ = mergeCppToken($1, $4); } - | apidecortokensq '(' strlit ')' [ZZLOG;] { $$ = mergeCppToken($1, $4); } + | apidecortokensq '(' name ')' [ZZLOG;] { $$ = MergeCppToken($1, $4); } + | apidecortokensq '(' tknNumber ')' [ZZLOG;] { $$ = MergeCppToken($1, $4); } + | apidecortokensq '(' strlit ')' [ZZLOG;] { $$ = MergeCppToken($1, $4); } ; apidecortokensq : tknApiDecor [ZZLOG;] { $$ = $1; } - | apidecortokensq tknApiDecor [ZZLOG;] { $$ = mergeCppToken($1, $2); } - | tknApiDecor '(' strlit ')' [ZZLOG;] { $$ = mergeCppToken($1, $4); } + | apidecortokensq tknApiDecor [ZZLOG;] { $$ = MergeCppToken($1, $2); } + | tknApiDecor '(' strlit ')' [ZZLOG;] { $$ = MergeCppToken($1, $4); } ; entityaccessspecifier @@ -1946,7 +1946,7 @@ externcblock strlit : tknStrLit [ZZLOG;] { $$ = $1; } - | strlit tknStrLit [ZZLOG;] { $$ = mergeCppToken($1, $2); } + | strlit tknStrLit [ZZLOG;] { $$ = MergeCppToken($1, $2); } ; expr @@ -2034,13 +2034,13 @@ expr | expr '.' '*' expr [ZZLOG;] { $$ = BinomialExpr(cppast::CppBinaryOperator::DOT, $1, MonomialExpr(cppast::CppUnaryOperator::DEREFER, $4)); } | expr tknArrow expr [ZZLOG;] { $$ = BinomialExpr(cppast::CppBinaryOperator::ARROW, $1, $3); } | expr tknArrowStar expr [ZZLOG;] { $$ = BinomialExpr(cppast::CppBinaryOperator::ARROW_STAR, $1, $3); } - | expr '.' '~' funcname [ZZLOG;] { $$ = BinomialExpr(cppast::CppBinaryOperator::DOT, $1, mergeCppToken($3, $4)); } - | expr tknArrow '~' funcname [ZZLOG;] { $$ = BinomialExpr(cppast::CppBinaryOperator::ARROW, $1, mergeCppToken($3, $4)); } + | expr '.' '~' funcname [ZZLOG;] { $$ = BinomialExpr(cppast::CppBinaryOperator::DOT, $1, MergeCppToken($3, $4)); } + | expr tknArrow '~' funcname [ZZLOG;] { $$ = BinomialExpr(cppast::CppBinaryOperator::ARROW, $1, MergeCppToken($3, $4)); } | expr '[' expr ']' %prec SUBSCRIPT [ZZLOG;] { $$ = BinomialExpr(cppast::CppBinaryOperator::ARRAY_INDEX, $1, $3); } /*| expr '[' ']' %prec SUBSCRIPT [ZZLOG;] { $$ = BinomialExpr($1, kArrayElem); }*/ | expr '(' optexprlist ')' %prec FUNCCALL [ZZLOG;] { $$ = FuncCallExpr($1, $3); } | funcname '(' optexprlist ')' %prec FUNCCALL [ZZLOG;] { $$ = FuncCallExpr(NameExpr($1), $3); } - | expr tknArrow '~' identifier '(' ')' %prec FUNCCALL [ZZLOG;] { $$ = BinomialExpr(cppast::CppBinaryOperator::ARROW, $1, FuncCallExpr(NameExpr(mergeCppToken($3, $4)))); } + | expr tknArrow '~' identifier '(' ')' %prec FUNCCALL [ZZLOG;] { $$ = BinomialExpr(cppast::CppBinaryOperator::ARROW, $1, FuncCallExpr(NameExpr(MergeCppToken($3, $4)))); } | expr '?' expr ':' expr %prec TERNARYCOND [ZZLOG;] { $$ = TrinomialExpr(cppast::CppTernaryOperator::CONDITIONAL, $1, $3, $5); } | identifier '{' optexprlist '}' %prec FUNCCALL [ZZLOG;] { $$ = UniformInitExpr($1, $3); } | '(' vartype ')' expr %prec CSTYLECAST [ZZLOG;] { $$ = CStyleCastExpr($2, $4); } @@ -2256,12 +2256,12 @@ static void setupEnv() #endif } -void setErrorHandler(ErrorHandler errorHandler) +void SetErrorHandler(ErrorHandler errorHandler) { gErrorHandler = errorHandler; } -void resetErrorHandler() +void ResetErrorHandler() { gErrorHandler = defaultErrorHandler; } @@ -2299,7 +2299,7 @@ int GetKeywordId(const std::string& keyword) return (itr != keywordToIdMap.end()) ? itr->second : -1; } -std::unique_ptr parseStream(char* stm, size_t stmSize) +std::unique_ptr ParseStream(char* stm, size_t stmSize) { gProgUnit = nullptr; diff --git a/cppparser/src/utils.cpp b/cppparser/src/utils.cpp index 0ac1243bd..ef4742334 100644 --- a/cppparser/src/utils.cpp +++ b/cppparser/src/utils.cpp @@ -11,12 +11,12 @@ namespace fs = std::filesystem; -static CppToken classNameFromTemplatedIdentifier(const CppToken& identifier) +static CppToken ClassNameFromTemplatedIdentifier(const CppToken& identifier) { - auto rbeg = rev(identifier.sz + identifier.len); + auto rbeg = std::reverse_iterator(identifier.sz + identifier.len); assert(*rbeg == '>'); - auto rend = rev(identifier.sz); + auto rend = std::reverse_iterator(identifier.sz); int numTempl = 1; for (++rbeg; rbeg != rend; ++rbeg) { @@ -38,13 +38,13 @@ static CppToken classNameFromTemplatedIdentifier(const CppToken& identifier) return CppToken {nullptr, 0U}; } -CppToken classNameFromIdentifier(const CppToken& identifier) +CppToken ClassNameFromIdentifier(const CppToken& identifier) { if (identifier.sz == nullptr) return identifier; if (identifier.sz[identifier.len - 1] == '>') - return classNameFromIdentifier(classNameFromTemplatedIdentifier(identifier)); + return ClassNameFromIdentifier(ClassNameFromTemplatedIdentifier(identifier)); const char* scopeResolutor = "::"; const char* end = identifier.sz + identifier.len; @@ -58,7 +58,7 @@ CppToken classNameFromIdentifier(const CppToken& identifier) return CppToken {itr, clsNameLen}; } -std::string readFile(const std::string& filename) +std::string ReadFile(const std::string& filename) { std::string contents; std::ifstream in(filename, std::ios::in | std::ios::binary); @@ -70,7 +70,7 @@ std::string readFile(const std::string& filename) in.seekg(0, std::ios::beg); in.read(contents.data(), size); in.close(); - auto len = stripChar(contents.data(), size, '\r'); + auto len = StripChar(contents.data(), size, '\r'); assert(len <= size); contents.resize(len + 3); contents[len] = '\n'; @@ -100,7 +100,7 @@ std::string readFile(const std::string& filename) // std::sort(files.begin(), files.end()); // } -std::vector explode(CppToken token, const char* delim) +std::vector Explode(CppToken token, const char* delim) { auto const delimLen = strlen(delim); std::vector elems; @@ -123,7 +123,7 @@ std::vector explode(CppToken token, const char* delim) return elems; } -std::string pruneClassName(const CppToken& identifier) +std::string PruneClassName(const CppToken& identifier) { std::string ret; for (size_t i = 0; i < identifier.len; ++i) diff --git a/cppparser/src/utils.h b/cppparser/src/utils.h index e2a5b7081..f2de2c546 100644 --- a/cppparser/src/utils.h +++ b/cppparser/src/utils.h @@ -9,18 +9,12 @@ #include #include -template -inline std::reverse_iterator rev(Iter i) -{ - return std::reverse_iterator(i); -} +CppToken ClassNameFromIdentifier(const CppToken& identifier); -CppToken classNameFromIdentifier(const CppToken& identifier); +std::string PruneClassName(const CppToken& identifier); -std::string pruneClassName(const CppToken& identifier); +std::string ReadFile(const std::string& filename); -std::string readFile(const std::string& filename); - -std::vector explode(CppToken token, const char* delim); +std::vector Explode(CppToken token, const char* delim); #endif /* A531EBC7_86A1_42D5_91DA_9257FBF65184 */ diff --git a/cppparser/test/unit/embedded-snippet-test-base.h b/cppparser/test/unit/embedded-snippet-test-base.h index c0bb77dae..b3923f3e2 100644 --- a/cppparser/test/unit/embedded-snippet-test-base.h +++ b/cppparser/test/unit/embedded-snippet-test-base.h @@ -18,7 +18,7 @@ class EmbeddedSnippetTestBase protected: EmbeddedSnippetTestBase(const std::string& testProgramFile) - : testProgramFileContent(readFile(testProgramFile)) + : testProgramFileContent(ReadFile(testProgramFile)) , reverseContent(testProgramFileContent.rbegin(), testProgramFileContent.rend()) { } diff --git a/cppparser/test/unit/initializer-list-test.cpp b/cppparser/test/unit/initializer-list-test.cpp index 6fdaa0d67..65e11248c 100644 --- a/cppparser/test/unit/initializer-list-test.cpp +++ b/cppparser/test/unit/initializer-list-test.cpp @@ -40,14 +40,14 @@ TEST_CASE_METHOD(InitializerListTest, "docstr in middle", "[initializerlist]") TEST_CASE_METHOD(InitializerListTest, "designated initializer", "[initializerlist]") { #if TEST_CASE_SNIPPET_STARTS_FROM_NEXT_LINE -# if EVADE_COMPILER +# if EVADE_COMPILER struct Point { int x; int y; }; Point p = {.x = 4, .y = 0}; -# endif +# endif #endif auto testSnippet = getTestSnippetParseStream(__LINE__ - 2); diff --git a/cppwriter/src/cppwriter.cpp b/cppwriter/src/cppwriter.cpp index 4e00e85ad..63e4dcfbb 100644 --- a/cppwriter/src/cppwriter.cpp +++ b/cppwriter/src/cppwriter.cpp @@ -276,7 +276,7 @@ void CppWriter::emitBlob(const cppast::CppBlob& blobObj, // } // else { - stm << blobObj.Blob(); + stm << blobObj.blob(); } } @@ -296,7 +296,7 @@ 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); + const auto attr = varTypeObj.typeAttr() | (IsConst(varTypeObj) ? cppast::CppIdentifierAttrib::CONST : 0); emitAttribute(attr, stm); if (varTypeObj.compound()) emit(*varTypeObj.compound(), stm, CppIndent(), true); @@ -529,7 +529,7 @@ void CppWriter::emitCompound(const cppast::CppCompound& compoundObj, CppIndent indentation, bool emitNewLine) const { - if (isNamespaceLike(compoundObj)) + if (IsNamespaceLike(compoundObj)) { if (compoundObj.isTemplated()) { @@ -559,7 +559,7 @@ void CppWriter::emitCompound(const cppast::CppCompound& compoundObj, } --indentation; } - if (isNamespaceLike(compoundObj)) + if (IsNamespaceLike(compoundObj)) stm << '\n' << indentation++ << "{\n"; else if (compoundObj.compoundType() == cppast::CppCompoundType::EXTERN_C_BLOCK) stm << indentation++ << "extern \"C\" {\n"; @@ -572,13 +572,13 @@ void CppWriter::emitCompound(const cppast::CppCompound& compoundObj, return true; }); - if (isNamespaceLike(compoundObj)) + if (IsNamespaceLike(compoundObj)) { stm << --indentation; stm << '}'; if (emitNewLine) { - if (isClassLike(compoundObj)) + if (IsClassLike(compoundObj)) stm << ';'; stm << '\n'; } @@ -771,7 +771,7 @@ void CppWriter::emitConstructor(const cppast::CppConstructor& ctorObj, } else { - if (isDeleted(ctorObj)) + if (IsDeleted(ctorObj)) stm << " = delete"; stm << ";\n"; }