Browse Source

HPCC-22930 Suppress location annotations when syntax checking

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 5 years ago
parent
commit
22f393bde9
4 changed files with 20 additions and 1 deletions
  1. 5 0
      ecl/eclcc/eclcc.cpp
  2. 10 0
      ecl/hql/hqlexpr.cpp
  3. 1 0
      ecl/hql/hqlexpr.hpp
  4. 4 1
      ecl/hqlcpp/hqlcpp.cpp

+ 5 - 0
ecl/eclcc/eclcc.cpp

@@ -1248,6 +1248,11 @@ void EclCC::processSingleQuery(EclCompileInstance & instance,
             parseCtx.setFastSyntax();
         parseCtx.timeParser = instance.wu->getDebugValueBool("timeParser", false);
 
+        //Avoid creating location annotations if syntax checking or creating an archive - since they are only really
+        //used when transforming the tree and generating code.  Can significantly speed up some queries.
+        //Option noteLocations can be used to override the default.
+        enableLocationAnnotations(instance.wu->getDebugValueBool("noteLocations", !optSyntax && !optArchive));
+
         unsigned maxErrorsDebugOption = instance.wu->getDebugValueInt("maxErrors", 0);
         if (maxErrorsDebugOption != 0)
             parseCtx.maxErrors = maxErrorsDebugOption;

+ 10 - 0
ecl/hql/hqlexpr.cpp

@@ -690,6 +690,9 @@ extern HQL_API IHqlExpression * queryOperator(node_operator search, const HqlExp
 
 extern HQL_API IHqlExpression * queryAnnotation(IHqlExpression * expr, annotate_kind search)
 {
+    if (!expr)
+        return nullptr;
+
     for (;;)
     {
         annotate_kind kind = expr->getAnnotationKind();
@@ -7776,6 +7779,11 @@ IHqlExpression * createParseMetaAnnotation(IHqlExpression * _ownedBody, HqlExprA
 
 //==============================================================================================================
 
+static bool suppressLocationAnnotations = false;
+void enableLocationAnnotations(bool value)
+{
+    suppressLocationAnnotations = !value;
+}
 
 CHqlLocationAnnotation::CHqlLocationAnnotation(IHqlExpression *_body, ISourcePath * _sourcePath, int _lineno, int _column)
 : CHqlAnnotation(_body), sourcePath(_sourcePath)
@@ -7828,6 +7836,8 @@ IHqlExpression * createLocationAnnotation(IHqlExpression * ownedBody, ISourcePat
     assertex(lineno != 0xcdcdcdcd && column != 0xcdcdcdcd);
     assertex(lineno != 0xcccccccc && column != 0xcccccccc);
 #endif
+    if (suppressLocationAnnotations)
+        return ownedBody;
     return CHqlLocationAnnotation::createLocationAnnotation(ownedBody, sourcePath, lineno, column);
 }
 

+ 1 - 0
ecl/hql/hqlexpr.hpp

@@ -1986,5 +1986,6 @@ extern HQL_API void setActiveSource(const char * filename);
 
 extern HQL_API IHqlExpression * annotateIndexBlobs(IHqlExpression * expr);
 extern HQL_API unsigned __int64 querySeqId(IHqlExpression * seq);   // Only for debugging when DEBUG_TRACK_INSTANCEID is defined
+extern HQL_API void enableLocationAnnotations(bool value);
 
 #endif

+ 4 - 1
ecl/hqlcpp/hqlcpp.cpp

@@ -2164,9 +2164,12 @@ bool HqlCppTranslator::getDebugFlag(const char * name, bool defValue)
     return wu()->getDebugValueBool(name, defValue);
 }
 
-void HqlCppTranslator::doReportWarning(WarnErrorCategory category, ErrorSeverity explicitSeverity, IHqlExpression * location, unsigned id, const char * msg)
+void HqlCppTranslator::doReportWarning(WarnErrorCategory category, ErrorSeverity explicitSeverity, IHqlExpression * expr, unsigned id, const char * msg)
 {
     Owned<IError> warnError;
+    IHqlExpression * location = queryAnnotation(expr, annotate_location);
+    if (!location)
+        location = queryAnnotation(expr, annotate_symbol);
     if (!location)
         location = queryActiveActivityLocation();
     unsigned activity = 0;