| ... | ... | @@ -23,8 +23,6 @@ |
| 23 | 23 | |
| 24 | 24 | using namespace clang; |
| 25 | 25 | |
| 26 | | struct TransScope; |
| 27 | | |
| 28 | 26 | struct MacroSymbol { |
| 29 | 27 | Buf *name; |
| 30 | 28 | Buf *value; |
| ... | ... | @@ -54,7 +52,6 @@ struct Context { |
| 54 | 52 | ASTContext *ctx; |
| 55 | 53 | |
| 56 | 54 | HashMap<Buf *, bool, buf_hash, buf_eql_buf> ptr_params; |
| 57 | | TransScope *child_scope; // TODO refactor out |
| 58 | 55 | }; |
| 59 | 56 | |
| 60 | 57 | enum ResultUsed { |
| ... | ... | @@ -71,6 +68,7 @@ enum TransScopeId { |
| 71 | 68 | TransScopeIdSwitch, |
| 72 | 69 | TransScopeIdVar, |
| 73 | 70 | TransScopeIdBlock, |
| 71 | TransScopeIdRoot, |
| 74 | 72 | }; |
| 75 | 73 | |
| 76 | 74 | struct TransScope { |
| ... | ... | @@ -94,17 +92,27 @@ struct TransScopeBlock { |
| 94 | 92 | AstNode *node; |
| 95 | 93 | }; |
| 96 | 94 | |
| 97 | | static AstNode *const skip_add_to_block_node = (AstNode *) 0x2; |
| 95 | struct TransScopeRoot { |
| 96 | TransScope base; |
| 97 | }; |
| 98 | 98 | |
| 99 | static TransScopeRoot *trans_scope_root_create(Context *c); |
| 99 | 100 | static TransScopeBlock *trans_scope_block_create(Context *c, TransScope *parent_scope); |
| 100 | 101 | static TransScopeVar *trans_scope_var_create(Context *c, TransScope *parent_scope, Buf *wanted_name); |
| 101 | 102 | //static TransScopeSwitch *trans_scope_switch_create(Context *c, TransScope *parent_scope); |
| 102 | 103 | |
| 104 | static TransScopeBlock *trans_scope_block_find(TransScope *scope); |
| 105 | |
| 103 | 106 | static AstNode *resolve_record_decl(Context *c, const RecordDecl *record_decl); |
| 104 | 107 | static AstNode *resolve_enum_decl(Context *c, const EnumDecl *enum_decl); |
| 105 | 108 | static AstNode *resolve_typedef_decl(Context *c, const TypedefNameDecl *typedef_decl); |
| 106 | 109 | |
| 107 | | static AstNode *trans_stmt(Context *c, ResultUsed result_used, TransScope *scope, const Stmt *stmt, TransLRValue lrval); |
| 110 | static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt, |
| 111 | ResultUsed result_used, TransLRValue lrval, |
| 112 | AstNode **out_node, TransScope **out_child_scope, |
| 113 | TransScope **out_node_scope); |
| 114 | static TransScope *trans_stmt(Context *c, TransScope *scope, const Stmt *stmt, AstNode **out_node); |
| 115 | static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const Expr *expr, TransLRValue lrval); |
| 108 | 116 | static AstNode *trans_qual_type(Context *c, QualType qt, const SourceLocation &source_loc); |
| 109 | 117 | |
| 110 | 118 | |
| ... | ... | @@ -620,10 +628,6 @@ static bool qual_type_has_wrapping_overflow(Context *c, QualType qt) { |
| 620 | 628 | } |
| 621 | 629 | } |
| 622 | 630 | |
| 623 | | static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const Expr *expr, TransLRValue lrval) { |
| 624 | | return trans_stmt(c, result_used, scope, expr, lrval); |
| 625 | | } |
| 626 | | |
| 627 | 631 | static AstNode *trans_type(Context *c, const Type *ty, const SourceLocation &source_loc) { |
| 628 | 632 | switch (ty->getTypeClass()) { |
| 629 | 633 | case Type::Builtin: |
| ... | ... | @@ -961,16 +965,22 @@ static AstNode *trans_qual_type(Context *c, QualType qt, const SourceLocation &s |
| 961 | 965 | return trans_type(c, qt.getTypePtr(), source_loc); |
| 962 | 966 | } |
| 963 | 967 | |
| 964 | | static AstNode *trans_compound_stmt(Context *c, TransScope *parent_scope, const CompoundStmt *stmt) { |
| 965 | | TransScopeBlock *child_scope_block = trans_scope_block_create(c, parent_scope); |
| 968 | static AstNode *trans_compound_stmt(Context *c, TransScope *scope, const CompoundStmt *stmt, |
| 969 | TransScope **out_node_scope) |
| 970 | { |
| 971 | TransScopeBlock *child_scope_block = trans_scope_block_create(c, scope); |
| 972 | scope = &child_scope_block->base; |
| 966 | 973 | for (CompoundStmt::const_body_iterator it = stmt->body_begin(), end_it = stmt->body_end(); it != end_it; ++it) { |
| 967 | | AstNode *child_node = trans_stmt(c, ResultUsedNo, &child_scope_block->base, *it, TransRValue); |
| 968 | | if (child_node == nullptr) |
| 974 | AstNode *child_node; |
| 975 | scope = trans_stmt(c, scope, *it, &child_node); |
| 976 | if (scope == nullptr) |
| 969 | 977 | return nullptr; |
| 970 | | if (child_node != skip_add_to_block_node) |
| 978 | if (child_node != nullptr) |
| 971 | 979 | child_scope_block->node->data.block.statements.append(child_node); |
| 972 | 980 | } |
| 973 | | c->child_scope = &child_scope_block->base; |
| 981 | if (out_node_scope != nullptr) { |
| 982 | *out_node_scope = &child_scope_block->base; |
| 983 | } |
| 974 | 984 | return child_scope_block->node; |
| 975 | 985 | } |
| 976 | 986 | |
| ... | ... | @@ -1809,7 +1819,15 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc |
| 1809 | 1819 | zig_unreachable(); |
| 1810 | 1820 | } |
| 1811 | 1821 | |
| 1812 | | static AstNode *trans_local_declaration(Context *c, TransScope *scope, const DeclStmt *stmt) { |
| 1822 | static int trans_local_declaration(Context *c, TransScope *scope, const DeclStmt *stmt, |
| 1823 | AstNode **out_node, TransScope **out_scope) |
| 1824 | { |
| 1825 | // declarations are added via the scope |
| 1826 | *out_node = nullptr; |
| 1827 | |
| 1828 | TransScopeBlock *scope_block = trans_scope_block_find(scope); |
| 1829 | assert(scope_block != nullptr); |
| 1830 | |
| 1813 | 1831 | for (auto iter = stmt->decl_begin(); iter != stmt->decl_end(); iter++) { |
| 1814 | 1832 | Decl *decl = *iter; |
| 1815 | 1833 | switch (decl->getKind()) { |
| ... | ... | @@ -1820,245 +1838,246 @@ static AstNode *trans_local_declaration(Context *c, TransScope *scope, const Dec |
| 1820 | 1838 | if (var_decl->hasInit()) { |
| 1821 | 1839 | init_node = trans_expr(c, ResultUsedYes, scope, var_decl->getInit(), TransRValue); |
| 1822 | 1840 | if (init_node == nullptr) |
| 1823 | | return nullptr; |
| 1841 | return ErrorUnexpected; |
| 1824 | 1842 | |
| 1825 | 1843 | } |
| 1826 | 1844 | AstNode *type_node = trans_qual_type(c, qual_type, stmt->getLocStart()); |
| 1827 | 1845 | if (type_node == nullptr) |
| 1828 | | return nullptr; |
| 1846 | return ErrorUnexpected; |
| 1847 | |
| 1848 | Buf *c_symbol_name = buf_create_from_str(decl_name(var_decl)); |
| 1829 | 1849 | |
| 1830 | | Buf *symbol_name = buf_create_from_str(decl_name(var_decl)); |
| 1850 | TransScopeVar *var_scope = trans_scope_var_create(c, scope, c_symbol_name); |
| 1851 | scope = &var_scope->base; |
| 1831 | 1852 | |
| 1832 | 1853 | AstNode *node = trans_create_node_var_decl_local(c, qual_type.isConstQualified(), |
| 1833 | | symbol_name, type_node, init_node); |
| 1854 | var_scope->zig_name, type_node, init_node); |
| 1834 | 1855 | |
| 1835 | | assert(scope->id == TransScopeIdBlock); |
| 1836 | | TransScopeBlock *scope_block = (TransScopeBlock *)scope; |
| 1837 | 1856 | scope_block->node->data.block.statements.append(node); |
| 1838 | 1857 | continue; |
| 1839 | 1858 | } |
| 1840 | 1859 | case Decl::AccessSpec: |
| 1841 | 1860 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind AccessSpec"); |
| 1842 | | return nullptr; |
| 1861 | return ErrorUnexpected; |
| 1843 | 1862 | case Decl::Block: |
| 1844 | 1863 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Block"); |
| 1845 | | return nullptr; |
| 1864 | return ErrorUnexpected; |
| 1846 | 1865 | case Decl::Captured: |
| 1847 | 1866 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Captured"); |
| 1848 | | return nullptr; |
| 1867 | return ErrorUnexpected; |
| 1849 | 1868 | case Decl::ClassScopeFunctionSpecialization: |
| 1850 | 1869 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ClassScopeFunctionSpecialization"); |
| 1851 | | return nullptr; |
| 1870 | return ErrorUnexpected; |
| 1852 | 1871 | case Decl::Empty: |
| 1853 | 1872 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Empty"); |
| 1854 | | return nullptr; |
| 1873 | return ErrorUnexpected; |
| 1855 | 1874 | case Decl::Export: |
| 1856 | 1875 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Export"); |
| 1857 | | return nullptr; |
| 1876 | return ErrorUnexpected; |
| 1858 | 1877 | case Decl::ExternCContext: |
| 1859 | 1878 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ExternCContext"); |
| 1860 | | return nullptr; |
| 1879 | return ErrorUnexpected; |
| 1861 | 1880 | case Decl::FileScopeAsm: |
| 1862 | 1881 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind FileScopeAsm"); |
| 1863 | | return nullptr; |
| 1882 | return ErrorUnexpected; |
| 1864 | 1883 | case Decl::Friend: |
| 1865 | 1884 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Friend"); |
| 1866 | | return nullptr; |
| 1885 | return ErrorUnexpected; |
| 1867 | 1886 | case Decl::FriendTemplate: |
| 1868 | 1887 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind FriendTemplate"); |
| 1869 | | return nullptr; |
| 1888 | return ErrorUnexpected; |
| 1870 | 1889 | case Decl::Import: |
| 1871 | 1890 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Import"); |
| 1872 | | return nullptr; |
| 1891 | return ErrorUnexpected; |
| 1873 | 1892 | case Decl::LinkageSpec: |
| 1874 | 1893 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind LinkageSpec"); |
| 1875 | | return nullptr; |
| 1894 | return ErrorUnexpected; |
| 1876 | 1895 | case Decl::Label: |
| 1877 | 1896 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Label"); |
| 1878 | | return nullptr; |
| 1897 | return ErrorUnexpected; |
| 1879 | 1898 | case Decl::Namespace: |
| 1880 | 1899 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Namespace"); |
| 1881 | | return nullptr; |
| 1900 | return ErrorUnexpected; |
| 1882 | 1901 | case Decl::NamespaceAlias: |
| 1883 | 1902 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind NamespaceAlias"); |
| 1884 | | return nullptr; |
| 1903 | return ErrorUnexpected; |
| 1885 | 1904 | case Decl::ObjCCompatibleAlias: |
| 1886 | 1905 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCCompatibleAlias"); |
| 1887 | | return nullptr; |
| 1906 | return ErrorUnexpected; |
| 1888 | 1907 | case Decl::ObjCCategory: |
| 1889 | 1908 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCCategory"); |
| 1890 | | return nullptr; |
| 1909 | return ErrorUnexpected; |
| 1891 | 1910 | case Decl::ObjCCategoryImpl: |
| 1892 | 1911 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCCategoryImpl"); |
| 1893 | | return nullptr; |
| 1912 | return ErrorUnexpected; |
| 1894 | 1913 | case Decl::ObjCImplementation: |
| 1895 | 1914 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCImplementation"); |
| 1896 | | return nullptr; |
| 1915 | return ErrorUnexpected; |
| 1897 | 1916 | case Decl::ObjCInterface: |
| 1898 | 1917 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCInterface"); |
| 1899 | | return nullptr; |
| 1918 | return ErrorUnexpected; |
| 1900 | 1919 | case Decl::ObjCProtocol: |
| 1901 | 1920 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCProtocol"); |
| 1902 | | return nullptr; |
| 1921 | return ErrorUnexpected; |
| 1903 | 1922 | case Decl::ObjCMethod: |
| 1904 | 1923 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCMethod"); |
| 1905 | | return nullptr; |
| 1924 | return ErrorUnexpected; |
| 1906 | 1925 | case Decl::ObjCProperty: |
| 1907 | 1926 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCProperty"); |
| 1908 | | return nullptr; |
| 1927 | return ErrorUnexpected; |
| 1909 | 1928 | case Decl::BuiltinTemplate: |
| 1910 | 1929 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind BuiltinTemplate"); |
| 1911 | | return nullptr; |
| 1930 | return ErrorUnexpected; |
| 1912 | 1931 | case Decl::ClassTemplate: |
| 1913 | 1932 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ClassTemplate"); |
| 1914 | | return nullptr; |
| 1933 | return ErrorUnexpected; |
| 1915 | 1934 | case Decl::FunctionTemplate: |
| 1916 | 1935 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind FunctionTemplate"); |
| 1917 | | return nullptr; |
| 1936 | return ErrorUnexpected; |
| 1918 | 1937 | case Decl::TypeAliasTemplate: |
| 1919 | 1938 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind TypeAliasTemplate"); |
| 1920 | | return nullptr; |
| 1939 | return ErrorUnexpected; |
| 1921 | 1940 | case Decl::VarTemplate: |
| 1922 | 1941 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind VarTemplate"); |
| 1923 | | return nullptr; |
| 1942 | return ErrorUnexpected; |
| 1924 | 1943 | case Decl::TemplateTemplateParm: |
| 1925 | 1944 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind TemplateTemplateParm"); |
| 1926 | | return nullptr; |
| 1945 | return ErrorUnexpected; |
| 1927 | 1946 | case Decl::Enum: |
| 1928 | 1947 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Enum"); |
| 1929 | | return nullptr; |
| 1948 | return ErrorUnexpected; |
| 1930 | 1949 | case Decl::Record: |
| 1931 | 1950 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Record"); |
| 1932 | | return nullptr; |
| 1951 | return ErrorUnexpected; |
| 1933 | 1952 | case Decl::CXXRecord: |
| 1934 | 1953 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind CXXRecord"); |
| 1935 | | return nullptr; |
| 1954 | return ErrorUnexpected; |
| 1936 | 1955 | case Decl::ClassTemplateSpecialization: |
| 1937 | 1956 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ClassTemplateSpecialization"); |
| 1938 | | return nullptr; |
| 1957 | return ErrorUnexpected; |
| 1939 | 1958 | case Decl::ClassTemplatePartialSpecialization: |
| 1940 | 1959 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ClassTemplatePartialSpecialization"); |
| 1941 | | return nullptr; |
| 1960 | return ErrorUnexpected; |
| 1942 | 1961 | case Decl::TemplateTypeParm: |
| 1943 | 1962 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind TemplateTypeParm"); |
| 1944 | | return nullptr; |
| 1963 | return ErrorUnexpected; |
| 1945 | 1964 | case Decl::ObjCTypeParam: |
| 1946 | 1965 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCTypeParam"); |
| 1947 | | return nullptr; |
| 1966 | return ErrorUnexpected; |
| 1948 | 1967 | case Decl::TypeAlias: |
| 1949 | 1968 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind TypeAlias"); |
| 1950 | | return nullptr; |
| 1969 | return ErrorUnexpected; |
| 1951 | 1970 | case Decl::Typedef: |
| 1952 | 1971 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Typedef"); |
| 1953 | | return nullptr; |
| 1972 | return ErrorUnexpected; |
| 1954 | 1973 | case Decl::UnresolvedUsingTypename: |
| 1955 | 1974 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind UnresolvedUsingTypename"); |
| 1956 | | return nullptr; |
| 1975 | return ErrorUnexpected; |
| 1957 | 1976 | case Decl::Using: |
| 1958 | 1977 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Using"); |
| 1959 | | return nullptr; |
| 1978 | return ErrorUnexpected; |
| 1960 | 1979 | case Decl::UsingDirective: |
| 1961 | 1980 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind UsingDirective"); |
| 1962 | | return nullptr; |
| 1981 | return ErrorUnexpected; |
| 1963 | 1982 | case Decl::UsingPack: |
| 1964 | 1983 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind UsingPack"); |
| 1965 | | return nullptr; |
| 1984 | return ErrorUnexpected; |
| 1966 | 1985 | case Decl::UsingShadow: |
| 1967 | 1986 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind UsingShadow"); |
| 1968 | | return nullptr; |
| 1987 | return ErrorUnexpected; |
| 1969 | 1988 | case Decl::ConstructorUsingShadow: |
| 1970 | 1989 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ConstructorUsingShadow"); |
| 1971 | | return nullptr; |
| 1990 | return ErrorUnexpected; |
| 1972 | 1991 | case Decl::Binding: |
| 1973 | 1992 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Binding"); |
| 1974 | | return nullptr; |
| 1993 | return ErrorUnexpected; |
| 1975 | 1994 | case Decl::Field: |
| 1976 | 1995 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Field"); |
| 1977 | | return nullptr; |
| 1996 | return ErrorUnexpected; |
| 1978 | 1997 | case Decl::ObjCAtDefsField: |
| 1979 | 1998 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCAtDefsField"); |
| 1980 | | return nullptr; |
| 1999 | return ErrorUnexpected; |
| 1981 | 2000 | case Decl::ObjCIvar: |
| 1982 | 2001 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCIvar"); |
| 1983 | | return nullptr; |
| 2002 | return ErrorUnexpected; |
| 1984 | 2003 | case Decl::Function: |
| 1985 | 2004 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Function"); |
| 1986 | | return nullptr; |
| 2005 | return ErrorUnexpected; |
| 1987 | 2006 | case Decl::CXXDeductionGuide: |
| 1988 | 2007 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind CXXDeductionGuide"); |
| 1989 | | return nullptr; |
| 2008 | return ErrorUnexpected; |
| 1990 | 2009 | case Decl::CXXMethod: |
| 1991 | 2010 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind CXXMethod"); |
| 1992 | | return nullptr; |
| 2011 | return ErrorUnexpected; |
| 1993 | 2012 | case Decl::CXXConstructor: |
| 1994 | 2013 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind CXXConstructor"); |
| 1995 | | return nullptr; |
| 2014 | return ErrorUnexpected; |
| 1996 | 2015 | case Decl::CXXConversion: |
| 1997 | 2016 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind CXXConversion"); |
| 1998 | | return nullptr; |
| 2017 | return ErrorUnexpected; |
| 1999 | 2018 | case Decl::CXXDestructor: |
| 2000 | 2019 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind CXXDestructor"); |
| 2001 | | return nullptr; |
| 2020 | return ErrorUnexpected; |
| 2002 | 2021 | case Decl::MSProperty: |
| 2003 | 2022 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind MSProperty"); |
| 2004 | | return nullptr; |
| 2023 | return ErrorUnexpected; |
| 2005 | 2024 | case Decl::NonTypeTemplateParm: |
| 2006 | 2025 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind NonTypeTemplateParm"); |
| 2007 | | return nullptr; |
| 2026 | return ErrorUnexpected; |
| 2008 | 2027 | case Decl::Decomposition: |
| 2009 | 2028 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind Decomposition"); |
| 2010 | | return nullptr; |
| 2029 | return ErrorUnexpected; |
| 2011 | 2030 | case Decl::ImplicitParam: |
| 2012 | 2031 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ImplicitParam"); |
| 2013 | | return nullptr; |
| 2032 | return ErrorUnexpected; |
| 2014 | 2033 | case Decl::OMPCapturedExpr: |
| 2015 | 2034 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind OMPCapturedExpr"); |
| 2016 | | return nullptr; |
| 2035 | return ErrorUnexpected; |
| 2017 | 2036 | case Decl::ParmVar: |
| 2018 | 2037 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ParmVar"); |
| 2019 | | return nullptr; |
| 2038 | return ErrorUnexpected; |
| 2020 | 2039 | case Decl::VarTemplateSpecialization: |
| 2021 | 2040 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind VarTemplateSpecialization"); |
| 2022 | | return nullptr; |
| 2041 | return ErrorUnexpected; |
| 2023 | 2042 | case Decl::VarTemplatePartialSpecialization: |
| 2024 | 2043 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind VarTemplatePartialSpecialization"); |
| 2025 | | return nullptr; |
| 2044 | return ErrorUnexpected; |
| 2026 | 2045 | case Decl::EnumConstant: |
| 2027 | 2046 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind EnumConstant"); |
| 2028 | | return nullptr; |
| 2047 | return ErrorUnexpected; |
| 2029 | 2048 | case Decl::IndirectField: |
| 2030 | 2049 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind IndirectField"); |
| 2031 | | return nullptr; |
| 2050 | return ErrorUnexpected; |
| 2032 | 2051 | case Decl::OMPDeclareReduction: |
| 2033 | 2052 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind OMPDeclareReduction"); |
| 2034 | | return nullptr; |
| 2053 | return ErrorUnexpected; |
| 2035 | 2054 | case Decl::UnresolvedUsingValue: |
| 2036 | 2055 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind UnresolvedUsingValue"); |
| 2037 | | return nullptr; |
| 2056 | return ErrorUnexpected; |
| 2038 | 2057 | case Decl::OMPThreadPrivate: |
| 2039 | 2058 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind OMPThreadPrivate"); |
| 2040 | | return nullptr; |
| 2059 | return ErrorUnexpected; |
| 2041 | 2060 | case Decl::ObjCPropertyImpl: |
| 2042 | 2061 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind ObjCPropertyImpl"); |
| 2043 | | return nullptr; |
| 2062 | return ErrorUnexpected; |
| 2044 | 2063 | case Decl::PragmaComment: |
| 2045 | 2064 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind PragmaComment"); |
| 2046 | | return nullptr; |
| 2065 | return ErrorUnexpected; |
| 2047 | 2066 | case Decl::PragmaDetectMismatch: |
| 2048 | 2067 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind PragmaDetectMismatch"); |
| 2049 | | return nullptr; |
| 2068 | return ErrorUnexpected; |
| 2050 | 2069 | case Decl::StaticAssert: |
| 2051 | 2070 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind StaticAssert"); |
| 2052 | | return nullptr; |
| 2071 | return ErrorUnexpected; |
| 2053 | 2072 | case Decl::TranslationUnit: |
| 2054 | 2073 | emit_warning(c, stmt->getLocStart(), "TODO handle decl kind TranslationUnit"); |
| 2055 | | return nullptr; |
| 2074 | return ErrorUnexpected; |
| 2056 | 2075 | } |
| 2057 | 2076 | zig_unreachable(); |
| 2058 | 2077 | } |
| 2059 | 2078 | |
| 2060 | | // declarations were already added |
| 2061 | | return skip_add_to_block_node; |
| 2079 | *out_scope = scope; |
| 2080 | return ErrorNone; |
| 2062 | 2081 | } |
| 2063 | 2082 | |
| 2064 | 2083 | static AstNode *trans_while_loop(Context *c, TransScope *scope, const WhileStmt *stmt) { |
| ... | ... | @@ -2068,8 +2087,8 @@ static AstNode *trans_while_loop(Context *c, TransScope *scope, const WhileStmt |
| 2068 | 2087 | if (while_node->data.while_expr.condition == nullptr) |
| 2069 | 2088 | return nullptr; |
| 2070 | 2089 | |
| 2071 | | while_node->data.while_expr.body = trans_stmt(c, ResultUsedNo, scope, stmt->getBody(), TransRValue); |
| 2072 | | if (while_node->data.while_expr.body == nullptr) |
| 2090 | TransScope *body_scope = trans_stmt(c, scope, stmt->getBody(), &while_node->data.while_expr.body); |
| 2091 | if (body_scope == nullptr) |
| 2073 | 2092 | return nullptr; |
| 2074 | 2093 | |
| 2075 | 2094 | return while_node; |
| ... | ... | @@ -2086,13 +2105,13 @@ static AstNode *trans_if_statement(Context *c, TransScope *scope, const IfStmt * |
| 2086 | 2105 | return nullptr; |
| 2087 | 2106 | if_node->data.if_bool_expr.condition = condition_node; |
| 2088 | 2107 | |
| 2089 | | if_node->data.if_bool_expr.then_block = trans_stmt(c, ResultUsedNo, scope, stmt->getThen(), TransRValue); |
| 2090 | | if (if_node->data.if_bool_expr.then_block == nullptr) |
| 2108 | TransScope *then_scope = trans_stmt(c, scope, stmt->getThen(), &if_node->data.if_bool_expr.then_block); |
| 2109 | if (then_scope == nullptr) |
| 2091 | 2110 | return nullptr; |
| 2092 | 2111 | |
| 2093 | 2112 | if (stmt->getElse() != nullptr) { |
| 2094 | | if_node->data.if_bool_expr.else_node = trans_stmt(c, ResultUsedNo, scope, stmt->getElse(), TransRValue); |
| 2095 | | if (if_node->data.if_bool_expr.else_node == nullptr) |
| 2113 | TransScope *else_scope = trans_stmt(c, scope, stmt->getElse(), &if_node->data.if_bool_expr.else_node); |
| 2114 | if (else_scope == nullptr) |
| 2096 | 2115 | return nullptr; |
| 2097 | 2116 | } |
| 2098 | 2117 | |
| ... | ... | @@ -2201,10 +2220,14 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const DoStmt |
| 2201 | 2220 | // zig: b; |
| 2202 | 2221 | // zig: if (!cond) break; |
| 2203 | 2222 | // zig: } |
| 2204 | | body_node = trans_stmt(c, ResultUsedNo, parent_scope, stmt->getBody(), TransRValue); |
| 2205 | | if (body_node == nullptr) return nullptr; |
| 2223 | |
| 2224 | // We call the low level function so that we can set child_scope to the scope of the generated block. |
| 2225 | if (trans_stmt_extra(c, parent_scope, stmt->getBody(), ResultUsedNo, TransRValue, &body_node, |
| 2226 | nullptr, &child_scope)) |
| 2227 | { |
| 2228 | return nullptr; |
| 2229 | } |
| 2206 | 2230 | assert(body_node->type == NodeTypeBlock); |
| 2207 | | child_scope = c->child_scope; |
| 2208 | 2231 | } else { |
| 2209 | 2232 | // the C statement is without a block, so we need to create a block to contain it. |
| 2210 | 2233 | // c: do |
| ... | ... | @@ -2216,10 +2239,10 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const DoStmt |
| 2216 | 2239 | // zig: } |
| 2217 | 2240 | TransScopeBlock *child_block_scope = trans_scope_block_create(c, parent_scope); |
| 2218 | 2241 | body_node = child_block_scope->node; |
| 2219 | | child_scope = &child_block_scope->base; |
| 2220 | | AstNode *child_statement = trans_stmt(c, ResultUsedNo, child_scope, stmt->getBody(), TransRValue); |
| 2221 | | if (child_statement == nullptr) return nullptr; |
| 2222 | | child_block_scope->node->data.block.statements.append(child_statement); |
| 2242 | AstNode *child_statement; |
| 2243 | child_scope = trans_stmt(c, &child_block_scope->base, stmt->getBody(), &child_statement); |
| 2244 | if (child_scope == nullptr) return nullptr; |
| 2245 | body_node->data.block.statements.append(child_statement); |
| 2223 | 2246 | } |
| 2224 | 2247 | |
| 2225 | 2248 | // if (!cond) break; |
| ... | ... | @@ -2229,10 +2252,7 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const DoStmt |
| 2229 | 2252 | terminator_node->data.if_bool_expr.condition = trans_create_node_prefix_op(c, PrefixOpBoolNot, condition_node); |
| 2230 | 2253 | terminator_node->data.if_bool_expr.then_block = trans_create_node(c, NodeTypeBreak); |
| 2231 | 2254 | |
| 2232 | | assert(child_scope->id == TransScopeIdBlock); |
| 2233 | | TransScopeBlock *child_block_scope = (TransScopeBlock *)child_scope; |
| 2234 | | |
| 2235 | | child_block_scope->node->data.block.statements.append(terminator_node); |
| 2255 | body_node->data.block.statements.append(terminator_node); |
| 2236 | 2256 | |
| 2237 | 2257 | while_node->data.while_expr.body = body_node; |
| 2238 | 2258 | |
| ... | ... | @@ -2244,10 +2264,10 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const DoStmt |
| 2244 | 2264 | // AstNode *switch_node = trans_create_node(c, NodeTypeSwitchExpr); |
| 2245 | 2265 | // const DeclStmt *var_decl_stmt = stmt->getConditionVariableDeclStmt(); |
| 2246 | 2266 | // if (var_decl_stmt != nullptr) { |
| 2247 | | // AstNode *vars_node = trans_stmt(c, ResultUsedNo, switch_block_node, var_decl_stmt, TransRValue); |
| 2267 | // AstNode *vars_node = trans_stmt(c, switch_block_node, var_decl_stmt); |
| 2248 | 2268 | // if (vars_node == nullptr) |
| 2249 | 2269 | // return nullptr; |
| 2250 | | // if (vars_node != skip_add_to_block_node) |
| 2270 | // if (vars_node != nullptr) |
| 2251 | 2271 | // switch_block_node->data.block.statements.append(vars_node); |
| 2252 | 2272 | // } |
| 2253 | 2273 | // switch_block_node->data.block.statements.append(switch_node); |
| ... | ... | @@ -2260,10 +2280,10 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const DoStmt |
| 2260 | 2280 | // return nullptr; |
| 2261 | 2281 | // switch_node->data.switch_expr.expr = expr_node; |
| 2262 | 2282 | // |
| 2263 | | // AstNode *body_node = trans_stmt(c, ResultUsedNo, switch_block_node, stmt->getBody(), TransRValue); |
| 2283 | // AstNode *body_node = trans_stmt(c, switch_block_node, stmt->getBody()); |
| 2264 | 2284 | // if (body_node == nullptr) |
| 2265 | 2285 | // return nullptr; |
| 2266 | | // if (body_node != skip_add_to_block_node) |
| 2286 | // if (body_node != nullptr) |
| 2267 | 2287 | // switch_block_node->data.block.statements.append(body_node); |
| 2268 | 2288 | // |
| 2269 | 2289 | // return switch_block_node; |
| ... | ... | @@ -2271,21 +2291,22 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const DoStmt |
| 2271 | 2291 | |
| 2272 | 2292 | static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const ForStmt *stmt) { |
| 2273 | 2293 | AstNode *loop_block_node; |
| 2274 | | TransScope *condition_scope; |
| 2294 | TransScope *inner_scope; |
| 2275 | 2295 | AstNode *while_node = trans_create_node(c, NodeTypeWhileExpr); |
| 2276 | 2296 | const Stmt *init_stmt = stmt->getInit(); |
| 2277 | 2297 | if (init_stmt == nullptr) { |
| 2278 | 2298 | loop_block_node = while_node; |
| 2279 | | condition_scope = parent_scope; |
| 2299 | inner_scope = parent_scope; |
| 2280 | 2300 | } else { |
| 2281 | 2301 | TransScopeBlock *child_scope = trans_scope_block_create(c, parent_scope); |
| 2282 | 2302 | loop_block_node = child_scope->node; |
| 2283 | | condition_scope = &child_scope->base; |
| 2303 | inner_scope = &child_scope->base; |
| 2284 | 2304 | |
| 2285 | | AstNode *vars_node = trans_stmt(c, ResultUsedNo, &child_scope->base, init_stmt, TransRValue); |
| 2286 | | if (vars_node == nullptr) |
| 2305 | AstNode *vars_node; |
| 2306 | inner_scope = trans_stmt(c, &child_scope->base, init_stmt, &vars_node); |
| 2307 | if (inner_scope == nullptr) |
| 2287 | 2308 | return nullptr; |
| 2288 | | if (vars_node != skip_add_to_block_node) |
| 2309 | if (vars_node != nullptr) |
| 2289 | 2310 | child_scope->node->data.block.statements.append(vars_node); |
| 2290 | 2311 | |
| 2291 | 2312 | child_scope->node->data.block.statements.append(while_node); |
| ... | ... | @@ -2297,21 +2318,23 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const ForSt |
| 2297 | 2318 | true_node->data.bool_literal.value = true; |
| 2298 | 2319 | while_node->data.while_expr.condition = true_node; |
| 2299 | 2320 | } else { |
| 2300 | | while_node->data.while_expr.condition = trans_stmt(c, ResultUsedNo, condition_scope, cond_stmt, TransRValue); |
| 2301 | | if (while_node->data.while_expr.condition == nullptr) |
| 2321 | TransScope *cond_scope = trans_stmt(c, inner_scope, cond_stmt, &while_node->data.while_expr.condition); |
| 2322 | if (cond_scope == nullptr) |
| 2302 | 2323 | return nullptr; |
| 2303 | 2324 | } |
| 2304 | 2325 | |
| 2305 | 2326 | const Stmt *inc_stmt = stmt->getInc(); |
| 2306 | 2327 | if (inc_stmt != nullptr) { |
| 2307 | | AstNode *inc_node = trans_stmt(c, ResultUsedNo, condition_scope, inc_stmt, TransRValue); |
| 2308 | | if (inc_node == nullptr) |
| 2328 | AstNode *inc_node; |
| 2329 | TransScope *inc_scope = trans_stmt(c, inner_scope, inc_stmt, &inc_node); |
| 2330 | if (inc_scope == nullptr) |
| 2309 | 2331 | return nullptr; |
| 2310 | 2332 | while_node->data.while_expr.continue_expr = inc_node; |
| 2311 | 2333 | } |
| 2312 | 2334 | |
| 2313 | | AstNode *child_statement = trans_stmt(c, ResultUsedNo, condition_scope, stmt->getBody(), TransRValue); |
| 2314 | | if (child_statement == nullptr) |
| 2335 | AstNode *child_statement; |
| 2336 | TransScope *body_scope = trans_stmt(c, inner_scope, stmt->getBody(), &child_statement); |
| 2337 | if (body_scope == nullptr) |
| 2315 | 2338 | return nullptr; |
| 2316 | 2339 | while_node->data.while_expr.body = child_statement; |
| 2317 | 2340 | |
| ... | ... | @@ -2344,578 +2367,636 @@ static AstNode *trans_continue_stmt(Context *c, TransScope *scope, const Continu |
| 2344 | 2367 | return trans_create_node(c, NodeTypeContinue); |
| 2345 | 2368 | } |
| 2346 | 2369 | |
| 2347 | | static AstNode *trans_stmt(Context *c, ResultUsed result_used, TransScope *scope, const Stmt *stmt, TransLRValue lrvalue) { |
| 2348 | | c->child_scope = scope; // TODO refactor out |
| 2370 | static int wrap_stmt(AstNode **out_node, TransScope **out_scope, TransScope *in_scope, AstNode *result_node) { |
| 2371 | if (result_node == nullptr) |
| 2372 | return ErrorUnexpected; |
| 2373 | *out_node = result_node; |
| 2374 | if (out_scope != nullptr) { |
| 2375 | *out_scope = in_scope; |
| 2376 | } |
| 2377 | return ErrorNone; |
| 2378 | } |
| 2379 | |
| 2380 | static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt, |
| 2381 | ResultUsed result_used, TransLRValue lrvalue, |
| 2382 | AstNode **out_node, TransScope **out_child_scope, |
| 2383 | TransScope **out_node_scope) |
| 2384 | { |
| 2349 | 2385 | Stmt::StmtClass sc = stmt->getStmtClass(); |
| 2350 | 2386 | switch (sc) { |
| 2351 | 2387 | case Stmt::ReturnStmtClass: |
| 2352 | | return trans_return_stmt(c, scope, (const ReturnStmt *)stmt); |
| 2388 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2389 | trans_return_stmt(c, scope, (const ReturnStmt *)stmt)); |
| 2353 | 2390 | case Stmt::CompoundStmtClass: |
| 2354 | | return trans_compound_stmt(c, scope, (const CompoundStmt *)stmt); |
| 2391 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2392 | trans_compound_stmt(c, scope, (const CompoundStmt *)stmt, out_node_scope)); |
| 2355 | 2393 | case Stmt::IntegerLiteralClass: |
| 2356 | | return trans_integer_literal(c, (const IntegerLiteral *)stmt); |
| 2394 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2395 | trans_integer_literal(c, (const IntegerLiteral *)stmt)); |
| 2357 | 2396 | case Stmt::ConditionalOperatorClass: |
| 2358 | | return trans_conditional_operator(c, result_used, scope, (const ConditionalOperator *)stmt); |
| 2397 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2398 | trans_conditional_operator(c, result_used, scope, (const ConditionalOperator *)stmt)); |
| 2359 | 2399 | case Stmt::BinaryOperatorClass: |
| 2360 | | return trans_binary_operator(c, result_used, scope, (const BinaryOperator *)stmt); |
| 2400 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2401 | trans_binary_operator(c, result_used, scope, (const BinaryOperator *)stmt)); |
| 2361 | 2402 | case Stmt::CompoundAssignOperatorClass: |
| 2362 | | return trans_compound_assign_operator(c, result_used, scope, (const CompoundAssignOperator *)stmt); |
| 2403 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2404 | trans_compound_assign_operator(c, result_used, scope, (const CompoundAssignOperator *)stmt)); |
| 2363 | 2405 | case Stmt::ImplicitCastExprClass: |
| 2364 | | return trans_implicit_cast_expr(c, scope, (const ImplicitCastExpr *)stmt); |
| 2406 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2407 | trans_implicit_cast_expr(c, scope, (const ImplicitCastExpr *)stmt)); |
| 2365 | 2408 | case Stmt::DeclRefExprClass: |
| 2366 | | return trans_decl_ref_expr(c, (const DeclRefExpr *)stmt, lrvalue); |
| 2409 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2410 | trans_decl_ref_expr(c, (const DeclRefExpr *)stmt, lrvalue)); |
| 2367 | 2411 | case Stmt::UnaryOperatorClass: |
| 2368 | | return trans_unary_operator(c, result_used, scope, (const UnaryOperator *)stmt); |
| 2412 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2413 | trans_unary_operator(c, result_used, scope, (const UnaryOperator *)stmt)); |
| 2369 | 2414 | case Stmt::DeclStmtClass: |
| 2370 | | return trans_local_declaration(c, scope, (const DeclStmt *)stmt); |
| 2415 | return trans_local_declaration(c, scope, (const DeclStmt *)stmt, out_node, out_child_scope); |
| 2371 | 2416 | case Stmt::WhileStmtClass: |
| 2372 | | return trans_while_loop(c, scope, (const WhileStmt *)stmt); |
| 2417 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2418 | trans_while_loop(c, scope, (const WhileStmt *)stmt)); |
| 2373 | 2419 | case Stmt::IfStmtClass: |
| 2374 | | return trans_if_statement(c, scope, (const IfStmt *)stmt); |
| 2420 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2421 | trans_if_statement(c, scope, (const IfStmt *)stmt)); |
| 2375 | 2422 | case Stmt::CallExprClass: |
| 2376 | | return trans_call_expr(c, result_used, scope, (const CallExpr *)stmt); |
| 2423 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2424 | trans_call_expr(c, result_used, scope, (const CallExpr *)stmt)); |
| 2377 | 2425 | case Stmt::NullStmtClass: |
| 2378 | | return skip_add_to_block_node; |
| 2426 | *out_node = nullptr; |
| 2427 | *out_child_scope = scope; |
| 2428 | return ErrorNone; |
| 2379 | 2429 | case Stmt::MemberExprClass: |
| 2380 | | return trans_member_expr(c, scope, (const MemberExpr *)stmt); |
| 2430 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2431 | trans_member_expr(c, scope, (const MemberExpr *)stmt)); |
| 2381 | 2432 | case Stmt::ArraySubscriptExprClass: |
| 2382 | | return trans_array_subscript_expr(c, scope, (const ArraySubscriptExpr *)stmt); |
| 2433 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2434 | trans_array_subscript_expr(c, scope, (const ArraySubscriptExpr *)stmt)); |
| 2383 | 2435 | case Stmt::CStyleCastExprClass: |
| 2384 | | return trans_c_style_cast_expr(c, result_used, scope, (const CStyleCastExpr *)stmt, lrvalue); |
| 2436 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2437 | trans_c_style_cast_expr(c, result_used, scope, (const CStyleCastExpr *)stmt, lrvalue)); |
| 2385 | 2438 | case Stmt::UnaryExprOrTypeTraitExprClass: |
| 2386 | | return trans_unary_expr_or_type_trait_expr(c, scope, (const UnaryExprOrTypeTraitExpr *)stmt); |
| 2439 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2440 | trans_unary_expr_or_type_trait_expr(c, scope, (const UnaryExprOrTypeTraitExpr *)stmt)); |
| 2387 | 2441 | case Stmt::DoStmtClass: |
| 2388 | | return trans_do_loop(c, scope, (const DoStmt *)stmt); |
| 2442 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2443 | trans_do_loop(c, scope, (const DoStmt *)stmt)); |
| 2389 | 2444 | case Stmt::ForStmtClass: |
| 2390 | | return trans_for_loop(c, scope, (const ForStmt *)stmt); |
| 2445 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2446 | trans_for_loop(c, scope, (const ForStmt *)stmt)); |
| 2391 | 2447 | case Stmt::StringLiteralClass: |
| 2392 | | return trans_string_literal(c, scope, (const StringLiteral *)stmt); |
| 2448 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2449 | trans_string_literal(c, scope, (const StringLiteral *)stmt)); |
| 2393 | 2450 | case Stmt::BreakStmtClass: |
| 2394 | | return trans_break_stmt(c, scope, (const BreakStmt *)stmt); |
| 2451 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2452 | trans_break_stmt(c, scope, (const BreakStmt *)stmt)); |
| 2395 | 2453 | case Stmt::ContinueStmtClass: |
| 2396 | | return trans_continue_stmt(c, scope, (const ContinueStmt *)stmt); |
| 2454 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2455 | trans_continue_stmt(c, scope, (const ContinueStmt *)stmt)); |
| 2456 | case Stmt::ParenExprClass: |
| 2457 | return wrap_stmt(out_node, out_child_scope, scope, |
| 2458 | trans_expr(c, result_used, scope, ((const ParenExpr*)stmt)->getSubExpr(), lrvalue)); |
| 2397 | 2459 | // case Stmt::SwitchStmtClass: |
| 2398 | | // return trans_switch_stmt(c, scope, (const SwitchStmt *)stmt); |
| 2460 | // return wrap_stmt(out_node, out_child_scope, scope, |
| 2461 | // trans_switch_stmt(c, scope, (const SwitchStmt *)stmt)); |
| 2399 | 2462 | case Stmt::SwitchStmtClass: |
| 2400 | 2463 | emit_warning(c, stmt->getLocStart(), "TODO handle C SwitchStmtClass"); |
| 2401 | | return nullptr; |
| 2464 | return ErrorUnexpected; |
| 2402 | 2465 | case Stmt::CaseStmtClass: |
| 2403 | 2466 | emit_warning(c, stmt->getLocStart(), "TODO handle C CaseStmtClass"); |
| 2404 | | return nullptr; |
| 2467 | return ErrorUnexpected; |
| 2405 | 2468 | case Stmt::DefaultStmtClass: |
| 2406 | 2469 | emit_warning(c, stmt->getLocStart(), "TODO handle C DefaultStmtClass"); |
| 2407 | | return nullptr; |
| 2470 | return ErrorUnexpected; |
| 2408 | 2471 | case Stmt::NoStmtClass: |
| 2409 | 2472 | emit_warning(c, stmt->getLocStart(), "TODO handle C NoStmtClass"); |
| 2410 | | return nullptr; |
| 2473 | return ErrorUnexpected; |
| 2411 | 2474 | case Stmt::GCCAsmStmtClass: |
| 2412 | 2475 | emit_warning(c, stmt->getLocStart(), "TODO handle C GCCAsmStmtClass"); |
| 2413 | | return nullptr; |
| 2476 | return ErrorUnexpected; |
| 2414 | 2477 | case Stmt::MSAsmStmtClass: |
| 2415 | 2478 | emit_warning(c, stmt->getLocStart(), "TODO handle C MSAsmStmtClass"); |
| 2416 | | return nullptr; |
| 2479 | return ErrorUnexpected; |
| 2417 | 2480 | case Stmt::AttributedStmtClass: |
| 2418 | 2481 | emit_warning(c, stmt->getLocStart(), "TODO handle C AttributedStmtClass"); |
| 2419 | | return nullptr; |
| 2482 | return ErrorUnexpected; |
| 2420 | 2483 | case Stmt::CXXCatchStmtClass: |
| 2421 | 2484 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXCatchStmtClass"); |
| 2422 | | return nullptr; |
| 2485 | return ErrorUnexpected; |
| 2423 | 2486 | case Stmt::CXXForRangeStmtClass: |
| 2424 | 2487 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXForRangeStmtClass"); |
| 2425 | | return nullptr; |
| 2488 | return ErrorUnexpected; |
| 2426 | 2489 | case Stmt::CXXTryStmtClass: |
| 2427 | 2490 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXTryStmtClass"); |
| 2428 | | return nullptr; |
| 2491 | return ErrorUnexpected; |
| 2429 | 2492 | case Stmt::CapturedStmtClass: |
| 2430 | 2493 | emit_warning(c, stmt->getLocStart(), "TODO handle C CapturedStmtClass"); |
| 2431 | | return nullptr; |
| 2494 | return ErrorUnexpected; |
| 2432 | 2495 | case Stmt::CoreturnStmtClass: |
| 2433 | 2496 | emit_warning(c, stmt->getLocStart(), "TODO handle C CoreturnStmtClass"); |
| 2434 | | return nullptr; |
| 2497 | return ErrorUnexpected; |
| 2435 | 2498 | case Stmt::CoroutineBodyStmtClass: |
| 2436 | 2499 | emit_warning(c, stmt->getLocStart(), "TODO handle C CoroutineBodyStmtClass"); |
| 2437 | | return nullptr; |
| 2500 | return ErrorUnexpected; |
| 2438 | 2501 | case Stmt::BinaryConditionalOperatorClass: |
| 2439 | 2502 | emit_warning(c, stmt->getLocStart(), "TODO handle C BinaryConditionalOperatorClass"); |
| 2440 | | return nullptr; |
| 2503 | return ErrorUnexpected; |
| 2441 | 2504 | case Stmt::AddrLabelExprClass: |
| 2442 | 2505 | emit_warning(c, stmt->getLocStart(), "TODO handle C AddrLabelExprClass"); |
| 2443 | | return nullptr; |
| 2506 | return ErrorUnexpected; |
| 2444 | 2507 | case Stmt::ArrayInitIndexExprClass: |
| 2445 | 2508 | emit_warning(c, stmt->getLocStart(), "TODO handle C ArrayInitIndexExprClass"); |
| 2446 | | return nullptr; |
| 2509 | return ErrorUnexpected; |
| 2447 | 2510 | case Stmt::ArrayInitLoopExprClass: |
| 2448 | 2511 | emit_warning(c, stmt->getLocStart(), "TODO handle C ArrayInitLoopExprClass"); |
| 2449 | | return nullptr; |
| 2512 | return ErrorUnexpected; |
| 2450 | 2513 | case Stmt::ArrayTypeTraitExprClass: |
| 2451 | 2514 | emit_warning(c, stmt->getLocStart(), "TODO handle C ArrayTypeTraitExprClass"); |
| 2452 | | return nullptr; |
| 2515 | return ErrorUnexpected; |
| 2453 | 2516 | case Stmt::AsTypeExprClass: |
| 2454 | 2517 | emit_warning(c, stmt->getLocStart(), "TODO handle C AsTypeExprClass"); |
| 2455 | | return nullptr; |
| 2518 | return ErrorUnexpected; |
| 2456 | 2519 | case Stmt::AtomicExprClass: |
| 2457 | 2520 | emit_warning(c, stmt->getLocStart(), "TODO handle C AtomicExprClass"); |
| 2458 | | return nullptr; |
| 2521 | return ErrorUnexpected; |
| 2459 | 2522 | case Stmt::BlockExprClass: |
| 2460 | 2523 | emit_warning(c, stmt->getLocStart(), "TODO handle C BlockExprClass"); |
| 2461 | | return nullptr; |
| 2524 | return ErrorUnexpected; |
| 2462 | 2525 | case Stmt::CXXBindTemporaryExprClass: |
| 2463 | 2526 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXBindTemporaryExprClass"); |
| 2464 | | return nullptr; |
| 2527 | return ErrorUnexpected; |
| 2465 | 2528 | case Stmt::CXXBoolLiteralExprClass: |
| 2466 | 2529 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXBoolLiteralExprClass"); |
| 2467 | | return nullptr; |
| 2530 | return ErrorUnexpected; |
| 2468 | 2531 | case Stmt::CXXConstructExprClass: |
| 2469 | 2532 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXConstructExprClass"); |
| 2470 | | return nullptr; |
| 2533 | return ErrorUnexpected; |
| 2471 | 2534 | case Stmt::CXXTemporaryObjectExprClass: |
| 2472 | 2535 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXTemporaryObjectExprClass"); |
| 2473 | | return nullptr; |
| 2536 | return ErrorUnexpected; |
| 2474 | 2537 | case Stmt::CXXDefaultArgExprClass: |
| 2475 | 2538 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXDefaultArgExprClass"); |
| 2476 | | return nullptr; |
| 2539 | return ErrorUnexpected; |
| 2477 | 2540 | case Stmt::CXXDefaultInitExprClass: |
| 2478 | 2541 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXDefaultInitExprClass"); |
| 2479 | | return nullptr; |
| 2542 | return ErrorUnexpected; |
| 2480 | 2543 | case Stmt::CXXDeleteExprClass: |
| 2481 | 2544 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXDeleteExprClass"); |
| 2482 | | return nullptr; |
| 2545 | return ErrorUnexpected; |
| 2483 | 2546 | case Stmt::CXXDependentScopeMemberExprClass: |
| 2484 | 2547 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXDependentScopeMemberExprClass"); |
| 2485 | | return nullptr; |
| 2548 | return ErrorUnexpected; |
| 2486 | 2549 | case Stmt::CXXFoldExprClass: |
| 2487 | 2550 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXFoldExprClass"); |
| 2488 | | return nullptr; |
| 2551 | return ErrorUnexpected; |
| 2489 | 2552 | case Stmt::CXXInheritedCtorInitExprClass: |
| 2490 | 2553 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXInheritedCtorInitExprClass"); |
| 2491 | | return nullptr; |
| 2554 | return ErrorUnexpected; |
| 2492 | 2555 | case Stmt::CXXNewExprClass: |
| 2493 | 2556 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXNewExprClass"); |
| 2494 | | return nullptr; |
| 2557 | return ErrorUnexpected; |
| 2495 | 2558 | case Stmt::CXXNoexceptExprClass: |
| 2496 | 2559 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXNoexceptExprClass"); |
| 2497 | | return nullptr; |
| 2560 | return ErrorUnexpected; |
| 2498 | 2561 | case Stmt::CXXNullPtrLiteralExprClass: |
| 2499 | 2562 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXNullPtrLiteralExprClass"); |
| 2500 | | return nullptr; |
| 2563 | return ErrorUnexpected; |
| 2501 | 2564 | case Stmt::CXXPseudoDestructorExprClass: |
| 2502 | 2565 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXPseudoDestructorExprClass"); |
| 2503 | | return nullptr; |
| 2566 | return ErrorUnexpected; |
| 2504 | 2567 | case Stmt::CXXScalarValueInitExprClass: |
| 2505 | 2568 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXScalarValueInitExprClass"); |
| 2506 | | return nullptr; |
| 2569 | return ErrorUnexpected; |
| 2507 | 2570 | case Stmt::CXXStdInitializerListExprClass: |
| 2508 | 2571 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXStdInitializerListExprClass"); |
| 2509 | | return nullptr; |
| 2572 | return ErrorUnexpected; |
| 2510 | 2573 | case Stmt::CXXThisExprClass: |
| 2511 | 2574 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXThisExprClass"); |
| 2512 | | return nullptr; |
| 2575 | return ErrorUnexpected; |
| 2513 | 2576 | case Stmt::CXXThrowExprClass: |
| 2514 | 2577 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXThrowExprClass"); |
| 2515 | | return nullptr; |
| 2578 | return ErrorUnexpected; |
| 2516 | 2579 | case Stmt::CXXTypeidExprClass: |
| 2517 | 2580 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXTypeidExprClass"); |
| 2518 | | return nullptr; |
| 2581 | return ErrorUnexpected; |
| 2519 | 2582 | case Stmt::CXXUnresolvedConstructExprClass: |
| 2520 | 2583 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXUnresolvedConstructExprClass"); |
| 2521 | | return nullptr; |
| 2584 | return ErrorUnexpected; |
| 2522 | 2585 | case Stmt::CXXUuidofExprClass: |
| 2523 | 2586 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXUuidofExprClass"); |
| 2524 | | return nullptr; |
| 2587 | return ErrorUnexpected; |
| 2525 | 2588 | case Stmt::CUDAKernelCallExprClass: |
| 2526 | 2589 | emit_warning(c, stmt->getLocStart(), "TODO handle C CUDAKernelCallExprClass"); |
| 2527 | | return nullptr; |
| 2590 | return ErrorUnexpected; |
| 2528 | 2591 | case Stmt::CXXMemberCallExprClass: |
| 2529 | | (void)result_used; |
| 2530 | 2592 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXMemberCallExprClass"); |
| 2531 | | return nullptr; |
| 2593 | return ErrorUnexpected; |
| 2532 | 2594 | case Stmt::CXXOperatorCallExprClass: |
| 2533 | 2595 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXOperatorCallExprClass"); |
| 2534 | | return nullptr; |
| 2596 | return ErrorUnexpected; |
| 2535 | 2597 | case Stmt::UserDefinedLiteralClass: |
| 2536 | 2598 | emit_warning(c, stmt->getLocStart(), "TODO handle C UserDefinedLiteralClass"); |
| 2537 | | return nullptr; |
| 2599 | return ErrorUnexpected; |
| 2538 | 2600 | case Stmt::CXXFunctionalCastExprClass: |
| 2539 | 2601 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXFunctionalCastExprClass"); |
| 2540 | | return nullptr; |
| 2602 | return ErrorUnexpected; |
| 2541 | 2603 | case Stmt::CXXConstCastExprClass: |
| 2542 | 2604 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXConstCastExprClass"); |
| 2543 | | return nullptr; |
| 2605 | return ErrorUnexpected; |
| 2544 | 2606 | case Stmt::CXXDynamicCastExprClass: |
| 2545 | 2607 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXDynamicCastExprClass"); |
| 2546 | | return nullptr; |
| 2608 | return ErrorUnexpected; |
| 2547 | 2609 | case Stmt::CXXReinterpretCastExprClass: |
| 2548 | 2610 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXReinterpretCastExprClass"); |
| 2549 | | return nullptr; |
| 2611 | return ErrorUnexpected; |
| 2550 | 2612 | case Stmt::CXXStaticCastExprClass: |
| 2551 | 2613 | emit_warning(c, stmt->getLocStart(), "TODO handle C CXXStaticCastExprClass"); |
| 2552 | | return nullptr; |
| 2614 | return ErrorUnexpected; |
| 2553 | 2615 | case Stmt::ObjCBridgedCastExprClass: |
| 2554 | 2616 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCBridgedCastExprClass"); |
| 2555 | | return nullptr; |
| 2617 | return ErrorUnexpected; |
| 2556 | 2618 | case Stmt::CharacterLiteralClass: |
| 2557 | 2619 | emit_warning(c, stmt->getLocStart(), "TODO handle C CharacterLiteralClass"); |
| 2558 | | return nullptr; |
| 2620 | return ErrorUnexpected; |
| 2559 | 2621 | case Stmt::ChooseExprClass: |
| 2560 | 2622 | emit_warning(c, stmt->getLocStart(), "TODO handle C ChooseExprClass"); |
| 2561 | | return nullptr; |
| 2623 | return ErrorUnexpected; |
| 2562 | 2624 | case Stmt::CompoundLiteralExprClass: |
| 2563 | 2625 | emit_warning(c, stmt->getLocStart(), "TODO handle C CompoundLiteralExprClass"); |
| 2564 | | return nullptr; |
| 2626 | return ErrorUnexpected; |
| 2565 | 2627 | case Stmt::ConvertVectorExprClass: |
| 2566 | 2628 | emit_warning(c, stmt->getLocStart(), "TODO handle C ConvertVectorExprClass"); |
| 2567 | | return nullptr; |
| 2629 | return ErrorUnexpected; |
| 2568 | 2630 | case Stmt::CoawaitExprClass: |
| 2569 | 2631 | emit_warning(c, stmt->getLocStart(), "TODO handle C CoawaitExprClass"); |
| 2570 | | return nullptr; |
| 2632 | return ErrorUnexpected; |
| 2571 | 2633 | case Stmt::CoyieldExprClass: |
| 2572 | 2634 | emit_warning(c, stmt->getLocStart(), "TODO handle C CoyieldExprClass"); |
| 2573 | | return nullptr; |
| 2635 | return ErrorUnexpected; |
| 2574 | 2636 | case Stmt::DependentCoawaitExprClass: |
| 2575 | 2637 | emit_warning(c, stmt->getLocStart(), "TODO handle C DependentCoawaitExprClass"); |
| 2576 | | return nullptr; |
| 2638 | return ErrorUnexpected; |
| 2577 | 2639 | case Stmt::DependentScopeDeclRefExprClass: |
| 2578 | 2640 | emit_warning(c, stmt->getLocStart(), "TODO handle C DependentScopeDeclRefExprClass"); |
| 2579 | | return nullptr; |
| 2641 | return ErrorUnexpected; |
| 2580 | 2642 | case Stmt::DesignatedInitExprClass: |
| 2581 | 2643 | emit_warning(c, stmt->getLocStart(), "TODO handle C DesignatedInitExprClass"); |
| 2582 | | return nullptr; |
| 2644 | return ErrorUnexpected; |
| 2583 | 2645 | case Stmt::DesignatedInitUpdateExprClass: |
| 2584 | 2646 | emit_warning(c, stmt->getLocStart(), "TODO handle C DesignatedInitUpdateExprClass"); |
| 2585 | | return nullptr; |
| 2647 | return ErrorUnexpected; |
| 2586 | 2648 | case Stmt::ExprWithCleanupsClass: |
| 2587 | 2649 | emit_warning(c, stmt->getLocStart(), "TODO handle C ExprWithCleanupsClass"); |
| 2588 | | return nullptr; |
| 2650 | return ErrorUnexpected; |
| 2589 | 2651 | case Stmt::ExpressionTraitExprClass: |
| 2590 | 2652 | emit_warning(c, stmt->getLocStart(), "TODO handle C ExpressionTraitExprClass"); |
| 2591 | | return nullptr; |
| 2653 | return ErrorUnexpected; |
| 2592 | 2654 | case Stmt::ExtVectorElementExprClass: |
| 2593 | 2655 | emit_warning(c, stmt->getLocStart(), "TODO handle C ExtVectorElementExprClass"); |
| 2594 | | return nullptr; |
| 2656 | return ErrorUnexpected; |
| 2595 | 2657 | case Stmt::FloatingLiteralClass: |
| 2596 | 2658 | emit_warning(c, stmt->getLocStart(), "TODO handle C FloatingLiteralClass"); |
| 2597 | | return nullptr; |
| 2659 | return ErrorUnexpected; |
| 2598 | 2660 | case Stmt::FunctionParmPackExprClass: |
| 2599 | 2661 | emit_warning(c, stmt->getLocStart(), "TODO handle C FunctionParmPackExprClass"); |
| 2600 | | return nullptr; |
| 2662 | return ErrorUnexpected; |
| 2601 | 2663 | case Stmt::GNUNullExprClass: |
| 2602 | 2664 | emit_warning(c, stmt->getLocStart(), "TODO handle C GNUNullExprClass"); |
| 2603 | | return nullptr; |
| 2665 | return ErrorUnexpected; |
| 2604 | 2666 | case Stmt::GenericSelectionExprClass: |
| 2605 | 2667 | emit_warning(c, stmt->getLocStart(), "TODO handle C GenericSelectionExprClass"); |
| 2606 | | return nullptr; |
| 2668 | return ErrorUnexpected; |
| 2607 | 2669 | case Stmt::ImaginaryLiteralClass: |
| 2608 | 2670 | emit_warning(c, stmt->getLocStart(), "TODO handle C ImaginaryLiteralClass"); |
| 2609 | | return nullptr; |
| 2671 | return ErrorUnexpected; |
| 2610 | 2672 | case Stmt::ImplicitValueInitExprClass: |
| 2611 | 2673 | emit_warning(c, stmt->getLocStart(), "TODO handle C ImplicitValueInitExprClass"); |
| 2612 | | return nullptr; |
| 2674 | return ErrorUnexpected; |
| 2613 | 2675 | case Stmt::InitListExprClass: |
| 2614 | 2676 | emit_warning(c, stmt->getLocStart(), "TODO handle C InitListExprClass"); |
| 2615 | | return nullptr; |
| 2677 | return ErrorUnexpected; |
| 2616 | 2678 | case Stmt::LambdaExprClass: |
| 2617 | 2679 | emit_warning(c, stmt->getLocStart(), "TODO handle C LambdaExprClass"); |
| 2618 | | return nullptr; |
| 2680 | return ErrorUnexpected; |
| 2619 | 2681 | case Stmt::MSPropertyRefExprClass: |
| 2620 | 2682 | emit_warning(c, stmt->getLocStart(), "TODO handle C MSPropertyRefExprClass"); |
| 2621 | | return nullptr; |
| 2683 | return ErrorUnexpected; |
| 2622 | 2684 | case Stmt::MSPropertySubscriptExprClass: |
| 2623 | 2685 | emit_warning(c, stmt->getLocStart(), "TODO handle C MSPropertySubscriptExprClass"); |
| 2624 | | return nullptr; |
| 2686 | return ErrorUnexpected; |
| 2625 | 2687 | case Stmt::MaterializeTemporaryExprClass: |
| 2626 | 2688 | emit_warning(c, stmt->getLocStart(), "TODO handle C MaterializeTemporaryExprClass"); |
| 2627 | | return nullptr; |
| 2689 | return ErrorUnexpected; |
| 2628 | 2690 | case Stmt::NoInitExprClass: |
| 2629 | 2691 | emit_warning(c, stmt->getLocStart(), "TODO handle C NoInitExprClass"); |
| 2630 | | return nullptr; |
| 2692 | return ErrorUnexpected; |
| 2631 | 2693 | case Stmt::OMPArraySectionExprClass: |
| 2632 | 2694 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPArraySectionExprClass"); |
| 2633 | | return nullptr; |
| 2695 | return ErrorUnexpected; |
| 2634 | 2696 | case Stmt::ObjCArrayLiteralClass: |
| 2635 | 2697 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCArrayLiteralClass"); |
| 2636 | | return nullptr; |
| 2698 | return ErrorUnexpected; |
| 2637 | 2699 | case Stmt::ObjCAvailabilityCheckExprClass: |
| 2638 | 2700 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCAvailabilityCheckExprClass"); |
| 2639 | | return nullptr; |
| 2701 | return ErrorUnexpected; |
| 2640 | 2702 | case Stmt::ObjCBoolLiteralExprClass: |
| 2641 | 2703 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCBoolLiteralExprClass"); |
| 2642 | | return nullptr; |
| 2704 | return ErrorUnexpected; |
| 2643 | 2705 | case Stmt::ObjCBoxedExprClass: |
| 2644 | 2706 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCBoxedExprClass"); |
| 2645 | | return nullptr; |
| 2707 | return ErrorUnexpected; |
| 2646 | 2708 | case Stmt::ObjCDictionaryLiteralClass: |
| 2647 | 2709 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCDictionaryLiteralClass"); |
| 2648 | | return nullptr; |
| 2710 | return ErrorUnexpected; |
| 2649 | 2711 | case Stmt::ObjCEncodeExprClass: |
| 2650 | 2712 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCEncodeExprClass"); |
| 2651 | | return nullptr; |
| 2713 | return ErrorUnexpected; |
| 2652 | 2714 | case Stmt::ObjCIndirectCopyRestoreExprClass: |
| 2653 | 2715 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCIndirectCopyRestoreExprClass"); |
| 2654 | | return nullptr; |
| 2716 | return ErrorUnexpected; |
| 2655 | 2717 | case Stmt::ObjCIsaExprClass: |
| 2656 | 2718 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCIsaExprClass"); |
| 2657 | | return nullptr; |
| 2719 | return ErrorUnexpected; |
| 2658 | 2720 | case Stmt::ObjCIvarRefExprClass: |
| 2659 | 2721 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCIvarRefExprClass"); |
| 2660 | | return nullptr; |
| 2722 | return ErrorUnexpected; |
| 2661 | 2723 | case Stmt::ObjCMessageExprClass: |
| 2662 | 2724 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCMessageExprClass"); |
| 2663 | | return nullptr; |
| 2725 | return ErrorUnexpected; |
| 2664 | 2726 | case Stmt::ObjCPropertyRefExprClass: |
| 2665 | 2727 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCPropertyRefExprClass"); |
| 2666 | | return nullptr; |
| 2728 | return ErrorUnexpected; |
| 2667 | 2729 | case Stmt::ObjCProtocolExprClass: |
| 2668 | 2730 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCProtocolExprClass"); |
| 2669 | | return nullptr; |
| 2731 | return ErrorUnexpected; |
| 2670 | 2732 | case Stmt::ObjCSelectorExprClass: |
| 2671 | 2733 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCSelectorExprClass"); |
| 2672 | | return nullptr; |
| 2734 | return ErrorUnexpected; |
| 2673 | 2735 | case Stmt::ObjCStringLiteralClass: |
| 2674 | 2736 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCStringLiteralClass"); |
| 2675 | | return nullptr; |
| 2737 | return ErrorUnexpected; |
| 2676 | 2738 | case Stmt::ObjCSubscriptRefExprClass: |
| 2677 | 2739 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCSubscriptRefExprClass"); |
| 2678 | | return nullptr; |
| 2740 | return ErrorUnexpected; |
| 2679 | 2741 | case Stmt::OffsetOfExprClass: |
| 2680 | 2742 | emit_warning(c, stmt->getLocStart(), "TODO handle C OffsetOfExprClass"); |
| 2681 | | return nullptr; |
| 2743 | return ErrorUnexpected; |
| 2682 | 2744 | case Stmt::OpaqueValueExprClass: |
| 2683 | 2745 | emit_warning(c, stmt->getLocStart(), "TODO handle C OpaqueValueExprClass"); |
| 2684 | | return nullptr; |
| 2746 | return ErrorUnexpected; |
| 2685 | 2747 | case Stmt::UnresolvedLookupExprClass: |
| 2686 | 2748 | emit_warning(c, stmt->getLocStart(), "TODO handle C UnresolvedLookupExprClass"); |
| 2687 | | return nullptr; |
| 2749 | return ErrorUnexpected; |
| 2688 | 2750 | case Stmt::UnresolvedMemberExprClass: |
| 2689 | 2751 | emit_warning(c, stmt->getLocStart(), "TODO handle C UnresolvedMemberExprClass"); |
| 2690 | | return nullptr; |
| 2752 | return ErrorUnexpected; |
| 2691 | 2753 | case Stmt::PackExpansionExprClass: |
| 2692 | 2754 | emit_warning(c, stmt->getLocStart(), "TODO handle C PackExpansionExprClass"); |
| 2693 | | return nullptr; |
| 2694 | | case Stmt::ParenExprClass: |
| 2695 | | return trans_expr(c, result_used, scope, ((const ParenExpr*)stmt)->getSubExpr(), lrvalue); |
| 2755 | return ErrorUnexpected; |
| 2696 | 2756 | case Stmt::ParenListExprClass: |
| 2697 | 2757 | emit_warning(c, stmt->getLocStart(), "TODO handle C ParenListExprClass"); |
| 2698 | | return nullptr; |
| 2758 | return ErrorUnexpected; |
| 2699 | 2759 | case Stmt::PredefinedExprClass: |
| 2700 | 2760 | emit_warning(c, stmt->getLocStart(), "TODO handle C PredefinedExprClass"); |
| 2701 | | return nullptr; |
| 2761 | return ErrorUnexpected; |
| 2702 | 2762 | case Stmt::PseudoObjectExprClass: |
| 2703 | 2763 | emit_warning(c, stmt->getLocStart(), "TODO handle C PseudoObjectExprClass"); |
| 2704 | | return nullptr; |
| 2764 | return ErrorUnexpected; |
| 2705 | 2765 | case Stmt::ShuffleVectorExprClass: |
| 2706 | 2766 | emit_warning(c, stmt->getLocStart(), "TODO handle C ShuffleVectorExprClass"); |
| 2707 | | return nullptr; |
| 2767 | return ErrorUnexpected; |
| 2708 | 2768 | case Stmt::SizeOfPackExprClass: |
| 2709 | 2769 | emit_warning(c, stmt->getLocStart(), "TODO handle C SizeOfPackExprClass"); |
| 2710 | | return nullptr; |
| 2770 | return ErrorUnexpected; |
| 2711 | 2771 | case Stmt::StmtExprClass: |
| 2712 | 2772 | emit_warning(c, stmt->getLocStart(), "TODO handle C StmtExprClass"); |
| 2713 | | return nullptr; |
| 2773 | return ErrorUnexpected; |
| 2714 | 2774 | case Stmt::SubstNonTypeTemplateParmExprClass: |
| 2715 | 2775 | emit_warning(c, stmt->getLocStart(), "TODO handle C SubstNonTypeTemplateParmExprClass"); |
| 2716 | | return nullptr; |
| 2776 | return ErrorUnexpected; |
| 2717 | 2777 | case Stmt::SubstNonTypeTemplateParmPackExprClass: |
| 2718 | 2778 | emit_warning(c, stmt->getLocStart(), "TODO handle C SubstNonTypeTemplateParmPackExprClass"); |
| 2719 | | return nullptr; |
| 2779 | return ErrorUnexpected; |
| 2720 | 2780 | case Stmt::TypeTraitExprClass: |
| 2721 | 2781 | emit_warning(c, stmt->getLocStart(), "TODO handle C TypeTraitExprClass"); |
| 2722 | | return nullptr; |
| 2782 | return ErrorUnexpected; |
| 2723 | 2783 | case Stmt::TypoExprClass: |
| 2724 | 2784 | emit_warning(c, stmt->getLocStart(), "TODO handle C TypoExprClass"); |
| 2725 | | return nullptr; |
| 2785 | return ErrorUnexpected; |
| 2726 | 2786 | case Stmt::VAArgExprClass: |
| 2727 | 2787 | emit_warning(c, stmt->getLocStart(), "TODO handle C VAArgExprClass"); |
| 2728 | | return nullptr; |
| 2788 | return ErrorUnexpected; |
| 2729 | 2789 | case Stmt::GotoStmtClass: |
| 2730 | 2790 | emit_warning(c, stmt->getLocStart(), "TODO handle C GotoStmtClass"); |
| 2731 | | return nullptr; |
| 2791 | return ErrorUnexpected; |
| 2732 | 2792 | case Stmt::IndirectGotoStmtClass: |
| 2733 | 2793 | emit_warning(c, stmt->getLocStart(), "TODO handle C IndirectGotoStmtClass"); |
| 2734 | | return nullptr; |
| 2794 | return ErrorUnexpected; |
| 2735 | 2795 | case Stmt::LabelStmtClass: |
| 2736 | 2796 | emit_warning(c, stmt->getLocStart(), "TODO handle C LabelStmtClass"); |
| 2737 | | return nullptr; |
| 2797 | return ErrorUnexpected; |
| 2738 | 2798 | case Stmt::MSDependentExistsStmtClass: |
| 2739 | 2799 | emit_warning(c, stmt->getLocStart(), "TODO handle C MSDependentExistsStmtClass"); |
| 2740 | | return nullptr; |
| 2800 | return ErrorUnexpected; |
| 2741 | 2801 | case Stmt::OMPAtomicDirectiveClass: |
| 2742 | 2802 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPAtomicDirectiveClass"); |
| 2743 | | return nullptr; |
| 2803 | return ErrorUnexpected; |
| 2744 | 2804 | case Stmt::OMPBarrierDirectiveClass: |
| 2745 | 2805 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPBarrierDirectiveClass"); |
| 2746 | | return nullptr; |
| 2806 | return ErrorUnexpected; |
| 2747 | 2807 | case Stmt::OMPCancelDirectiveClass: |
| 2748 | 2808 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPCancelDirectiveClass"); |
| 2749 | | return nullptr; |
| 2809 | return ErrorUnexpected; |
| 2750 | 2810 | case Stmt::OMPCancellationPointDirectiveClass: |
| 2751 | 2811 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPCancellationPointDirectiveClass"); |
| 2752 | | return nullptr; |
| 2812 | return ErrorUnexpected; |
| 2753 | 2813 | case Stmt::OMPCriticalDirectiveClass: |
| 2754 | 2814 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPCriticalDirectiveClass"); |
| 2755 | | return nullptr; |
| 2815 | return ErrorUnexpected; |
| 2756 | 2816 | case Stmt::OMPFlushDirectiveClass: |
| 2757 | 2817 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPFlushDirectiveClass"); |
| 2758 | | return nullptr; |
| 2818 | return ErrorUnexpected; |
| 2759 | 2819 | case Stmt::OMPDistributeDirectiveClass: |
| 2760 | 2820 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPDistributeDirectiveClass"); |
| 2761 | | return nullptr; |
| 2821 | return ErrorUnexpected; |
| 2762 | 2822 | case Stmt::OMPDistributeParallelForDirectiveClass: |
| 2763 | 2823 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPDistributeParallelForDirectiveClass"); |
| 2764 | | return nullptr; |
| 2824 | return ErrorUnexpected; |
| 2765 | 2825 | case Stmt::OMPDistributeParallelForSimdDirectiveClass: |
| 2766 | 2826 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPDistributeParallelForSimdDirectiveClass"); |
| 2767 | | return nullptr; |
| 2827 | return ErrorUnexpected; |
| 2768 | 2828 | case Stmt::OMPDistributeSimdDirectiveClass: |
| 2769 | 2829 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPDistributeSimdDirectiveClass"); |
| 2770 | | return nullptr; |
| 2830 | return ErrorUnexpected; |
| 2771 | 2831 | case Stmt::OMPForDirectiveClass: |
| 2772 | 2832 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPForDirectiveClass"); |
| 2773 | | return nullptr; |
| 2833 | return ErrorUnexpected; |
| 2774 | 2834 | case Stmt::OMPForSimdDirectiveClass: |
| 2775 | 2835 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPForSimdDirectiveClass"); |
| 2776 | | return nullptr; |
| 2836 | return ErrorUnexpected; |
| 2777 | 2837 | case Stmt::OMPParallelForDirectiveClass: |
| 2778 | 2838 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPParallelForDirectiveClass"); |
| 2779 | | return nullptr; |
| 2839 | return ErrorUnexpected; |
| 2780 | 2840 | case Stmt::OMPParallelForSimdDirectiveClass: |
| 2781 | 2841 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPParallelForSimdDirectiveClass"); |
| 2782 | | return nullptr; |
| 2842 | return ErrorUnexpected; |
| 2783 | 2843 | case Stmt::OMPSimdDirectiveClass: |
| 2784 | 2844 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPSimdDirectiveClass"); |
| 2785 | | return nullptr; |
| 2845 | return ErrorUnexpected; |
| 2786 | 2846 | case Stmt::OMPTargetParallelForSimdDirectiveClass: |
| 2787 | 2847 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetParallelForSimdDirectiveClass"); |
| 2788 | | return nullptr; |
| 2848 | return ErrorUnexpected; |
| 2789 | 2849 | case Stmt::OMPTargetSimdDirectiveClass: |
| 2790 | 2850 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetSimdDirectiveClass"); |
| 2791 | | return nullptr; |
| 2851 | return ErrorUnexpected; |
| 2792 | 2852 | case Stmt::OMPTargetTeamsDistributeDirectiveClass: |
| 2793 | 2853 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetTeamsDistributeDirectiveClass"); |
| 2794 | | return nullptr; |
| 2854 | return ErrorUnexpected; |
| 2795 | 2855 | case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass: |
| 2796 | 2856 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetTeamsDistributeParallelForDirectiveClass"); |
| 2797 | | return nullptr; |
| 2857 | return ErrorUnexpected; |
| 2798 | 2858 | case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass: |
| 2799 | 2859 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetTeamsDistributeParallelForSimdDirectiveClass"); |
| 2800 | | return nullptr; |
| 2860 | return ErrorUnexpected; |
| 2801 | 2861 | case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass: |
| 2802 | 2862 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetTeamsDistributeSimdDirectiveClass"); |
| 2803 | | return nullptr; |
| 2863 | return ErrorUnexpected; |
| 2804 | 2864 | case Stmt::OMPTaskLoopDirectiveClass: |
| 2805 | 2865 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTaskLoopDirectiveClass"); |
| 2806 | | return nullptr; |
| 2866 | return ErrorUnexpected; |
| 2807 | 2867 | case Stmt::OMPTaskLoopSimdDirectiveClass: |
| 2808 | 2868 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTaskLoopSimdDirectiveClass"); |
| 2809 | | return nullptr; |
| 2869 | return ErrorUnexpected; |
| 2810 | 2870 | case Stmt::OMPTeamsDistributeDirectiveClass: |
| 2811 | 2871 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTeamsDistributeDirectiveClass"); |
| 2812 | | return nullptr; |
| 2872 | return ErrorUnexpected; |
| 2813 | 2873 | case Stmt::OMPTeamsDistributeParallelForDirectiveClass: |
| 2814 | 2874 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTeamsDistributeParallelForDirectiveClass"); |
| 2815 | | return nullptr; |
| 2875 | return ErrorUnexpected; |
| 2816 | 2876 | case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass: |
| 2817 | 2877 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTeamsDistributeParallelForSimdDirectiveClass"); |
| 2818 | | return nullptr; |
| 2878 | return ErrorUnexpected; |
| 2819 | 2879 | case Stmt::OMPTeamsDistributeSimdDirectiveClass: |
| 2820 | 2880 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTeamsDistributeSimdDirectiveClass"); |
| 2821 | | return nullptr; |
| 2881 | return ErrorUnexpected; |
| 2822 | 2882 | case Stmt::OMPMasterDirectiveClass: |
| 2823 | 2883 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPMasterDirectiveClass"); |
| 2824 | | return nullptr; |
| 2884 | return ErrorUnexpected; |
| 2825 | 2885 | case Stmt::OMPOrderedDirectiveClass: |
| 2826 | 2886 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPOrderedDirectiveClass"); |
| 2827 | | return nullptr; |
| 2887 | return ErrorUnexpected; |
| 2828 | 2888 | case Stmt::OMPParallelDirectiveClass: |
| 2829 | 2889 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPParallelDirectiveClass"); |
| 2830 | | return nullptr; |
| 2890 | return ErrorUnexpected; |
| 2831 | 2891 | case Stmt::OMPParallelSectionsDirectiveClass: |
| 2832 | 2892 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPParallelSectionsDirectiveClass"); |
| 2833 | | return nullptr; |
| 2893 | return ErrorUnexpected; |
| 2834 | 2894 | case Stmt::OMPSectionDirectiveClass: |
| 2835 | 2895 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPSectionDirectiveClass"); |
| 2836 | | return nullptr; |
| 2896 | return ErrorUnexpected; |
| 2837 | 2897 | case Stmt::OMPSectionsDirectiveClass: |
| 2838 | 2898 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPSectionsDirectiveClass"); |
| 2839 | | return nullptr; |
| 2899 | return ErrorUnexpected; |
| 2840 | 2900 | case Stmt::OMPSingleDirectiveClass: |
| 2841 | 2901 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPSingleDirectiveClass"); |
| 2842 | | return nullptr; |
| 2902 | return ErrorUnexpected; |
| 2843 | 2903 | case Stmt::OMPTargetDataDirectiveClass: |
| 2844 | 2904 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetDataDirectiveClass"); |
| 2845 | | return nullptr; |
| 2905 | return ErrorUnexpected; |
| 2846 | 2906 | case Stmt::OMPTargetDirectiveClass: |
| 2847 | 2907 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetDirectiveClass"); |
| 2848 | | return nullptr; |
| 2908 | return ErrorUnexpected; |
| 2849 | 2909 | case Stmt::OMPTargetEnterDataDirectiveClass: |
| 2850 | 2910 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetEnterDataDirectiveClass"); |
| 2851 | | return nullptr; |
| 2911 | return ErrorUnexpected; |
| 2852 | 2912 | case Stmt::OMPTargetExitDataDirectiveClass: |
| 2853 | 2913 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetExitDataDirectiveClass"); |
| 2854 | | return nullptr; |
| 2914 | return ErrorUnexpected; |
| 2855 | 2915 | case Stmt::OMPTargetParallelDirectiveClass: |
| 2856 | 2916 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetParallelDirectiveClass"); |
| 2857 | | return nullptr; |
| 2917 | return ErrorUnexpected; |
| 2858 | 2918 | case Stmt::OMPTargetParallelForDirectiveClass: |
| 2859 | 2919 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetParallelForDirectiveClass"); |
| 2860 | | return nullptr; |
| 2920 | return ErrorUnexpected; |
| 2861 | 2921 | case Stmt::OMPTargetTeamsDirectiveClass: |
| 2862 | 2922 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetTeamsDirectiveClass"); |
| 2863 | | return nullptr; |
| 2923 | return ErrorUnexpected; |
| 2864 | 2924 | case Stmt::OMPTargetUpdateDirectiveClass: |
| 2865 | 2925 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTargetUpdateDirectiveClass"); |
| 2866 | | return nullptr; |
| 2926 | return ErrorUnexpected; |
| 2867 | 2927 | case Stmt::OMPTaskDirectiveClass: |
| 2868 | 2928 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTaskDirectiveClass"); |
| 2869 | | return nullptr; |
| 2929 | return ErrorUnexpected; |
| 2870 | 2930 | case Stmt::OMPTaskgroupDirectiveClass: |
| 2871 | 2931 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTaskgroupDirectiveClass"); |
| 2872 | | return nullptr; |
| 2932 | return ErrorUnexpected; |
| 2873 | 2933 | case Stmt::OMPTaskwaitDirectiveClass: |
| 2874 | 2934 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTaskwaitDirectiveClass"); |
| 2875 | | return nullptr; |
| 2935 | return ErrorUnexpected; |
| 2876 | 2936 | case Stmt::OMPTaskyieldDirectiveClass: |
| 2877 | 2937 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTaskyieldDirectiveClass"); |
| 2878 | | return nullptr; |
| 2938 | return ErrorUnexpected; |
| 2879 | 2939 | case Stmt::OMPTeamsDirectiveClass: |
| 2880 | 2940 | emit_warning(c, stmt->getLocStart(), "TODO handle C OMPTeamsDirectiveClass"); |
| 2881 | | return nullptr; |
| 2941 | return ErrorUnexpected; |
| 2882 | 2942 | case Stmt::ObjCAtCatchStmtClass: |
| 2883 | 2943 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCAtCatchStmtClass"); |
| 2884 | | return nullptr; |
| 2944 | return ErrorUnexpected; |
| 2885 | 2945 | case Stmt::ObjCAtFinallyStmtClass: |
| 2886 | 2946 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCAtFinallyStmtClass"); |
| 2887 | | return nullptr; |
| 2947 | return ErrorUnexpected; |
| 2888 | 2948 | case Stmt::ObjCAtSynchronizedStmtClass: |
| 2889 | 2949 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCAtSynchronizedStmtClass"); |
| 2890 | | return nullptr; |
| 2950 | return ErrorUnexpected; |
| 2891 | 2951 | case Stmt::ObjCAtThrowStmtClass: |
| 2892 | 2952 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCAtThrowStmtClass"); |
| 2893 | | return nullptr; |
| 2953 | return ErrorUnexpected; |
| 2894 | 2954 | case Stmt::ObjCAtTryStmtClass: |
| 2895 | 2955 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCAtTryStmtClass"); |
| 2896 | | return nullptr; |
| 2956 | return ErrorUnexpected; |
| 2897 | 2957 | case Stmt::ObjCAutoreleasePoolStmtClass: |
| 2898 | 2958 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCAutoreleasePoolStmtClass"); |
| 2899 | | return nullptr; |
| 2959 | return ErrorUnexpected; |
| 2900 | 2960 | case Stmt::ObjCForCollectionStmtClass: |
| 2901 | 2961 | emit_warning(c, stmt->getLocStart(), "TODO handle C ObjCForCollectionStmtClass"); |
| 2902 | | return nullptr; |
| 2962 | return ErrorUnexpected; |
| 2903 | 2963 | case Stmt::SEHExceptStmtClass: |
| 2904 | 2964 | emit_warning(c, stmt->getLocStart(), "TODO handle C SEHExceptStmtClass"); |
| 2905 | | return nullptr; |
| 2965 | return ErrorUnexpected; |
| 2906 | 2966 | case Stmt::SEHFinallyStmtClass: |
| 2907 | 2967 | emit_warning(c, stmt->getLocStart(), "TODO handle C SEHFinallyStmtClass"); |
| 2908 | | return nullptr; |
| 2968 | return ErrorUnexpected; |
| 2909 | 2969 | case Stmt::SEHLeaveStmtClass: |
| 2910 | 2970 | emit_warning(c, stmt->getLocStart(), "TODO handle C SEHLeaveStmtClass"); |
| 2911 | | return nullptr; |
| 2971 | return ErrorUnexpected; |
| 2912 | 2972 | case Stmt::SEHTryStmtClass: |
| 2913 | 2973 | emit_warning(c, stmt->getLocStart(), "TODO handle C SEHTryStmtClass"); |
| 2914 | | return nullptr; |
| 2974 | return ErrorUnexpected; |
| 2915 | 2975 | } |
| 2916 | 2976 | zig_unreachable(); |
| 2917 | 2977 | } |
| 2918 | 2978 | |
| 2979 | // Returns null if there was an error |
| 2980 | static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const Expr *expr, |
| 2981 | TransLRValue lrval) |
| 2982 | { |
| 2983 | AstNode *result_node; |
| 2984 | if (trans_stmt_extra(c, scope, expr, result_used, lrval, &result_node, nullptr, nullptr)) { |
| 2985 | return nullptr; |
| 2986 | } |
| 2987 | return result_node; |
| 2988 | } |
| 2989 | |
| 2990 | // Statements have no result and no concept of L or R value. |
| 2991 | // Returns child scope, or null if there was an error |
| 2992 | static TransScope *trans_stmt(Context *c, TransScope *scope, const Stmt *stmt, AstNode **out_node) { |
| 2993 | TransScope *child_scope; |
| 2994 | if (trans_stmt_extra(c, scope, stmt, ResultUsedNo, TransRValue, out_node, &child_scope, nullptr)) { |
| 2995 | return nullptr; |
| 2996 | } |
| 2997 | return child_scope; |
| 2998 | } |
| 2999 | |
| 2919 | 3000 | static void visit_fn_decl(Context *c, const FunctionDecl *fn_decl) { |
| 2920 | 3001 | Buf *fn_name = buf_create_from_str(decl_name(fn_decl)); |
| 2921 | 3002 | |
| ... | ... | @@ -2946,7 +3027,8 @@ static void visit_fn_decl(Context *c, const FunctionDecl *fn_decl) { |
| 2946 | 3027 | return; |
| 2947 | 3028 | } |
| 2948 | 3029 | |
| 2949 | | TransScope *scope = nullptr; |
| 3030 | TransScopeRoot *root_scope = trans_scope_root_create(c); |
| 3031 | TransScope *scope = &root_scope->base; |
| 2950 | 3032 | |
| 2951 | 3033 | for (size_t i = 0; i < proto_node->data.fn_proto.params.length; i += 1) { |
| 2952 | 3034 | AstNode *param_node = proto_node->data.fn_proto.params.at(i); |
| ... | ... | @@ -2978,16 +3060,17 @@ static void visit_fn_decl(Context *c, const FunctionDecl *fn_decl) { |
| 2978 | 3060 | // actual function definition with body |
| 2979 | 3061 | c->ptr_params.clear(); |
| 2980 | 3062 | Stmt *body = fn_decl->getBody(); |
| 2981 | | AstNode *actual_body_node = trans_stmt(c, ResultUsedNo, scope, body, TransRValue); |
| 2982 | | assert(actual_body_node != skip_add_to_block_node); |
| 2983 | | if (actual_body_node == nullptr) { |
| 3063 | AstNode *actual_body_node; |
| 3064 | TransScope *result_scope = trans_stmt(c, scope, body, &actual_body_node); |
| 3065 | if (result_scope == nullptr) { |
| 2984 | 3066 | emit_warning(c, fn_decl->getLocation(), "unable to translate function"); |
| 2985 | 3067 | return; |
| 2986 | 3068 | } |
| 3069 | assert(actual_body_node != nullptr); |
| 3070 | assert(actual_body_node->type == NodeTypeBlock); |
| 2987 | 3071 | |
| 2988 | 3072 | // it worked |
| 2989 | 3073 | |
| 2990 | | assert(actual_body_node->type == NodeTypeBlock); |
| 2991 | 3074 | AstNode *body_node_with_param_inits = trans_create_node(c, NodeTypeBlock); |
| 2992 | 3075 | |
| 2993 | 3076 | for (size_t i = 0; i < proto_node->data.fn_proto.params.length; i += 1) { |
| ... | ... | @@ -3447,6 +3530,12 @@ static Buf *get_unique_name(Context *c, Buf *name, TransScope *scope) { |
| 3447 | 3530 | return proposed_name; |
| 3448 | 3531 | } |
| 3449 | 3532 | |
| 3533 | static TransScopeRoot *trans_scope_root_create(Context *c) { |
| 3534 | TransScopeRoot *result = allocate<TransScopeRoot>(1); |
| 3535 | result->base.id = TransScopeIdRoot; |
| 3536 | return result; |
| 3537 | } |
| 3538 | |
| 3450 | 3539 | static TransScopeBlock *trans_scope_block_create(Context *c, TransScope *parent_scope) { |
| 3451 | 3540 | TransScopeBlock *result = allocate<TransScopeBlock>(1); |
| 3452 | 3541 | result->base.id = TransScopeIdBlock; |
| ... | ... | @@ -3472,6 +3561,16 @@ static TransScopeVar *trans_scope_var_create(Context *c, TransScope *parent_scop |
| 3472 | 3561 | // return result; |
| 3473 | 3562 | //} |
| 3474 | 3563 | |
| 3564 | static TransScopeBlock *trans_scope_block_find(TransScope *scope) { |
| 3565 | while (scope != nullptr) { |
| 3566 | if (scope->id == TransScopeIdBlock) { |
| 3567 | return (TransScopeBlock *)scope; |
| 3568 | } |
| 3569 | scope = scope->parent; |
| 3570 | } |
| 3571 | return nullptr; |
| 3572 | } |
| 3573 | |
| 3475 | 3574 | static void render_aliases(Context *c) { |
| 3476 | 3575 | for (size_t i = 0; i < c->aliases.length; i += 1) { |
| 3477 | 3576 | Alias *alias = &c->aliases.at(i); |