KDevelop API Documentation

gccoptionsplugin.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2000-2001 by Bernd Gehrmann                             *
00003  *   bernd@kdevelop.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00012 #include <qapplication.h>
00013 #include <qlabel.h>
00014 #include <qvbuttongroup.h>
00015 #include <qradiobutton.h>
00016 #include <qvaluelist.h>
00017 #include <qtabwidget.h>
00018 #include <qlayout.h>
00019 #include <qvbox.h>
00020 #include <kdialog.h>
00021 #include <klocale.h>
00022 #include <kgenericfactory.h>
00023 
00024 #include "flagboxes.h"
00025 #include "gccoptionsplugin.h"
00026 
00027 K_EXPORT_COMPONENT_FACTORY( libkdevgccoptions, KGenericFactory<GccOptionsPlugin>( "kdevgccoptions" ) )
00028 
00029 class GeneralTab : public QWidget
00030 {
00031 public:
00032     GeneralTab( GccOptionsPlugin::Type type, QWidget *parent=0, const char *name=0 );
00033     ~GeneralTab();
00034 
00035     void readFlags(QStringList *str);
00036     void writeFlags(QStringList *str);
00037 
00038 private:
00039     FlagCheckBoxController *controller;
00040 };
00041 
00042 
00043 class OptimizationTab : public QWidget
00044 {
00045 public:
00046     OptimizationTab( GccOptionsPlugin::Type type, QWidget *parent=0, const char *name=0 );
00047     ~OptimizationTab();
00048 
00049     void readFlags(QStringList *str);
00050     void writeFlags(QStringList *str);
00051 
00052 private:
00053     QRadioButton *Odefault, *O0, *O1, *O2;
00054     FlagListBox *optBox;
00055 };
00056 
00057 
00058 class G77Tab : public QWidget
00059 {
00060 public:
00061     G77Tab( QWidget *parent=0, const char *name=0 );
00062     ~G77Tab();
00063 
00064     void readFlags(QStringList *str);
00065     void writeFlags(QStringList *str);
00066 
00067 private:
00068     FlagCheckBoxController *controller;
00069 };
00070 
00071 
00072 class Warnings1Tab : public QWidget
00073 {
00074 public:
00075     Warnings1Tab( GccOptionsPlugin::Type type, QWidget *parent=0, const char *name=0 );
00076     ~Warnings1Tab();
00077 
00078     void readFlags(QStringList *str);
00079     void writeFlags(QStringList *str);
00080 
00081 private:
00082     FlagCheckBoxController *controller;
00083     FlagListBox *wallBox;
00084 };
00085 
00086 
00087 class Warnings2Tab : public QWidget
00088 {
00089 public:
00090     Warnings2Tab( GccOptionsPlugin::Type type, QWidget *parent=0, const char *name=0 );
00091     ~Warnings2Tab();
00092 
00093     void readFlags(QStringList *str);
00094     void writeFlags(QStringList *str);
00095 
00096 private:
00097     FlagListBox *wrestBox;
00098 };
00099 
00100 
00101 GeneralTab::GeneralTab(GccOptionsPlugin::Type type, QWidget *parent, const char *name)
00102     : QWidget(parent, name), controller(new FlagCheckBoxController)
00103 {
00104     QBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
00105     layout->setAutoAdd(true);
00106     layout->addSpacing(10);
00107 
00108     QVButtonGroup *output_group = new QVButtonGroup(i18n("Output"), this);
00109     new FlagCheckBox(output_group, controller,
00110                      "-fsyntax-only", i18n("Only check the code for syntax errors, do not produce object code"));
00111     new FlagCheckBox(output_group, controller,
00112                      "-pg",           i18n("Generate extra code to write profile information for gprof"));
00113     new FlagCheckBox(output_group, controller,
00114                      "-save-temps",   i18n("Do not delete intermediate output like assembler files"));
00115 
00116     QApplication::sendPostedEvents(this, QEvent::ChildInserted);
00117     layout->addSpacing(10);
00118 
00119     QVButtonGroup *codegen_group = new QVButtonGroup(i18n("Code Generation"), this);
00120     if (type != GccOptionsPlugin::GPP) {
00121     new FlagCheckBox(codegen_group, controller,
00122                      "-fexceptions",        i18n("Enable exception handling"),
00123                      "-fno-exception");
00124     } else {
00125     new FlagCheckBox(codegen_group, controller,
00126                      "-fno-exceptions",     i18n("Disable exception handling"),
00127                      "-fexception");
00128     }
00129     // The following two are somehow mutually exclusive, but the default is
00130     // platform-dependent, so if we would leave out one of them, we wouldn't
00131     // know how to set the remaining one.
00132     new FlagCheckBox(codegen_group, controller,
00133                      "-fpcc-struct-return", i18n("Return certain struct and union values in memory rather than in registers"));
00134     new FlagCheckBox(codegen_group, controller,
00135                      "-freg-struct-return", i18n("Return certain struct and union values in registers when possible"));
00136     new FlagCheckBox(codegen_group, controller,
00137                      "-short-enums",        i18n("For an enum, choose the smallest possible integer type"));
00138     new FlagCheckBox(codegen_group, controller,
00139                      "-short-double",       i18n("Make 'double' the same as 'float'"));
00140 
00141     QApplication::sendPostedEvents(this, QEvent::ChildInserted);
00142     layout->addStretch();
00143 }
00144 
00145 
00146 GeneralTab::~GeneralTab()
00147 {
00148     delete controller;
00149 }
00150 
00151 
00152 void GeneralTab::readFlags(QStringList *list)
00153 {
00154     controller->readFlags(list);
00155 }
00156 
00157 
00158 void GeneralTab::writeFlags(QStringList *list)
00159 {
00160     controller->writeFlags(list);
00161 }
00162 
00163 
00164 OptimizationTab::OptimizationTab(GccOptionsPlugin::Type type, QWidget *parent, const char *name)
00165     : QWidget(parent, name)
00166 {
00167     QBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
00168     layout->setAutoAdd(true);
00169 
00170     QVButtonGroup *group = new QVButtonGroup(i18n("Optimization Level"), this);
00171     Odefault = new QRadioButton(i18n("Default"), group);
00172     Odefault->setChecked(true);
00173     O0 = new QRadioButton(i18n("No optimization"), group);
00174     O1 = new QRadioButton(i18n("Level 1"), group);
00175     O2 = new QRadioButton(i18n("Level 2"), group);
00176 
00177     optBox = new FlagListBox(this);
00178 
00179     new FlagListItem(optBox,
00180                      "-ffloat-store",       i18n("<qt>Do not store floating point variables in registers</qt>"),
00181                      "-fno-float-store");
00182     new FlagListItem(optBox,
00183                      "-fno-defer-pop",      i18n("<qt>Pop the arguments to each function call directly "
00184                                                  "after the function returns</qt>"),
00185                      "-fdefer-pop");
00186     new FlagListItem(optBox,
00187                      "-fforce-mem",         i18n("<qt>Force memory operands to be copied into registers before "
00188                                                  "doing arithmetic on them</qt>"),
00189                      "-fno-force-mem");
00190     new FlagListItem(optBox,
00191                      "-fforce-addr",        i18n("<qt>Force memory address constants to be copied into registers before "
00192                                                  "doing arithmetic on them</qt>"),
00193                      "-fno-force-addr");
00194     new FlagListItem(optBox,
00195                      "-omit-frame-pointer", i18n("<qt>Do not keep the frame pointer in a register for functions that "
00196                                                  "do not need one</qt>"),
00197                      "-fno-omit-frame-pointer");
00198     new FlagListItem(optBox,
00199                      "-no-inline",          i18n("<qt>Ignore the <i>inline</i> keyword</qt>"),
00200                      "-finline");
00201 
00202     if (type == GccOptionsPlugin::GPP) {
00203     new FlagListItem(optBox,
00204                      "-fno-default-inline", i18n("<qt>Do not make member functions inline merely because they "
00205                                                  "are defined inside the class scope</qt>"),
00206                      "-fdefault-inline");
00207     }
00208 
00209     QApplication::sendPostedEvents(this, QEvent::ChildInserted);
00210     layout->addStretch();
00211 }
00212 
00213 
00214 OptimizationTab::~OptimizationTab()
00215 {}
00216 
00217 
00218 void OptimizationTab::readFlags(QStringList *list)
00219 {
00220     optBox->readFlags(list);
00221 
00222     QStringList::Iterator sli;
00223     sli = list->find("-O0");
00224     if (sli != list->end()) {
00225         O0->setChecked(true);
00226         list->remove(sli);
00227     }
00228     sli = list->find("-O1");
00229     if (sli != list->end()) {
00230         O1->setChecked(true);
00231         list->remove(sli);
00232     }
00233     sli = list->find("-O2");
00234     if (sli != list->end()) {
00235         O2->setChecked(true);
00236         list->remove(sli);
00237     }
00238 }
00239 
00240 
00241 void OptimizationTab::writeFlags(QStringList *list)
00242 {
00243     optBox->writeFlags(list);
00244 
00245     if (O0->isChecked())
00246         (*list) << "-O0";
00247     else if (O1->isChecked())
00248         (*list) << "-O1";
00249     else if (O2->isChecked())
00250         (*list) << "-O2";
00251 }
00252 
00253 
00254 G77Tab::G77Tab(QWidget *parent, const char *name)
00255     : QWidget(parent, name), controller(new FlagCheckBoxController)
00256 {
00257     QBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
00258     layout->setAutoAdd(true);
00259     layout->addSpacing(10);
00260 
00261     QVButtonGroup *dialect_group = new QVButtonGroup(i18n("Dialect"), this);
00262     new FlagCheckBox(dialect_group, controller,
00263                      "-ffree-form",       i18n("Interpret source code as Fortran 90 free form"),
00264                      "-fno-exception");
00265     new FlagCheckBox(dialect_group, controller,
00266                      "-ff90",             i18n("Allow certain Fortran 90 constructs"));
00267     new FlagCheckBox(dialect_group, controller,
00268                      "-fdollar-ok",       i18n("Allow '$' in symbol names"));
00269     new FlagCheckBox(dialect_group, controller,
00270                      "-fbackslash",       i18n("Allow '\' in character constants to escape special characters"),
00271                      "-fno-backslah");
00272     new FlagCheckBox(dialect_group, controller,
00273                      "-fonetrip",         i18n("DO loops are executed at least once"));
00274 
00275     QApplication::sendPostedEvents(this, QEvent::ChildInserted);
00276     layout->addSpacing(10);
00277 
00278     QVButtonGroup *codegen_group = new QVButtonGroup(i18n("Code Generation"), this);
00279     new FlagCheckBox(codegen_group, controller,
00280                      "-fno-automatic",    i18n("Treat local variables as if SAVE statement had been specified"));
00281     new FlagCheckBox(codegen_group, controller,
00282                      "-finit-local-zero", i18n("Init local variables to zero"));
00283     new FlagCheckBox(codegen_group, controller,
00284                      "-fbounds-check",    i18n("Generate run-time checks for array subscripts"));
00285 
00286     QApplication::sendPostedEvents(this, QEvent::ChildInserted);
00287     layout->addStretch();
00288 }
00289 
00290 
00291 G77Tab::~G77Tab()
00292 {
00293     delete controller;
00294 }
00295 
00296 
00297 void G77Tab::readFlags(QStringList *list)
00298 {
00299     controller->readFlags(list);
00300 }
00301 
00302 
00303 void G77Tab::writeFlags(QStringList *list)
00304 {
00305     controller->writeFlags(list);
00306 }
00307 
00308 
00309 Warnings1Tab::Warnings1Tab(GccOptionsPlugin::Type type, QWidget *parent, const char *name)
00310     : QWidget(parent, name), controller(new FlagCheckBoxController)
00311 {
00312     QBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
00313     layout->setAutoAdd(true);
00314 
00315     new FlagCheckBox(this, controller,
00316                      "-w",               i18n("Inhibit all warnings"));
00317     new FlagCheckBox(this, controller,
00318                      "-Wno-import",      i18n("Inhibit warnings about the use of #import"));
00319     new FlagCheckBox(this, controller,
00320                      "-Werror",      i18n("Make all warnings into errors"));
00321     new FlagCheckBox(this, controller,
00322                      "-pedantic",        i18n("Issue all warnings demanded by strict ANSI C or ISO C++"));
00323     new FlagCheckBox(this, controller,
00324                      "-pedantic-errors", i18n("Like -pedantic, but errors are produced instead of warnings"));
00325     new FlagCheckBox(this, controller,
00326                      "-Wall",            i18n("All warnings below, combined (-Wall):"));
00327 
00328     wallBox = new FlagListBox(this);
00329 
00330     new FlagListItem(wallBox,
00331                      "-Wchar-subscripts",    i18n("<qt>Warn if an array subscript has type <i>char</i></qt>"));
00332     new FlagListItem(wallBox,
00333                      "-Wcomment",            i18n("<qt>Warn when a comment-start sequence /* appears inside a comment</qt>"));
00334     new FlagListItem(wallBox,
00335                      "-Wformat",             i18n("<qt>Check calls to <i>printf()</i>, <i>scanf()</i> etc\n"
00336                                                   "to make sure that the arguments supplied have types appropriate\n"
00337                                                   "to the format string specified, and that the conversions specified\n"
00338                                                   "in the format string make sense</qt>"));
00339     new FlagListItem(wallBox,
00340                      "-Wimplicit-int",       i18n("<qt>Warn when a declaration does not specify a type</qt>"));
00341     new FlagListItem(wallBox,
00342                      "-Wimplicit-funtion-declaration",
00343                                              i18n("<qt>Issue a warning when a non-declared function is used</qt>"));
00344     new FlagListItem(wallBox,
00345                      "-Werror-implicit-function-declaration",
00346                                              i18n("<qt>Issue an error when a non-declared function is used</qt>"));
00347     new FlagListItem(wallBox,
00348                      "-Wmain",               i18n("<qt>Warn if the type of <i>main()</i> is suspicious</qt>"));
00349     new FlagListItem(wallBox,
00350                      "-Wmultichar",          i18n("<qt>Warn when multicharacter constants are encountered</qt>"));
00351     new FlagListItem(wallBox,
00352                      "-Wmissing-braces",     i18n("<qt>Warn if an aggregate or union initializer is not fully bracketed</qt>"));
00353     new FlagListItem(wallBox,
00354                      "-Wparentheses",        i18n("<qt>Warn when parentheses are omitted in certain contexts</qt>"));
00355     new FlagListItem(wallBox,
00356                      "-Wsequence-point",     i18n("<qt>Warn about code that may have undefined semantics because of\n"
00357                                                   "violations of sequence point rules in the C standard</qt>"));
00358     new FlagListItem(wallBox,
00359                      "-Wreturn-type",        i18n("<qt>Warn when a function without explicit return type is defined</qt>"));
00360     new FlagListItem(wallBox,
00361                      "-Wswitch",             i18n("<qt>Warn whenever a <i>switch</i> statement has an index of enumeral type\n"
00362                                                   "and lacks a <i>case</i> for one or more of the named codes of that enumeration</qt>"));
00363     new FlagListItem(wallBox,
00364                      "-Wtrigraphs",          i18n("<qt>Warn when trigraphs are encountered</qt>"));
00365     new FlagListItem(wallBox,
00366                      "-Wunused",             i18n("<qt>Warn when a variable is declared but not used</qt>"));
00367     new FlagListItem(wallBox,
00368                      "-Wuninitialized",      i18n("<qt>Warn when a variable is used without being initialized first</qt>"));
00369     new FlagListItem(wallBox,
00370                      "-Wunknown-pragmas",    i18n("<qt>Warn when an unknown #pragma statement is encountered</qt>"));
00371     if (type == GccOptionsPlugin::GPP) {
00372     new FlagListItem(wallBox,
00373                      "-Wreorder",            i18n("<qt>Warn when the order of member initializers is different from\n"
00374                                                   "the order in the class declaration</qt>"));
00375     }
00376 }
00377 
00378 
00379 Warnings1Tab::~Warnings1Tab()
00380 {
00381     delete controller;
00382 }
00383 
00384 
00385 void Warnings1Tab::readFlags(QStringList *list)
00386 {
00387     controller->readFlags(list);
00388     wallBox->readFlags(list);
00389 }
00390 
00391 
00392 void Warnings1Tab::writeFlags(QStringList *list)
00393 {
00394     controller->writeFlags(list);
00395     wallBox->writeFlags(list);
00396 }
00397 
00398 
00399 Warnings2Tab::Warnings2Tab(GccOptionsPlugin::Type type, QWidget *parent, const char *name)
00400     : QWidget(parent, name)
00401 {
00402     QBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
00403     layout->setAutoAdd(true);
00404 
00405     wrestBox = new FlagListBox(this);
00406 
00407     new FlagListItem(wrestBox,
00408                      "-W",                    i18n("<qt>Set options not included in -Wall which are very specific</qt>"));
00409     new FlagListItem(wrestBox,
00410                      "-Wfloat-equal",         i18n("<qt>Warn if floating point values are used in equality comparisons</qt>"));
00411     new FlagListItem(wrestBox,
00412                      "-Wundef",               i18n("<qt>Warn if an undefined identifier is evaluated in an <i>#if</i> directive</qt>"));
00413     new FlagListItem(wrestBox,
00414                      "-Wshadow",              i18n("<qt>Warn whenever a local variable shadows another local variable</qt>"));
00415     new FlagListItem(wrestBox,
00416                      "-Wpointer-arith",       i18n("<qt>Warn about anything that depends on the <i>sizeof</i> a\n"
00417                                                    "function type or of <i>void</i></qt>"));
00418     new FlagListItem(wrestBox,
00419                      "-Wcast-qual",           i18n("<qt>Warn whenever a pointer is cast so as to remove a type\n"
00420                                                    "qualifier from the target type</qt>"));
00421     new FlagListItem(wrestBox,
00422                      "-Wcast-align",          i18n("<qt>Warn whenever a pointer is cast such that the required\n"
00423                                                    "alignment of the target is increased</qt>"));
00424     new FlagListItem(wrestBox,
00425                      "-Wwrite-strings",       i18n("<qt>Warn when the address of a string constant is cast\n"
00426                                                    "into a non-const <i>char *</i> pointer</qt>"));
00427     new FlagListItem(wrestBox,
00428                      "-Wconversion",          i18n("<qt>Warn if a prototype causes a type conversion that is different\n"
00429                                                    "from what would happen to the same argument in the absence\n"
00430                                                    "of a prototype</qt>"));
00431     new FlagListItem(wrestBox,
00432                      "-Wsign-compare",        i18n("<qt>Warn when a comparison between signed and unsigned values\n"
00433                                                    "could produce an incorrect result when the signed value\n"
00434                                                    "is converted to unsigned</qt>"));
00435     new FlagListItem(wrestBox,
00436                      "-Wmissing-noreturn",    i18n("<qt>Warn about functions which might be candidates for attribute 'noreturn'</qt>"));
00437     new FlagListItem(wrestBox,
00438                      "-Waggregate-return",    i18n("<qt>Warn if any functions that return structures or unions are\n"
00439                                                    "defined or called</qt>"));
00440     new FlagListItem(wrestBox,
00441                      "-Wmissing-declarations",i18n("<qt>Warn if a global function is defined without a previous declaration</qt>"));
00442     new FlagListItem(wrestBox,
00443                      "-Wno-deprecated-declarations",
00444                                               i18n("<qt>Do not warn about uses of functions, variables, and types marked as\n"
00445                                                    "deprecated by using the 'deprecated' attribute</qt>"));
00446     new FlagListItem(wrestBox,
00447                      "-Wpacked",              i18n("<qt>Warn if a structure is given the packed attribute, but the packed\n"
00448                                                    "attribute has no effect on the layout or size of the structure</qt>"));
00449     new FlagListItem(wrestBox,
00450                      "-Wpadded",              i18n("<qt>Warn if padding is included in a structure, either to align an\n"
00451                                                    "element of the structure or to align the whole structure</qt>"));
00452     new FlagListItem(wrestBox,
00453                      "-Wredundant-decls",     i18n("<qt>Warn if anything is declared more than once in the same scope</qt>"));
00454     new FlagListItem(wrestBox,
00455                      "-Wunreachable-code",    i18n("<qt>Warn if the compiler detects that code will never be executed</qt>"));
00456     new FlagListItem(wrestBox,
00457                      "-Winline",              i18n("<qt>Warn if an <i>inline</i> function can not be inlined</qt>"));
00458     new FlagListItem(wrestBox,
00459                      "-Wlong-long",           i18n("<qt>Warn if the <i>long long</i> type is used</qt>"));
00460     new FlagListItem(wrestBox,
00461                      "-Wdisabled-optimization",i18n("<qt>Warn if a requested optimization pass is disabled</qt>"));
00462 
00463 
00464     if (type == GccOptionsPlugin::GCC) {
00465     new FlagListItem(wrestBox,
00466                      "-Wtraditional",         i18n("<qt>Warn about certain constructs that behave differently\n"
00467                                                    "in traditional and ANSI C</qt>"));
00468     new FlagListItem(wrestBox,
00469                      "-Wbad-function-cast",   i18n("<qt>Warn whenever a function call is cast to a non-matching type</qt>"));
00470     new FlagListItem(wrestBox,
00471                      "-Wstrict-prototypes",   i18n("<qt>Warn if a function is declared or defined without specifying\n"
00472                                                    "the argument types</qt>"));
00473     new FlagListItem(wrestBox,
00474                      "-Wmissing-prototypes",  i18n("<qt>Warn if a global function is defined without a previous prototype declaration</qt>"));
00475     new FlagListItem(wrestBox,
00476                      "-Wnested-externs",      i18n("<qt>Warn if an <i>extern</i> declaration is encountered within a function</qt>"));
00477     }
00478 
00479 
00480     if (type == GccOptionsPlugin::GPP) {
00481     new FlagListItem(wrestBox,
00482                      "-Woverloaded-virtual",  i18n("<qt>Warn when a function declaration hides virtual\n"
00483                                                    "functions from a base class</qt>"));
00484     new FlagListItem(wrestBox,
00485                      "-Wsynth",               i18n("<qt>Warn when g++'s synthesis behavior does\n"
00486                                                    "not match that of cfront</qt>"));
00487     new FlagListItem(wrestBox,
00488                      "-Wctor-dtor-privacy",   i18n("<qt>Warn when a class seems unusable, because all the constructors or\n"
00489                                                    "destructors in a class are private and the class has no friends or\n"
00490                                                    "public static member functions</qt>"));
00491     new FlagListItem(wrestBox,
00492                      "-Wnon-virtual-dtor",    i18n("<qt>Warn when a class declares a non-virtual destructor that should\n"
00493                                                    "probably be virtual, because it looks like the class will be used\n"
00494                                                    "polymorphically</qt>"));
00495     new FlagListItem(wrestBox,
00496                      "-Wsign-promo",          i18n("<qt>Warn when overload resolution chooses a promotion from unsigned or\n"
00497                                                    "enumeral type to a signed type over a conversion to an unsigned\n"
00498                                                    "type of the same size. Previous versions of G++ would try to\n"
00499                                                    "preserve unsignedness, but the standard mandates the current behavior</qt>"));
00500     new FlagListItem(wrestBox,
00501                      "-Wabi",                 i18n("<qt>Warn when G++ generates code that is probably not compatible with\n"
00502                                                    "the vendor-neutral C++ ABI</qt>"));
00503 /*    new FlagListItem(wrestBox,
00504                      "-Wreorder",             i18n("<qt>Warn when the order of member initializers given in the code does\n"
00505                                                    "not match the order in which they must be executed.</qt>"));*/
00506     new FlagListItem(wrestBox,
00507                      "-Weffc++",              i18n("<qt>Warn about violations of the following style guidelines from Scott\n"
00508                                                    "Meyers' 'Effective C++' book:\n"
00509                                                    "* Item 11:  Define a copy constructor and an assignment\n"
00510                                                    "  operator for classes with dynamically allocated memory;\n"
00511                                                    "* Item 12:  Prefer initialization to assignment in constructors;\n"
00512                                                    "* Item 14:  Make destructors virtual in base classes;\n"
00513                                                    "* Item 15:  Have `operator=' return a reference to `*this';\n"
00514                                                    "* Item 23:  Do not try to return a reference when you must\n"
00515                                                    "  return an object\n"
00516                                                    "\n"
00517                                                    "and about violations of the following style guidelines from Scott\n"
00518                                                    "Meyers' 'More Effective C++' book:\n"
00519                                                    "* Item 6:  Distinguish between prefix and postfix forms of\n"
00520                                                    "  increment and decrement operators;\n"
00521                                                    "* Item 7:  Never overload '&&', '||', or ','</qt>"));
00522     new FlagListItem(wrestBox,
00523                      "-Wno-deprecated",       i18n("<qt>Do not warn about usage of deprecated features</qt>"));
00524     new FlagListItem(wrestBox,
00525                      "-Wno-non-template-friend", i18n("<qt>Disable warnings when non-templatized friend functions are declared\n"
00526                                                    "within a template</qt>"));
00527     new FlagListItem(wrestBox,
00528                      "-Wold-style-cast",      i18n("<qt>Warn if an old-style (C-style) cast to a non-void type is used\n"
00529                                                    "within a C++ program</qt>"));
00530     new FlagListItem(wrestBox,
00531                      "-Wno-pmf-conversions",  i18n("<qt>Disable the diagnostic for converting a bound pointer to member\n"
00532                                                    "function to a plain pointer</qt>"));
00533     }
00534 }
00535 
00536 
00537 Warnings2Tab::~Warnings2Tab()
00538 {}
00539 
00540 
00541 void Warnings2Tab::readFlags(QStringList *list)
00542 {
00543     wrestBox->readFlags(list);
00544 }
00545 
00546 
00547 void Warnings2Tab::writeFlags(QStringList *list)
00548 {
00549     wrestBox->writeFlags(list);
00550 }
00551 
00552 
00553 // Last but not least... :-)
00554 GccOptionsDialog::GccOptionsDialog(GccOptionsPlugin::Type type, QWidget *parent, const char *name)
00555     : KDialogBase(Tabbed, GccOptionsPlugin::captionForType(type), Ok|Cancel, Ok, parent, name, true)
00556 {
00557     QVBox *vbox;
00558 
00559     vbox = addVBoxPage(i18n("General"));
00560     general = new GeneralTab(type, vbox, "general tab");
00561 
00562     vbox = addVBoxPage(i18n("Optimization"));
00563     optimization = new OptimizationTab(type, vbox, "optimization tab");
00564 
00565     if (type == GccOptionsPlugin::G77) {
00566         vbox = addVBoxPage(i18n("Fortran Specifics"));
00567         g77 = new G77Tab(vbox, "g77 tab");
00568     } else
00569         g77 = 0;
00570 
00571     vbox = addVBoxPage(i18n("Warnings (safe)"));
00572     warnings1 = new Warnings1Tab(type, vbox, "warnings1 tab");
00573 
00574     vbox = addVBoxPage(i18n("Warnings (unsafe)"));
00575     warnings2 = new Warnings2Tab(type, vbox, "warnings2 tab");
00576 }
00577 
00578 
00579 GccOptionsDialog::~GccOptionsDialog()
00580 {
00581 }
00582 
00583 
00584 void GccOptionsDialog::setFlags(const QString &flags)
00585 {
00586     QStringList flaglist = QStringList::split(" ", flags);
00587 
00588     // Hand them to 'general' at last, so it can make a line edit
00589     // with the unprocessed items
00590     if (g77)
00591         g77->readFlags(&flaglist);
00592     optimization->readFlags(&flaglist);
00593     warnings1->readFlags(&flaglist);
00594     warnings2->readFlags(&flaglist);
00595     general->readFlags(&flaglist);
00596     unrecognizedFlags = flaglist;
00597 }
00598 
00599 
00600 QString GccOptionsDialog::flags() const
00601 {
00602     QStringList flaglist;
00603 
00604     if (g77)
00605         g77->writeFlags(&flaglist);
00606     optimization->writeFlags(&flaglist);
00607     warnings1->writeFlags(&flaglist);
00608     warnings2->writeFlags(&flaglist);
00609     general->writeFlags(&flaglist);
00610 
00611     QString flags;
00612     QStringList::ConstIterator li;
00613     for (li = flaglist.begin(); li != flaglist.end(); ++li) {
00614         flags += (*li);
00615         flags += " ";
00616     }
00617 
00618     for (li = unrecognizedFlags.begin(); li != unrecognizedFlags.end(); ++li) {
00619         flags += (*li);
00620         flags += " ";
00621     }
00622 
00623     flags.truncate(flags.length()-1);
00624     return flags;
00625 }
00626 
00627 
00628 GccOptionsPlugin::GccOptionsPlugin(QObject *parent, const char *name, const QStringList &args)
00629     : KDevCompilerOptions(parent, name)
00630 {
00631     gcctype = Unknown;
00632 
00633     if ( args.count() == 0 )
00634     return;
00635 
00636     QString typeStr = args[ 0 ];
00637 
00638     if ( typeStr == "gcc" )
00639     gcctype = GccOptionsPlugin::GCC;
00640     else if ( typeStr == "g++" )
00641     gcctype = GccOptionsPlugin::GPP;
00642     else if ( typeStr == "g77" )
00643     gcctype = GccOptionsPlugin::G77;
00644 }
00645 
00646 
00647 GccOptionsPlugin::~GccOptionsPlugin()
00648 {}
00649 
00650 
00651 QString GccOptionsPlugin::captionForType(Type type)
00652 {
00653     switch (type)
00654         {
00655         case GCC: return i18n("GNU C Compiler Options");
00656         case GPP: return i18n("GNU C++ Compiler Options");
00657         case G77: return i18n("GNU Fortran 77 Compiler Options");
00658         default: return QString::null;
00659         }
00660 }
00661 
00662 
00663 QString GccOptionsPlugin::exec(QWidget *parent, const QString &flags)
00664 {
00665     if ( gcctype == Unknown ) return QString::null;
00666     GccOptionsDialog *dlg = new GccOptionsDialog(gcctype, parent, "gcc options dialog");
00667     QString newFlags = flags;
00668     dlg->setFlags(flags);
00669     if (dlg->exec() == QDialog::Accepted)
00670         newFlags = dlg->flags();
00671     delete dlg;
00672     return newFlags;
00673 }
00674 
00675 #include "gccoptionsplugin.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:28 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003