Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build project
on: [push, pull_request, workflow_dispatch]

env:
BUILD_TYPE: Release
BUILD_TYPE: Debug

jobs:
build:
Expand Down
35 changes: 26 additions & 9 deletions plugins/cpp/test/src/cppparsertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <model/cppnamespace-odb.hxx>
#include <model/cpprecord.h>
#include <model/cpprecord-odb.hxx>
#include <model/cpptypedef.h>
#include <model/cpptypedef-odb.hxx>
#include <model/cppvariable.h>
#include <model/cppvariable-odb.hxx>
#include <model/file.h>
Expand All @@ -31,8 +33,11 @@ using QCppEnum = odb::query<model::CppEnum>;
using QCppEnumConstant = odb::query<model::CppEnumConstant>;
using QCppNamespace = odb::query<model::CppNamespace>;
using QCppRecord = odb::query<model::CppRecord>;
using QCppTypedef = odb::query<model::CppTypedef>;
using QCppVariable = odb::query<model::CppVariable>;
using QFile = odb::query<model::File>;
using RCppEnum = odb::result<model::CppEnum>;
using RCppFunction = odb::result<model::CppFunction>;
using RCppAstNode = odb::result<model::CppAstNode>;

class CppParserTest : public ::testing::Test
Expand Down Expand Up @@ -135,10 +140,12 @@ TEST_F(CppParserTest, FunctionDeclarationOnly)
TEST_F(CppParserTest, FunctionWithMultipleDeclarations)
{
_transaction([&, this]() {
model::CppFunction callee = _db->query_value<model::CppFunction>(
RCppFunction callees = _db->query<model::CppFunction>(
QCppFunction::name == "multiFunction");
EXPECT_FALSE(callees.empty());

RCppAstNode multiFuncAstNode = _db->query<model::CppAstNode>(
QCppAstNode::entityHash == callee.entityHash);
QCppAstNode::entityHash == callees.begin()->entityHash);

int numDecl = 0, numDef = 0, numOther = 0;
for (const model::CppAstNode& n : multiFuncAstNode)
Expand Down Expand Up @@ -296,10 +303,11 @@ TEST_F(CppParserTest, FunctionCall)
TEST_F(CppParserTest, Typedef)
{
_transaction([&, this]() {
model::CppEnum integer = _db->query_value<model::CppEnum>(
QCppEnum::name == "Integer");
model::CppTypedef integer = _db->query_value<model::CppTypedef>(
QCppTypedef::name == "Integer");
Comment on lines -299 to +307
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here Integer was not an enum, but a typedef in the parsed source code.

RCppAstNode astNodes = _db->query<model::CppAstNode>(
QCppAstNode::entityHash == integer.entityHash);
EXPECT_FALSE(astNodes.empty());

for (const model::CppAstNode& n : astNodes)
{
Expand Down Expand Up @@ -449,11 +457,15 @@ TEST_F(CppParserTest, Record)

TEST_F(CppParserTest, Enum)
{
_transaction([&, this] {
model::CppEnum enumeration = _db->query_value<model::CppEnum>(
_transaction([&, this]
{
RCppEnum enumerations = _db->query<model::CppEnum>(
QCppEnum::name == "Enumeration");
EXPECT_FALSE(enumerations.empty());

RCppAstNode astNodes = _db->query<model::CppAstNode>(
QCppAstNode::entityHash == enumeration.entityHash);
QCppAstNode::entityHash == enumerations.begin()->entityHash);
EXPECT_FALSE(astNodes.empty());

for (const model::CppAstNode& n : astNodes)
{
Expand Down Expand Up @@ -526,10 +538,15 @@ TEST_F(CppParserTest, Enum)
break;
}
}
});
}

model::CppFunction fieldFunction = _db->query_value<model::CppFunction>(
TEST_F(CppParserTest, Fields)
{
_transaction([&, this] {
model::CppVariable fieldFunction = _db->query_value<model::CppVariable>(
QCppFunction::name == "fieldFunction");
astNodes = _db->query<model::CppAstNode>(
RCppAstNode astNodes = _db->query<model::CppAstNode>(
Comment on lines -530 to +549
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the case where I was uncertain about my fix. This fieldFunction is a defined like this:

struct Derived : public MyClass
{
  MyClass fieldVariable;
  MyClass (*fieldFunction)(const MyClass&);
  
  // etc...
};

So it is a class member field, as a function pointer. It gets parsed into the CppVariable table, not the CppFunction, but that is correct that way, right @bruntib ? It is a variable, not a function semantically.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the above code, the function pointer is considered a fieldDecl.
image

QCppAstNode::entityHash == fieldFunction.entityHash);

for (const model::CppAstNode& n : astNodes)
Expand Down