Commit 13675cf6 authored by Roberto Raggi's avatar Roberto Raggi

Cleanup the C++ front-end.

Removed CPLUSPLUS_BEGIN/END_NAMESPACE & co and made it possible to compile the parser with CPLUSPLUS_WITHOUT_QT.
parent 0a7d402d
......@@ -54,7 +54,7 @@
#include <cstddef>
#include <algorithm>
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
AST::AST()
{ }
......@@ -2493,4 +2493,4 @@ unsigned ObjCSynchronizedStatementAST::lastToken() const
return synchronized_token + 1;
}
CPLUSPLUS_END_NAMESPACE
......@@ -53,8 +53,8 @@
#include "ASTfwd.h"
#include "MemoryPool.h"
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
template <typename _Tp>
class List: public Managed
......@@ -3168,7 +3168,7 @@ protected:
virtual void accept0(ASTVisitor *visitor);
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_AST_H
......@@ -30,7 +30,7 @@
#include "AST.h"
#include "ASTVisitor.h"
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
SimpleSpecifierAST *SimpleSpecifierAST::clone(MemoryPool *pool) const
{
......@@ -1516,4 +1516,4 @@ ObjCSynchronizedStatementAST *ObjCSynchronizedStatementAST::clone(MemoryPool *po
}
CPLUSPLUS_END_NAMESPACE
......@@ -30,7 +30,7 @@
#include "AST.h"
#include "ASTVisitor.h"
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
void SimpleSpecifierAST::accept0(ASTVisitor *visitor)
{
......@@ -1465,4 +1465,4 @@ void ObjCSynchronizedStatementAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
CPLUSPLUS_END_NAMESPACE
......@@ -51,7 +51,7 @@
#include "TranslationUnit.h"
#include "Control.h"
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
ASTVisitor::ASTVisitor(Control *control)
: _control(control)
......@@ -111,4 +111,4 @@ void ASTVisitor::getTokenStartPosition(unsigned index, unsigned *line, unsigned
void ASTVisitor::getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const
{ getPosition(tokenAt(index).end(), line, column); }
CPLUSPLUS_END_NAMESPACE
......@@ -52,8 +52,8 @@
#include "CPlusPlusForwardDeclarations.h"
#include "ASTfwd.h"
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT ASTVisitor
{
......@@ -371,7 +371,7 @@ private:
Control *_control;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_ASTVISITOR_H
......@@ -51,8 +51,8 @@
#include <CPlusPlusForwardDeclarations.h>
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class AST;
class ASTVisitor;
......@@ -203,7 +203,7 @@ class ObjCDynamicPropertiesDeclarationAST;
class ObjCFastEnumerationAST;
class ObjCSynchronizedStatementAST;
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_ASTFWD_H
......@@ -53,8 +53,8 @@
#include <new>
#include <cstdlib>
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
template <typename _Tp, int SEGMENT_SHIFT = 4>
class Array
......@@ -125,7 +125,7 @@ private:
int _count;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_ARRAY_H
......@@ -49,34 +49,19 @@
#ifndef CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H
#define CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H
#ifndef CPLUSPLUS_WITH_NO_QT
#ifndef CPLUSPLUS_WITHOUT_QT
# include <QtCore/qglobal.h>
# define CPLUSPLUS_BEGIN_HEADER
# define CPLUSPLUS_END_HEADER
# if defined(CPLUSPLUS_BUILD_LIB)
# define CPLUSPLUS_EXPORT Q_DECL_EXPORT
# else
# define CPLUSPLUS_EXPORT Q_DECL_IMPORT
# endif
# define CPLUSPLUS_WITH_NAMESPACE
#else
# define CPLUSPLUS_BEGIN_HEADER
# define CPLUSPLUS_END_HEADER
# define CPLUSPLUS_EXPORT
#endif
#ifdef CPLUSPLUS_WITH_NAMESPACE
# define CPLUSPLUS_BEGIN_NAMESPACE namespace CPlusPlus {
# define CPLUSPLUS_END_NAMESPACE } // end of namespace CPlusPLus
# define CPLUSPLUS_USE_NAMESPACE using namespace CPlusPlus;
#else
# define CPLUSPLUS_BEGIN_NAMESPACE
# define CPLUSPLUS_END_NAMESPACE
# define CPLUSPLUS_USE_NAMESPACE ;
#endif
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class TranslationUnit;
class Semantic;
......@@ -144,7 +129,6 @@ class ObjCProtocol;
class ObjCForwardProtocolDeclaration;
class ObjCMethod;
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H
......@@ -57,9 +57,8 @@
#include "Control.h"
#include "Literals.h"
#include <cassert>
#include <QtCore/QByteArray>
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
CheckDeclaration::CheckDeclaration(Semantic *semantic)
: SemanticCheck(semantic),
......@@ -228,7 +227,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
if (it->declarator && it->declarator->initializer) {
FullySpecifiedType initTy = semantic()->check(it->declarator->initializer, _scope);
Q_UNUSED(initTy)
}
*decl_it = new (translationUnit()->memoryPool()) List<Declaration *>();
......@@ -703,25 +701,25 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast)
continue;
const char *attrName = spell(attrAst->attribute_identifier_token);
if (!qstrcmp("getter", attrName)) {
if (!strcmp("getter", attrName)) {
if (checkPropertyAttribute(attrAst, propAttrs, Getter)) {
// TODO: find method declaration for getter
}
} else if (!qstrcmp("setter", attrName)) {
} else if (!strcmp("setter", attrName)) {
if (checkPropertyAttribute(attrAst, propAttrs, Setter)) {
// TODO: find method declaration for setter
}
} else if (!qstrcmp("readwrite", attrName)) {
} else if (!strcmp("readwrite", attrName)) {
checkPropertyAttribute(attrAst, propAttrs, ReadWrite);
} else if (!qstrcmp("readonly", attrName)) {
} else if (!strcmp("readonly", attrName)) {
checkPropertyAttribute(attrAst, propAttrs, ReadOnly);
} else if (!qstrcmp("assign", attrName)) {
} else if (!strcmp("assign", attrName)) {
checkPropertyAttribute(attrAst, propAttrs, Assign);
} else if (!qstrcmp("retain", attrName)) {
} else if (!strcmp("retain", attrName)) {
checkPropertyAttribute(attrAst, propAttrs, Retain);
} else if (!qstrcmp("copy", attrName)) {
} else if (!strcmp("copy", attrName)) {
checkPropertyAttribute(attrAst, propAttrs, Copy);
} else if (!qstrcmp("nonatomic", attrName)) {
} else if (!strcmp("nonatomic", attrName)) {
checkPropertyAttribute(attrAst, propAttrs, NonAtomic);
}
}
......@@ -745,4 +743,4 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast)
return false;
}
CPLUSPLUS_END_NAMESPACE
......@@ -52,8 +52,8 @@
#include "CPlusPlusForwardDeclarations.h"
#include "SemanticCheck.h"
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT CheckDeclaration: public SemanticCheck
{
......@@ -111,7 +111,7 @@ private:
bool _checkAnonymousArguments: 1;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_CHECKDECLARATION_H
......@@ -55,7 +55,7 @@
#include "CoreTypes.h"
#include "Symbols.h"
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
CheckDeclarator::CheckDeclarator(Semantic *semantic)
: SemanticCheck(semantic),
......@@ -300,4 +300,4 @@ void CheckDeclarator::applyCvQualifiers(SpecifierAST *cv)
}
}
CPLUSPLUS_END_NAMESPACE
......@@ -53,8 +53,8 @@
#include "SemanticCheck.h"
#include "FullySpecifiedType.h"
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT CheckDeclarator: public SemanticCheck
{
......@@ -106,7 +106,7 @@ private:
FullySpecifiedType _fullySpecifiedType;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_CHECKDECLARATOR_H
......@@ -56,7 +56,7 @@
#include "Symbols.h"
#include "Control.h"
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
CheckExpression::CheckExpression(Semantic *semantic)
: SemanticCheck(semantic),
......@@ -207,7 +207,6 @@ bool CheckExpression::visit(NewExpressionAST *ast)
if (ast->new_placement) {
for (ExpressionListAST *it = ast->new_placement->expression_list; it; it = it->next) {
FullySpecifiedType exprTy = semantic()->check(it->expression, _scope);
Q_UNUSED(exprTy)
}
}
......@@ -215,18 +214,15 @@ bool CheckExpression::visit(NewExpressionAST *ast)
if (ast->new_type_id) {
FullySpecifiedType ty = semantic()->check(ast->new_type_id->type_specifier, _scope);
Q_UNUSED(ty)
for (NewArrayDeclaratorAST *it = ast->new_type_id->new_array_declarators; it; it = it->next) {
FullySpecifiedType exprTy = semantic()->check(it->expression, _scope);
Q_UNUSED(exprTy)
}
}
// ### process new-initializer
if (ast->new_initializer) {
FullySpecifiedType exprTy = semantic()->check(ast->new_initializer->expression, _scope);
Q_UNUSED(exprTy)
}
return false;
......@@ -397,4 +393,4 @@ bool CheckExpression::visit(ObjCSelectorExpressionAST *ast)
return false;
}
CPLUSPLUS_END_NAMESPACE
......@@ -53,8 +53,8 @@
#include "SemanticCheck.h"
#include "FullySpecifiedType.h"
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT CheckExpression: public SemanticCheck
{
......@@ -122,7 +122,7 @@ private:
bool _checkOldStyleCasts: 1;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_CHECKEXPRESSION_H
......@@ -58,7 +58,7 @@
#include "Scope.h"
#include <cassert>
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
CheckName::CheckName(Semantic *semantic)
: SemanticCheck(semantic),
......@@ -425,4 +425,4 @@ bool CheckName::visit(ObjCMessageArgumentDeclarationAST *ast)
return false;
}
CPLUSPLUS_END_NAMESPACE
......@@ -52,8 +52,8 @@
#include "CPlusPlusForwardDeclarations.h"
#include "SemanticCheck.h"
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT CheckName: public SemanticCheck
{
......@@ -89,7 +89,7 @@ private:
Scope *_scope;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_CHECKNAME_H
......@@ -58,7 +58,7 @@
#include "Control.h"
#include "Scope.h"
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
CheckSpecifier::CheckSpecifier(Semantic *semantic)
: SemanticCheck(semantic),
......@@ -420,4 +420,4 @@ bool CheckSpecifier::visit(ObjCTypeNameAST * /*ast*/)
return true;
}
CPLUSPLUS_END_NAMESPACE
......@@ -53,8 +53,8 @@
#include "SemanticCheck.h"
#include "FullySpecifiedType.h"
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT CheckSpecifier: public SemanticCheck
{
......@@ -88,7 +88,7 @@ private:
Scope *_scope;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_CHECKSPECIFIER_H
......@@ -55,7 +55,7 @@
#include "Control.h"
#include "Symbols.h"
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
CheckStatement::CheckStatement(Semantic *semantic)
: SemanticCheck(semantic),
......@@ -307,4 +307,4 @@ bool CheckStatement::visit(WhileStatementAST *ast)
return false;
}
CPLUSPLUS_END_NAMESPACE
......@@ -52,8 +52,8 @@
#include "CPlusPlusForwardDeclarations.h"
#include "SemanticCheck.h"
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT CheckStatement: public SemanticCheck
{
......@@ -94,7 +94,7 @@ private:
Scope *_scope;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_CHECKSTATEMENT_H
......@@ -57,7 +57,7 @@
#include <map> // ### replace me with LiteralTable
#include <string>
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
template <typename _Iterator>
......@@ -766,4 +766,4 @@ ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsig
ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, Name *name)
{ return d->newObjCMethod(sourceLocation, name); }
CPLUSPLUS_END_NAMESPACE
......@@ -52,8 +52,8 @@
#include "CPlusPlusForwardDeclarations.h"
#include <cstddef>
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT Control
{
......@@ -199,7 +199,7 @@ private:
Data *d;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_CONTROL_H
......@@ -51,7 +51,7 @@
#include "Names.h"
#include <algorithm>
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
bool VoidType::isEqualTo(const Type *other) const
......@@ -230,4 +230,4 @@ bool NamedType::isEqualTo(const Type *other) const
void NamedType::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
CPLUSPLUS_END_NAMESPACE
......@@ -54,8 +54,8 @@
#include "FullySpecifiedType.h"
#include <cstddef>
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT UndefinedType : public Type
{
......@@ -272,7 +272,7 @@ private:
Name *_name;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_CORETYPES_H
......@@ -48,7 +48,7 @@
#include "DiagnosticClient.h"
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
DiagnosticClient::DiagnosticClient()
{ }
......@@ -56,4 +56,4 @@ DiagnosticClient::DiagnosticClient()
DiagnosticClient::~DiagnosticClient()
{ }
CPLUSPLUS_END_NAMESPACE
......@@ -52,8 +52,8 @@
#include "CPlusPlusForwardDeclarations.h"
#include "stdarg.h"
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT DiagnosticClient
{
......@@ -76,7 +76,7 @@ public:
const char *format, va_list ap) = 0;
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_DIAGNOSTICCLIENT_H
......@@ -50,7 +50,7 @@
#include "Type.h"
#include "CoreTypes.h"
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
FullySpecifiedType::FullySpecifiedType(Type *type) :
_type(type), _flags(0)
......@@ -209,4 +209,4 @@ FullySpecifiedType FullySpecifiedType::simplified() const
return *this;
}
CPLUSPLUS_END_NAMESPACE
......@@ -51,8 +51,8 @@
#include "CPlusPlusForwardDeclarations.h"
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
namespace CPlusPlus {
class CPLUSPLUS_EXPORT FullySpecifiedType
{
......@@ -151,7 +151,7 @@ private:
};
};
CPLUSPLUS_END_NAMESPACE
CPLUSPLUS_END_HEADER
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_FULLYSPECIFIEDTYPE_H
......@@ -49,7 +49,7 @@
#include "Lexer.h"
#include "Token.h"
CPLUSPLUS_BEGIN_NAMESPACE
using namespace CPlusPlus;
static inline int classify2(const char *s, bool) {
if (s[0] == 'd') {
......@@ -1400,4 +1400,4 @@ int Lexer::classifyOperator(const char *s, int n) {
} // switch
}
CPLUSPLUS_END_NAMESPACE