From 6386f0e6332fd8534e3a128be0ee2715fd7360a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 21 Jan 2020 17:14:01 +0100 Subject: [PATCH] Clang import; CXXDeleteExpr --- lib/clangimport.cpp | 6 ++++++ test/testclangimport.cpp | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index cdc521f1a..e008d3314 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -44,6 +44,7 @@ static const std::string CXXBoolLiteralExpr = "CXXBoolLiteralExpr"; static const std::string CXXConstructorDecl = "CXXConstructorDecl"; static const std::string CXXConstructExpr = "CXXConstructExpr"; static const std::string CXXDefaultArgExpr = "CXXDefaultArgExpr"; +static const std::string CXXDeleteExpr = "CXXDeleteExpr"; static const std::string CXXForRangeStmt = "CXXForRangeStmt"; static const std::string CXXMemberCallExpr = "CXXMemberCallExpr"; static const std::string CXXMethodDecl = "CXXMethodDecl"; @@ -608,6 +609,11 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList) createTokensFunctionDecl(tokenList); return nullptr; } + if (nodeType == CXXDeleteExpr) { + addtoken(tokenList, "delete"); + children[0]->createTokens(tokenList); + return nullptr; + } if (nodeType == CXXForRangeStmt) { Token *forToken = addtoken(tokenList, "for"); Token *par1 = addtoken(tokenList, "("); diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index 793616d69..34c48b409 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -45,6 +45,7 @@ private: TEST_CASE(cxxConstructExpr1); TEST_CASE(cxxConstructExpr2); TEST_CASE(cxxConstructExpr3); + TEST_CASE(cxxDeleteExpr); TEST_CASE(cxxForRangeStmt); TEST_CASE(cxxMemberCall); TEST_CASE(cxxMethodDecl); @@ -311,6 +312,16 @@ private: ASSERT_EQUALS("void f ( ) { char * p@1 ; std::string s@2 ( p@1 ) ; }", parse(clang)); } + void cxxDeleteExpr() { + const char clang[] = "|-FunctionDecl 0x2e0e740 <1.cpp:1:1, col:28> col:6 f 'void (int *)'\n" + "| |-ParmVarDecl 0x2e0e680 col:13 used p 'int *'\n" + "| `-CompoundStmt 0x2e0ee70 \n" + "| `-CXXDeleteExpr 0x2e0ee48 'void' Function 0x2e0ebb8 'operator delete' 'void (void *) noexcept'\n" + "| `-ImplicitCastExpr 0x2e0e850 'int *' \n" + "| `-DeclRefExpr 0x2e0e828 'int *' lvalue ParmVar 0x2e0e680 'p' 'int *'"; + ASSERT_EQUALS("void f ( int * p@1 ) { delete p@1 ; }", parse(clang)); + } + void cxxForRangeStmt() { const char clang[] = "`-FunctionDecl 0x4280820 line:4:6 foo 'void ()'\n" " `-CompoundStmt 0x42810f0 \n"