Bladeren bron

Clang-Tidy - partial revert for cert-err58-cpp.

Yao Wei Tjong 姚伟忠 8 jaren geleden
bovenliggende
commit
20eeec2b84

+ 2 - 2
Source/Urho3D/AngelScript/APITemplates.h

@@ -407,6 +407,8 @@ template <class T> void RegisterNamedObjectConstructor(asIScriptEngine* engine,
     engine->RegisterObjectBehaviour(className, asBEHAVE_FACTORY, declFactoryWithName.CString(), asFUNCTION(ConstructNamedObject<T>), asCALL_CDECL);
 }
 
+static const AttributeInfo noAttributeInfo;
+
 // To keep Xcode LLVM/Clang happy - it erroneously warns on unused functions defined below which are actually being referenced in the code
 #if __clang__
 #pragma clang diagnostic push
@@ -415,8 +417,6 @@ template <class T> void RegisterNamedObjectConstructor(asIScriptEngine* engine,
 
 static const AttributeInfo& SerializableGetAttributeInfo(unsigned index, Serializable* ptr)
 {
-    static const AttributeInfo noAttributeInfo;
-
     const Vector<AttributeInfo>* attributes = ptr->GetAttributes();
     if (!attributes || index >= attributes->Size())
     {

+ 2 - 2
Source/Urho3D/AngelScript/GraphicsAPI.cpp

@@ -614,10 +614,10 @@ static CScriptArray* MaterialGetShaderParameterNames(Material* material)
     return VectorToArray<String>(result, "Array<String>");
 }
 
+static TechniqueEntry noTechniqueEntry;
+
 static const TechniqueEntry& MaterialGetTechniqueEntry(unsigned index, Material* ptr)
 {
-    static TechniqueEntry noTechniqueEntry;
-
     if (index >= ptr->GetNumTechniques())
     {
         asGetActiveContext()->SetException("Index out of bounds");

+ 2 - 11
Source/Urho3D/Core/Object.cpp

@@ -530,19 +530,10 @@ void Object::RemoveEventSender(Object* sender)
     }
 }
 
-
-Urho3D::StringHash EventNameRegistrar::RegisterEventName(const char* eventName) noexcept
+Urho3D::StringHash EventNameRegistrar::RegisterEventName(const char* eventName)
 {
     StringHash id(eventName);
-    try
-    {
-        GetEventNameMap()[id] = eventName;
-    }
-    catch (std::bad_alloc&)
-    {
-        PrintLine("An out-of-memory error occurred. The application will now terminate.", true);
-        std::terminate();
-    }
+    GetEventNameMap()[id] = eventName;
     return id;
 }
 

+ 1 - 1
Source/Urho3D/Core/Object.h

@@ -358,7 +358,7 @@ private:
 struct URHO3D_API EventNameRegistrar
 {
     /// Register an event name for hash reverse mapping.
-    static StringHash RegisterEventName(const char* eventName) noexcept;
+    static StringHash RegisterEventName(const char* eventName);
     /// Return Event name or empty string if not found.
     static const String& GetEventName(StringHash eventID);
     /// Return Event name map.

+ 5 - 5
Source/Urho3D/Core/StringUtils.cpp

@@ -31,6 +31,11 @@
 namespace Urho3D
 {
 
+static const String base64_chars =
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+    "abcdefghijklmnopqrstuvwxyz"
+    "0123456789+/";
+
 unsigned CountElements(const char* buffer, char separator)
 {
     if (!buffer)
@@ -789,11 +794,6 @@ static inline bool IsBase64(char c) {
 
 PODVector<unsigned char> DecodeBase64(String encodedString)
 {
-    static const String base64_chars =
-        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-        "abcdefghijklmnopqrstuvwxyz"
-        "0123456789+/";
-
     int inLen = encodedString.Length();
     int i = 0;
     int j = 0;

+ 11 - 11
Source/Urho3D/Graphics/AnimatedModel.cpp

@@ -49,6 +49,17 @@ namespace Urho3D
 
 extern const char* GEOMETRY_CATEGORY;
 
+static const StringVector animationStatesStructureElementNames =
+{
+    "Anim State Count",
+    "   Animation",
+    "   Start Bone",
+    "   Is Looped",
+    "   Weight",
+    "   Time",
+    "   Layer"
+};
+
 static bool CompareAnimationOrder(const SharedPtr<AnimationState>& lhs, const SharedPtr<AnimationState>& rhs)
 {
     return lhs->GetLayer() < rhs->GetLayer();
@@ -90,17 +101,6 @@ AnimatedModel::~AnimatedModel()
 
 void AnimatedModel::RegisterObject(Context* context)
 {
-    static const StringVector animationStatesStructureElementNames =
-        {
-            "Anim State Count",
-            "   Animation",
-            "   Start Bone",
-            "   Is Looped",
-            "   Weight",
-            "   Time",
-            "   Layer"
-        };
-
     context->RegisterFactory<AnimatedModel>(GEOMETRY_CATEGORY);
 
     URHO3D_ACCESSOR_ATTRIBUTE("Is Enabled", IsEnabled, SetEnabled, bool, true, AM_DEFAULT);

+ 12 - 12
Source/Urho3D/Graphics/BillboardSet.cpp

@@ -57,6 +57,18 @@ const char* faceCameraModeNames[] =
     nullptr
 };
 
+static const StringVector billboardsStructureElementNames =
+{
+    "Billboard Count",
+    "   Position",
+    "   Size",
+    "   UV Coordinates",
+    "   Color",
+    "   Rotation",
+    "   Direction",
+    "   Is Enabled"
+};
+
 inline bool CompareBillboards(Billboard* lhs, Billboard* rhs)
 {
     return lhs->sortDistance_ > rhs->sortDistance_;
@@ -97,18 +109,6 @@ BillboardSet::~BillboardSet() = default;
 
 void BillboardSet::RegisterObject(Context* context)
 {
-    static const StringVector billboardsStructureElementNames =
-        {
-            "Billboard Count",
-            "   Position",
-            "   Size",
-            "   UV Coordinates",
-            "   Color",
-            "   Rotation",
-            "   Direction",
-            "   Is Enabled"
-        };
-
     context->RegisterFactory<BillboardSet>(GEOMETRY_CATEGORY);
 
     URHO3D_ACCESSOR_ATTRIBUTE("Is Enabled", IsEnabled, SetEnabled, bool, true, AM_DEFAULT);

+ 2 - 2
Source/Urho3D/Graphics/Material.cpp

@@ -155,6 +155,8 @@ StringHash ParseTextureTypeXml(ResourceCache* cache, String filename)
     return type;
 }
 
+static TechniqueEntry noEntry;
+
 bool CompareTechniqueEntries(const TechniqueEntry& lhs, const TechniqueEntry& rhs)
 {
     if (lhs.lodDistance_ != rhs.lodDistance_)
@@ -1186,8 +1188,6 @@ void Material::MarkForAuxView(unsigned frameNumber)
 
 const TechniqueEntry& Material::GetTechniqueEntry(unsigned index) const
 {
-    static TechniqueEntry noEntry;
-
     return index < techniques_.Size() ? techniques_[index] : noEntry;
 }
 

+ 6 - 6
Source/Urho3D/Graphics/StaticModelGroup.cpp

@@ -40,6 +40,12 @@ namespace Urho3D
 
 extern const char* GEOMETRY_CATEGORY;
 
+static const StringVector instanceNodesStructureElementNames =
+{
+    "Instance Count",
+    "   NodeID"
+};
+
 StaticModelGroup::StaticModelGroup(Context* context) :
     StaticModel(context),
     nodesDirty_(false),
@@ -53,12 +59,6 @@ StaticModelGroup::~StaticModelGroup() = default;
 
 void StaticModelGroup::RegisterObject(Context* context)
 {
-    static const StringVector instanceNodesStructureElementNames =
-        {
-            "Instance Count",
-            "   NodeID"
-        };
-
     context->RegisterFactory<StaticModelGroup>(GEOMETRY_CATEGORY);
 
     URHO3D_COPY_BASE_ATTRIBUTES(StaticModel);

+ 23 - 23
Source/Urho3D/Navigation/CrowdManager.cpp

@@ -46,6 +46,29 @@ extern const char* NAVIGATION_CATEGORY;
 static const unsigned DEFAULT_MAX_AGENTS = 512;
 static const float DEFAULT_MAX_AGENT_RADIUS = 0.f;
 
+static const StringVector filterTypesStructureElementNames =
+{
+    "Query Filter Type Count",
+    "   Include Flags",
+    "   Exclude Flags",
+    "   >AreaCost"
+};
+
+static const StringVector obstacleAvoidanceTypesStructureElementNames =
+{
+    "Obstacle Avoid. Type Count",
+    "   Velocity Bias",
+    "   Desired Velocity Weight",
+    "   Current Velocity Weight",
+    "   Side Bias Weight",
+    "   Time of Impact Weight",
+    "   Time Horizon",
+    "   Grid Size",
+    "   Adaptive Divs",
+    "   Adaptive Rings",
+    "   Adaptive Depth"
+};
+
 void CrowdAgentUpdateCallback(dtCrowdAgent* ag, float dt)
 {
     static_cast<CrowdAgent*>(ag->params.userData)->OnCrowdUpdate(ag, dt);
@@ -74,29 +97,6 @@ CrowdManager::~CrowdManager()
 
 void CrowdManager::RegisterObject(Context* context)
 {
-    static const StringVector filterTypesStructureElementNames =
-        {
-            "Query Filter Type Count",
-            "   Include Flags",
-            "   Exclude Flags",
-            "   >AreaCost"
-        };
-
-    static const StringVector obstacleAvoidanceTypesStructureElementNames =
-        {
-            "Obstacle Avoid. Type Count",
-            "   Velocity Bias",
-            "   Desired Velocity Weight",
-            "   Current Velocity Weight",
-            "   Side Bias Weight",
-            "   Time of Impact Weight",
-            "   Time Horizon",
-            "   Grid Size",
-            "   Adaptive Divs",
-            "   Adaptive Rings",
-            "   Adaptive Depth"
-        };
-
     context->RegisterFactory<CrowdManager>(NAVIGATION_CATEGORY);
 
     URHO3D_ATTRIBUTE("Max Agents", unsigned, maxAgents_, DEFAULT_MAX_AGENTS, AM_DEFAULT);

+ 26 - 26
Source/Urho3D/Physics/RaycastVehicle.cpp

@@ -147,34 +147,34 @@ RaycastVehicle::~RaycastVehicle()
     wheelNodes_.Clear();
 }
 
+static const StringVector wheelElementNames =
+{
+    "Number of wheels",
+    "   Wheel node id",
+    "   Wheel direction",
+    "   Wheel axle",
+    "   Wheel rest length",
+    "   Wheel radius",
+    "   Wheel is front wheel",
+    "   Steering",
+    "   Connection point vector",
+    "   Original rotation",
+    "   Cumulative skid info",
+    "   Side skip speed",
+    "   Grounded",
+    "   Contact position",
+    "   Contact normal",
+    "   Suspension stiffness",
+    "   Damping relaxation",
+    "   Damping compression",
+    "   Friction slip",
+    "   Roll influence",
+    "   Engine force",
+    "   Brake"
+};
+
 void RaycastVehicle::RegisterObject(Context* context)
 {
-    static const StringVector wheelElementNames =
-        {
-            "Number of wheels",
-            "   Wheel node id",
-            "   Wheel direction",
-            "   Wheel axle",
-            "   Wheel rest length",
-            "   Wheel radius",
-            "   Wheel is front wheel",
-            "   Steering",
-            "   Connection point vector",
-            "   Original rotation",
-            "   Cumulative skid info",
-            "   Side skip speed",
-            "   Grounded",
-            "   Contact position",
-            "   Contact normal",
-            "   Suspension stiffness",
-            "   Damping relaxation",
-            "   Damping compression",
-            "   Friction slip",
-            "   Roll influence",
-            "   Engine force",
-            "   Brake"
-        };
-
     context->RegisterFactory<RaycastVehicle>();
     URHO3D_MIXED_ACCESSOR_ATTRIBUTE("Wheel data", GetWheelDataAttr, SetWheelDataAttr, VariantVector, Variant::emptyVariantVector, AM_DEFAULT)
         .SetMetadata(AttributeMetadata::P_VECTOR_STRUCT_ELEMENTS, wheelElementNames);

+ 6 - 6
Source/Urho3D/Scene/SplinePath.cpp

@@ -33,6 +33,12 @@ namespace Urho3D
 extern const char* interpolationModeNames[];
 extern const char* LOGIC_CATEGORY;
 
+static const StringVector controlPointsStructureElementNames =
+{
+    "Control Point Count",
+    "   NodeID"
+};
+
 SplinePath::SplinePath(Context* context) :
     Component(context),
     spline_(BEZIER_CURVE),
@@ -48,12 +54,6 @@ SplinePath::SplinePath(Context* context) :
 
 void SplinePath::RegisterObject(Context* context)
 {
-    static const StringVector controlPointsStructureElementNames =
-        {
-            "Control Point Count",
-            "   NodeID"
-        };
-
     context->RegisterFactory<SplinePath>(LOGIC_CATEGORY);
 
     URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Interpolation Mode", GetInterpolationMode, SetInterpolationMode, InterpolationMode,

+ 3 - 3
Source/Urho3D/Scene/UnknownComponent.cpp

@@ -35,11 +35,11 @@
 namespace Urho3D
 {
 
+static HashMap<StringHash, String> unknownTypeToName;
+static String letters("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
+
 static String GenerateNameFromType(StringHash typeHash)
 {
-    static HashMap<StringHash, String> unknownTypeToName;
-    static String letters("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
-
     if (unknownTypeToName.Contains(typeHash))
         return unknownTypeToName[typeHash];