forked from qt-creator/qt-creator
Added a simple auto test for our C++ front-end.
This commit is contained in:
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
me=$(dirname $0)
|
||||
${CPP-gcc} -xc++ -E -include $me/conf.c++ $* | $me/cplusplus0
|
||||
@@ -0,0 +1,7 @@
|
||||
#define __extension__
|
||||
#define __context__
|
||||
#define __range__
|
||||
#define __asm(a...)
|
||||
#define __asm__(a...)
|
||||
#define restrict
|
||||
#define __restrict
|
||||
@@ -0,0 +1,19 @@
|
||||
QT = core
|
||||
macx:CONFIG -= app_bundle
|
||||
TARGET = cplusplus0
|
||||
|
||||
include(../../../shared/cplusplus/cplusplus.pri)
|
||||
|
||||
# Input
|
||||
SOURCES += main.cpp
|
||||
|
||||
unix {
|
||||
debug:OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared
|
||||
release:OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared
|
||||
|
||||
debug:MOC_DIR = $${OUT_PWD}/.moc/debug-shared
|
||||
release:MOC_DIR = $${OUT_PWD}/.moc/release-shared
|
||||
|
||||
RCC_DIR = $${OUT_PWD}/.rcc/
|
||||
UI_DIR = $${OUT_PWD}/.uic/
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <TranslationUnit.h>
|
||||
#include <Control.h>
|
||||
#include <AST.h>
|
||||
#include <Semantic.h>
|
||||
#include <Scope.h>
|
||||
|
||||
int main(int, char *[])
|
||||
{
|
||||
Control control;
|
||||
StringLiteral *fileId = control.findOrInsertFileName("<stdin>");
|
||||
|
||||
QFile in;
|
||||
if (! in.open(stdin, QFile::ReadOnly))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
const QByteArray source = in.readAll();
|
||||
|
||||
TranslationUnit unit(&control, fileId);
|
||||
unit.setSource(source.constData(), source.size());
|
||||
unit.parse();
|
||||
|
||||
if (TranslationUnitAST *ast = unit.ast()) {
|
||||
Scope globalScope;
|
||||
Semantic sem(&control);
|
||||
for (DeclarationAST *decl = ast->declarations; decl; decl = decl->next) {
|
||||
sem.check(decl, &globalScope);
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user