Clang import; fwrite FunctionDecl

This commit is contained in:
Daniel Marjamäki 2020-01-08 16:42:21 +01:00
parent c4c929a6a7
commit b8ae957365
2 changed files with 12 additions and 0 deletions

View File

@ -176,6 +176,8 @@ std::string clangastdump::AstNode::getSpelling() const
return mExtTokens[mExtTokens.size() - 3];
if (mExtTokens[mExtTokens.size() - 2].compare(0,4,"col:") == 0)
return "";
if ((mExtTokens[mExtTokens.size() - 2].compare(0,8,"<invalid") == 0))
return "";
return mExtTokens[mExtTokens.size() - 2];
}

View File

@ -35,6 +35,7 @@ private:
TEST_CASE(funcdecl1);
TEST_CASE(funcdecl2);
TEST_CASE(funcdecl3);
TEST_CASE(funcdecl4);
TEST_CASE(ifelse);
TEST_CASE(memberExpr);
TEST_CASE(recordDecl);
@ -124,6 +125,15 @@ private:
ASSERT_EQUALS("int __overflow ( FILE * , int ) ;", parse(clang));
}
void funcdecl4() {
const char clang[] = "|-FunctionDecl 0x272bb60 <line:658:15> col:15 implicit fwrite 'unsigned long (const void *, unsigned long, unsigned long, FILE *)' extern\n"
"| |-ParmVarDecl 0x272cc40 <<invalid sloc>> <invalid sloc> 'const void *'\n"
"| |-ParmVarDecl 0x272cca0 <<invalid sloc>> <invalid sloc> 'unsigned long'\n"
"| |-ParmVarDecl 0x272cd00 <<invalid sloc>> <invalid sloc> 'unsigned long'\n"
"| `-ParmVarDecl 0x272cd60 <<invalid sloc>> <invalid sloc> 'FILE *'";
ASSERT_EQUALS("unsigned long fwrite ( const void * , unsigned long , unsigned long , FILE * ) ;", parse(clang));
}
void ifelse() {
const char clang[] = "`-FunctionDecl 0x2637ba8 <1.c:1:1, line:4:1> line:1:5 foo 'int (int)'\n"
" |-ParmVarDecl 0x2637ae0 <col:9, col:13> col:13 used x 'int'\n"