Skip to content

Commit

Permalink
Clean up clang warnings, potential errors.
Browse files Browse the repository at this point in the history
Signed-off-by: furby™ <[email protected]>
  • Loading branch information
furby-tm committed Sep 15, 2024
1 parent f103cb2 commit 42de343
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 26 deletions.
7 changes: 4 additions & 3 deletions Sources/Arch/include/Arch/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@
# define ARCH_HAS_GNU_STL_EXTENSIONS
#endif

// The current version of Apple clang does not support the thread_local
// keyword.
#if !(defined(ARCH_OS_DARWIN) && defined(ARCH_COMPILER_CLANG))
// The current version of Apple clang does not support the thread_local keyword.
// WABI: always enabled thread_local, removed the all darwin platform disabling:
// !(defined(ARCH_OS_DARWIN) && defined(ARCH_COMPILER_CLANG))
#if 1
# define ARCH_HAS_THREAD_LOCAL
#endif

Expand Down
3 changes: 2 additions & 1 deletion Sources/Hd/sceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ std::string HdSceneIndexBase::GetDisplayName() const
return _displayName;
}

return ArchGetDemangled(typeid(*this).name());
auto& thisType = (*this);
return ArchGetDemangled(typeid(thisType).name());
}

void HdSceneIndexBase::SetDisplayName(const std::string &n)
Expand Down
2 changes: 1 addition & 1 deletion Sources/HdSt/materialXFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ static mx::NodePtr _AddStrippedSurfaceNode(mx::DocumentPtr mxDocument,
auto const &hdConnectedNode = hdNetwork.nodes.at(hdConnectedPath);
mx::NodePtr mxConnectedNode = _AddStrippedSurfaceNode(
mxDocument, hdConnectedPath.GetName(), hdConnectedNode, hdNetwork);
mx::InputPtr mxInput = mxNode->addInput(mxInput->getName(), mxInput->getType());
mx::InputPtr mxInput = mxNode->addInput(mxInputDef->getName(), mxInputDef->getType());
mxInput->setConnectedNode(mxConnectedNode);
}
// Add the connection as an input with each component set to 0.5
Expand Down
6 changes: 4 additions & 2 deletions Sources/Sdf/fileFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,12 @@ void SdfFileFormat::_SetLayerData(SdfLayer *layer,
// to have the qualities the file format dictates, even if the
// underlying data object type is the same.
const SdfAbstractDataConstPtr oldData = _GetLayerData(*layer);
const auto& dataType = *get_pointer(data);
const auto& oldDataType = *get_pointer(oldData);
const bool differentDataImpl = data->StreamsData() != oldData->StreamsData() ||
data->IsDetached() != oldData->IsDetached() ||
!TfSafeTypeCompare(typeid(*get_pointer(data)),
typeid(*get_pointer(oldData)));
!TfSafeTypeCompare(typeid(dataType),
typeid(oldDataType));

if (differentDataImpl) {
layer->_AdoptData(data);
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sdf/include/Sdf/predicateProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ SdfPredicateProgram<DomainType> SdfLinkPredicateExpression(

if (!errs.empty()) {
prog = {};
TF_RUNTIME_ERROR(errs.c_str());
TF_RUNTIME_ERROR("%s", errs.c_str());
}
return prog;
}
Expand Down
8 changes: 5 additions & 3 deletions Sources/Sdf/specType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ static bool _CanCast(const Sdf_SpecTypeInfo &specTypeInfo,
TfType Sdf_SpecType::Cast(const SdfSpec &from, const std::type_info &to)
{
const Sdf_SpecTypeInfo &specTypeInfo = Sdf_SpecTypeInfo::GetInstance();

const TfType &schemaType = TfType::Find(typeid(from.GetSchema()));

const auto& needle = from.GetSchema();
const TfType &schemaType = TfType::Find(typeid(needle));
if (!TF_VERIFY(!schemaType.IsUnknown())) {
return TfType();
}
Expand Down Expand Up @@ -234,7 +235,8 @@ bool Sdf_SpecType::CanCast(const SdfSpec &from, const std::type_info &to)
const SdfSpecType fromType = from.GetSpecType();
const TfType &toType = TfType::Find(to);

const TfType &fromSchemaType = TfType::Find(typeid(from.GetSchema()));
const auto& needle = from.GetSchema();
const TfType &fromSchemaType = TfType::Find(typeid(needle));

TfBigRWMutex::ScopedLock lock(specTypeInfo.mutex, /*write=*/false);

Expand Down
3 changes: 2 additions & 1 deletion Sources/Tf/notice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ size_t TfNotice::_Send(const TfWeakBase *s,
{
// Look up the notice type using the static type_info.
// This is faster than TfType::Find().
TfType noticeType = TfType::Find(typeid(*this));
auto& thisType = (*this);
TfType noticeType = TfType::Find(typeid(thisType));

return Tf_NoticeRegistry::_GetInstance()._Send(*this, noticeType, s, senderUniqueId, senderType);
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Usd/primDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ SdfPropertySpecHandle UsdPrimDefinition::_FindOrCreatePropertySpecForComposition
// we create a new layer for this prim definition to write its composed
// properties.
if (_composedPropertyLayer) {
if (destProp = _composedPropertyLayer->GetPropertyAtPath(primPath.AppendProperty(propName))) {
if ((destProp = _composedPropertyLayer->GetPropertyAtPath(primPath.AppendProperty(propName)))) {
return destProp;
}
}
Expand Down
10 changes: 6 additions & 4 deletions Sources/UsdGeom/include/UsdGeom/hermiteCurves.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ class UsdGeomHermiteCurves : public UsdGeomCurves {
///
/// If points and tangents are not the same size, an empty container
/// is created.
PointAndTangentArrays(const VtVec3fArray &points, const VtVec3fArray &tangents)
: _points(points), _tangents(tangents)
explicit PointAndTangentArrays(const VtVec3fArray &points,
const VtVec3fArray &tangents)
: _points(points),
_tangents(tangents)
{
if (_points.size() != _tangents.size()) {
TF_RUNTIME_ERROR("Points and tangents must be the same size.");
Expand Down Expand Up @@ -254,11 +256,11 @@ class UsdGeomHermiteCurves : public UsdGeomCurves {
return _tangents;
}

bool operator==(const PointAndTangentArrays &other)
bool operator==(const PointAndTangentArrays &other) const
{
return (GetPoints() == other.GetPoints()) && (GetTangents() == other.GetTangents());
}
bool operator!=(const PointAndTangentArrays &other)
bool operator!=(const PointAndTangentArrays &other) const
{
return !((*this) == other);
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/UsdImaging/include/UsdImaging/cylinderLightAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class UsdImagingCylinderLightAdapter : public UsdImagingLightAdapter {
USDIMAGING_API
virtual SdfPath Populate(UsdPrim const &prim,
UsdImagingIndexProxy *index,
UsdImagingInstancerContext const *instancerContext = NULL);
UsdImagingInstancerContext const *instancerContext = NULL) override;

USDIMAGING_API
virtual bool IsSupported(UsdImagingIndexProxy const *index) const;
virtual bool IsSupported(UsdImagingIndexProxy const *index) const override;

protected:
virtual void _RemovePrim(SdfPath const &cachePath, UsdImagingIndexProxy *index) final;
Expand Down
4 changes: 2 additions & 2 deletions Sources/UsdImaging/include/UsdImaging/portalLightAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class UsdImagingPortalLightAdapter : public UsdImagingLightAdapter {
USDIMAGING_API
virtual SdfPath Populate(UsdPrim const &prim,
UsdImagingIndexProxy *index,
UsdImagingInstancerContext const *instancerContext = NULL);
UsdImagingInstancerContext const *instancerContext = NULL) override;

USDIMAGING_API
virtual bool IsSupported(UsdImagingIndexProxy const *index) const;
virtual bool IsSupported(UsdImagingIndexProxy const *index) const override;

// ---------------------------------------------------------------------- //
/// \name Scene Index Support
Expand Down
2 changes: 1 addition & 1 deletion Sources/UsdImaging/include/UsdImaging/tetMeshAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class UsdImagingTetMeshAdapter : public UsdImagingGprimAdapter {
void TrackVariability(UsdPrim const &prim,
SdfPath const &cachePath,
HdDirtyBits *timeVaryingBits,
UsdImagingInstancerContext const *instancerContext = nullptr) const;
UsdImagingInstancerContext const *instancerContext = nullptr) const override;

// ---------------------------------------------------------------------- //
/// \name Change Processing
Expand Down
6 changes: 4 additions & 2 deletions Sources/UsdImaging/indexProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ UsdImagingDelegate::_HdPrimInfo *UsdImagingIndexProxy::_AddHdPrimInfo(
}
}

auto& adapterToInsertType = *(adapterToInsert.get());
TF_DEBUG(USDIMAGING_CHANGES)
.Msg("[Add HdPrim Info] <%s> adapter=%s\n",
cachePath.GetText(),
TfType::GetCanonicalTypeName(typeid(*(adapterToInsert.get()))).c_str());
TfType::GetCanonicalTypeName(typeid(adapterToInsertType)).c_str());

// Currently, we don't support more than one adapter dependency per usd
// prim, but we could relax this restriction if it's useful.
Expand Down Expand Up @@ -250,10 +251,11 @@ void UsdImagingIndexProxy::InsertInstancer(SdfPath const &cachePath,
primInfo->dirtyBits = HdChangeTracker::AllDirty;
_delegate->_dirtyCachePaths.insert(cachePath);

auto& adapterType = (*adapter);
TF_DEBUG(USDIMAGING_INSTANCER)
.Msg("[Instancer Inserted] %s, adapter = %s\n",
cachePath.GetText(),
adapter ? TfType::GetCanonicalTypeName(typeid(*adapter)).c_str() : "none");
adapter ? TfType::GetCanonicalTypeName(typeid(adapterType)).c_str() : "none");

_AddTask(cachePath);
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/UsdImaging/instanceAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,13 @@ SdfPath UsdImagingInstanceAdapter::_Populate(UsdPrim const &prim,
protoPath = newProtoPath;
}

auto& primAdapterType = (*primAdapter);
TF_DEBUG(USDIMAGING_INSTANCER)
.Msg("[Add Instance NI] <%s> %s (%s), adapter = %s\n",
instancerPath.GetText(),
protoPath.GetText(),
iter->GetName().GetText(),
primAdapter ? TfType::GetCanonicalTypeName(typeid(*primAdapter)).c_str() : "none");
primAdapter ? TfType::GetCanonicalTypeName(typeid(primAdapterType)).c_str() : "none");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class UsdUtils_ReadOnlyLocalizationDelegate : public UsdUtils_LocalizationDelega
virtual std::vector<std::string> ProcessSublayers(const SdfLayerRefPtr &layer) override;

virtual std::vector<std::string> ProcessPayloads(const SdfLayerRefPtr &layer,
const SdfPrimSpecHandle &primSpec);
const SdfPrimSpecHandle &primSpec) override;

virtual std::vector<std::string> ProcessReferences(const SdfLayerRefPtr &layer,
const SdfPrimSpecHandle &primSpec) override;
Expand Down

0 comments on commit 42de343

Please sign in to comment.