Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] ASTRewrite: Comment handling


I'm currently working with the ASTRewrite for moving methods around and stumbled upon the following which I consider to be a bug. Given the following code snippet:

#ifndef A_H_
#define A_H_

class Base {
class Derived : Base {
    void myMethod(int a) {
        // comment in body
#endif /* A_H_ */

In this sample, the body comment of the method is considered to be a leading comment to the #endif node by the ASTRewrite for that TranslationUnit. This kind of makes sense because its the next node after the comment, but I feel the comment should rather be associated with the method it stands in. For now it takes some crazy extra effort to move all the comments of one method definition to a copy, because in the sample above, the comment is not associated with any node which belongs to the definition.

Back to the top