Przeglądaj źródła

HPCC-16446 Fix various warnings in the code generator

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 8 lat temu
rodzic
commit
b2739825c4

+ 4 - 3
ecl/hql/hqlexpr.cpp

@@ -3763,11 +3763,12 @@ IHqlExpression * CHqlExpression::commonUpExpression()
         if (!static_cast<CHqlExpression *>(match)->isAlive())
         if (!static_cast<CHqlExpression *>(match)->isAlive())
         {
         {
             exprCache->replace(*this);
             exprCache->replace(*this);
-#ifndef GATHER_COMMON_STATS
-            return this;
-#endif
+#ifdef GATHER_COMMON_STATS
             Link();
             Link();
             match = this;
             match = this;
+#else
+            return this;
+#endif
         }
         }
     }
     }
 
 

+ 6 - 0
ecl/hql/hqlfold.cpp

@@ -2638,9 +2638,12 @@ IHqlExpression * foldConstantOperator(IHqlExpression * expr, unsigned foldOption
                     IUStrRegExprFindInstance * match = compiled->find(search, 0, slen);
                     IUStrRegExprFindInstance * match = compiled->find(search, 0, slen);
                     ITypeInfo * type = expr->queryType();
                     ITypeInfo * type = expr->queryType();
                     if(type->getTypeCode() == type_boolean)
                     if(type->getTypeCode() == type_boolean)
+                    {
                         result = createBoolValue(match->found());
                         result = createBoolValue(match->found());
+                    }
                     else
                     else
                     {
                     {
+                        assertex(c2 && t2);
                         size32_t len;
                         size32_t len;
                         UChar * data;
                         UChar * data;
                         match->getMatchX(len, data, (unsigned)t2->getIntValue());
                         match->getMatchX(len, data, (unsigned)t2->getIntValue());
@@ -2662,9 +2665,12 @@ IHqlExpression * foldConstantOperator(IHqlExpression * expr, unsigned foldOption
                     IStrRegExprFindInstance * match = compiled->find(search.str(), 0, search.length(), false);
                     IStrRegExprFindInstance * match = compiled->find(search.str(), 0, search.length(), false);
                     ITypeInfo * type = expr->queryType();
                     ITypeInfo * type = expr->queryType();
                     if(type->getTypeCode() == type_boolean)
                     if(type->getTypeCode() == type_boolean)
+                    {
                         result = createBoolValue(match->found());
                         result = createBoolValue(match->found());
+                    }
                     else
                     else
                     {
                     {
+                        assertex(c2 && t2);
                         size32_t len;
                         size32_t len;
                         char * data;
                         char * data;
                         match->getMatchX(len, data, (unsigned)t2->getIntValue());
                         match->getMatchX(len, data, (unsigned)t2->getIntValue());

+ 1 - 1
ecl/hql/hqlgram.y

@@ -8933,7 +8933,7 @@ simpleDataSet
                             IHqlExpression * arg = $7.getExpr();
                             IHqlExpression * arg = $7.getExpr();
                             if (isStringType(arg->queryType()))
                             if (isStringType(arg->queryType()))
                             {
                             {
-                                arg = createAttribute(nameAtom, arg);
+                                arg = createExprAttribute(nameAtom, arg);
                                 arg = createComma(createExprAttribute(sequenceAtom, createConstant(0)), arg);
                                 arg = createComma(createExprAttribute(sequenceAtom, createConstant(0)), arg);
                             }
                             }
                             else
                             else

+ 3 - 9
ecl/hql/hqlgram2.cpp

@@ -1819,12 +1819,6 @@ bool haveAssignedToChildren(IHqlExpression * select, IHqlExpression * transform)
             if (haveAssignedToChildren(select, assign))
             if (haveAssignedToChildren(select, assign))
                 return true;
                 return true;
             break;
             break;
-            IHqlExpression * child0 = assign->queryChild(0);
-            //Only need to check the first subfield, or field of originalAttr
-            //if (haveAssignedToChildren(select, assign))
-            if (child0 && containsSelect(child0->queryChild(0), select))
-                return true;
-            break;
         }
         }
     }
     }
     return false;
     return false;
@@ -11798,13 +11792,13 @@ IHqlExpression * PseudoPatternScope::lookupSymbol(IIdAtom * name, unsigned looku
     const char * text = str(name);
     const char * text = str(name);
     if (*text == '$')
     if (*text == '$')
     {
     {
-        unsigned index = atoi(text+1);
-        IHqlExpression * match = patternList->queryChild(index-1);
+        unsigned index = (unsigned)(atoi(text+1)-1);
+        IHqlExpression * match = patternList->queryChild(index);
         if (match)
         if (match)
         {
         {
             Owned<ITypeInfo> retType;
             Owned<ITypeInfo> retType;
             ITypeInfo * type = match->queryType()->queryChildType();
             ITypeInfo * type = match->queryType()->queryChildType();
-            IHqlExpression * indexExpr = createConstant((__int64)index-1);
+            IHqlExpression * indexExpr = createConstant((__int64)index);
             if (type)
             if (type)
                 return createRow(no_matchattr, LINK(queryOriginalRecord(type)), indexExpr);
                 return createRow(no_matchattr, LINK(queryOriginalRecord(type)), indexExpr);
 
 

+ 1 - 0
ecl/hql/hqlthql.cpp

@@ -2850,6 +2850,7 @@ StringBuffer &HqltHql::getTypeString(ITypeInfo * i, StringBuffer &s)
     {
     {
     case type_transform:
     case type_transform:
         i = i->queryChildType();
         i = i->queryChildType();
+        //fallthrough
     case type_record:
     case type_record:
     case type_row:
     case type_row:
     {   
     {   

+ 1 - 0
ecl/hql/hqlutil.cpp

@@ -8219,6 +8219,7 @@ void EclXmlSchemaBuilder::build(IHqlExpression * record, bool &hasMixedContent)
                     }
                     }
                 case type_alien:
                 case type_alien:
                     type = queryAlienType(type)->queryLogicalType();
                     type = queryAlienType(type)->queryLogicalType();
+                    //fallthrough
                 default:
                 default:
                     extractName(name.clear(), NULL, NULL, cur, NULL);
                     extractName(name.clear(), NULL, NULL, cur, NULL);
                     if (name.length())
                     if (name.length())

+ 0 - 2
ecl/hqlcpp/hqlcpp.cpp

@@ -3415,10 +3415,8 @@ void HqlCppTranslator::buildExpr(BuildCtx & ctx, IHqlExpression * expr, CHqlBoun
     StringBuffer msg;
     StringBuffer msg;
     msg.append("Unexpected operator '").append(getOpString(op)).append("' in: HqlCppTranslator::buildExpr(");
     msg.append("Unexpected operator '").append(getOpString(op)).append("' in: HqlCppTranslator::buildExpr(");
     toECL(expr, msg, true);
     toECL(expr, msg, true);
-//  expr->toString(msg);
     msg.append(")");
     msg.append(")");
     throw MakeStringException(HQLERR_UnexpectedOperator, "%s", msg.str());
     throw MakeStringException(HQLERR_UnexpectedOperator, "%s", msg.str());
-    doBuildPureSubExpr(ctx, expr, tgt);
 }
 }
 
 
 
 

+ 1 - 10
ecl/hqlcpp/hqlcset.cpp

@@ -1179,7 +1179,7 @@ void ListSetCursor::buildIterateClass(BuildCtx & ctx, CHqlBoundExpr & tgt)
     translator.buildSimpleExpr(ctx, expr, boundList);
     translator.buildSimpleExpr(ctx, expr, boundList);
 
 
     UNIMPLEMENTED;
     UNIMPLEMENTED;
-    ctx.addQuotedLiteral("create fixed iterate (bound.length, bound.getAddress()");
+    //ctx.addQuotedLiteral("create fixed iterate (bound.length, bound.getAddress()");
 }
 }
 
 
 void ListSetCursor::gatherSelect(BuildCtx & ctx, IHqlExpression * indexExpr, CHqlBoundExpr & value, HqlExprAttr & cond)
 void ListSetCursor::gatherSelect(BuildCtx & ctx, IHqlExpression * indexExpr, CHqlBoundExpr & value, HqlExprAttr & cond)
@@ -1237,14 +1237,7 @@ void ListSetCursor::buildExprSelect(BuildCtx & ctx, IHqlExpression * indexExpr,
     HqlExprAttr cond;
     HqlExprAttr cond;
     gatherSelect(ctx, indexExpr, value, cond);
     gatherSelect(ctx, indexExpr, value, cond);
     if (cond)
     if (cond)
-    {
         translator.buildTempExpr(ctx, indexExpr, tgt);
         translator.buildTempExpr(ctx, indexExpr, tgt);
-        return;
-        CHqlBoundTarget tempTarget;
-        translator.createTempFor(ctx, indexExpr, tempTarget);
-        buildAssignSelect(ctx, tempTarget, indexExpr);
-        tgt.setFromTarget(tempTarget);
-    }
     else
     else
         tgt.set(value);
         tgt.set(value);
 }
 }
@@ -1380,8 +1373,6 @@ void GeneralSetCursor::buildIterateLoop(BuildCtx & ctx, CHqlBoundExpr & curBound
 void GeneralSetCursor::buildIterateClass(BuildCtx & ctx, CHqlBoundExpr & tgt)
 void GeneralSetCursor::buildIterateClass(BuildCtx & ctx, CHqlBoundExpr & tgt)
 {
 {
     UNIMPLEMENTED;
     UNIMPLEMENTED;
-    HqlExprAttr row;
-    dsCursor->buildIterateClass(ctx, tgt.expr, row);
 }
 }
 
 
 IHqlExpression * GeneralSetCursor::createDatasetSelect(IHqlExpression * indexExpr)
 IHqlExpression * GeneralSetCursor::createDatasetSelect(IHqlExpression * indexExpr)

+ 1 - 19
ecl/hqlcpp/hqlhtcpp.cpp

@@ -19226,25 +19226,7 @@ bool needsRealThor(IHqlExpression *expr)
 
 
 IHqlExpression * HqlCppTranslator::getDefaultOutputAttr(IHqlExpression * expr)
 IHqlExpression * HqlCppTranslator::getDefaultOutputAttr(IHqlExpression * expr)
 {
 {
-    return createAttribute(workunitAtom);       // backwards compatibility!
-    IHqlExpression * dataset = expr->queryChild(0);
-    if (dataset->getOperator() == no_selectfields)
-        dataset = dataset->queryChild(0);
-    if (dataset->getOperator()==no_choosen)
-    {
-        //If choosen() is specified, then output to SDS if small enough, else a temporary file.
-        IHqlExpression * count = dataset->queryChild(1);
-        if (count->queryValue())
-        {
-            unsigned __int64 value = count->queryValue()->getIntValue();
-            if (value <= MAX_ROWS_OUTPUT_TO_SDS)
-                return createAttribute(workunitAtom);
-        }
-        return createAttribute(diskAtom);
-    }
-
-    //No support yet in IFileView for delayed browsing - so output to disk.
-    return createAttribute(diskAtom);
+    return createAttribute(workunitAtom);
 }
 }
 
 
 void HqlCppTranslator::modifyOutputLocations(HqlExprArray & exprs)
 void HqlCppTranslator::modifyOutputLocations(HqlExprArray & exprs)

+ 2 - 2
ecl/hqlcpp/hqlres.cpp

@@ -466,9 +466,9 @@ bool ResourceManager::flush(StringBuffer &filename, const char *basename, bool f
 
 
     //MORE: This should really use targetCompiler instead
     //MORE: This should really use targetCompiler instead
 #if defined(__APPLE__)
 #if defined(__APPLE__)
-    bool generateClang = true;
+    const bool generateClang = true;
 #else
 #else
-    bool generateClang = false;
+    const bool generateClang = false;
 #endif
 #endif
     ForEachItemIn(idx, resources)
     ForEachItemIn(idx, resources)
     {
     {

+ 1 - 1
ecl/hqlcpp/hqlresource.cpp

@@ -1076,7 +1076,7 @@ void ActivityInvariantHoister::gatherChildSplitPoints(IHqlExpression * expr, Act
 bool ActivityInvariantHoister::findSplitPoints(IHqlExpression * expr, bool isProjected)
 bool ActivityInvariantHoister::findSplitPoints(IHqlExpression * expr, bool isProjected)
 {
 {
     ActivityInvariantInfo * info = queryBodyInfo(expr);
     ActivityInvariantInfo * info = queryBodyInfo(expr);
-    if (info && info->visited)
+    if (info->visited)
     {
     {
         if (!isProjected)
         if (!isProjected)
             info->clearProjected();
             info->clearProjected();

+ 1 - 1
ecl/hqlcpp/hqlresource.ipp

@@ -430,7 +430,7 @@ public:
     unsigned numExternalUses;
     unsigned numExternalUses;
     unsigned conditionSourceCount;
     unsigned conditionSourceCount;
     unsigned currentSource;
     unsigned currentSource;
-    unsigned curBalanceLink;
+    unsigned curBalanceLink = 0;
     unsigned lastPass;
     unsigned lastPass;
     unsigned balancedExternalUses;
     unsigned balancedExternalUses;
     unsigned balancedInternalUses;
     unsigned balancedInternalUses;

+ 6 - 0
ecl/hqlcpp/hqltomita.cpp

@@ -374,27 +374,33 @@ void TomProduction::buildProduction(LRTableBuilder & builder, IHqlExpression * t
         case no_pat_checkin:
         case no_pat_checkin:
             {
             {
                 UNIMPLEMENTED;
                 UNIMPLEMENTED;
+                /*
                 AsciiDfa * dfa = NULL;
                 AsciiDfa * dfa = NULL;
                 builder.addValidator(id, LRVcheckin, 0, 0, dfa);
                 builder.addValidator(id, LRVcheckin, 0, 0, dfa);
                 break;
                 break;
+                */
             }
             }
         case no_pat_x_before_y:
         case no_pat_x_before_y:
         case no_pat_before_y:
         case no_pat_before_y:
             {
             {
                 UNIMPLEMENTED;
                 UNIMPLEMENTED;
+                /*
                 AsciiDfa * dfa = NULL;
                 AsciiDfa * dfa = NULL;
                 builder.addValidator(id, LRVbefore, 0, 0, dfa);
                 builder.addValidator(id, LRVbefore, 0, 0, dfa);
                 break;
                 break;
+                */
             }
             }
         case no_pat_x_after_y:
         case no_pat_x_after_y:
         case no_pat_after_y:
         case no_pat_after_y:
             {
             {
                 UNIMPLEMENTED;
                 UNIMPLEMENTED;
+                /*
                 unsigned minLength = 0;
                 unsigned minLength = 0;
                 unsigned maxLength = 0;
                 unsigned maxLength = 0;
                 AsciiDfa * dfa = NULL;
                 AsciiDfa * dfa = NULL;
                 builder.addValidator(id, LRVafter, minLength, maxLength, dfa);
                 builder.addValidator(id, LRVafter, minLength, maxLength, dfa);
                 break;
                 break;
+                */
             }
             }
         default:
         default:
             UNIMPLEMENTED;
             UNIMPLEMENTED;

+ 10 - 0
ecl/hqlcpp/hqlttcpp.cpp

@@ -3143,6 +3143,9 @@ IHqlExpression * ThorHqlTransformer::normalizeScalarAggregate(IHqlExpression * e
 IHqlExpression * ThorHqlTransformer::normalizeSelect(IHqlExpression * expr)
 IHqlExpression * ThorHqlTransformer::normalizeSelect(IHqlExpression * expr)
 {
 {
     return NULL;
     return NULL;
+
+#if 0
+    //Not used at the moment - for reasons see the comments below.
     /*
     /*
     The idea of this code is to convert a.b.c into normalize(a.b, a.b.c) if a.b is an out-of scope dataset
     The idea of this code is to convert a.b.c into normalize(a.b, a.b.c) if a.b is an out-of scope dataset
     However the following isn't good enough since the fields from a.b also need to be accessible.  We would
     However the following isn't good enough since the fields from a.b also need to be accessible.  We would
@@ -3178,6 +3181,7 @@ IHqlExpression * ThorHqlTransformer::normalizeSelect(IHqlExpression * expr)
     args.append(*createAttribute(_internal_Atom));
     args.append(*createAttribute(_internal_Atom));
 
 
     return createDataset(no_normalize, args);
     return createDataset(no_normalize, args);
+#endif
 }
 }
 
 
 
 
@@ -9365,6 +9369,7 @@ IHqlExpression * HqlLinkedChildRowTransformer::createTransformedBody(IHqlExpress
         {
         {
             return QuickHqlTransformer::createTransformedBody(expr);
             return QuickHqlTransformer::createTransformedBody(expr);
         }
         }
+        break;
     case no_output:
     case no_output:
         //would this be a good idea for output to file?  output to pipe?
         //would this be a good idea for output to file?  output to pipe?
         if (false)
         if (false)
@@ -10426,6 +10431,10 @@ IHqlExpression * AnnotationTransformInfo::cloneAnnotations(IHqlExpression * newB
         return LINK(newBody);
         return LINK(newBody);
 
 
     return annotations.item(0).cloneAllAnnotations(newBody);
     return annotations.item(0).cloneAllAnnotations(newBody);
+
+#if 0
+    //This code is not currently used - saved for future reference
+
     LinkedHqlExpr ret = newBody;
     LinkedHqlExpr ret = newBody;
 
 
 #if 1
 #if 1
@@ -10446,6 +10455,7 @@ IHqlExpression * AnnotationTransformInfo::cloneAnnotations(IHqlExpression * newB
 #endif
 #endif
 
 
     return ret.getClear();
     return ret.getClear();
+#endif
 }
 }
 
 
 void AnnotationTransformInfo::noteAnnotation(IHqlExpression * annotation)
 void AnnotationTransformInfo::noteAnnotation(IHqlExpression * annotation)

+ 1 - 0
ecl/hqlcpp/hqlwcpp.cpp

@@ -1910,6 +1910,7 @@ void HqlCppWriter::generateStmtAssignModify(IHqlStmt * assign)
         case type_groupedtable:
         case type_groupedtable:
             //check it is a pointer increment
             //check it is a pointer increment
             assertex(hasReferenceModifier(type));
             assertex(hasReferenceModifier(type));
+            //fallthrough
         case type_int:
         case type_int:
         case type_real:
         case type_real:
         case type_boolean:
         case type_boolean: