]> OCCT Git - occt-copy.git/commitdiff
0026042: OCCT won't work with the latest Xcode
authorkgv <kgv@opencascade.com>
Wed, 6 May 2015 06:41:08 +0000 (09:41 +0300)
committerkgv <kgv@opencascade.com>
Thu, 23 Jul 2015 16:10:44 +0000 (19:10 +0300)
Workaround Clang optimization issue with NULL-reference checks
using new macros Standard_IS_NULL_REFERENCE().

src/BSplCLib/BSplCLib.cxx
src/BSplCLib/BSplCLib_2.cxx
src/BSplCLib/BSplCLib_CurveComputation.gxx
src/BSplSLib/BSplSLib.cxx
src/BSplSLib/BSplSLib_BzSyntaxes.cxx
src/LDOM/LDOM_CharacterData.cxx
src/PLib/PLib.cxx
src/Standard/Standard_Address.hxx

index e4cb5fe9a4af5c906b2ca11b0bf5343335823005..571504a2fac7bfdc283aed34d29a7fb2c2c54c1b 100644 (file)
@@ -322,7 +322,7 @@ void BSplCLib::LocateParameter
  Standard_Real&                 NewU) 
 {
   Standard_Integer first,last;
-  if (&Mults) {
+  if (!Standard_IS_NULL_REFERENCE(Mults)) {
     if (Periodic) {
       first = Knots.Lower();
       last  = Knots.Upper();
@@ -1460,7 +1460,7 @@ void BSplCLib::BuildKnots(const Standard_Integer         Degree,
   const Standard_Real * pkn = &Knots(KLower);
   pkn -= KLower;
   Standard_Real *knot = &LK;
-  if (&Mults == NULL) {
+  if (Standard_IS_NULL_REFERENCE(Mults)) {
     switch (Degree) {
     case 1 : {
       Standard_Integer j = Index    ;
@@ -1698,7 +1698,7 @@ Standard_Boolean  BSplCLib::PrepareInsertKnots
  const Standard_Real            Tolerance,
  const Standard_Boolean         Add)
 {
-  Standard_Boolean addflat = &AddMults == NULL;
+  Standard_Boolean addflat = Standard_IS_NULL_REFERENCE(AddMults);
   
   Standard_Integer first,last;
   if (Periodic) {
@@ -1882,7 +1882,7 @@ void BSplCLib::InsertKnots
  const Standard_Real            Tolerance,
  const Standard_Boolean         Add)
 {
-  Standard_Boolean addflat  = &AddMults == NULL;
+  Standard_Boolean addflat  = Standard_IS_NULL_REFERENCE(AddMults);
   
   Standard_Integer i,k,mult,firstmult;
   Standard_Integer index,kn,curnk,curk;
@@ -3932,7 +3932,7 @@ void BSplCLib::Resolution(      Standard_Real&        Poles,
   num_poles = FlatKnots.Length() - Deg1;
   switch (ArrayDimension) {
   case 2 : {
-    if (&Weights != NULL) {
+    if (!Standard_IS_NULL_REFERENCE(Weights)) {
       const Standard_Real * WG = &Weights(Weights.Lower());
       min_weights = WG[0];
       
@@ -4000,7 +4000,7 @@ void BSplCLib::Resolution(      Standard_Real&        Poles,
     break;
   }
   case 3 : {
-    if (&Weights != NULL) {
+    if (!Standard_IS_NULL_REFERENCE(Weights)) {
       const Standard_Real * WG = &Weights(Weights.Lower());
       min_weights = WG[0];
       
@@ -4077,7 +4077,7 @@ void BSplCLib::Resolution(      Standard_Real&        Poles,
     break;
   }
   case 4 : {
-    if (&Weights != NULL) {
+    if (!Standard_IS_NULL_REFERENCE(Weights)) {
       const Standard_Real * WG = &Weights(Weights.Lower());
       min_weights = WG[0];
       
@@ -4164,7 +4164,7 @@ void BSplCLib::Resolution(      Standard_Real&        Poles,
   }
     default : {
       Standard_Integer kk;
-      if (&Weights != NULL) {
+      if (!Standard_IS_NULL_REFERENCE(Weights)) {
        const Standard_Real * WG = &Weights(Weights.Lower());
        min_weights = WG[0];
        
index 204755cf1d5bbdd8bf960655523feddd87005d9c..6d99f42c0bbf41670eedfaccc64780f602aee66e 100644 (file)
@@ -70,7 +70,7 @@ void  BSplCLib::BuildEval(const Standard_Integer         Degree,
   Standard_Integer i;
   Standard_Integer ip = PLower + Index - 1;
   Standard_Real w, *pole = &LP;
-  if (&Weights == NULL) {
+  if (Standard_IS_NULL_REFERENCE(Weights)) {
     
     for (i = 0; i <= Degree; i++) {
       ip++;
@@ -115,13 +115,13 @@ static void PrepareEval
   
   // make the knots
   BSplCLib::BuildKnots(Degree,index,Periodic,Knots,Mults,*dc.knots);
-  if (&Mults == NULL)
+  if (Standard_IS_NULL_REFERENCE(Mults))
     index -= Knots.Lower() + Degree;
   else
     index = BSplCLib::PoleIndex(Degree,index,Periodic,Mults);
   
   // check truly rational
-  rational = (&Weights != NULL);
+  rational = (!Standard_IS_NULL_REFERENCE(Weights));
   if (rational) {
     Standard_Integer WLower = Weights.Lower() + index;
     rational = BSplCLib::IsRational(Weights, WLower, WLower + Degree);
index f35fdd5f27cd31e5486affd79fe2375031975b2c..cb13ca41758691078a6084eb9787e3a5174de8e7 100644 (file)
@@ -93,7 +93,7 @@ Standard_Boolean BSplCLib::RemoveKnot
  TColStd_Array1OfInteger&       NewMults,
  const Standard_Real            Tolerance) 
 {
-  Standard_Boolean rational = &Weights  != NULL;
+  Standard_Boolean rational = !Standard_IS_NULL_REFERENCE(Weights);
   Standard_Integer dim;
   dim = Dimension_gen;
   if (rational) dim++;
@@ -134,7 +134,7 @@ void BSplCLib::InsertKnots
  const Standard_Real            Epsilon,
  const Standard_Boolean         Add) 
 {
-  Standard_Boolean rational = &Weights  != NULL;
+  Standard_Boolean rational = !Standard_IS_NULL_REFERENCE(Weights);
   Standard_Integer dim;
   dim = Dimension_gen;
   if (rational) dim++;
@@ -223,7 +223,7 @@ void BSplCLib::IncreaseDegree
  TColStd_Array1OfReal&           NewKnots,
  TColStd_Array1OfInteger&        NewMults) 
 {
-  Standard_Boolean rational = &Weights  != NULL;
+  Standard_Boolean rational = !Standard_IS_NULL_REFERENCE(Weights);
   Standard_Integer dim;
   dim = Dimension_gen;
   if (rational) dim++;
@@ -257,7 +257,7 @@ void  BSplCLib::Unperiodize
  Array1OfPoints&          NewPoles,
  TColStd_Array1OfReal&    NewWeights)
 {
-  Standard_Boolean rational = &Weights  != NULL;
+  Standard_Boolean rational = !Standard_IS_NULL_REFERENCE(Weights);
   Standard_Integer dim;
   dim = Dimension_gen;
   if (rational) dim++;
@@ -293,7 +293,7 @@ void BSplCLib::Trimming(const Standard_Integer         Degree,
                        Array1OfPoints&          NewPoles,
                        TColStd_Array1OfReal&    NewWeights)
 {
-  Standard_Boolean rational = &Weights  != NULL;
+  Standard_Boolean rational = !Standard_IS_NULL_REFERENCE(Weights);
   Standard_Integer dim;
   dim = Dimension_gen;
   if (rational) dim++;
@@ -340,7 +340,7 @@ void  BSplCLib::BuildEval(const Standard_Integer         Degree,
   Standard_Integer PUpper = Poles.Upper();
   Standard_Integer i;
   Standard_Integer ip = PLower + Index - 1;
-  if (&Weights == NULL) {
+  if (Standard_IS_NULL_REFERENCE(Weights)) {
     for (i = 0; i <= Degree; i++) {
       ip++;
       if (ip > PUpper) ip = PLower;
@@ -385,13 +385,13 @@ static void PrepareEval
 
   // make the knots
   BSplCLib::BuildKnots(Degree,index,Periodic,Knots,Mults,*dc.knots);
-  if (&Mults == NULL)
+  if (Standard_IS_NULL_REFERENCE(Mults))
     index -= Knots.Lower() + Degree;
   else
     index = BSplCLib::PoleIndex(Degree,index,Periodic,Mults);
   
   // check truly rational
-  rational = (&Weights != NULL);
+  rational = (!Standard_IS_NULL_REFERENCE(Weights));
   if (rational) {
     Standard_Integer WLower = Weights.Lower() + index;
     rational = BSplCLib::IsRational(Weights, WLower, WLower + Degree);
@@ -742,7 +742,7 @@ void  BSplCLib::CacheD0(const Standard_Real                  Parameter,
                       Degree * Dimension_gen,
                       PArray[0],
                       myPoint[0]) ;
-  if (&WeightsArray != NULL) {
+  if (!Standard_IS_NULL_REFERENCE(WeightsArray)) {
     Standard_Real *
       WArray = (Standard_Real *) &WeightsArray(WeightsArray.Lower()) ;
     PLib::NoDerivativeEvalPolynomial(NewParameter,
@@ -799,7 +799,7 @@ void  BSplCLib::CacheD1(const Standard_Real                  Parameter,
 
   ModifyCoords (LocalPDerivatives + Dimension_gen, /= SpanLenght);
   
-  if (&WeightsArray != NULL) {
+  if (!Standard_IS_NULL_REFERENCE(WeightsArray)) {
     Standard_Real *
       WArray = (Standard_Real *) &WeightsArray(WeightsArray.Lower()) ;
     PLib::EvalPolynomial(NewParameter,
@@ -879,7 +879,7 @@ void  BSplCLib::CacheD2(const Standard_Real                  Parameter,
     Index += Dimension_gen;
   }
 
-  if (&WeightsArray != NULL) {
+  if (!Standard_IS_NULL_REFERENCE(WeightsArray)) {
     Standard_Real *
       WArray = (Standard_Real *) &WeightsArray(WeightsArray.Lower()) ;
     
@@ -972,7 +972,7 @@ void  BSplCLib::CacheD3(const Standard_Real                  Parameter,
     Index  += Dimension_gen;
   }
   
-  if (&WeightsArray != NULL) {
+  if (!Standard_IS_NULL_REFERENCE(WeightsArray)) {
     Standard_Real *
       WArray = (Standard_Real *) &WeightsArray(WeightsArray.Lower()) ;
     
@@ -1082,7 +1082,7 @@ void BSplCLib::BuildCache
       LocalValue *= SpanDomain / (Standard_Real) ii ;
     }
 
-    if (&Weights != NULL) { 
+    if (!Standard_IS_NULL_REFERENCE(Weights)) {
       for (ii = 1 ; ii <= Degree + 1 ; ii++)
        CacheWeights(ii) = 0.0e0 ;
       CacheWeights(1) = 1.0e0 ;
index 4feae6544ccb589d6964c1168d297374fc466b82..42597a7ae15aa88c48fb8b5f8352da8bbbe8ee1c 100644 (file)
@@ -311,12 +311,12 @@ static Standard_Boolean  PrepareEval (const Standard_Real            U,
     BSplCLib::BuildKnots(UDegree,uindex,UPer,UKnots,UMults,*dc.knots1);
     BSplCLib::BuildKnots(VDegree,vindex,VPer,VKnots,VMults,*dc.knots2);
     
-    if (&UMults == NULL)
+    if (Standard_IS_NULL_REFERENCE(UMults))
       uindex -= UKLower + UDegree;
     else
       uindex  = BSplCLib::PoleIndex(UDegree,uindex,UPer,UMults);
 
-    if (&VMults == NULL)
+    if (Standard_IS_NULL_REFERENCE(VMults))
       vindex -= VKLower + VDegree;
     else
       vindex  = BSplCLib::PoleIndex(VDegree,vindex,VPer,VMults);
@@ -462,12 +462,12 @@ static Standard_Boolean  PrepareEval (const Standard_Real            U,
     BSplCLib::BuildKnots(UDegree,uindex,UPer,UKnots,UMults,*dc.knots2);
     BSplCLib::BuildKnots(VDegree,vindex,VPer,VKnots,VMults,*dc.knots1);
 
-    if (&UMults == NULL)
+    if (Standard_IS_NULL_REFERENCE(UMults))
       uindex -= UKLower + UDegree;
     else
       uindex  = BSplCLib::PoleIndex(UDegree,uindex,UPer,UMults);
 
-    if (&VMults == NULL)
+    if (Standard_IS_NULL_REFERENCE(VMults))
       vindex -= VKLower + VDegree;
     else
       vindex  = BSplCLib::PoleIndex(VDegree,vindex,VPer,VMults);
@@ -1304,7 +1304,7 @@ void  BSplSLib::Iso(const Standard_Real            Param,
 {
   Standard_Integer index = 0;
   Standard_Real    u = Param;
-  Standard_Boolean rational = &Weights != NULL;
+  Standard_Boolean rational = !Standard_IS_NULL_REFERENCE(Weights);
   Standard_Integer dim = rational ? 4 : 3;
   
   // compute local knots
@@ -1312,7 +1312,7 @@ void  BSplSLib::Iso(const Standard_Real            Param,
   NCollection_LocalArray<Standard_Real> locknots1 (2*Degree);  
   BSplCLib::LocateParameter(Degree,Knots,Mults,u,Periodic,index,u);
   BSplCLib::BuildKnots(Degree,index,Periodic,Knots,Mults,*locknots1);
-  if (&Mults == NULL)
+  if (Standard_IS_NULL_REFERENCE(Mults))
     index -= Knots.Lower() + Degree;
   else
     index = BSplCLib::PoleIndex(Degree,index,Periodic,Mults);
@@ -1386,7 +1386,7 @@ void  BSplSLib::Iso(const Standard_Real            Param,
   }
   
   // if the input is not rational but weights are wanted
-  if (!rational && (&CWeights != NULL)) {
+  if (!rational && !Standard_IS_NULL_REFERENCE(CWeights)) {
 
     for (i = CWeights.Lower(); i <= CWeights.Upper(); i++)
       CWeights(i) = 1.;
@@ -1746,7 +1746,7 @@ void  BSplSLib::InsertKnots(const Standard_Boolean         UDirection,
                            const Standard_Real            Epsilon, 
                            const Standard_Boolean         Add )
 {
-  Standard_Boolean rational = &Weights != NULL;
+  Standard_Boolean rational = !Standard_IS_NULL_REFERENCE(Weights);
   Standard_Integer dim = 3;
   if (rational) dim++;
   
@@ -1792,7 +1792,7 @@ Standard_Boolean  BSplSLib::RemoveKnot
  TColStd_Array1OfInteger& NewMults,
  const Standard_Real            Tolerance)
 {
-  Standard_Boolean rational = &Weights != NULL;
+  Standard_Boolean rational = !Standard_IS_NULL_REFERENCE(Weights);
   Standard_Integer dim = 3;
   if (rational) dim++;
   
@@ -1839,7 +1839,7 @@ void  BSplSLib::IncreaseDegree
  TColStd_Array1OfReal&    NewKnots, 
  TColStd_Array1OfInteger& NewMults)
 {
-  Standard_Boolean rational = &Weights != NULL;
+  Standard_Boolean rational = !Standard_IS_NULL_REFERENCE(Weights);
   Standard_Integer dim = 3;
   if (rational) dim++;
   
@@ -1881,7 +1881,7 @@ void  BSplSLib::Unperiodize
  TColgp_Array2OfPnt&      NewPoles,
  TColStd_Array2OfReal&    NewWeights)
 {
-  Standard_Boolean rational = &Weights != NULL;
+  Standard_Boolean rational = !Standard_IS_NULL_REFERENCE(Weights);
   Standard_Integer dim = 3;
   if (rational) dim++;
   
@@ -1934,7 +1934,7 @@ void BSplSLib::BuildCache
   Standard_Boolean rational,rational_u,rational_v,flag_u_or_v;                  
   Standard_Integer kk,d1,d1p1,d2,d2p1,ii,jj,iii,jjj,Index;
   Standard_Real u1,min_degree_domain,max_degree_domain,f,factor[2],u2;
-  if (&Weights != NULL) 
+  if (!Standard_IS_NULL_REFERENCE(Weights))
     rational_u = rational_v = Standard_True;
   else
     rational_u = rational_v = Standard_False;
@@ -2030,7 +2030,7 @@ void BSplSLib::BuildCache
       }
       factor[0] *= max_degree_domain / (Standard_Real) (iii) ;
     }
-    if (&Weights != NULL) {
+    if (!Standard_IS_NULL_REFERENCE(Weights)) {
       //
       // means that PrepareEval did found out that the surface was 
       // locally polynomial but since the surface is constructed
@@ -2210,7 +2210,7 @@ void  BSplSLib::CacheD0(const Standard_Real                  UParameter,
                       (min_degree << 1) + min_degree,
                       locpoles[0],
                       myPoint[0]) ;
-  if (&WeightsArray != NULL) {
+  if (!Standard_IS_NULL_REFERENCE(WeightsArray)) {
     dimension = min_degree + 1 ;
     Standard_Real *
       WArray = (Standard_Real *) 
@@ -2290,7 +2290,7 @@ void  BSplSLib::CacheD1(const Standard_Real                  UParameter,
   // the coefficients
   //
   //
-  if (&WeightsArray != NULL) {
+  if (!Standard_IS_NULL_REFERENCE(WeightsArray)) {
 
     local_poles_array            [0][0][0] = 0.0e0 ;
     local_poles_array            [0][0][1] = 0.0e0 ;
@@ -2375,7 +2375,7 @@ void  BSplSLib::CacheD1(const Standard_Real                  UParameter,
                       locpoles[dimension],
                       local_poles_array[1][0][0]) ;
   
-  if (&WeightsArray != NULL) {
+  if (!Standard_IS_NULL_REFERENCE(WeightsArray)) {
     dimension = min_degree + 1 ;
     Standard_Real *
       WArray = (Standard_Real *) 
@@ -2535,7 +2535,7 @@ void  BSplSLib::CacheD2(const Standard_Real                  UParameter,
   // the coefficients
   //
   //
-  if (&WeightsArray != NULL) {
+  if (!Standard_IS_NULL_REFERENCE(WeightsArray)) {
     
     local_poles_and_weights_array[0][0][0] = 0.0e0 ;
     local_poles_and_weights_array[0][0][1] = 0.0e0 ;
@@ -2664,7 +2664,7 @@ void  BSplSLib::CacheD2(const Standard_Real                  UParameter,
                       locpoles[dimension + dimension],
                       local_poles_array[2][0][0]) ;
   
-  if (&WeightsArray != NULL) {
+  if (!Standard_IS_NULL_REFERENCE(WeightsArray)) {
     dimension = min_degree + 1 ;
     Standard_Real *
       WArray = (Standard_Real *) 
index 0faf6b64f100f3f1120d94a73fdc8302a5605a4e..62befe3145c8745222a9f24e9592c86205d20e4d 100644 (file)
@@ -68,7 +68,7 @@ void BSplSLib::PolesCoefficients (const TColgp_Array2OfPnt& Poles,
                         biduflatknots,bidvflatknots,
                         Poles,Weights,
                         CPoles,CWeights);
-    if (&Weights == NULL) {
+    if (Standard_IS_NULL_REFERENCE(Weights)) {
       
       for (ii = 1; ii <= uclas; ii++) {
        
index fca8b39bafe070dae8e8f938349ecc0efcc4ab68..4b82750092a6e60e088b8a5a73e7689401a73fb5 100644 (file)
@@ -59,7 +59,7 @@ LDOM_CharacterData& LDOM_CharacterData::operator =
 void LDOM_CharacterData::setData (const LDOMString& theValue)
 {
   LDOM_BasicText& aText = (LDOM_BasicText&) Origin ();
-  if (&aText == NULL)
+  if (Standard_IS_NULL_REFERENCE(aText))
     Standard_ProgramError::Raise("LDOM_CharacterData::setData: called on void");
   aText.SetData (theValue, myDocument);
   myLength = -1;
index 73f5977a8fce347bf87cfffaaf772126df371adf..b23e393398d49c7d94505d3978d4bb285f9f9ce5 100644 (file)
@@ -1385,7 +1385,7 @@ void PLib::CoefficientsPoles (const Standard_Integer      dim,
                              TColStd_Array1OfReal&       Poles, 
                              TColStd_Array1OfReal&       Weights)
 {
-  Standard_Boolean rat = &WCoefs != NULL;
+  Standard_Boolean rat = !Standard_IS_NULL_REFERENCE(WCoefs);
   Standard_Integer loc = Coefs.Lower();
   Standard_Integer lop = Poles.Lower();
   Standard_Integer lowc=0;
@@ -1508,7 +1508,7 @@ void PLib::Trimming(const Standard_Real U1,
   Standard_Integer indc, indw=0;
   Standard_Integer upc = Coefs.Upper() - dim + 1, upw=0;
   Standard_Integer len = Coefs.Length()/dim;
-  Standard_Boolean rat = &WCoefs != NULL;
+  Standard_Boolean rat = !Standard_IS_NULL_REFERENCE(WCoefs);
 
   if (rat) {
     if(len != WCoefs.Length())
@@ -1565,7 +1565,7 @@ void PLib::CoefficientsPoles (const TColgp_Array2OfPnt&   Coefs,
                              TColgp_Array2OfPnt&         Poles,
                              TColStd_Array2OfReal&       Weights) 
 {
-  Standard_Boolean rat = (&WCoefs != NULL);
+  Standard_Boolean rat = !Standard_IS_NULL_REFERENCE(WCoefs);
   Standard_Integer LowerRow  = Poles.LowerRow();
   Standard_Integer UpperRow  = Poles.UpperRow();
   Standard_Integer LowerCol  = Poles.LowerCol();
@@ -1659,7 +1659,7 @@ void PLib::UTrimming(const Standard_Real U1,
                     TColgp_Array2OfPnt& Coeffs, 
                     TColStd_Array2OfReal& WCoeffs)
 {
-  Standard_Boolean rat = &WCoeffs != NULL;
+  Standard_Boolean rat = !Standard_IS_NULL_REFERENCE(WCoeffs);
   Standard_Integer lr = Coeffs.LowerRow();
   Standard_Integer ur = Coeffs.UpperRow();
   Standard_Integer lc = Coeffs.LowerCol();
@@ -1693,7 +1693,7 @@ void PLib::VTrimming(const Standard_Real V1,
                     TColgp_Array2OfPnt& Coeffs, 
                     TColStd_Array2OfReal& WCoeffs)
 {
-  Standard_Boolean rat = &WCoeffs != NULL;
+  Standard_Boolean rat = !Standard_IS_NULL_REFERENCE(WCoeffs);
   Standard_Integer lr = Coeffs.LowerRow();
   Standard_Integer ur = Coeffs.UpperRow();
   Standard_Integer lc = Coeffs.LowerCol();
index 2663762049b3fa177a076d6a55a0cc590e6848de..687dc400648e36aa7954157e620be865b628f83e 100644 (file)
@@ -47,4 +47,17 @@ inline Standard_Boolean IsEqual(const Standard_Address One
                               ,const Standard_Address Two)
 { return One == Two; }
 
+//! Workaround CLang extreme optimization, which causes failures in case when reference is passed for NULL pointer.
+#ifdef __APPLE__
+template<typename T> bool Standard_IS_NULL_REFERENCE (const T& theRef) __attribute__((optnone))
+{
+  return &theRef == NULL;
+}
+#else
+template<typename T> bool Standard_IS_NULL_REFERENCE (const T& theRef)
+{
+  return &theRef == NULL;
+}
+#endif
+
 #endif