Ericsson / clang

Cross Translation Unit analysis capability for Clang Static Analyzer. (Fork of official clang at http://llvm.org/git/clang)
http://clang.llvm.org/
Other
15 stars 10 forks source link

Destructor not imported? #576

Closed balazske closed 5 years ago

balazske commented 5 years ago

[ RUN ] ParameterizedTests/ASTImporterOptionSpecificTestBase.ImportUnnamedFieldsInCorrectOrder/0

AST after import:

FunctionDecl 0x2c67250 <input0.cc:2:7, line:4:7> line:2:12 f 'void (int, int, bool)'
|-ParmVarDecl 0x2c67108 <col:14, col:18> col:18 used X 'int'
|-ParmVarDecl 0x2c67180 <col:21, col:25> col:25 used Y 'int'
|-ParmVarDecl 0x2c671f0 <col:28, col:33> col:33 used Z 'bool'
`-CompoundStmt 0x2c678f8 <col:36, line:4:7>
  `-CStyleCastExpr 0x2c678d0 <line:3:9, col:36> 'void' <ToVoid>
    `-LambdaExpr 0x2c67848 <col:15, col:36> '(lambda at input0.cc:3:15)'
      |-CXXRecordDecl 0x2c67390 <col:15> col:15 implicit class definition
      | |-DefinitionData lambda pass_in_registers standard_layout trivially_copyable can_const_default_init
      | | |-DefaultConstructor
      | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
      | | |-MoveConstructor exists simple trivial needs_implicit
      | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param
      | | |-MoveAssignment
      | | `-Destructor simple irrelevant trivial needs_implicit
      | |-FieldDecl 0x2c674e8 <col:16> col:16 implicit 'int'
      | |-FieldDecl 0x2c67548 <col:19> col:19 implicit 'int'
      | |-FieldDecl 0x2c675a0 <col:22> col:22 implicit 'bool'
      | `-CXXMethodDecl 0x2c67670 <col:23, col:36> col:15 operator() 'auto () const -> void' inline
      |   `-CompoundStmt 0x2c67770 <col:25, col:36>
      |     `-CStyleCastExpr 0x2c67748 <col:27, col:33> 'void' <ToVoid>
      |       `-DeclRefExpr 0x2c67710 <col:33> 'const bool' lvalue ParmVar 0x2c671f0 'Z' 'bool'
      |-ImplicitCastExpr 0x2c677b0 <col:16> 'int' <LValueToRValue>
      | `-DeclRefExpr 0x2c67788 <col:16> 'int' lvalue ParmVar 0x2c67108 'X' 'int'
      |-ImplicitCastExpr 0x2c677f0 <col:19> 'int' <LValueToRValue>
      | `-DeclRefExpr 0x2c677c8 <col:19> 'int' lvalue ParmVar 0x2c67180 'Y' 'int'
      |-ImplicitCastExpr 0x2c67830 <col:22> 'bool' <LValueToRValue>
      | `-DeclRefExpr 0x2c67808 <col:22> 'bool' lvalue ParmVar 0x2c671f0 'Z' 'bool'
      `-CompoundStmt 0x2c67770 <col:25, col:36>
        `-CStyleCastExpr 0x2c67748 <col:27, col:33> 'void' <ToVoid>
          `-DeclRefExpr 0x2c67710 <col:33> 'const bool' lvalue ParmVar 0x2c671f0 'Z' 'bool'

AST before import:

FunctionDecl 0x2b9a3a0 <input0.cc:2:7, line:4:7> line:2:12 f 'void (int, int, bool)'
|-ParmVarDecl 0x2b9a1d0 <col:14, col:18> col:18 used X 'int'
|-ParmVarDecl 0x2b9a248 <col:21, col:25> col:25 used Y 'int'
|-ParmVarDecl 0x2b9a2b8 <col:28, col:33> col:33 used Z 'bool'
`-CompoundStmt 0x2b9abe8 <col:36, line:4:7>
  `-CStyleCastExpr 0x2b9abc0 <line:3:9, col:36> 'void' <ToVoid>
    `-LambdaExpr 0x2b9a9e0 <col:15, col:36> '(lambda at input0.cc:3:15)'
      |-CXXRecordDecl 0x2b9a520 <col:15> col:15 implicit class definition
      | |-DefinitionData lambda pass_in_registers standard_layout trivially_copyable can_const_default_init
      | | |-DefaultConstructor
      | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
      | | |-MoveConstructor exists simple trivial needs_implicit
      | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param
      | | |-MoveAssignment
      | | `-Destructor simple irrelevant trivial
      | |-FieldDecl 0x2b9a728 <col:16> col:16 implicit 'int'
      | |-FieldDecl 0x2b9a788 <col:19> col:19 implicit 'int'
      | |-FieldDecl 0x2b9a7e0 <col:22> col:22 implicit 'bool'
      | |-CXXMethodDecl 0x2b9a660 <col:23, col:36> col:15 operator() 'auto () const -> void' inline
      | | `-CompoundStmt 0x2b9a888 <col:25, col:36>
      | |   `-CStyleCastExpr 0x2b9a860 <col:27, col:33> 'void' <ToVoid>
      | |     `-DeclRefExpr 0x2b9a828 <col:33> 'const bool' lvalue ParmVar 0x2b9a2b8 'Z' 'bool'
      | `-CXXDestructorDecl 0x2b9aa58 <col:15> col:15 implicit referenced ~ 'void () noexcept' inline default trivial
      |-ImplicitCastExpr 0x2b9a928 <col:16> 'int' <LValueToRValue>
      | `-DeclRefExpr 0x2b9a900 <col:16> 'int' lvalue ParmVar 0x2b9a1d0 'X' 'int'
      |-ImplicitCastExpr 0x2b9a968 <col:19> 'int' <LValueToRValue>
      | `-DeclRefExpr 0x2b9a940 <col:19> 'int' lvalue ParmVar 0x2b9a248 'Y' 'int'
      |-ImplicitCastExpr 0x2b9a9a8 <col:22> 'bool' <LValueToRValue>
      | `-DeclRefExpr 0x2b9a980 <col:22> 'bool' lvalue ParmVar 0x2b9a2b8 'Z' 'bool'
      `-CompoundStmt 0x2b9a888 <col:25, col:36>
        `-CStyleCastExpr 0x2b9a860 <col:27, col:33> 'void' <ToVoid>
          `-DeclRefExpr 0x2b9a828 <col:33> 'const bool' lvalue ParmVar 0x2b9a2b8 'Z' 'bool'

Check why the destructor is missing, is it a problem or not.

balazske commented 5 years ago

The problem occurs when a lambda record is imported. Only the fields are imported in this case. #577 contains the fix to import not only fields.