Commit e134e249 authored by Wolfgang Beck's avatar Wolfgang Beck

Source update.

parent cc278a59
......@@ -33,30 +33,32 @@
#include <cplusplus/CheckUndefinedSymbols.h>
#include "cppmodelmanager.h"
#include "cpptoolsconstants.h"
#include "cpptoolseditorsupport.h"
#include "cppfindreferences.h"
#ifndef ICHECK_BUILD
# include "cpptoolsconstants.h"
# include "cpptoolseditorsupport.h"
# include "cppfindreferences.h"
#endif
#include <functional>
#include <QtConcurrentRun>
#include <QFutureSynchronizer>
#include <qtconcurrent/runextensions.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/session.h>
#include <coreplugin/icore.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <extensionsystem/pluginmanager.h>
#ifndef ICHECK_BUILD
# include <QFutureSynchronizer>
# include <qtconcurrent/runextensions.h>
# include <texteditor/itexteditor.h>
# include <texteditor/basetexteditor.h>
# include <projectexplorer/project.h>
# include <projectexplorer/projectexplorer.h>
# include <projectexplorer/projectexplorerconstants.h>
# include <projectexplorer/session.h>
# include <coreplugin/icore.h>
# include <coreplugin/uniqueidmanager.h>
# include <coreplugin/mimedatabase.h>
# include <coreplugin/editormanager/editormanager.h>
# include <coreplugin/progressmanager/progressmanager.h>
# include <extensionsystem/pluginmanager.h>
#else
# include <QDir>
#endif
#include <utils/qtcassert.h>
......@@ -199,9 +201,8 @@ void CppPreprocessor::setProjectFiles(const QStringList &files)
void CppPreprocessor::setTodo(const QStringList &files)
{ m_todo = QSet<QString>::fromList(files); }
namespace {
#ifndef ICHECK_BUILD
namespace {
class Process: public std::unary_function<Document::Ptr, void>
{
QPointer<CppModelManager> _modelManager;
......@@ -256,8 +257,8 @@ public:
_modelManager->emitDocumentUpdated(doc); // ### TODO: compress
}
};
#endif
} // end of anonymous namespace
#endif
void CppPreprocessor::run(const QString &fileName)
{
......
......@@ -31,21 +31,26 @@
#define CPPMODELMANAGER_H
#include <cpptools/cppmodelmanagerinterface.h>
#include <projectexplorer/project.h>
#ifndef ICHECK_BUILD
# include <projectexplorer/project.h>
#endif
#include <cplusplus/CppDocument.h>
#include <cplusplus/PreprocessorClient.h>
#include <texteditor/basetexteditor.h>
#ifndef ICHECK_BUILD
# include <texteditor/basetexteditor.h>
#endif
#include <cplusplus/PreprocessorEnvironment.h>
#include <cplusplus/pp-engine.h>
#ifdef ICHECK_BUILD
# include "ParseManager.h"
# include "parsemanager.h"
#else
# include <QtCore/QHash>
# include <QtCore/QFutureInterface>
# include <QtCore/QFutureSynchronizer>
# include <QtCore/QMutex>
# include <QtCore/QTimer>
# include <QtGui/QTextEdit> // for QTextEdit::ExtraSelection
#endif
#include <QtCore/QHash>
#include <QtCore/QFutureInterface>
#include <QtCore/QFutureSynchronizer>
#include <QtCore/QMutex>
#include <QtCore/QTimer>
#include <QtGui/QTextEdit> // for QTextEdit::ExtraSelection
namespace Core {
class ICore;
......
......@@ -586,6 +586,8 @@ public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual QPropertyDeclarationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
virtual bool match0(AST *, ASTMatcher *);
......@@ -606,6 +608,8 @@ public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual QEnumDeclarationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
virtual bool match0(AST *, ASTMatcher *);
......@@ -626,6 +630,8 @@ public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual QFlagsDeclarationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
virtual bool match0(AST *, ASTMatcher *);
......@@ -647,6 +653,8 @@ public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual QDeclareFlagsDeclarationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
virtual bool match0(AST *, ASTMatcher *);
......
......@@ -138,6 +138,67 @@ AccessDeclarationAST *AccessDeclarationAST::clone(MemoryPool *pool) const
return ast;
}
#ifdef ICHECK_BUILD
QPropertyDeclarationAST *QPropertyDeclarationAST::clone(MemoryPool *pool) const
{
QPropertyDeclarationAST *ast = new (pool) QPropertyDeclarationAST;
ast->property_specifier_token = property_specifier_token;
ast->lparen_token = lparen_token;
ast->type_token = type_token;
ast->type_name_token = type_name_token;
ast->read_token = read_token;
ast->read_function_token = read_function_token;
ast->write_token = write_token;
ast->write_function_token = write_function_token;
ast->reset_token = reset_token;
ast->reset_function_token = reset_function_token;
ast->notify_token = notify_token;
ast->notify_function_token = notify_function_token;
ast->rparen_token = rparen_token;
return ast;
}
QEnumDeclarationAST *QEnumDeclarationAST::clone(MemoryPool *pool) const
{
QEnumDeclarationAST *ast = new (pool)QEnumDeclarationAST;
ast->enum_specifier_token = enum_specifier_token;
ast->lparen_token = lparen_token;
ast->rparen_token = rparen_token;
EnumeratorListAST *enumerator_list;
for (EnumeratorListAST *iter = enumerator_list, **ast_iter = &ast->enumerator_list;
iter; iter = iter->next, ast_iter = &(*ast_iter)->next)
*ast_iter = new (pool) EnumeratorListAST((iter->value) ? iter->value->clone(pool) : 0);
return ast;
}
QFlagsDeclarationAST *QFlagsDeclarationAST::clone(MemoryPool *pool) const
{
QFlagsDeclarationAST *ast = new (pool) QFlagsDeclarationAST;
ast->flags_specifier_token = flags_specifier_token;
ast->lparen_token = lparen_token;
ast->rparen_token = rparen_token;
EnumeratorListAST *enumerator_list;
for (EnumeratorListAST *iter = enumerator_list, **ast_iter = &ast->enumerator_list;
iter; iter = iter->next, ast_iter = &(*ast_iter)->next)
*ast_iter = new (pool) EnumeratorListAST((iter->value) ? iter->value->clone(pool) : 0);
return ast;
}
QDeclareFlagsDeclarationAST *QDeclareFlagsDeclarationAST::clone(MemoryPool *pool) const
{
QDeclareFlagsDeclarationAST *ast = new (pool) QDeclareFlagsDeclarationAST;
ast->declareflags_specifier_token = declareflags_specifier_token;
ast->lparen_token = lparen_token;
ast->flag_token = flag_token;
ast->enum_token = enum_token;
ast->rparen_token = rparen_token;
return ast;
}
#endif
AsmDefinitionAST *AsmDefinitionAST::clone(MemoryPool *pool) const
{
AsmDefinitionAST *ast = new (pool) AsmDefinitionAST;
......
......@@ -272,7 +272,7 @@ bool CheckDeclarator::visit(ObjCMethodPrototypeAST *ast)
if (semantic()->isObjCClassMethod(tokenKind(ast->method_type_token)))
method->setStorage(Symbol::Static);
if (ast->selector->asObjCSelectorWithArguments()) {
if (ast->selector && ast->selector->asObjCSelectorWithArguments()) {
for (ObjCMessageArgumentDeclarationListAST *it = ast->argument_list; it; it = it->next) {
ObjCMessageArgumentDeclarationAST *argDecl = it->value;
......
......@@ -210,6 +210,16 @@ public:
} // end of anonymous namespace
#ifdef ICHECK_BUILD
//Symbian compiler has some difficulties to understand the templates.
static void delete_array_entries(std::vector<Symbol *> vt)
{
std::vector<Symbol *>::iterator it;
for (it = vt.begin(); it != vt.end(); ++it) {
delete *it;
}
}
#else
template <typename _Iterator>
static void delete_array_entries(_Iterator first, _Iterator last)
{
......@@ -220,6 +230,7 @@ static void delete_array_entries(_Iterator first, _Iterator last)
template <typename _Array>
static void delete_array_entries(const _Array &a)
{ delete_array_entries(a.begin(), a.end()); }
#endif
class Control::Data
{
......
......@@ -1748,11 +1748,12 @@ bool Parser::parseAccessSpecifier(SpecifierAST *&node)
bool Parser::parseAccessDeclaration(DeclarationAST *&node)
{
DEBUG_THIS_RULE();
if (LA() == T_PUBLIC || LA() == T_PROTECTED || LA() == T_PRIVATE || LA() == T_Q_SIGNALS) {
if (LA() == T_PUBLIC || LA() == T_PROTECTED || LA() == T_PRIVATE || LA() == T_Q_SIGNALS || LA() == T_Q_SLOTS) {
bool isSignals = LA() == T_Q_SIGNALS;
bool isSlots = LA() == T_Q_SLOTS;
AccessDeclarationAST *ast = new (_pool) AccessDeclarationAST;
ast->access_specifier_token = consumeToken();
if (! isSignals && LA() == T_Q_SLOTS)
if (! isSignals && (LA() == T_Q_SLOTS || isSlots))
ast->slots_token = consumeToken();
match(T_COLON, &ast->colon_token);
node = ast;
......@@ -1930,6 +1931,7 @@ bool Parser::parseMemberSpecification(DeclarationAST *&node)
case T_PUBLIC:
case T_PROTECTED:
case T_PRIVATE:
case T_Q_SLOTS:
return parseAccessDeclaration(node);
#ifdef ICHECK_BUILD
......@@ -2426,6 +2428,7 @@ bool Parser::parseStatement(StatementAST *&node)
return parseExpressionOrDeclarationStatement(node);
} // switch
return false; //Avoid compiler warning
}
bool Parser::parseBreakStatement(StatementAST *&node)
......
......@@ -222,7 +222,9 @@ bool Function::isEqualTo(const Type *other) const
else if (isVolatile() != o->isVolatile())
return false;
#ifdef ICHECK_BUILD
else if (isInvokable() != o->isInvokable())
else if (isInvokable() != o->isInvokable())
return false;
else if (isSignal() != o->isSignal())
return false;
#endif
......@@ -258,6 +260,8 @@ bool Function::isEqualTo(const Function* fct, bool ignoreName/* = false*/) const
return false;
else if (isInvokable() != fct->isInvokable())
return false;
else if (isSignal() != fct->isSignal())
return false;
if (_arguments->symbolCount() != fct->_arguments->symbolCount())
return false;
......
......@@ -20,6 +20,6 @@ TARGET=tst_$$TARGET
include(./ichecklib.pri)
HEADERS += ./ichecklib.h \
./ichecklib_global.h \
./ParseManager.h
./parsemanager.h
SOURCES += ./ichecklib.cpp \
./ParseManager.cpp
./parsemanager.cpp
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "ichecklib.h"
#include "ParseManager.h"
#include "parsemanager.h"
#include <QtCore/QCoreApplication>
#include <QString>
#include <QStringList>
......@@ -17,7 +58,32 @@ QStringList getQTIncludePath()
foreach(QString item, processevironment){
if(item.indexOf("QTDIR=") == 0){
QString qtpath = item.remove("QTDIR=");
ret << qtpath + "/include";
ret << qtpath + "/include/ActiveQt";
ret << qtpath + "/include/phonon";
ret << qtpath + "/include/phonon_compat";
ret << qtpath + "/include/Qt";
ret << qtpath + "/include/Qt3Support";
ret << qtpath + "/include/QtAssistant";
ret << qtpath + "/include/QtCore";
ret << qtpath + "/include/QtDBus";
ret << qtpath + "/include/QtDeclarative";
ret << qtpath + "/include/QtDesigner";
ret << qtpath + "/include/QtGui";
ret << qtpath + "/include/QtHelp";
ret << qtpath + "/include/QtMultimedia";
ret << qtpath + "/include/QtNetwork";
ret << qtpath + "/include/QtOpenGL";
ret << qtpath + "/include/QtOpenVG";
ret << qtpath + "/include/QtScript";
ret << qtpath + "/include/QtScriptTools";
ret << qtpath + "/include/QtSql";
ret << qtpath + "/include/QtSvg";
ret << qtpath + "/include/QtTest";
ret << qtpath + "/include/QtUiTools";
ret << qtpath + "/include/QtWebKit";
ret << qtpath + "/include/QtXml";
ret << qtpath + "/include/QtXmlPatterns";
break;
}
}
......@@ -39,11 +105,11 @@ void ICheckLib::ParseHeader(const QStringList& includePath, const QStringList& f
pParseManager->parse(filelist);
}
bool ICheckLib::check(const ICheckLib& ichecklib /*ICheckLib from interface header*/)
bool ICheckLib::check(const ICheckLib& ichecklib /*ICheckLib from interface header*/, QString outputfile)
{
if(pParseManager){
CPlusPlus::ParseManager* cpparsemanager = ichecklib.pParseManager;
return pParseManager->checkAllMetadatas(cpparsemanager);
return pParseManager->checkAllMetadatas(cpparsemanager, outputfile);
}
return false;
}
......
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef ICHECKLIB_H
#define ICHECKLIB_H
......@@ -11,7 +52,7 @@ class ICHECKLIBSHARED_EXPORT ICheckLib {
public:
ICheckLib();
void ParseHeader(const QStringList& includePath, const QStringList& filelist);
bool check(const ICheckLib& ichecklib /*ICheckLib from interface header*/);
bool check(const ICheckLib& ichecklib /*ICheckLib from interface header*/, QString outputfile);
QStringList getErrorMsg();
private:
CPlusPlus::ParseManager* pParseManager;
......
......@@ -56,11 +56,13 @@ HEADERS += $$REL_PATH_TO_SRC/shared/cplusplus/Array.h \
$$REL_PATH_TO_SRC/shared/cplusplus/Type.h \
$$REL_PATH_TO_SRC/shared/cplusplus/TypeMatcher.h \
$$REL_PATH_TO_SRC/libs/cplusplus/TypePrettyPrinter.h \
$$REL_PATH_TO_SRC/shared/cplusplus/TypeVisitor.h
$$REL_PATH_TO_SRC/shared/cplusplus/TypeVisitor.h \
$$REL_PATH_TO_SRC/plugins/cpptools/cpptools_global.h
SOURCES += $$REL_PATH_TO_SRC/shared/cplusplus/Array.cpp \
$$REL_PATH_TO_SRC/shared/cplusplus/AST.cpp \
$$REL_PATH_TO_SRC/shared/cplusplus/ASTMatch0.cpp \
$$REL_PATH_TO_SRC/shared/cplusplus/ASTMatcher.cpp \
$$REL_PATH_TO_SRC/shared/cplusplus/ASTClone.cpp \
$$REL_PATH_TO_SRC/shared/cplusplus/ASTVisit.cpp \
$$REL_PATH_TO_SRC/shared/cplusplus/ASTVisitor.cpp \
$$REL_PATH_TO_SRC/shared/cplusplus/CheckDeclaration.cpp \
......
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef ICHECKLIB_GLOBAL_H
#define ICHECKLIB_GLOBAL_H
......
......@@ -27,7 +27,7 @@
**
**************************************************************************/
#include "ParseManager.h"
#include "parsemanager.h"
#include "cplusplus/CppDocument.h"
#include "Control.h"
#include "TranslationUnit.h"
......@@ -36,6 +36,7 @@
#include <QDebug>
#include "Name.h"
#include "cpptools/cppmodelmanager.h"
#include <QTextStream>
using namespace CppTools;
using namespace CppTools::Internal;
......@@ -160,6 +161,11 @@ ParseManager::~ParseManager()
{
if(pCppPreprocessor)
delete pCppPreprocessor;
if(::m_resultFile){
::m_resultFile->close();
delete ::m_resultFile;
::m_resultFile = 0;
}
}
/**************************************
......@@ -236,12 +242,13 @@ void ParseManager::parse(CppTools::Internal::CppPreprocessor *preproc,
//==> list[0] = {Cl1, Cl11, Cl12}
// list[1] = {Cl2, Cl21, Cl22}
QList<CLASSTREE*> ParseManager::CreateClassLists()
QList<CLASSTREE*> ParseManager::CreateClassLists(bool isInterfaceHeader)
{
QList<CLASSTREE*>ret;
QList<CLASSLISTITEM*> classlist;
QList<CLASSLISTITEM*> allclasslist;
Trace("Following classes scaned for header file: " + m_strHeaderFile);
//Iteration over all parsed documents
if(getPreProcessor()){
for (Snapshot::const_iterator it = getPreProcessor()->snapshot.begin()
......@@ -270,12 +277,14 @@ QList<CLASSTREE*> ParseManager::CreateClassLists()
item->classspec = pclassspec;
item->trlUnit = trlUnit;
allclasslist.push_back(item);
QString classname = item->trlUnit->spell(item->classspec->name->firstToken());
Trace("- " + classname + " class scaned");
//We found a class that is defined in the header file that needs to be checked
if(fileinf.fileName().toLower() == fileinf1.fileName().toLower()){
CLASSTREE* cltree = new CLASSTREE();
cltree->highestlevelclass = item;
cltree->classlist.push_back(item);
//now add all baseclasses from this class
ret.push_back(cltree);
}
}
......@@ -288,45 +297,70 @@ QList<CLASSTREE*> ParseManager::CreateClassLists()
}
}
//after we search for the classes we need to search for the baseclasses
Trace("Following classes found in Header file: " + m_strHeaderFile);
foreach(CLASSTREE *cltree, ret){
QString classname = cltree->highestlevelclass->trlUnit->spell(cltree->highestlevelclass->classspec->name->firstToken());
Trace("- " + classname + " class found");
QList<CLASSLISTITEM*> baseclasslist;
getBaseClasses(cltree->highestlevelclass, baseclasslist, allclasslist);
getBaseClasses(cltree->highestlevelclass, baseclasslist, allclasslist, 0, isInterfaceHeader);
cltree->classlist.append(baseclasslist);
}
return ret;
}
/********************************************
Gets all the baseclass from a class and
Gets all the baseclass from a class and
add those base classes into the baseclasslist
********************************************/
void ParseManager::getBaseClasses(const CLASSLISTITEM* pclass, QList<CLASSLISTITEM*> &baseclasslist, const QList<CLASSLISTITEM*> &allclasslist)
void ParseManager::getBaseClasses(const CLASSLISTITEM* pclass
, QList<CLASSLISTITEM*> &baseclasslist
, const QList<CLASSLISTITEM*> &allclasslist
, int level
, bool isInterfaceHeader)
{
//iteration over the base_clause_list of the current class
QString levelmarker = " ";
for(int i = 0; i < level; i++)
levelmarker += " ";
levelmarker += "|- ";
QList<CLASSLISTITEM*>child;