Clang import: Fixed problems when handling CXXConstructorDecl
This commit is contained in:
parent
565e67d373
commit
87323b33bd
|
@ -320,7 +320,7 @@ std::string clangimport::AstNode::getSpelling() const
|
||||||
}
|
}
|
||||||
|
|
||||||
int typeIndex = mExtTokens.size() - 1;
|
int typeIndex = mExtTokens.size() - 1;
|
||||||
if (nodeType == FunctionDecl) {
|
if (nodeType == FunctionDecl || nodeType == CXXConstructorDecl) {
|
||||||
while (typeIndex >= 0 && mExtTokens[typeIndex][0] != '\'')
|
while (typeIndex >= 0 && mExtTokens[typeIndex][0] != '\'')
|
||||||
typeIndex--;
|
typeIndex--;
|
||||||
if (typeIndex <= 0)
|
if (typeIndex <= 0)
|
||||||
|
@ -1111,7 +1111,7 @@ Token * clangimport::AstNode::createTokensCall(TokenList *tokenList)
|
||||||
void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
|
void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
|
||||||
{
|
{
|
||||||
const bool prev = (std::find(mExtTokens.begin(), mExtTokens.end(), "prev") != mExtTokens.end());
|
const bool prev = (std::find(mExtTokens.begin(), mExtTokens.end(), "prev") != mExtTokens.end());
|
||||||
const bool hasBody = mFile == 0 && !children.empty() && children.back()->nodeType == CompoundStmt;
|
const bool hasBody = !children.empty() && children.back()->nodeType == CompoundStmt;
|
||||||
const bool isStatic = (std::find(mExtTokens.begin(), mExtTokens.end(), "static") != mExtTokens.end());
|
const bool isStatic = (std::find(mExtTokens.begin(), mExtTokens.end(), "static") != mExtTokens.end());
|
||||||
const bool isInline = (std::find(mExtTokens.begin(), mExtTokens.end(), "inline") != mExtTokens.end());
|
const bool isInline = (std::find(mExtTokens.begin(), mExtTokens.end(), "inline") != mExtTokens.end());
|
||||||
|
|
||||||
|
@ -1207,6 +1207,11 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
|
||||||
bodyStart->link(bodyEnd);
|
bodyStart->link(bodyEnd);
|
||||||
bodyEnd->link(bodyStart);
|
bodyEnd->link(bodyStart);
|
||||||
} else {
|
} else {
|
||||||
|
if (nodeType == CXXConstructorDecl && (std::find(mExtTokens.begin(), mExtTokens.end(), "default") != mExtTokens.end())) {
|
||||||
|
addtoken(tokenList, "=");
|
||||||
|
addtoken(tokenList, "default");
|
||||||
|
}
|
||||||
|
|
||||||
addtoken(tokenList, ";");
|
addtoken(tokenList, ";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,8 @@ private:
|
||||||
TEST_CASE(continueStmt);
|
TEST_CASE(continueStmt);
|
||||||
TEST_CASE(cstyleCastExpr);
|
TEST_CASE(cstyleCastExpr);
|
||||||
TEST_CASE(cxxBoolLiteralExpr);
|
TEST_CASE(cxxBoolLiteralExpr);
|
||||||
TEST_CASE(cxxConstructorDecl);
|
TEST_CASE(cxxConstructorDecl1);
|
||||||
|
TEST_CASE(cxxConstructorDecl2);
|
||||||
TEST_CASE(cxxConstructExpr1);
|
TEST_CASE(cxxConstructExpr1);
|
||||||
TEST_CASE(cxxConstructExpr2);
|
TEST_CASE(cxxConstructExpr2);
|
||||||
TEST_CASE(cxxConstructExpr3);
|
TEST_CASE(cxxConstructExpr3);
|
||||||
|
@ -250,7 +251,7 @@ private:
|
||||||
"| | `-ParmVarDecl 0x247c790 <col:25> col:25 'const C<int> &'\n"
|
"| | `-ParmVarDecl 0x247c790 <col:25> col:25 'const C<int> &'\n"
|
||||||
"| `-CXXConstructorDecl 0x247c828 <col:25> col:25 implicit constexpr C 'void (C<int> &&)' inline default trivial noexcept-unevaluated 0x247c828\n"
|
"| `-CXXConstructorDecl 0x247c828 <col:25> col:25 implicit constexpr C 'void (C<int> &&)' inline default trivial noexcept-unevaluated 0x247c828\n"
|
||||||
"| `-ParmVarDecl 0x247c960 <col:25> col:25 'C<int> &&'\n";
|
"| `-ParmVarDecl 0x247c960 <col:25> col:25 'C<int> &&'\n";
|
||||||
ASSERT_EQUALS("class C { int foo ( ) { return 0 ; } default ( ) { } noexcept-unevaluated ( const C<int> & ) ; noexcept-unevaluated ( C<int> && ) ; } ;", parse(clang));
|
ASSERT_EQUALS("class C { int foo ( ) { return 0 ; } C ( ) { } C ( const C<int> & ) = default ; C ( C<int> && ) = default ; } ;", parse(clang));
|
||||||
}
|
}
|
||||||
|
|
||||||
void conditionalExpr() {
|
void conditionalExpr() {
|
||||||
|
@ -297,7 +298,7 @@ private:
|
||||||
ASSERT_EQUALS("bool x@1 = true ;", parse(clang));
|
ASSERT_EQUALS("bool x@1 = true ;", parse(clang));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cxxConstructorDecl() {
|
void cxxConstructorDecl1() {
|
||||||
const char clang[] = "|-CXXConstructorDecl 0x428e890 <col:11, col:24> col:11 C 'void ()'\n"
|
const char clang[] = "|-CXXConstructorDecl 0x428e890 <col:11, col:24> col:11 C 'void ()'\n"
|
||||||
"| `-CompoundStmt 0x428ea58 <col:15, col:24>\n"
|
"| `-CompoundStmt 0x428ea58 <col:15, col:24>\n"
|
||||||
"| `-BinaryOperator 0x428ea30 <col:17, col:21> 'int' lvalue '='\n"
|
"| `-BinaryOperator 0x428ea30 <col:17, col:21> 'int' lvalue '='\n"
|
||||||
|
@ -308,6 +309,12 @@ private:
|
||||||
ASSERT_EQUALS("C ( ) { this . x@1 = 0 ; } int x@1", parse(clang));
|
ASSERT_EQUALS("C ( ) { this . x@1 = 0 ; } int x@1", parse(clang));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cxxConstructorDecl2() {
|
||||||
|
const char clang[] = "`-CXXConstructorDecl 0x1c208c0 <col:11> col:11 implicit constexpr basic_string 'void (std::basic_string<char> &&)' inline default trivial noexcept-unevaluated 0x1c208c0\n"
|
||||||
|
" `-ParmVarDecl 0x1c209f0 <col:11> col:11 'std::basic_string<char> &&'";
|
||||||
|
ASSERT_EQUALS("basic_string ( std :: basic_string<char> && ) = default ;", parse(clang));
|
||||||
|
}
|
||||||
|
|
||||||
void cxxConstructExpr1() {
|
void cxxConstructExpr1() {
|
||||||
const char clang[] = "`-FunctionDecl 0x2dd7940 <line:2:1, col:30> col:5 f 'Foo (Foo)'\n"
|
const char clang[] = "`-FunctionDecl 0x2dd7940 <line:2:1, col:30> col:5 f 'Foo (Foo)'\n"
|
||||||
" |-ParmVarDecl 0x2dd7880 <col:7, col:11> col:11 used foo 'Foo'\n"
|
" |-ParmVarDecl 0x2dd7880 <col:7, col:11> col:11 used foo 'Foo'\n"
|
||||||
|
|
Loading…
Reference in New Issue