Browse Source

HPCC-16446 Fix various warnings in the code generator

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 8 years ago
parent
commit
b2739825c4

+ 4 - 3
ecl/hql/hqlexpr.cpp

@@ -3763,11 +3763,12 @@ IHqlExpression * CHqlExpression::commonUpExpression()
         if (!static_cast<CHqlExpression *>(match)->isAlive())
         {
             exprCache->replace(*this);
-#ifndef GATHER_COMMON_STATS
-            return this;
-#endif
+#ifdef GATHER_COMMON_STATS
             Link();
             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);
                     ITypeInfo * type = expr->queryType();
                     if(type->getTypeCode() == type_boolean)
+                    {
                         result = createBoolValue(match->found());
+                    }
                     else
                     {
+                        assertex(c2 && t2);
                         size32_t len;
                         UChar * data;
                         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);
                     ITypeInfo * type = expr->queryType();
                     if(type->getTypeCode() == type_boolean)
+                    {
                         result = createBoolValue(match->found());
+                    }
                     else
                     {
+                        assertex(c2 && t2);
                         size32_t len;
                         char * data;
                         match->getMatchX(len, data, (unsigned)t2->getIntValue());

+ 1 - 1
ecl/hql/hqlgram.y

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

+ 3 - 9
ecl/hql/hqlgram2.cpp

@@ -1819,12 +1819,6 @@ bool haveAssignedToChildren(IHqlExpression * select, IHqlExpression * transform)
             if (haveAssignedToChildren(select, assign))
                 return true;
             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;
@@ -11798,13 +11792,13 @@ IHqlExpression * PseudoPatternScope::lookupSymbol(IIdAtom * name, unsigned looku
     const char * text = str(name);
     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)
         {
             Owned<ITypeInfo> retType;
             ITypeInfo * type = match->queryType()->queryChildType();
-            IHqlExpression * indexExpr = createConstant((__int64)index-1);
+            IHqlExpression * indexExpr = createConstant((__int64)index);
             if (type)
                 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:
         i = i->queryChildType();
+        //fallthrough
     case type_record:
     case type_row:
     {   

+ 1 - 0
ecl/hql/hqlutil.cpp

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

+ 0 - 2
ecl/hqlcpp/hqlcpp.cpp

@@ -3415,10 +3415,8 @@ void HqlCppTranslator::buildExpr(BuildCtx & ctx, IHqlExpression * expr, CHqlBoun
     StringBuffer msg;
     msg.append("Unexpected operator '").append(getOpString(op)).append("' in: HqlCppTranslator::buildExpr(");
     toECL(expr, msg, true);
-//  expr->toString(msg);
     msg.append(")");
     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);
 
     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)
@@ -1237,14 +1237,7 @@ void ListSetCursor::buildExprSelect(BuildCtx & ctx, IHqlExpression * indexExpr,
     HqlExprAttr cond;
     gatherSelect(ctx, indexExpr, value, cond);
     if (cond)
-    {
         translator.buildTempExpr(ctx, indexExpr, tgt);
-        return;
-        CHqlBoundTarget tempTarget;
-        translator.createTempFor(ctx, indexExpr, tempTarget);
-        buildAssignSelect(ctx, tempTarget, indexExpr);
-        tgt.setFromTarget(tempTarget);
-    }
     else
         tgt.set(value);
 }
@@ -1380,8 +1373,6 @@ void GeneralSetCursor::buildIterateLoop(BuildCtx & ctx, CHqlBoundExpr & curBound
 void GeneralSetCursor::buildIterateClass(BuildCtx & ctx, CHqlBoundExpr & tgt)
 {
     UNIMPLEMENTED;
-    HqlExprAttr row;
-    dsCursor->buildIterateClass(ctx, tgt.expr, row);
 }
 
 IHqlExpression * GeneralSetCursor::createDatasetSelect(IHqlExpression * indexExpr)

+ 1 - 19
ecl/hqlcpp/hqlhtcpp.cpp

@@ -19226,25 +19226,7 @@ bool needsRealThor(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)

+ 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
 #if defined(__APPLE__)
-    bool generateClang = true;
+    const bool generateClang = true;
 #else
-    bool generateClang = false;
+    const bool generateClang = false;
 #endif
     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)
 {
     ActivityInvariantInfo * info = queryBodyInfo(expr);
-    if (info && info->visited)
+    if (info->visited)
     {
         if (!isProjected)
             info->clearProjected();

+ 1 - 1
ecl/hqlcpp/hqlresource.ipp

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

+ 6 - 0
ecl/hqlcpp/hqltomita.cpp

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

+ 10 - 0
ecl/hqlcpp/hqlttcpp.cpp

@@ -3143,6 +3143,9 @@ IHqlExpression * ThorHqlTransformer::normalizeScalarAggregate(IHqlExpression * e
 IHqlExpression * ThorHqlTransformer::normalizeSelect(IHqlExpression * expr)
 {
     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
     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));
 
     return createDataset(no_normalize, args);
+#endif
 }
 
 
@@ -9365,6 +9369,7 @@ IHqlExpression * HqlLinkedChildRowTransformer::createTransformedBody(IHqlExpress
         {
             return QuickHqlTransformer::createTransformedBody(expr);
         }
+        break;
     case no_output:
         //would this be a good idea for output to file?  output to pipe?
         if (false)
@@ -10426,6 +10431,10 @@ IHqlExpression * AnnotationTransformInfo::cloneAnnotations(IHqlExpression * newB
         return LINK(newBody);
 
     return annotations.item(0).cloneAllAnnotations(newBody);
+
+#if 0
+    //This code is not currently used - saved for future reference
+
     LinkedHqlExpr ret = newBody;
 
 #if 1
@@ -10446,6 +10455,7 @@ IHqlExpression * AnnotationTransformInfo::cloneAnnotations(IHqlExpression * newB
 #endif
 
     return ret.getClear();
+#endif
 }
 
 void AnnotationTransformInfo::noteAnnotation(IHqlExpression * annotation)

+ 1 - 0
ecl/hqlcpp/hqlwcpp.cpp

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