Open PathogenDavid opened 3 years ago
Wrote a test for this issue. Even though ConstOverloadRenameTransformation
is for method const-ness, I think it makes sense to someone who isn't a C++ spec nerd to expect it to handle this case as well.
[Fact]
[RelatedIssue("https://github.com/InfectedLibraries/Biohazrd/issues/154")]
public void ConstParameterOverloads()
{
TranslatedLibrary library = CreateLibrary
(@"
void Test(int*);
void Test(const int*);
"
);
Assert.Equal("Test", library.Declarations[0].Name);
Assert.Equal("Test", library.Declarations[1].Name);
Assert.Equal(2, library.Declarations.Count);
TranslatedLibrary transformed = new ConstOverloadRenameTransformation().Transform(library);
TranslatedFunction function0 = Assert.IsType<TranslatedFunction>(transformed.Declarations[0]);
TranslatedFunction function1 = Assert.IsType<TranslatedFunction>(transformed.Declarations[1]);
Assert.NotEqual(function0.Name, function1.Name);
}
We should also add a test case for methods (as with the example in the OP.)
We should also check for this awful and contrived but valid case:
class MyClass
{
public:
void Test(int*);
void Test(const int*);
void Test(int*) const;
void Test(const int*) const;
};
Separate from const overloads, C++ also allows methods which differ only by the constness of parameters for some reason:
Discovered here in OpenCV:
https://github.com/opencv/opencv/blob/e250bae356f2a69026c8b24524fc0d768e180dbf/modules/flann/include/opencv2/flann/any.h#L48-L49