LCOV - code coverage report
Current view: top level - idlc/source - errorhandler.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 143 312 45.8 %
Date: 2014-11-03 Functions: 17 25 68.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <idlc/errorhandler.hxx>
      21             : #include <idlc/astinterface.hxx>
      22             : 
      23         478 : static const sal_Char* errorCodeToMessage(ErrorCode eCode)
      24             : {
      25         478 :     switch (eCode)
      26             :     {
      27             :     case EIDL_NONE:
      28           0 :         return "all is fine ";
      29             :     case EIDL_SYNTAX_ERROR:
      30         148 :         return "";
      31             :     case EIDL_REDEF:
      32           0 :         return "illegal redefinition ";
      33             :     case EIDL_REDEF_SCOPE:
      34           8 :         return "illegal redefinition in scope ";
      35             :     case EIDL_DEF_USE:
      36           0 :         return "redefinition after use, ";
      37             :     case EIDL_COERCION_FAILURE:
      38          76 :         return "coercion failure ";
      39             :     case EIDL_SCOPE_CONFLICT:
      40           0 :         return "definition scope is different than fwd declare scope, ";
      41             :     case EIDL_ILLEGAL_ADD:
      42           4 :         return "illegal add operation, ";
      43             :     case EIDL_ILLEGAL_USE:
      44           0 :         return "illegal type used in expression, ";
      45             :     case EIDL_ILLEGAL_RAISES:
      46           4 :         return "non-exception type in raises(..) clause, ";
      47             :     case EIDL_CANT_INHERIT:
      48           6 :         return "cannot inherit ";
      49             :     case EIDL_LOOKUP_ERROR:
      50           8 :         return "error in lookup of symbol: ";
      51             :     case EIDL_INHERIT_FWD_ERROR:
      52           4 :         return "";
      53             :     case EIDL_CONSTANT_EXPECTED:
      54           0 :         return "constant expected: ";
      55             :     case EIDL_NAME_CASE_ERROR:
      56           0 :         return "identifier used with two differing spellings: ";
      57             :     case EIDL_EVAL_ERROR:
      58           0 :         return "expression evaluation error: ";
      59             :     case EIDL_AMBIGUOUS:
      60           0 :         return "ambiguous definition: ";
      61             :     case EIDL_DECL_NOT_DEFINED:
      62           0 :         return "forward declared but never defined: ";
      63             :     case EIDL_FWD_DECL_LOOKUP:
      64           0 :         return "";
      65             :     case EIDL_RECURSIVE_TYPE:
      66          20 :         return "illegal recursive use of type: ";
      67             :     case EIDL_NOT_A_TYPE:
      68          10 :         return "specified symbol is not a type: ";
      69             :     case EIDL_TYPE_NOT_VALID:
      70           0 :         return "specified type is not valid in this context: ";
      71             :     case EIDL_INTERFACEMEMBER_LOOKUP:
      72           0 :         return "error in lookup of symbol, expected interface is not defined and no forward exists: ";
      73             :     case EIDL_SERVICEMEMBER_LOOKUP:
      74           0 :         return "error in lookup of symbol, expected service is not defined: ";
      75             :     case EIDL_TYPE_IDENT_CONFLICT:
      76           0 :         return "type and parameter/member name are equal: ";
      77             :     case EIDL_WRONGATTRIBUTEFLAG:
      78           0 :         return "the used flag is not valid in this context: ";
      79             :     case EIDL_DEFINED_ATTRIBUTEFLAG:
      80           0 :         return "flag is already set: ";
      81             :     case EIDL_WRONGATTRIBUTEKEYWORD:
      82           0 :         return "keyword not allowed: ";
      83             :     case EIDL_MISSINGATTRIBUTEKEYWORD:
      84           0 :         return "missing keyword: ";
      85             :     case EIDL_BAD_ATTRIBUTE_FLAGS:
      86             :         return
      87             :             "the 'attribute' flag is mandatory, and only the 'bound' and"
      88          14 :             " 'readonly' optional flags are accepted: ";
      89             :     case EIDL_OPTIONALEXPECTED:
      90           0 :         return "only the 'optional' flag is accepted: ";
      91             :     case EIDL_MIXED_INHERITANCE:
      92             :         return "interface inheritance declarations cannot appear in both an"
      93           0 :             " interface's header and its body";
      94             :     case EIDL_DOUBLE_INHERITANCE:
      95             :         return
      96          26 :             "interface is (directly or indirectly) inherited more than once: ";
      97             :     case EIDL_DOUBLE_MEMBER:
      98             :         return
      99          16 :             "member is (directly or indirectly) declared more than once: ";
     100             :     case EIDL_CONSTRUCTOR_PARAMETER_NOT_IN:
     101             :         return
     102             :             "a service constructor parameter may not be an out or inout"
     103           4 :             " parameter";
     104             :     case EIDL_CONSTRUCTOR_REST_PARAMETER_NOT_FIRST:
     105             :         return
     106             :             "no parameters may precede a rest parameter in a service"
     107           4 :             " constructor";
     108             :     case EIDL_REST_PARAMETER_NOT_LAST:
     109           2 :         return "no parameters may follow a rest parameter";
     110             :     case EIDL_REST_PARAMETER_NOT_ANY:
     111           2 :         return "a rest parameter must be of type any";
     112             :     case EIDL_METHOD_HAS_REST_PARAMETER:
     113           4 :         return "a rest parameter may not be used on an interface method";
     114             :     case EIDL_READONLY_ATTRIBUTE_SET_EXCEPTIONS:
     115           2 :         return "a readonly attribute may not have a setter raises clause";
     116             :     case EIDL_UNSIGNED_TYPE_ARGUMENT:
     117          14 :         return "an unsigned type cannot be used as a type argument";
     118             :     case EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS:
     119             :         return
     120             :             "the number of given type arguments does not match the expected"
     121          14 :             " number of type parameters";
     122             :     case EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF:
     123             :         return
     124             :             "an instantiated polymorphic struct type cannot be used in a"
     125           2 :             " typedef";
     126             :     case EIDL_IDENTICAL_TYPE_PARAMETERS:
     127           2 :         return "two type parameters have the same name";
     128             :     case EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE:
     129           4 :         return "a polymorphic struct type template may not have a base type";
     130             :     case EIDL_PUBLISHED_FORWARD:
     131             :         return
     132             :             "a published forward declaration of an interface type cannot be"
     133           2 :             " followed by an unpublished declaration of that type";
     134             :     case EIDL_PUBLISHED_USES_UNPUBLISHED:
     135             :         return
     136             :             "an unpublished entity cannot be used in the declaration of a"
     137          72 :             " published entity: ";
     138             :     case EIDL_SIMILAR_CONSTRUCTORS:
     139           6 :         return "two constructors have identical lists of parameter types";
     140             :     }
     141           0 :     return "unknown error";
     142             : }
     143             : 
     144           0 : static const sal_Char* warningCodeToMessage(WarningCode wCode)
     145             : {
     146           0 :     switch (wCode)
     147             :     {
     148             :     case WIDL_EXPID_CONFLICT:
     149           0 :         return "exception id conflict: ";
     150             :     case WIDL_REQID_CONFLICT:
     151           0 :         return "request id conflict: ";
     152             :     case WIDL_INHERIT_IDCONFLICT:
     153           0 :         return "request id conflict in inheritance tree: ";
     154             :     case WIDL_TYPE_IDENT_CONFLICT:
     155           0 :         return "type and parameter|member name are equal: ";
     156             :     case WIDL_WRONG_NAMING_CONV:
     157           0 :         return "type or identifier doesn't fulfill the UNO naming convention: ";
     158             :     }
     159           0 :     return "unknown warning";
     160             : }
     161             : 
     162         148 : static const sal_Char* parseStateToMessage(ParseState state)
     163             : {
     164         148 :     switch (state)
     165             :     {
     166             :     case PS_NoState:
     167         102 :         return "Statement can not be parsed";
     168             :     case PS_TypeDeclSeen:
     169           0 :         return "Malformed type declaration";
     170             :     case PS_ConstantDeclSeen:
     171           0 :         return "Malformed const declaration";
     172             :     case PS_ExceptionDeclSeen:
     173           0 :         return "Malformed exception declaration";
     174             :     case PS_InterfaceDeclSeen:
     175           4 :         return "Malformed interface declaration";
     176             :     case PS_ServiceDeclSeen:
     177           0 :         return "Malformed service declaration";
     178             :     case PS_ModuleDeclSeen:
     179           0 :         return "Malformed module declaration";
     180             :     case PS_AttributeDeclSeen:
     181           0 :         return "Malformed attribute declaration";
     182             :     case PS_PropertyDeclSeen:
     183           0 :         return "Malformed property declaration";
     184             :     case PS_OperationDeclSeen:
     185           0 :         return "Malformed operation declaration";
     186             :     case PS_InterfaceInheritanceDeclSeen:
     187           0 :         return "Malformed interface inheritance declaration";
     188             :     case PS_ConstantsDeclSeen:
     189           0 :         return "Malformed constants declaration";
     190             :     case PS_ServiceSeen:
     191           0 :         return "Missing service identifier following SERVICE keyword";
     192             :     case PS_ServiceIDSeen:
     193           0 :         return "Missing '{' or illegal syntax following service identifier";
     194             :     case PS_ServiceSqSeen:
     195           0 :         return "Illegal syntax following service '{' opener";
     196             :     case PS_ServiceBodySeen:
     197           0 :         return "Illegal syntax following service '}' closer";
     198             :     case PS_ServiceMemberSeen:
     199           0 :         return "Illegal syntax following service member declaration";
     200             :     case PS_ServiceIFHeadSeen:
     201           0 :         return "Illegal syntax following header of an interface member";
     202             :     case PS_ServiceSHeadSeen:
     203           0 :         return "Illegal syntax following header of an service member";
     204             :     case PS_ModuleSeen:
     205           0 :         return "Missing module identifier following MODULE keyword";
     206             :     case PS_ModuleIDSeen:
     207           0 :         return "Missing '{' or illegal syntax following module identifier";
     208             :     case PS_ModuleSqSeen:
     209           6 :         return "Illegal syntax following module '{' opener";
     210             :     case PS_ModuleQsSeen:
     211           0 :         return "Illegal syntax following module '}' closer";
     212             :     case PS_ModuleBodySeen:
     213           0 :         return "Illegal syntax following module export(s)";
     214             :     case PS_ConstantsSeen:
     215           0 :         return "Missing constants identifier following CONSTANTS keyword";
     216             :     case PS_ConstantsIDSeen:
     217           0 :         return "Missing '{' or illegal syntax following constants identifier";
     218             :     case PS_ConstantsSqSeen:
     219           0 :         return "Illegal syntax following module '{' opener";
     220             :     case PS_ConstantsQsSeen:
     221           0 :         return "Illegal syntax following module '}' closer";
     222             :     case PS_ConstantsBodySeen:
     223           4 :         return "Illegal syntax following constants export(s)";
     224             :     case PS_InterfaceSeen:
     225           0 :         return "Missing interface identifier following INTERFACE keyword";
     226             :     case PS_InterfaceIDSeen:
     227           0 :         return "Illegal syntax following interface identifier";
     228             :     case PS_InterfaceHeadSeen:
     229           0 :         return "Illegal syntax following interface head";
     230             :     case PS_InheritSpecSeen:
     231           0 :         return "Missing '{' or illegal syntax following inheritance spec";
     232             :     case PS_ForwardDeclSeen:
     233           0 :         return "Missing ';' following forward interface declaration";
     234             :     case PS_InterfaceSqSeen:
     235           2 :         return "Illegal syntax following interface '{' opener";
     236             :     case PS_InterfaceQsSeen:
     237           0 :         return "Illegal syntax following interface '}' closer";
     238             :     case PS_InterfaceBodySeen:
     239           0 :         return "Illegal syntax following interface export(s)";
     240             :     case PS_InheritColonSeen:
     241           0 :         return "Illegal syntax following ':' starting inheritance list";
     242             :     case PS_SNListCommaSeen:
     243           0 :         return "Found illegal scoped name in scoped name list";
     244             :     case PS_ScopedNameSeen:
     245           0 :         return "Missing ',' following scoped name in scoped name list";
     246             :     case PS_SN_IDSeen:
     247           4 :         return "Illegal component in scoped name";
     248             :     case PS_ScopeDelimSeen:
     249           0 :         return "Illegal component in scoped name following '::'";
     250             :     case PS_ConstSeen:
     251           4 :         return "Missing type or illegal syntax following CONST keyword";
     252             :     case PS_ConstTypeSeen:
     253           0 :         return "Missing identifier or illegal syntax following const type";
     254             :     case PS_ConstIDSeen:
     255           0 :         return "Missing '=' or illegal syntax after const identifier";
     256             :     case PS_ConstAssignSeen:
     257           0 :         return "Missing value expr or illegal syntax following '='";
     258             :     case PS_ConstExprSeen:
     259           0 :         return "Missing ';' or illegal syntax following value expr in const";
     260             :     case PS_TypedefSeen:
     261           2 :         return "Missing type or illegal syntax following TYPEDEF keyword";
     262             :     case PS_TypeSpecSeen:
     263           0 :         return "Missing declarators or illegal syntax following type spec";
     264             :     case PS_DeclaratorsSeen:
     265           0 :         return "Illegal syntax following declarators in TYPEDEF declaration";
     266             :     case PS_StructSeen:
     267           0 :         return "Missing struct identifier following STRUCT keyword";
     268             :     case PS_StructHeaderSeen:
     269           4 :         return "Missing '{' or illegal syntax following struct inheritance spec";
     270             :     case PS_StructIDSeen:
     271           0 :         return "Missing '{' or illegal syntax following struct identifier";
     272             :     case PS_StructSqSeen:
     273           2 :         return "Illegal syntax following struct '{' opener";
     274             :     case PS_StructQsSeen:
     275           0 :         return "Illegal syntax following struct '}' closer";
     276             :     case PS_StructBodySeen:
     277           0 :         return "Illegal syntax following struct member(s)";
     278             :     case PS_MemberTypeSeen:
     279           0 :         return "Illegal syntax or missing identifier following member type";
     280             :     case PS_MemberDeclsSeen:
     281           0 :         return "Illegal syntax following member declarator(s)";
     282             :     case PS_MemberDeclsCompleted:
     283           0 :         return "Missing ',' between member decls of same type(?)";
     284             :     case PS_EnumSeen:
     285           0 :         return "Illegal syntax or missing identifier following ENUM keyword";
     286             :     case PS_EnumIDSeen:
     287           0 :         return "Illegal syntax or missing '{' following enum identifier";
     288             :     case PS_EnumSqSeen:
     289           0 :         return "Illegal syntax following enum '{' opener";
     290             :     case PS_EnumQsSeen:
     291           0 :         return "Illegal syntax following enum '}' closer";
     292             :     case PS_EnumBodySeen:
     293           0 :         return "Illegal syntax following enum enumerator(s)";
     294             :     case PS_EnumCommaSeen:
     295           0 :         return "Illegal syntax or missing identifier following ',' in enum";
     296             :     case PS_SequenceSeen:
     297           0 :         return "Illegal syntax or missing '<' following SEQUENCE keyword";
     298             :     case PS_SequenceSqSeen:
     299           2 :         return "Illegal syntax or missing type following '<' in sequence";
     300             :     case PS_SequenceQsSeen:
     301           0 :         return "Illegal syntax following '>' in sequence";
     302             :     case PS_SequenceTypeSeen:
     303           2 :         return "Illegal syntax following sequence type declaration";
     304             :     case PS_FlagHeaderSeen:
     305           0 :         return "Illegal syntax after flags";
     306             :     case PS_AttrSeen:
     307           2 :         return "Illegal syntax after ATTRIBUTE keyword";
     308             :     case PS_AttrTypeSeen:
     309           0 :         return "Illegal syntax after type in attribute declaration";
     310             :     case PS_AttrCompleted:
     311           0 :         return "Illegal syntax after attribute declaration";
     312             :     case PS_ReadOnlySeen:
     313           0 :         return "Illegal syntax after READONLY keyword";
     314             :     case PS_OptionalSeen:
     315           0 :         return "Illegal syntax after OPTIONAL keyword";
     316             :     case PS_MayBeVoidSeen:
     317           0 :         return "Illegal syntax after MAYBEVOID keyword";
     318             :     case PS_BoundSeen:
     319           0 :         return "Illegal syntax after BOUND keyword";
     320             :     case PS_ConstrainedSeen:
     321           0 :         return "Illegal syntax after CONSTRAINED keyword";
     322             :     case PS_TransientSeen:
     323           0 :         return "Illegal syntax after TRANSIENT keyword";
     324             :     case PS_MayBeAmbigiousSeen:
     325           0 :         return "Illegal syntax after MAYBEAMBIGIOUS keyword";
     326             :     case PS_MayBeDefaultSeen:
     327           0 :         return "Illegal syntax after MAYBEDEFAULT keyword";
     328             :     case PS_RemoveableSeen:
     329           0 :         return "Illegal syntax after REMOVABLE keyword";
     330             :     case PS_PropertySeen:
     331           0 :         return "Illegal syntax after PROPERTY keyword";
     332             :     case PS_PropertyTypeSeen:
     333           0 :         return "Illegal syntax after type in property declaration";
     334             :     case PS_PropertyCompleted:
     335           0 :         return "Illegal syntax after property declaration";
     336             :     case PS_ExceptSeen:
     337           0 :         return "Illegal syntax or missing identifier after EXCEPTION keyword";
     338             :     case PS_ExceptHeaderSeen:
     339           0 :         return "Missing '{' or illegal syntax following exception inheritance spec";
     340             :     case PS_ExceptIDSeen:
     341           0 :         return "Illegal syntax or missing '{' after exception identifier";
     342             :     case PS_ExceptSqSeen:
     343           0 :         return "Illegal syntax after exception '{' opener";
     344             :     case PS_ExceptQsSeen:
     345           0 :         return "Illegal syntax after exception '}' closer";
     346             :     case PS_ExceptBodySeen:
     347           0 :         return "Illegal syntax after exception member(s)";
     348             :     case PS_OpTypeSeen:
     349           0 :         return "Illegal syntax or missing identifier after operation type";
     350             :     case PS_OpIDSeen:
     351           0 :         return "Illegal syntax or missing '(' after operation identifier";
     352             :     case PS_OpParsCompleted:
     353           0 :         return "Illegal syntax after operation parameter list";
     354             :     case PS_OpCompleted:
     355           0 :         return "Illegal syntax after operation declaration";
     356             :     case PS_OpSqSeen:
     357           0 :         return "Illegal syntax after operation parameter list '(' opener";
     358             :     case PS_OpQsSeen:
     359           0 :         return "Illegal syntax after operation parameter list ')' closer";
     360             :     case PS_OpParCommaSeen:
     361           0 :         return "Illegal syntax or missing direction in parameter declaration";
     362             :     case PS_OpParDirSeen:
     363           0 :         return "Illegal syntax or missing type in parameter declaration";
     364             :     case PS_OpParTypeSeen:
     365           0 :         return "Illegal syntax or missing declarator in parameter declaration";
     366             :     case PS_OpParDeclSeen:
     367           0 :         return "Illegal syntax following parameter declarator";
     368             :     case PS_RaiseSeen:
     369           0 :         return "Illegal syntax or missing '(' after RAISES keyword";
     370             :     case PS_RaiseSqSeen:
     371           4 :         return "Illegal syntax after RAISES '(' opener";
     372             :     case PS_RaiseQsSeen:
     373           2 :         return "Illegal syntax after RAISES ')' closer";
     374             :     case PS_DeclsCommaSeen:
     375           0 :         return "Illegal syntax after ',' in declarators list";
     376             :     case PS_DeclsDeclSeen:
     377           0 :         return "Illegal syntax after declarator in declarators list";
     378             :     default:
     379           2 :         return "no wider described syntax error";
     380             :     }
     381             : }
     382             : 
     383          14 : static OString flagToString(sal_uInt32 flag)
     384             : {
     385          14 :     OString flagStr;
     386          14 :     if ( (flag & AF_READONLY) == AF_READONLY )
     387           0 :         flagStr += "'readonly'";
     388          14 :     if ( (flag & AF_OPTIONAL) == AF_OPTIONAL )
     389           2 :         flagStr += "'optional'";
     390          14 :     if ( (flag & AF_MAYBEVOID) == AF_MAYBEVOID )
     391           2 :         flagStr += "'maybevoid'";
     392          14 :     if ( (flag & AF_BOUND) == AF_BOUND )
     393           0 :         flagStr += "'bound'";
     394          14 :     if ( (flag & AF_CONSTRAINED) == AF_CONSTRAINED )
     395           2 :         flagStr += "'constrained'";
     396          14 :     if ( (flag & AF_TRANSIENT) == AF_TRANSIENT )
     397           2 :             flagStr += "'transient'";
     398          14 :     if ( (flag & AF_MAYBEAMBIGUOUS) == AF_MAYBEAMBIGUOUS )
     399           0 :         flagStr += "'maybeambiguous'";
     400          14 :     if ( (flag & AF_MAYBEDEFAULT) == AF_MAYBEDEFAULT )
     401           2 :         flagStr += "'maybedefault'";
     402          14 :     if ( (flag & AF_REMOVABLE) == AF_REMOVABLE )
     403           2 :         flagStr += "'removable'";
     404          14 :     if ( (flag & AF_ATTRIBUTE) == AF_ATTRIBUTE )
     405          14 :         flagStr += "'attribute'";
     406          14 :     if ( (flag & AF_PROPERTY) == AF_PROPERTY )
     407           2 :         flagStr += "'property'";
     408          14 :     if ( flagStr.isEmpty() )
     409           0 :         flagStr += "'unknown'";
     410             : 
     411          14 :     return flagStr;
     412             : }
     413             : 
     414         478 : static void errorHeader(ErrorCode eCode, sal_Int32 lineNumber, sal_uInt32 start, sal_uInt32 end)
     415             : {
     416         478 :     OString file;
     417         478 :     if ( idlc()->getFileName() == idlc()->getRealFileName() )
     418         478 :         file = idlc()->getMainFileName();
     419             :     else
     420           0 :         file = idlc()->getFileName();
     421             : 
     422             :     fprintf(stderr, "%s:%lu [%lu:%lu] : %s", file.getStr(),
     423             :             sal::static_int_cast< unsigned long >(lineNumber),
     424             :             sal::static_int_cast< unsigned long >(start),
     425             :             sal::static_int_cast< unsigned long >(end),
     426         478 :             errorCodeToMessage(eCode));
     427         478 : }
     428             : 
     429         148 : static void errorHeader(ErrorCode eCode, sal_uInt32 lineNumber)
     430             : {
     431             :     errorHeader(eCode, lineNumber,
     432         148 :             idlc()->getOffsetStart(), idlc()->getOffsetEnd());
     433         148 : }
     434             : 
     435         330 : static void errorHeader(ErrorCode eCode)
     436             : {
     437         330 :     errorHeader(eCode, idlc()->getLineNumber(),
     438         660 :             idlc()->getOffsetStart(), idlc()->getOffsetEnd());
     439         330 : }
     440             : 
     441           0 : static void warningHeader(WarningCode wCode)
     442             : {
     443           0 :     OString file;
     444           0 :     if ( idlc()->getFileName() == idlc()->getRealFileName() )
     445           0 :         file = idlc()->getMainFileName();
     446             :     else
     447           0 :         file = idlc()->getFileName();
     448             : 
     449             :     fprintf(stderr, "%s(%lu) : WARNING, %s", file.getStr(),
     450             :             sal::static_int_cast< unsigned long >(idlc()->getLineNumber()),
     451           0 :             warningCodeToMessage(wCode));
     452           0 : }
     453             : 
     454          66 : void ErrorHandler::error0(ErrorCode e)
     455             : {
     456          66 :     errorHeader(e);
     457          66 :     fprintf(stderr, "\n");
     458          66 :     idlc()->incErrorCount();
     459          66 : }
     460             : 
     461         122 : void ErrorHandler::error1(ErrorCode e, AstDeclaration const * d)
     462             : {
     463         122 :     errorHeader(e);
     464         122 :     fprintf(stderr, "'%s'\n", d->getScopedName().getStr());
     465         122 :     idlc()->incErrorCount();
     466         122 : }
     467             : 
     468          24 : void ErrorHandler::error2(
     469             :     ErrorCode e, AstDeclaration const * d1, AstDeclaration const * d2)
     470             : {
     471          24 :     errorHeader(e);
     472          24 :     fprintf(stderr, "'%s', '%s'\n", d1->getScopedName().getStr(),
     473          48 :             d2->getScopedName().getStr());
     474          24 :     idlc()->incErrorCount();
     475          24 : }
     476             : 
     477           0 : void ErrorHandler::error3(ErrorCode e, AstDeclaration* d1, AstDeclaration* d2, AstDeclaration* d3)
     478             : {
     479           0 :     errorHeader(e);
     480           0 :     fprintf(stderr, "'%s', '%s', '%s'\n", d1->getScopedName().getStr(),
     481           0 :             d2->getScopedName().getStr(), d3->getScopedName().getStr());
     482           0 :     idlc()->incErrorCount();
     483           0 : }
     484             : 
     485           0 : void ErrorHandler::warning0(WarningCode w, const sal_Char* warningmsg)
     486             : {
     487           0 :     if ( idlc()->getOptions()->isValid("-w") || idlc()->getOptions()->isValid("-we") ) {
     488           0 :         warningHeader(w);
     489           0 :         fprintf(stderr, "%s\n", warningmsg);
     490             :     }
     491             : 
     492           0 :     if ( idlc()->getOptions()->isValid("-we") )
     493           0 :         idlc()->incErrorCount();
     494             :     else
     495           0 :         idlc()->incWarningCount();
     496           0 : }
     497             : 
     498         148 : void ErrorHandler::syntaxError(ParseState ps, sal_Int32 lineNumber, const sal_Char* errmsg)
     499             : {
     500         148 :     errorHeader(EIDL_SYNTAX_ERROR, lineNumber);
     501         148 :     fprintf(stderr, "%s: %s\n", parseStateToMessage(ps), errmsg);
     502         148 :     idlc()->incErrorCount();
     503         148 : }
     504             : 
     505          76 : void ErrorHandler::coercionError(AstExpression *pExpr, ExprType et)
     506             : {
     507          76 :     errorHeader(EIDL_COERCION_FAILURE);
     508             :     fprintf(stderr, "'%s' to '%s'\n", pExpr->toString().getStr(),
     509          76 :             exprTypeToString(et));
     510          76 :     idlc()->incErrorCount();
     511          76 : }
     512             : 
     513           8 : void ErrorHandler::lookupError(const OString& n)
     514             : {
     515           8 :     errorHeader(EIDL_LOOKUP_ERROR);
     516           8 :     fprintf(stderr, "'%s'\n", n.getStr());
     517           8 :     idlc()->incErrorCount();
     518           8 : }
     519             : 
     520           0 : void ErrorHandler::lookupError(ErrorCode e, const OString& n, AstDeclaration* pScope)
     521             : {
     522           0 :     errorHeader(e);
     523           0 :     fprintf(stderr, "'%s' in '%s'\n", n.getStr(), pScope->getFullName().getStr());
     524           0 :     idlc()->incErrorCount();
     525           0 : }
     526             : 
     527          14 : void ErrorHandler::flagError(ErrorCode e, sal_uInt32 flag)
     528             : {
     529          14 :     errorHeader(e);
     530          14 :     fprintf(stderr, "'%s'\n", flagToString(flag).getStr());
     531          14 :     idlc()->incErrorCount();
     532          14 : }
     533             : 
     534          10 : void ErrorHandler::noTypeError(AstDeclaration const * pDecl)
     535             : {
     536          10 :     errorHeader(EIDL_NOT_A_TYPE);
     537          10 :     fprintf(stderr, "'%s'\n", pDecl->getScopedName().getStr());
     538          10 :     idlc()->incErrorCount();
     539          10 : }
     540             : 
     541             : namespace {
     542             : 
     543           6 : char const * nodeTypeName(NodeType nodeType) {
     544           6 :     switch (nodeType) {
     545             :     case NT_interface:
     546           4 :         return "interface";
     547             : 
     548             :     case NT_exception:
     549           0 :         return "exception";
     550             : 
     551             :     case NT_struct:
     552           2 :         return "struct";
     553             : 
     554             :     default:
     555           0 :         return "";
     556             :     }
     557             : }
     558             : 
     559             : }
     560             : 
     561          10 : void ErrorHandler::inheritanceError(NodeType nodeType, const OString* name, AstDeclaration* pDecl)
     562             : {
     563          18 :     if ( nodeType == NT_interface &&
     564          14 :          (pDecl->getNodeType() == NT_interface) &&
     565           4 :          !(static_cast<AstInterface*>(pDecl)->isDefined()) )
     566             :     {
     567           4 :         errorHeader(EIDL_INHERIT_FWD_ERROR);
     568             :         fprintf(stderr, "interface '%s' cannot inherit from forward declared interface '%s'\n",
     569           4 :                 name->getStr(), pDecl->getScopedName().getStr());
     570             :     } else
     571             :     {
     572           6 :         errorHeader(EIDL_CANT_INHERIT);
     573             :         fprintf(stderr, "%s '%s' from '%s'\n",
     574             :                 nodeTypeName(nodeType), name->getStr(),
     575           6 :                 pDecl->getScopedName().getStr());
     576             :     }
     577          10 :     idlc()->incErrorCount();
     578          10 : }
     579             : 
     580           0 : void ErrorHandler::forwardLookupError(const AstDeclaration* pForward,
     581             :                                       const OString& name)
     582             : {
     583           0 :     errorHeader(EIDL_FWD_DECL_LOOKUP);
     584             :     fprintf(stderr, "trying to look up '%s' in undefined forward declared interface '%s'\n",
     585           0 :             pForward->getScopedName().getStr(), name.getStr());
     586           0 :     idlc()->incErrorCount();
     587           0 : }
     588             : 
     589           0 : void ErrorHandler::constantExpected(AstDeclaration* pDecl,
     590             :                                     const OString& name)
     591             : {
     592           0 :     errorHeader(EIDL_CONSTANT_EXPECTED);
     593           0 :     fprintf(stderr, "'%s' is bound to '%s'\n", name.getStr(), pDecl->getScopedName().getStr());
     594           0 :     idlc()->incErrorCount();
     595           0 : }
     596             : 
     597           0 : void ErrorHandler::evalError(AstExpression* pExpr)
     598             : {
     599           0 :     errorHeader(EIDL_EVAL_ERROR);
     600           0 :     fprintf(stderr, "'%s'\n", pExpr->toString().getStr());
     601           0 :     idlc()->incErrorCount();
     602           0 : }
     603             : 
     604        1088 : bool ErrorHandler::checkPublished(AstDeclaration const * decl, bool bOptional) {
     605        1088 :     if (idlc()->isPublished() && !decl->isPublished() && !bOptional) {
     606          72 :         error1(EIDL_PUBLISHED_USES_UNPUBLISHED, decl);
     607          72 :         return false;
     608             :     } else {
     609        1016 :         return true;
     610             :     }
     611             : }
     612             : 
     613             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10