================
@@ -266,9 +300,20 @@ void OverridePureVirtuals::collectMissingPureVirtuals() {
std::string generateOverrideString(const CXXMethodDecl *Method,
const LangOptions &LangOpts) {
- std::string MethodDecl;
- auto OS = llvm::raw_string_ostream(MethodDecl);
- Method->print(OS);
+ // Try to get the original source text first to preserve original formatting,
+ // comments, and attributes (e.g., [[nodiscard]]). This is important because
+ // printing the declaration via AST can lose formatting and some attributes.
----------------
timon-ul wrote:
I don't think I can quite follow this comment. Could you explain what
formatting and attributes are lost? Because your tests do not have any examples
for either. The only behaviour change I could observe was the initial issue of
`[[nodiscard]]` turning into `[[nodiscard("")]]` and comments inside of
function disappearing.
Formatting actually is still lost, but quite frankly I think this is fine
anyway (I don't even know if this would be desired behaviour in any way).
https://github.com/llvm/llvm-project/pull/184023
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits