data: token locations for constructor calls

* fixed token locations for implicit constructor calls.
* removed error line from test code.
This commit is contained in:
malte_langkabel
2015-01-19 15:08:16 +01:00
parent bdb38acbce
commit 6fc61a7e22
4 changed files with 66 additions and 26 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ int main()
int b = diff(a, 3);
int c = a * b;
int x = y;
// int x = y;
return 0;
}
+19 -19
View File
@@ -1,22 +1,4 @@
ConfigManager.cpp ERROR: value path/to/nowhere is not present in config.
Token.cpp ERROR: Location Id was not referenced by this Token.
Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class
Edge.cpp ERROR: Nodes are not plain copies.
Storage.cpp INFO: class: A <input.cc 1:7 1:7>
Storage.cpp INFO: method: A::A <input.cc 4:2 4:2>
Storage.cpp INFO: global usage: A::A -> A::count <input.cc 5:3 5:7>
Storage.cpp INFO: method: A::getCount <input.cc 8:13 8:20>
Storage.cpp INFO: global usage: A::getCount -> A::count <input.cc 10:10 10:14>
Storage.cpp INFO: method: A::process <input.cc 14:15 14:21>
Storage.cpp INFO: field: A::count <input.cc 17:13 17:17>
Storage.cpp INFO: class: B <input.cc 20:7 20:7>
Storage.cpp INFO: inheritance: B : A <input.cc 21:4 21:11>
Storage.cpp INFO: method: B::process <input.cc 24:15 24:21>
Storage.cpp INFO: type usage: B::process -> int <input.cc 26:3 26:5>
Storage.cpp INFO: function: main <input.cc 30:5 30:8>
Storage.cpp INFO: type usage: main -> B <input.cc 32:2 32:2>
Storage.cpp INFO: call: main -> B::B <input.cc 32:4 32:4>
Storage.cpp INFO: call: main -> A::getCount <input.cc 34:9 34:21>
Storage.cpp INFO: class: A <input.cc 1:7 1:7>
Storage.cpp INFO: method: A::A <input.cc 4:2 4:2>
Storage.cpp INFO: global usage: A::A -> A::count <input.cc 5:3 5:7>
@@ -49,6 +31,24 @@ SearchMatch.cpp INFO:
237 A::A
^^^^
Storage.cpp INFO: class: A <input.cc 1:7 1:7>
Storage.cpp INFO: method: A::A <input.cc 4:2 4:2>
Storage.cpp INFO: global usage: A::A -> A::count <input.cc 5:3 5:7>
Storage.cpp INFO: method: A::getCount <input.cc 8:13 8:20>
Storage.cpp INFO: global usage: A::getCount -> A::count <input.cc 10:10 10:14>
Storage.cpp INFO: method: A::process <input.cc 14:15 14:21>
Storage.cpp INFO: field: A::count <input.cc 17:13 17:17>
Storage.cpp INFO: class: B <input.cc 20:7 20:7>
Storage.cpp INFO: inheritance: B : A <input.cc 21:4 21:11>
Storage.cpp INFO: method: B::process <input.cc 24:15 24:21>
Storage.cpp INFO: type usage: B::process -> int <input.cc 26:3 26:5>
Storage.cpp INFO: function: main <input.cc 30:5 30:8>
Storage.cpp INFO: type usage: main -> B <input.cc 32:2 32:2>
Storage.cpp INFO: call: main -> B::B <input.cc 32:4 32:4>
Storage.cpp INFO: call: main -> A::getCount <input.cc 34:9 34:21>
Token.cpp ERROR: Location Id was not referenced by this Token.
Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class
Edge.cpp ERROR: Nodes are not plain copies.
Settings.cpp WARNING: File for Settings not found.
ConfigManager.cpp ERROR: value Bool is not present in config.
ConfigManager.cpp ERROR: value Int is not present in config.
@@ -64,6 +64,7 @@ ConfigManager.cpp ERROR: value Int is not present in config.
ConfigManager.cpp ERROR: value Float is not present in config.
ConfigManager.cpp ERROR: value String is not present in config.
ConfigManager.cpp ERROR: value NewBool is not present in config.
Graph.cpp ERROR: Can't remove member edge, without removing the child node.
Storage.cpp INFO: typedef: type -> int <file.cpp 1:1 1:1>
Storage.cpp INFO: class: Class <file.cpp 1:1 1:1>
Storage.cpp INFO: struct: Struct <file.cpp 1:1 1:1>
@@ -106,7 +107,6 @@ Storage.cpp INFO: global usage: isTrue -> global <file.cpp 1:7 1:7>
Storage.cpp INFO: function: isTrue <file.cpp 1:0 1:0>
Storage.cpp INFO: struct: Struct <file.cpp 1:0 1:0>
Storage.cpp INFO: type usage: isTrue -> Struct <file.cpp 1:0 1:0>
Graph.cpp ERROR: Can't remove member edge, without removing the child node.
TextAccess.cpp WARNING: Index 'firstLine' has to be lower or equal index 'lastLine', is 3 > 2
TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8
TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8
+41 -1
View File
@@ -1,5 +1,6 @@
#include "data/parser/cxx/ASTVisitor.h"
#include <clang/AST/ParentMap.h>
#include <clang/Lex/Lexer.h>
#include "data/parser/cxx/ASTBodyVisitor.h"
@@ -424,8 +425,47 @@ void ASTVisitor::VisitCallExprInDeclBody(clang::VarDecl* decl, clang::CallExpr*
void ASTVisitor::VisitCXXConstructExprInDeclBody(clang::FunctionDecl* decl, clang::CXXConstructExpr* expr)
{
std::string caller = decl->getNameAsString();
std::string callee = expr->getConstructor()->getNameAsString();
clang::SourceRange sourceRange = expr->getSourceRange();
// expr->getParenOrBraceRange(); // is null when no parens found (for implicit constructor calls; maybe we will have to use this in the future)
// expr->getNumArgs(); // and maybe we will need this one, too.. for same reasons as above.
const clang::SourceManager& sourceManager = m_context->getSourceManager();
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(sourceRange.getBegin(), false);
const clang::PresumedLoc& presumedEnd = sourceManager.getPresumedLoc(sourceRange.getEnd(), false);
int endLocationOffset = 0;
bool oneCharacterLocation = (
presumedBegin.getLine() == presumedEnd.getLine() && presumedBegin.getColumn() == presumedEnd.getColumn()
);
if (oneCharacterLocation) // get the exact range of name of declard variable
{
clang::ParentMap pm(decl->getBody());
clang::Stmt* parentStmt = pm.getParent(expr);
if (parentStmt && parentStmt->getStmtClass() == clang::Stmt::DeclStmtClass)
{
clang::DeclStmt* declStmt = clang::dyn_cast<clang::DeclStmt>(parentStmt);
clang::Decl* decl = declStmt->getSingleDecl();
if (clang::isa<clang::NamedDecl>(decl))
{
clang::NamedDecl* namedDecl = clang::dyn_cast<clang::NamedDecl>(decl);
int variableNameLength = namedDecl->getName().size();
endLocationOffset = variableNameLength - 1;
}
}
}
ParseLocation location(
presumedBegin.getFilename(),
presumedBegin.getLine(),
presumedBegin.getColumn(),
presumedEnd.getLine(),
presumedEnd.getColumn() + endLocationOffset
);
m_client->onCallParsed(
getParseLocation(expr->getSourceRange()),
location,
getParseFunction(decl),
getParseFunction(expr->getConstructor())
);
+5 -5
View File
@@ -710,7 +710,7 @@ public:
);
TS_ASSERT_EQUALS(client->calls.size(), 1);
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <8:6 8:6>");
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <8:6 8:8>");
}
void test_cxx_parser_finds_constructor_without_definition_call()
@@ -726,7 +726,7 @@ public:
);
TS_ASSERT_EQUALS(client->calls.size(), 1);
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <6:6 6:6>");
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <6:6 6:8>");
}
void test_cxx_parser_finds_constructor_call_of_field()
@@ -768,7 +768,7 @@ public:
TS_ASSERT_EQUALS(client->calls[0], "void App::App() -> void Item::Item(int) <9:5 9:11>");
}
void test_cxx_parser_finds_function_call_within_constructor_call_of_field_in_initialization_list()
void test_cxx_parser_finds_function_call_as_parameter_of_constructor_call_of_field_in_initialization_list()
{
std::shared_ptr<TestParserClient> client = parseCode(
"int one() { return 1; }\n"
@@ -808,7 +808,7 @@ public:
);
TS_ASSERT_EQUALS(client->calls.size(), 2);
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <9:6 9:6>");
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <9:6 9:8>");
TS_ASSERT_EQUALS(client->calls[1], "int main() -> void App::App(App const &) <10:6 10:14>");
}
@@ -856,7 +856,7 @@ public:
);
TS_ASSERT_EQUALS(client->calls.size(), 2);
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <10:6 10:6>");
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <10:6 10:8>");
TS_ASSERT_EQUALS(client->calls[1], "int main() -> void App::operator+(int) <11:2 11:8>");
}