cppalliance / mrdocs

MrDocs: A Clang/LLVM tool for building reference documentation from C++ code and javadoc comments.
https://mrdocs.com
Other
77 stars 17 forks source link

Ambiguity resolution for names should account for type decay #142

Closed sdkrystian closed 1 year ago

sdkrystian commented 1 year ago
void f(int x);

void f(const int x)
{
}

Both declarations of f refer to the same function. mrdox produces the following output:

<?xml version="1.0" encoding="UTF-8"?>
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
<namespace name="">
  <function name="f" id="ackjGh57CJQLwtO8PihiSPPKIBY=">
    <file path="input.cpp" line="1"/>
    <param name="x" type="int"/>
  </function>
  <function name="f" id="6i4Aiw+mGDmAJKzUMLtNaLS8qjs=">
    <file path="input.cpp" line="3" class="def"/>
    <param name="x" type="const int"/>
  </function>
</namespace>
</mrdox>

Although the parameter types as declared are different, the determination of whether two function declarations refer to the same function only considers the parameter types after decaying array & function to pointers and removing top-level cv-qualifiers ; see http://eel.is/c++draft/basic.scope.scope#4 & http://eel.is/c++draft/dcl.fct#5

vinniefalco commented 1 year ago

The parameters are extracted here:

https://github.com/cppalliance/mrdox/blob/d8ac598412ac774978bd83e776a33aeed93d0fa1/source/api/AST/Serializer.cpp#L270

I guess getTypeInfoForType could use a boolean to indicate whether or not it should apply the decay algorithm to its return value.