Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352181

Summary: some refactoring functions remove macros and are confused by macros
Product: [Tools] CDT Reporter: Stefan Peters <peters>
Component: cdt-refactoringAssignee: Sergey Prigogin <eclipse.sprigogin>
Status: RESOLVED FIXED QA Contact: Sergey Prigogin <eclipse.sprigogin>
Severity: normal    
Priority: P3 CC: cdtdoug, yevshif
Version: 8.0   
Target Milestone: 8.1.0   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Stefan Peters CLA 2011-07-15 02:56:22 EDT
Build Identifier:  20110615-0604

when developing with Qt is necessary to use the moc ( http://doc.qt.nokia.com/latest/moc.html ) which uses some keywords to identify special sections and these keywords are removed. The keywords are just empty macros.

except from qobjectdef.h:

#   define slots
#   define signals protected

It looks like the macros are expanded on using the function (but for example the Q_OBJECT macro is untouched). Also the formatting is changed (this seems not to be happen if no macros are used)

This is not a Qt specific problem. I attached two examples. the second one does not produce valid code!

Reproducible: Always

Steps to Reproduce:
example 1 (Qt):

original class:

class GotoLineWidget : public QWidget {

    Q_OBJECT


public:

    GotoLineWidget(QWidget *parent = 0);
    ~GotoLineWidget();

    void myToogleTest() {
        qDebug() << "I am here";
    }

private slots:

    void on_close_clicked();
    void on_line_edit_textChanged(QString input_text);
    void on_line_edit_editingFinished();


signals:

    void gotoLine(int line_number);


private:

    Ui::GotoLineWidgetClass ui;
};

and after using "toogle function" on "myToogleTest":

class GotoLineWidget : public QWidget {

    Q_OBJECT


public:

    GotoLineWidget(QWidget *parent = 0);
    ~GotoLineWidget();

    void myToogleTest();
private:
    void on_close_clicked();
    void on_line_edit_textChanged(QString input_text);
    void on_line_edit_editingFinished();
protected:

    void gotoLine(int line_number);


private:

    Ui::GotoLineWidgetClass ui;
};

inline void GotoLineWidget::myToogleTest()
{
    qDebug() << "I am here";
}


example 2:

#ifdef __GNUC__
// gcc emulation mode
#define FINLINE            __attribute__((always_inline))
#define NOINLINE            __attribute__((noinline))
#else
// msvc emulation mode
#define FINLINE               __forceinline
#define NOINLINE            __declspec(noinline)
#endif

class System {


public:

    System();
    virtual ~System();

    static bool isWindows();
    static bool startHelpSystem();
    NOINLINE static QString getVersion();
    NOINLINE static QString getRelease();
};

and in the cpp:

QString System::getRelease() {
    return QString(_RTTUI_RELEASE_);
}

becomes after "toogle function":

class System {


public:

    System();
    virtual ~System();

    static bool isWindows();
    static bool startHelpSystem();
    static QString getVersion()
    {

    }static QString getRelease();

};
Comment 1 Sergey Prigogin CLA 2011-12-14 15:38:53 EST
Fixed together with bug 363244.