forked from qt-creator/qt-creator
C++: Tools: Compile with QT_NO_CAST_FROM_ASCII
Change-Id: I9de2c7fe51fea7844813cecb7c68f9a85a8e1e62 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -45,9 +45,9 @@ public:
|
|||||||
if (Utils::HostOsInfo::isLinuxHost()) {
|
if (Utils::HostOsInfo::isLinuxHost()) {
|
||||||
QString ldLibraryPath = value(QLatin1String("LD_LIBRARY_PATH"));
|
QString ldLibraryPath = value(QLatin1String("LD_LIBRARY_PATH"));
|
||||||
QDir lib(QCoreApplication::applicationDirPath());
|
QDir lib(QCoreApplication::applicationDirPath());
|
||||||
lib.cd("../lib");
|
lib.cd(QLatin1String("../lib"));
|
||||||
QString toReplace = lib.path();
|
QString toReplace = lib.path();
|
||||||
lib.cd("qtcreator");
|
lib.cd(QLatin1String("qtcreator"));
|
||||||
toReplace.append(QLatin1String(":"));
|
toReplace.append(QLatin1String(":"));
|
||||||
toReplace.append(lib.path());
|
toReplace.append(lib.path());
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class MkVisitor: protected SymbolVisitor
|
|||||||
if (interfaces.contains(b) || isMiscNode(b)) {
|
if (interfaces.contains(b) || isMiscNode(b)) {
|
||||||
QString className = oo(b->symbols().first()->name());
|
QString className = oo(b->symbols().first()->name());
|
||||||
|
|
||||||
if (className.endsWith("AST")) {
|
if (className.endsWith(QLatin1String("AST"))) {
|
||||||
className.chop(3);
|
className.chop(3);
|
||||||
|
|
||||||
QString funcName = className;
|
QString funcName = className;
|
||||||
@@ -141,13 +141,13 @@ public:
|
|||||||
Q_ASSERT(klass != 0);
|
Q_ASSERT(klass != 0);
|
||||||
|
|
||||||
QString className = oo(klass->name());
|
QString className = oo(klass->name());
|
||||||
if (className == "AST")
|
if (className == QLatin1String("AST"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QString baseClassName = className;
|
QString baseClassName = className;
|
||||||
baseClassName.chop(3);
|
baseClassName.chop(3);
|
||||||
|
|
||||||
QString retTy = false;
|
QString retTy;
|
||||||
QString funcName = getAcceptFunctionName(b, &retTy);
|
QString funcName = getAcceptFunctionName(b, &retTy);
|
||||||
|
|
||||||
std::cout
|
std::cout
|
||||||
@@ -222,13 +222,13 @@ public:
|
|||||||
Q_ASSERT(klass != 0);
|
Q_ASSERT(klass != 0);
|
||||||
|
|
||||||
QString className = oo(klass->name());
|
QString className = oo(klass->name());
|
||||||
if (className == "AST")
|
if (className == QLatin1String("AST"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QString baseClassName = className;
|
QString baseClassName = className;
|
||||||
baseClassName.chop(3);
|
baseClassName.chop(3);
|
||||||
|
|
||||||
QString current = "_current";
|
QString current = QLatin1String("_current");
|
||||||
current += baseClassName;
|
current += baseClassName;
|
||||||
|
|
||||||
std::cout << " " << qPrintable(baseClassName) << "Ty " << qPrintable(current) << ";" << std::endl;
|
std::cout << " " << qPrintable(baseClassName) << "Ty " << qPrintable(current) << ";" << std::endl;
|
||||||
@@ -255,7 +255,7 @@ public:
|
|||||||
Q_ASSERT(klass != 0);
|
Q_ASSERT(klass != 0);
|
||||||
|
|
||||||
QString className = oo(klass->name());
|
QString className = oo(klass->name());
|
||||||
if (className == "AST")
|
if (className == QLatin1String("AST"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QString baseClassName = className;
|
QString baseClassName = className;
|
||||||
@@ -264,7 +264,7 @@ public:
|
|||||||
QString retTy;
|
QString retTy;
|
||||||
QString funcName = getAcceptFunctionName(b, &retTy);
|
QString funcName = getAcceptFunctionName(b, &retTy);
|
||||||
|
|
||||||
QString current = "_current";
|
QString current = QLatin1String("_current");
|
||||||
current += baseClassName;
|
current += baseClassName;
|
||||||
|
|
||||||
std::cout << "Semantic::" << qPrintable(baseClassName) << "Ty Semantic::"
|
std::cout << "Semantic::" << qPrintable(baseClassName) << "Ty Semantic::"
|
||||||
@@ -322,10 +322,10 @@ public:
|
|||||||
if (PointerType *ptrTy = decl->type()->asPointerType()) {
|
if (PointerType *ptrTy = decl->type()->asPointerType()) {
|
||||||
if (NamedType *namedTy = ptrTy->elementType()->asNamedType()) {
|
if (NamedType *namedTy = ptrTy->elementType()->asNamedType()) {
|
||||||
const QString eltTyName = oo(namedTy->name());
|
const QString eltTyName = oo(namedTy->name());
|
||||||
if (eltTyName.endsWith("ListAST")) {
|
if (eltTyName.endsWith(QLatin1String("ListAST"))) {
|
||||||
QString name = eltTyName;
|
QString name = eltTyName;
|
||||||
name.chop(7);
|
name.chop(7);
|
||||||
name += "AST";
|
name += QLatin1String("AST");
|
||||||
|
|
||||||
Control *control = context.thisDocument()->control();
|
Control *control = context.thisDocument()->control();
|
||||||
const Name *n = control->identifier(name.toLatin1().constData());
|
const Name *n = control->identifier(name.toLatin1().constData());
|
||||||
@@ -352,7 +352,7 @@ public:
|
|||||||
if (ClassOrNamespace *ty = context.lookupType(namedTy->name(), klass)) {
|
if (ClassOrNamespace *ty = context.lookupType(namedTy->name(), klass)) {
|
||||||
QString className = oo(ty->symbols().first()->name());
|
QString className = oo(ty->symbols().first()->name());
|
||||||
QString baseClassName = className;
|
QString baseClassName = className;
|
||||||
if (baseClassName.endsWith("AST")) {
|
if (baseClassName.endsWith(QLatin1String("AST"))) {
|
||||||
baseClassName.chop(3);
|
baseClassName.chop(3);
|
||||||
|
|
||||||
QString retTy;
|
QString retTy;
|
||||||
@@ -394,7 +394,7 @@ protected:
|
|||||||
|
|
||||||
virtual bool visit(Class *klass) {
|
virtual bool visit(Class *klass) {
|
||||||
const QString className = oo(klass->name());
|
const QString className = oo(klass->name());
|
||||||
if (! className.endsWith("AST"))
|
if (! className.endsWith(QLatin1String("AST")))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ClassOrNamespace *b = context.lookupType(klass);
|
ClassOrNamespace *b = context.lookupType(klass);
|
||||||
@@ -429,7 +429,7 @@ void printUsage()
|
|||||||
std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName())
|
std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName())
|
||||||
<< " [-v] [path to AST.h]\n\n"
|
<< " [-v] [path to AST.h]\n\n"
|
||||||
<< "Print a visitor class based on AST.h to stdout.\n\n";
|
<< "Print a visitor class based on AST.h to stdout.\n\n";
|
||||||
const QString defaulPath = QFileInfo(PATH_AST_H).canonicalFilePath();
|
const QString defaulPath = QFileInfo(QLatin1String(PATH_AST_H)).canonicalFilePath();
|
||||||
std::cout << "Default path: " << qPrintable(defaulPath) << '.' << "\n";
|
std::cout << "Default path: " << qPrintable(defaulPath) << '.' << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,18 +442,19 @@ int main(int argc, char *argv[])
|
|||||||
bool optionVerbose = false;
|
bool optionVerbose = false;
|
||||||
|
|
||||||
// Process options & arguments
|
// Process options & arguments
|
||||||
if (args.contains("-v")) {
|
if (args.contains(QLatin1String("-v"))) {
|
||||||
optionVerbose = true;
|
optionVerbose = true;
|
||||||
args.removeOne("-v");
|
args.removeOne(QLatin1String("-v"));
|
||||||
}
|
}
|
||||||
const bool helpRequested = args.contains("-h") || args.contains("-help");
|
const bool helpRequested = args.contains(QLatin1String("-h"))
|
||||||
|
|| args.contains(QLatin1String("-help"));
|
||||||
if (helpRequested || args.count() >= 2) {
|
if (helpRequested || args.count() >= 2) {
|
||||||
printUsage();
|
printUsage();
|
||||||
return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE;
|
return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the preprocessor
|
// Run the preprocessor
|
||||||
QString fileName = PATH_AST_H;
|
QString fileName = QLatin1String(PATH_AST_H);
|
||||||
if (!args.isEmpty())
|
if (!args.isEmpty())
|
||||||
fileName = args.first();
|
fileName = args.first();
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ include(../../../qtcreator.pri)
|
|||||||
include(../../libs/cplusplus/cplusplus-lib.pri)
|
include(../../libs/cplusplus/cplusplus-lib.pri)
|
||||||
include(../../../src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri)
|
include(../../../src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri)
|
||||||
|
|
||||||
|
DEFINES *= QT_NO_CAST_FROM_ASCII
|
||||||
DEFINES += PATH_AST_H=\\\"$$PWD/../../libs/3rdparty/cplusplus/AST.h\\\"
|
DEFINES += PATH_AST_H=\\\"$$PWD/../../libs/3rdparty/cplusplus/AST.h\\\"
|
||||||
SOURCES += cplusplus-mkvisitor.cpp
|
SOURCES += cplusplus-mkvisitor.cpp
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ void executeCommand(const QString &command, const QStringList &arguments, const
|
|||||||
process.setStandardOutputFile(outputFile, QIODevice::Truncate);
|
process.setStandardOutputFile(outputFile, QIODevice::Truncate);
|
||||||
process.start(command, arguments);
|
process.start(command, arguments);
|
||||||
if (!process.waitForStarted()) {
|
if (!process.waitForStarted()) {
|
||||||
out << QString("Error: Process \"%1\" did not start within timeout: %2.")
|
out << QString::fromLatin1("Error: Process \"%1\" did not start within timeout: %2.")
|
||||||
.arg(fullCommand, process.errorString())
|
.arg(fullCommand, process.errorString())
|
||||||
<< endl;
|
<< endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@@ -73,14 +73,15 @@ void executeCommand(const QString &command, const QStringList &arguments, const
|
|||||||
if (!process.waitForFinished()) {
|
if (!process.waitForFinished()) {
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
out << process.readAll() << endl;
|
out << process.readAll() << endl;
|
||||||
out << QString("Error: Process \"%1\" did not finish within timeout.").arg(fullCommand)
|
out << QString::fromLatin1("Error: Process \"%1\" did not finish within timeout.")
|
||||||
|
.arg(fullCommand)
|
||||||
<< endl;
|
<< endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
const int exitCode = process.exitCode();
|
const int exitCode = process.exitCode();
|
||||||
if (exitCode != 0) {
|
if (exitCode != 0) {
|
||||||
out << process.readAllStandardError() << endl;
|
out << process.readAllStandardError() << endl;
|
||||||
out << QString("Error: Process \"%1\" finished with non zero exit value %2")
|
out << QString::fromLatin1("Error: Process \"%1\" finished with non zero exit value %2")
|
||||||
.arg(fullCommand, exitCode) << endl;
|
.arg(fullCommand, exitCode) << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -89,9 +90,9 @@ void executeCommand(const QString &command, const QStringList &arguments, const
|
|||||||
SystemPreprocessor::SystemPreprocessor(bool verbose)
|
SystemPreprocessor::SystemPreprocessor(bool verbose)
|
||||||
: m_verbose(verbose)
|
: m_verbose(verbose)
|
||||||
{
|
{
|
||||||
m_knownCompilers[portableExecutableName("gcc")]
|
m_knownCompilers[portableExecutableName(QLatin1String("gcc"))]
|
||||||
= QLatin1String("-DCPLUSPLUS_WITHOUT_QT -U__BLOCKS__ -xc++ -E -include");
|
= QLatin1String("-DCPLUSPLUS_WITHOUT_QT -U__BLOCKS__ -xc++ -E -include");
|
||||||
m_knownCompilers[portableExecutableName("cl")]
|
m_knownCompilers[portableExecutableName(QLatin1String("cl"))]
|
||||||
= QLatin1String("/DCPLUSPLUS_WITHOUT_QT /U__BLOCKS__ /TP /E /I . /FI");
|
= QLatin1String("/DCPLUSPLUS_WITHOUT_QT /U__BLOCKS__ /TP /E /I . /FI");
|
||||||
|
|
||||||
QMapIterator<QString, QString> i(m_knownCompilers);
|
QMapIterator<QString, QString> i(m_knownCompilers);
|
||||||
@@ -112,14 +113,17 @@ SystemPreprocessor::SystemPreprocessor(bool verbose)
|
|||||||
void SystemPreprocessor::check() const
|
void SystemPreprocessor::check() const
|
||||||
{
|
{
|
||||||
QTextStream out(stderr);
|
QTextStream out(stderr);
|
||||||
if (!QFile::exists(PATH_PREPROCESSOR_CONFIG)) {
|
if (!QFile::exists(QLatin1String(PATH_PREPROCESSOR_CONFIG))) {
|
||||||
out << QString("Error: File \"%1\" does not exist.").arg(PATH_PREPROCESSOR_CONFIG) << endl;
|
out << QString::fromLatin1("Error: File \"%1\" does not exist.")
|
||||||
|
.arg(QLatin1String(PATH_PREPROCESSOR_CONFIG))
|
||||||
|
<< endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (m_compiler.isEmpty()) {
|
if (m_compiler.isEmpty()) {
|
||||||
const QString triedCompilers
|
const QString triedCompilers
|
||||||
= QStringList(m_knownCompilers.keys()).join(QLatin1String(", "));
|
= QStringList(m_knownCompilers.keys()).join(QLatin1String(", "));
|
||||||
out << QString("Error: No compiler found. Tried %1.").arg(triedCompilers) << endl;
|
out << QString::fromLatin1("Error: No compiler found. Tried %1.").arg(triedCompilers)
|
||||||
|
<< endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,7 +133,7 @@ void SystemPreprocessor::preprocessFile(const QString &inputFile, const QString
|
|||||||
check();
|
check();
|
||||||
if (!QFile::exists(inputFile)) {
|
if (!QFile::exists(inputFile)) {
|
||||||
QTextStream out(stderr);
|
QTextStream out(stderr);
|
||||||
out << QString("Error: File \"%1\" does not exist.").arg(inputFile) << endl;
|
out << QString::fromLatin1("Error: File \"%1\" does not exist.").arg(inputFile) << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
const QStringList arguments = QStringList(m_compilerArguments)
|
const QStringList arguments = QStringList(m_compilerArguments)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
DEPENDPATH += $$PWD
|
DEPENDPATH += $$PWD
|
||||||
INCLUDEPATH += $$PWD $$PWD/../../libs/utils
|
INCLUDEPATH += $$PWD $$PWD/../../libs/utils
|
||||||
|
|
||||||
|
DEFINES *= QT_NO_CAST_FROM_ASCII
|
||||||
DEFINES += PATH_PREPROCESSOR_CONFIG=\\\"$$PWD/pp-configuration.inc\\\"
|
DEFINES += PATH_PREPROCESSOR_CONFIG=\\\"$$PWD/pp-configuration.inc\\\"
|
||||||
DEFINES += QTCREATOR_UTILS_STATIC_LIB
|
DEFINES += QTCREATOR_UTILS_STATIC_LIB
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ protected:
|
|||||||
|
|
||||||
const QString className = oo(klass->name());
|
const QString className = oo(klass->name());
|
||||||
|
|
||||||
if (className.endsWith("AST")) {
|
if (className.endsWith(QLatin1String("AST"))) {
|
||||||
if (className == QLatin1String("AST"))
|
if (className == QLatin1String("AST"))
|
||||||
_nodes.base = ast;
|
_nodes.base = ast;
|
||||||
else {
|
else {
|
||||||
@@ -1414,11 +1414,16 @@ QStringList generateAST_H(const Snapshot &snapshot, const QDir &cplusplusDir, co
|
|||||||
cursors[classAST] = removeCastMethods(classAST);
|
cursors[classAST] = removeCastMethods(classAST);
|
||||||
const QString className = oo(classAST->symbol->name());
|
const QString className = oo(classAST->symbol->name());
|
||||||
const QString methodName = QLatin1String("as") + className.mid(0, className.length() - 3);
|
const QString methodName = QLatin1String("as") + className.mid(0, className.length() - 3);
|
||||||
replacementCastMethods[classAST] = QString(" virtual %1 *%2() { return this; }\n").arg(className, methodName);
|
replacementCastMethods[classAST]
|
||||||
castMethods.append(QString(" virtual %1 *%2() { return 0; }\n").arg(className, methodName));
|
= QString::fromLatin1(" virtual %1 *%2() { return this; }\n")
|
||||||
|
.arg(className, methodName);
|
||||||
|
castMethods.append(
|
||||||
|
QString::fromLatin1(" virtual %1 *%2() { return 0; }\n")
|
||||||
|
.arg(className, methodName));
|
||||||
astDerivedClasses.append(className);
|
astDerivedClasses.append(className);
|
||||||
|
|
||||||
constructors[classAST] = removeConstructors(classAST, AST_h_document->translationUnit(), &document);
|
constructors[classAST] = removeConstructors(classAST, AST_h_document->translationUnit(),
|
||||||
|
&document);
|
||||||
replacementConstructors[classAST] = createConstructor(classAST);
|
replacementConstructors[classAST] = createConstructor(classAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1612,7 +1617,7 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir)
|
|||||||
|
|
||||||
const QString className = oo(klass->name());
|
const QString className = oo(klass->name());
|
||||||
|
|
||||||
if (! className.endsWith("AST"))
|
if (! className.endsWith(QLatin1String("AST")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const QString methodName = className.left(className.length() - 3);
|
const QString methodName = className.left(className.length() - 3);
|
||||||
@@ -1633,9 +1638,9 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
const QString tyName = oo(ptrTy->elementType());
|
const QString tyName = oo(ptrTy->elementType());
|
||||||
if (tyName.endsWith("ListAST"))
|
if (tyName.endsWith(QLatin1String("ListAST")))
|
||||||
listClasses.insert(tyName);
|
listClasses.insert(tyName);
|
||||||
if (tyName.endsWith("AST")) {
|
if (tyName.endsWith(QLatin1String("AST"))) {
|
||||||
if (! first)
|
if (! first)
|
||||||
out << ", ";
|
out << ", ";
|
||||||
|
|
||||||
@@ -1699,8 +1704,10 @@ void printUsage()
|
|||||||
<< "to AST.h and print the paths of the written files. Run this tool after\n"
|
<< "to AST.h and print the paths of the written files. Run this tool after\n"
|
||||||
<< "modifying AST.h."
|
<< "modifying AST.h."
|
||||||
<< "\n\n";
|
<< "\n\n";
|
||||||
const QString defaultPathCppFrontend = QFileInfo(PATH_CPP_FRONTEND).canonicalFilePath();
|
const QString defaultPathCppFrontend
|
||||||
const QString defaultPathDumpersFile = QFileInfo(PATH_DUMPERS_FILE).canonicalFilePath();
|
= QFileInfo(QLatin1String(PATH_CPP_FRONTEND)).canonicalFilePath();
|
||||||
|
const QString defaultPathDumpersFile
|
||||||
|
= QFileInfo(QLatin1String(PATH_DUMPERS_FILE)).canonicalFilePath();
|
||||||
std::cout << "Default values:" << "\n"
|
std::cout << "Default values:" << "\n"
|
||||||
<< " frontend-dir: " << qPrintable(defaultPathCppFrontend) << "\n"
|
<< " frontend-dir: " << qPrintable(defaultPathCppFrontend) << "\n"
|
||||||
<< " dumpers-file: " << qPrintable(defaultPathDumpersFile) << "\n";
|
<< " dumpers-file: " << qPrintable(defaultPathDumpersFile) << "\n";
|
||||||
@@ -1712,10 +1719,11 @@ int main(int argc, char *argv[])
|
|||||||
QStringList args = app.arguments();
|
QStringList args = app.arguments();
|
||||||
args.removeFirst();
|
args.removeFirst();
|
||||||
|
|
||||||
QString pathCppFrontend = PATH_CPP_FRONTEND;
|
QString pathCppFrontend = QLatin1String(PATH_CPP_FRONTEND);
|
||||||
QString pathDumpersFile = PATH_DUMPERS_FILE;
|
QString pathDumpersFile = QLatin1String(PATH_DUMPERS_FILE);
|
||||||
|
|
||||||
const bool helpRequested = args.contains("-h") || args.contains("-help");
|
const bool helpRequested = args.contains(QLatin1String("-h"))
|
||||||
|
|| args.contains(QLatin1String("-help"));
|
||||||
if (args.count() == 1 || args.count() >= 3 || helpRequested) {
|
if (args.count() == 1 || args.count() >= 3 || helpRequested) {
|
||||||
printUsage();
|
printUsage();
|
||||||
return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE;
|
return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ INCLUDEPATH += . ../../libs
|
|||||||
include(../../../qtcreator.pri)
|
include(../../../qtcreator.pri)
|
||||||
include(../../libs/cplusplus/cplusplus-lib.pri)
|
include(../../libs/cplusplus/cplusplus-lib.pri)
|
||||||
|
|
||||||
|
DEFINES *= QT_NO_CAST_FROM_ASCII
|
||||||
DEFINES += PATH_CPP_FRONTEND=\\\"$$PWD/../../libs/3rdparty/cplusplus\\\"
|
DEFINES += PATH_CPP_FRONTEND=\\\"$$PWD/../../libs/3rdparty/cplusplus\\\"
|
||||||
DEFINES += PATH_DUMPERS_FILE=\\\"$$PWD/../../../tests/tools/cplusplus-ast2png/dumpers.inc\\\"
|
DEFINES += PATH_DUMPERS_FILE=\\\"$$PWD/../../../tests/tools/cplusplus-ast2png/dumpers.inc\\\"
|
||||||
SOURCES += cplusplus-update-frontend.cpp ../../libs/utils/changeset.cpp
|
SOURCES += cplusplus-update-frontend.cpp ../../libs/utils/changeset.cpp
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ QString example()
|
|||||||
#else
|
#else
|
||||||
QString::fromLatin1("$ echo \"int foo() {}\" | ./%1 && xdg-open %2.ast.png")
|
QString::fromLatin1("$ echo \"int foo() {}\" | ./%1 && xdg-open %2.ast.png")
|
||||||
#endif
|
#endif
|
||||||
.arg(QFileInfo(qApp->arguments().at(0)).fileName(), PATH_STDIN_FILE);
|
.arg(QFileInfo(qApp->arguments().at(0)).fileName(), QLatin1String(PATH_STDIN_FILE));
|
||||||
}
|
}
|
||||||
|
|
||||||
void printUsage()
|
void printUsage()
|
||||||
@@ -391,7 +391,7 @@ void printUsage()
|
|||||||
std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName())
|
std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName())
|
||||||
<< " [-v] <file1> <file2> ...\n\n";
|
<< " [-v] <file1> <file2> ...\n\n";
|
||||||
|
|
||||||
std::cout << qPrintable(QString::fromLatin1(
|
std::cout << QString::fromLatin1(
|
||||||
"Visualize AST and symbol hierarchy of given C++ files by generating png image files\n"
|
"Visualize AST and symbol hierarchy of given C++ files by generating png image files\n"
|
||||||
"in the same directory as the input files. Print paths to generated image files.\n"
|
"in the same directory as the input files. Print paths to generated image files.\n"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -404,7 +404,7 @@ void printUsage()
|
|||||||
"Prerequisites:\n"
|
"Prerequisites:\n"
|
||||||
" 1) Make sure to have 'dot' from graphviz locatable by PATH.\n"
|
" 1) Make sure to have 'dot' from graphviz locatable by PATH.\n"
|
||||||
" 2) Make sure to have an up to date dumpers file by using 'cplusplus-update-frontend'.\n"
|
" 2) Make sure to have an up to date dumpers file by using 'cplusplus-update-frontend'.\n"
|
||||||
).arg(PATH_STDIN_FILE, example()));
|
).arg(QLatin1String(PATH_STDIN_FILE), example()).toLocal8Bit().constData();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -417,7 +417,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Data from stdin?
|
// Data from stdin?
|
||||||
if (!tty_for_stdin()) {
|
if (!tty_for_stdin()) {
|
||||||
QFile file("_stdincontents.cpp");
|
QFile file((QLatin1String(PATH_STDIN_FILE)));
|
||||||
if (! file.open(QFile::WriteOnly)) {
|
if (! file.open(QFile::WriteOnly)) {
|
||||||
std::cerr << "Error: Cannot open file for writing\"" << qPrintable(file.fileName())
|
std::cerr << "Error: Cannot open file for writing\"" << qPrintable(file.fileName())
|
||||||
<< "\"" << std::endl;
|
<< "\"" << std::endl;
|
||||||
@@ -429,11 +429,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process options & arguments
|
// Process options & arguments
|
||||||
if (args.contains("-v")) {
|
if (args.contains(QLatin1String("-v"))) {
|
||||||
optionVerbose = true;
|
optionVerbose = true;
|
||||||
args.removeOne("-v");
|
args.removeOne(QLatin1String("-v"));
|
||||||
}
|
}
|
||||||
const bool helpRequested = args.contains("-h") || args.contains("-help");
|
const bool helpRequested = args.contains(QLatin1String("-h"))
|
||||||
|
|| args.contains(QLatin1String("-help"));
|
||||||
if (args.isEmpty() || helpRequested) {
|
if (args.isEmpty() || helpRequested) {
|
||||||
printUsage();
|
printUsage();
|
||||||
return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE;
|
return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ include(../../../qtcreator.pri)
|
|||||||
include(../../../src/libs/cplusplus/cplusplus-lib.pri)
|
include(../../../src/libs/cplusplus/cplusplus-lib.pri)
|
||||||
include(../../../src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri)
|
include(../../../src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri)
|
||||||
|
|
||||||
|
DEFINES *= QT_NO_CAST_FROM_ASCII
|
||||||
SOURCES += cplusplus-ast2png.cpp
|
SOURCES += cplusplus-ast2png.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user