Baudouin Feildel via llvm-dev
2019-Nov-22 07:57 UTC
[llvm-dev] Clang-AST extract information out of invalid method declaration
Hello, In our company we are integrate a closed source library in our project. Everything is working when compiling with MSVC, but clang refuse to compile the source because of some non conformant method declaration. We would like to use clang LibTooling to automatically refactor this automatically across all versions of the vendor library. Here is a short example: class Foo { public: int compute(int a, int b, std::string& error_message = std::string()); }; We want to refactor such code into: class Foo { public: int compute(int a, int b, std::string& error_message); inline int compute(int a, int b) { std::string tmp; return compute(a, b, tmp); } }; When going through the clang ast I can successfully find the method with non-const reference parameter, but the default argument value is not present in the AST. I understand that this is because it is wrong code, but I wonder if there is a way to search all instances of this error in order to refactor them. Do you have any idea how we can refactor this automatically with clang tools ? Thanks for your help Best regards -- Baudouin Feildel