[cfe-dev] clang_isDynamicCall always returns true for CallExpr which call virtual methods

Borges, Matt via cfe-dev cfe-dev at lists.llvm.org
Fri May 8 08:36:55 PDT 2020


Hi,

I’m visiting the AST of this simple code with libclang:

class Base
{
    public:
        virtual void Print() {}
};

class Derived : public Base
{
    public:
        virtual void Print() {}
};

void func1( Base * b )
{
    b->Print();
}

void func2( Base b )
{
    b.Print();
}

void func3( Base & b )
{
    b.Print();
}

clang_isDynamicCall returns true for all three CallExpr cursors in the code.  I would have expected clang_isDynamicCall to return false for the call in func2 because the call is definitely to the Print method of Base.  Is this intended behaviour?  If yes, is there another way to determine whether the function call is going to be made polymorphically?

Thanks in advance,
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200508/0f1f74f2/attachment.html>


More information about the cfe-dev mailing list