2006-11-09 14:54:47 +08:00
|
|
|
//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
|
2006-11-03 14:42:29 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 03:59:25 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-11-03 14:42:29 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2006-11-09 14:54:47 +08:00
|
|
|
// This file defines the Sema class, which performs semantic analysis and
|
|
|
|
// builds ASTs.
|
2006-11-03 14:42:29 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2006-11-09 14:54:47 +08:00
|
|
|
#ifndef LLVM_CLANG_AST_SEMA_H
|
|
|
|
#define LLVM_CLANG_AST_SEMA_H
|
2006-11-03 14:42:29 +08:00
|
|
|
|
2008-04-11 15:00:53 +08:00
|
|
|
#include "IdentifierResolver.h"
|
2006-11-03 14:42:29 +08:00
|
|
|
#include "clang/Parse/Action.h"
|
2007-11-12 11:44:46 +08:00
|
|
|
#include "clang/Parse/DeclSpec.h"
|
2007-07-22 15:07:56 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2007-10-06 02:00:57 +08:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2007-10-07 09:13:46 +08:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2006-11-03 14:42:29 +08:00
|
|
|
#include <vector>
|
2006-11-10 13:17:58 +08:00
|
|
|
#include <string>
|
2006-11-03 14:42:29 +08:00
|
|
|
|
2007-08-23 13:46:52 +08:00
|
|
|
namespace llvm {
|
|
|
|
class APSInt;
|
|
|
|
}
|
|
|
|
|
2006-11-03 14:42:29 +08:00
|
|
|
namespace clang {
|
2006-11-10 14:20:45 +08:00
|
|
|
class ASTContext;
|
2008-02-06 08:46:58 +08:00
|
|
|
class ASTConsumer;
|
2006-11-03 14:42:29 +08:00
|
|
|
class Preprocessor;
|
|
|
|
class Decl;
|
2008-04-06 12:47:34 +08:00
|
|
|
class DeclContext;
|
2008-04-02 07:04:06 +08:00
|
|
|
class NamedDecl;
|
2007-09-14 02:10:37 +08:00
|
|
|
class ScopedDecl;
|
2007-04-03 06:55:05 +08:00
|
|
|
class Expr;
|
2007-09-02 23:34:30 +08:00
|
|
|
class InitListExpr;
|
2007-12-28 13:29:59 +08:00
|
|
|
class CallExpr;
|
2007-01-21 15:42:07 +08:00
|
|
|
class VarDecl;
|
2007-06-14 04:44:40 +08:00
|
|
|
class ParmVarDecl;
|
2007-01-28 03:27:06 +08:00
|
|
|
class TypedefDecl;
|
|
|
|
class FunctionDecl;
|
2007-04-06 06:36:20 +08:00
|
|
|
class QualType;
|
2007-09-04 10:45:27 +08:00
|
|
|
struct LangOptions;
|
2007-07-21 00:59:19 +08:00
|
|
|
class Token;
|
2007-05-07 08:24:15 +08:00
|
|
|
class IntegerLiteral;
|
2008-01-22 08:55:40 +08:00
|
|
|
class StringLiteral;
|
2007-05-09 05:09:37 +08:00
|
|
|
class ArrayType;
|
2007-05-28 14:28:18 +08:00
|
|
|
class LabelStmt;
|
2007-07-22 15:07:56 +08:00
|
|
|
class SwitchStmt;
|
2008-04-19 07:10:10 +08:00
|
|
|
class ExtVectorType;
|
2007-07-30 00:33:31 +08:00
|
|
|
class TypedefDecl;
|
2008-01-08 03:49:32 +08:00
|
|
|
class ObjCInterfaceDecl;
|
2008-04-02 07:04:06 +08:00
|
|
|
class ObjCCompatibleAliasDecl;
|
2008-01-08 03:49:32 +08:00
|
|
|
class ObjCProtocolDecl;
|
|
|
|
class ObjCImplementationDecl;
|
|
|
|
class ObjCCategoryImplDecl;
|
|
|
|
class ObjCCategoryDecl;
|
|
|
|
class ObjCIvarDecl;
|
|
|
|
class ObjCMethodDecl;
|
2008-05-01 08:03:38 +08:00
|
|
|
class ObjCPropertyDecl;
|
2007-07-30 00:33:31 +08:00
|
|
|
|
2006-11-09 14:54:47 +08:00
|
|
|
/// Sema - This implements semantic analysis and AST building for C.
|
|
|
|
class Sema : public Action {
|
2008-06-29 08:28:59 +08:00
|
|
|
public:
|
2007-02-28 09:22:02 +08:00
|
|
|
Preprocessor &PP;
|
2006-11-10 14:20:45 +08:00
|
|
|
ASTContext &Context;
|
2008-02-06 08:46:58 +08:00
|
|
|
ASTConsumer &Consumer;
|
2008-04-04 14:12:32 +08:00
|
|
|
|
2008-06-28 14:07:14 +08:00
|
|
|
/// CurContext - This is the current declaration context of parsing.
|
2008-04-06 12:47:34 +08:00
|
|
|
DeclContext *CurContext;
|
2008-04-04 14:12:32 +08:00
|
|
|
|
2007-05-28 14:28:18 +08:00
|
|
|
/// LabelMap - This is a mapping from label identifiers to the LabelStmt for
|
|
|
|
/// it (which acts like the label decl in some ways). Forward referenced
|
|
|
|
/// labels have a LabelStmt created for them with a null location & SubStmt.
|
2007-06-16 07:05:46 +08:00
|
|
|
llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap;
|
2007-07-22 15:07:56 +08:00
|
|
|
|
|
|
|
llvm::SmallVector<SwitchStmt*, 8> SwitchStack;
|
2007-07-30 00:33:31 +08:00
|
|
|
|
2008-04-19 07:10:10 +08:00
|
|
|
/// ExtVectorDecls - This is a list all the extended vector types. This allows
|
|
|
|
/// us to associate a raw vector type with one of the ext_vector type names.
|
2007-07-30 00:33:31 +08:00
|
|
|
/// This is only necessary for issuing pretty diagnostics.
|
2008-04-19 07:10:10 +08:00
|
|
|
llvm::SmallVector<TypedefDecl*, 24> ExtVectorDecls;
|
2007-08-11 04:18:51 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
/// ObjCImplementations - Keep track of all of the classes with
|
2007-10-07 09:13:46 +08:00
|
|
|
/// @implementation's, so that we can emit errors on duplicates.
|
2008-01-08 03:49:32 +08:00
|
|
|
llvm::DenseMap<IdentifierInfo*, ObjCImplementationDecl*> ObjCImplementations;
|
2007-10-07 09:13:46 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
/// ObjCProtocols - Keep track of all protocol declarations declared
|
2007-10-10 02:03:53 +08:00
|
|
|
/// with @protocol keyword, so that we can emit errors on duplicates and
|
2007-10-10 02:18:24 +08:00
|
|
|
/// find the declarations when needed.
|
2008-01-08 03:49:32 +08:00
|
|
|
llvm::DenseMap<IdentifierInfo*, ObjCProtocolDecl*> ObjCProtocols;
|
2008-04-03 02:30:49 +08:00
|
|
|
|
|
|
|
/// ObjCInterfaceDecls - Keep track of all class declarations declared
|
|
|
|
/// with @interface, so that we can emit errors on duplicates and
|
|
|
|
/// find the declarations when needed.
|
|
|
|
typedef llvm::DenseMap<const IdentifierInfo*,
|
|
|
|
ObjCInterfaceDecl*> ObjCInterfaceDeclsTy;
|
|
|
|
ObjCInterfaceDeclsTy ObjCInterfaceDecls;
|
|
|
|
|
2008-04-02 07:04:06 +08:00
|
|
|
/// ObjCAliasDecls - Keep track of all class declarations declared
|
|
|
|
/// with @compatibility_alias, so that we can emit errors on duplicates and
|
|
|
|
/// find the declarations when needed. This construct is ancient and will
|
|
|
|
/// likely never be seen. Nevertheless, it is here for compatibility.
|
2008-04-02 08:39:51 +08:00
|
|
|
typedef llvm::DenseMap<const IdentifierInfo*,
|
|
|
|
ObjCCompatibleAliasDecl*> ObjCAliasTy;
|
2008-04-02 07:04:06 +08:00
|
|
|
ObjCAliasTy ObjCAliasDecls;
|
2008-04-03 02:30:49 +08:00
|
|
|
|
2008-04-11 15:00:53 +08:00
|
|
|
IdentifierResolver IdResolver;
|
|
|
|
|
2007-08-11 04:18:51 +08:00
|
|
|
// Enum values used by KnownFunctionIDs (see below).
|
|
|
|
enum {
|
|
|
|
id_printf,
|
|
|
|
id_fprintf,
|
|
|
|
id_sprintf,
|
|
|
|
id_snprintf,
|
|
|
|
id_asprintf,
|
2008-06-17 02:00:42 +08:00
|
|
|
id_NSLog,
|
2007-08-11 05:13:51 +08:00
|
|
|
id_vsnprintf,
|
2007-08-11 04:18:51 +08:00
|
|
|
id_vasprintf,
|
|
|
|
id_vfprintf,
|
|
|
|
id_vsprintf,
|
|
|
|
id_vprintf,
|
|
|
|
id_num_known_functions
|
|
|
|
};
|
|
|
|
|
|
|
|
/// KnownFunctionIDs - This is a list of IdentifierInfo objects to a set
|
|
|
|
/// of known functions used by the semantic analysis to do various
|
|
|
|
/// kinds of checking (e.g. checking format string errors in printf calls).
|
|
|
|
/// This list is populated upon the creation of a Sema object.
|
|
|
|
IdentifierInfo* KnownFunctionIDs[ id_num_known_functions ];
|
|
|
|
|
2007-10-11 01:32:04 +08:00
|
|
|
/// Translation Unit Scope - useful to Objective-C actions that need
|
|
|
|
/// to lookup file scope declarations in the "ordinary" C decl namespace.
|
|
|
|
/// For example, user-defined classes, built-in "id" type, etc.
|
2007-10-10 06:01:59 +08:00
|
|
|
Scope *TUScope;
|
2007-10-11 05:53:07 +08:00
|
|
|
|
2007-10-14 08:58:41 +08:00
|
|
|
/// ObjCMethodList - a linked list of methods with different signatures.
|
2008-01-08 03:49:32 +08:00
|
|
|
struct ObjCMethodList {
|
|
|
|
ObjCMethodDecl *Method;
|
|
|
|
ObjCMethodList *Next;
|
2007-10-14 08:58:41 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
ObjCMethodList() {
|
2007-10-14 08:58:41 +08:00
|
|
|
Method = 0;
|
|
|
|
Next = 0;
|
|
|
|
}
|
2008-01-08 03:49:32 +08:00
|
|
|
ObjCMethodList(ObjCMethodDecl *M, ObjCMethodList *C) {
|
2007-10-14 08:58:41 +08:00
|
|
|
Method = M;
|
|
|
|
Next = C;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/// Instance/Factory Method Pools - allows efficient lookup when typechecking
|
|
|
|
/// messages to "id". We need to maintain a list, since selectors can have
|
|
|
|
/// differing signatures across classes. In Cocoa, this happens to be
|
|
|
|
/// extremely uncommon (only 1% of selectors are "overloaded").
|
2008-01-08 03:49:32 +08:00
|
|
|
llvm::DenseMap<Selector, ObjCMethodList> InstanceMethodPool;
|
|
|
|
llvm::DenseMap<Selector, ObjCMethodList> FactoryMethodPool;
|
2006-11-03 14:42:29 +08:00
|
|
|
public:
|
2008-02-06 08:46:58 +08:00
|
|
|
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer);
|
2006-11-03 14:42:29 +08:00
|
|
|
|
2006-11-20 14:49:47 +08:00
|
|
|
const LangOptions &getLangOptions() const;
|
|
|
|
|
2007-05-19 06:53:50 +08:00
|
|
|
/// The primitive diagnostic helpers - always returns true, which simplifies
|
|
|
|
/// error handling (i.e. less code).
|
2007-05-17 01:56:50 +08:00
|
|
|
bool Diag(SourceLocation Loc, unsigned DiagID);
|
|
|
|
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg);
|
|
|
|
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
|
|
|
|
const std::string &Msg2);
|
2007-05-19 06:53:50 +08:00
|
|
|
|
|
|
|
/// More expressive diagnostic helpers for expressions (say that 6 times:-)
|
|
|
|
bool Diag(SourceLocation Loc, unsigned DiagID, SourceRange R1);
|
|
|
|
bool Diag(SourceLocation Loc, unsigned DiagID,
|
|
|
|
SourceRange R1, SourceRange R2);
|
|
|
|
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
|
|
|
|
SourceRange R1);
|
|
|
|
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
|
|
|
|
SourceRange R1, SourceRange R2);
|
|
|
|
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
|
|
|
|
const std::string &Msg2, SourceRange R1);
|
2008-01-04 07:38:43 +08:00
|
|
|
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
|
|
|
|
const std::string &Msg2, const std::string &Msg3, SourceRange R1);
|
2007-05-19 06:53:50 +08:00
|
|
|
bool Diag(SourceLocation Loc, unsigned DiagID,
|
|
|
|
const std::string &Msg1, const std::string &Msg2,
|
|
|
|
SourceRange R1, SourceRange R2);
|
2007-09-29 08:54:24 +08:00
|
|
|
|
2007-08-31 12:53:24 +08:00
|
|
|
virtual void DeleteExpr(ExprTy *E);
|
|
|
|
virtual void DeleteStmt(StmtTy *S);
|
|
|
|
|
2006-11-12 06:59:23 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Type Analysis / Processing: SemaType.cpp.
|
|
|
|
//
|
2008-06-26 14:27:57 +08:00
|
|
|
QualType ConvertDeclSpecToType(const DeclSpec &DS);
|
|
|
|
void ProcessTypeAttributes(QualType &Result, const AttributeList *AL);
|
2007-04-06 06:36:20 +08:00
|
|
|
QualType GetTypeForDeclarator(Declarator &D, Scope *S);
|
2008-02-21 09:07:18 +08:00
|
|
|
|
2006-11-12 06:59:23 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
QualType ObjCGetTypeForMethodDefinition(DeclTy *D);
|
2007-11-09 07:49:49 +08:00
|
|
|
|
|
|
|
|
2007-09-16 02:49:24 +08:00
|
|
|
virtual TypeResult ActOnTypeName(Scope *S, Declarator &D);
|
2007-03-22 05:08:52 +08:00
|
|
|
private:
|
2006-11-03 14:42:29 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2006-11-10 13:29:30 +08:00
|
|
|
// Symbol table / Decl tracking callbacks: SemaDecl.cpp.
|
2006-11-03 14:42:29 +08:00
|
|
|
//
|
2008-04-02 22:35:35 +08:00
|
|
|
virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S);
|
2007-09-16 02:49:24 +08:00
|
|
|
virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup);
|
2008-04-08 12:40:51 +08:00
|
|
|
virtual DeclTy *ActOnParamDeclarator(Scope *S, Declarator &D);
|
|
|
|
virtual void ActOnParamDefaultArgument(DeclTy *param,
|
|
|
|
SourceLocation EqualLoc,
|
|
|
|
ExprTy *defarg);
|
2007-09-12 22:07:44 +08:00
|
|
|
void AddInitializerToDecl(DeclTy *dcl, ExprTy *init);
|
2007-06-09 08:53:06 +08:00
|
|
|
virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group);
|
|
|
|
|
2007-10-10 01:14:05 +08:00
|
|
|
virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, Declarator &D);
|
2008-06-25 06:12:16 +08:00
|
|
|
// Until 'real' implementation is in place, override both
|
|
|
|
// 'ActOnStartOfFunctionDef' to satisfy the compiler.
|
|
|
|
virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, DeclTy *D) { return D; }
|
2008-01-08 03:49:32 +08:00
|
|
|
virtual void ObjCActOnStartOfMethodDef(Scope *S, DeclTy *D);
|
2007-11-12 07:20:51 +08:00
|
|
|
|
|
|
|
virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtTy *Body);
|
2008-01-12 15:05:38 +08:00
|
|
|
virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, SourceLocation LBrace,
|
2008-02-21 06:57:40 +08:00
|
|
|
SourceLocation RBrace, const char *Lang,
|
|
|
|
unsigned StrSize, DeclTy *D);
|
2008-02-08 08:33:21 +08:00
|
|
|
virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprTy *expr);
|
|
|
|
|
2007-10-10 06:01:59 +08:00
|
|
|
/// Scope actions.
|
|
|
|
virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
|
|
|
|
virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S);
|
2007-01-28 03:27:06 +08:00
|
|
|
|
2006-11-19 10:43:37 +08:00
|
|
|
/// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
|
|
|
|
/// no declarator (e.g. "struct foo;") is parsed.
|
|
|
|
virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS);
|
|
|
|
|
2007-09-16 02:49:24 +08:00
|
|
|
virtual DeclTy *ActOnTag(Scope *S, unsigned TagType, TagKind TK,
|
2007-01-23 12:08:05 +08:00
|
|
|
SourceLocation KWLoc, IdentifierInfo *Name,
|
2007-06-09 11:47:53 +08:00
|
|
|
SourceLocation NameLoc, AttributeList *Attr);
|
2008-06-22 03:39:06 +08:00
|
|
|
virtual void ActOnDefs(Scope *S, SourceLocation DeclStart, IdentifierInfo
|
|
|
|
*ClassName, llvm::SmallVector<DeclTy*, 16> &Decls);
|
2008-04-11 07:32:45 +08:00
|
|
|
virtual DeclTy *ActOnField(Scope *S, SourceLocation DeclStart,
|
2007-01-24 07:42:53 +08:00
|
|
|
Declarator &D, ExprTy *BitfieldWidth);
|
2008-04-11 07:32:45 +08:00
|
|
|
|
|
|
|
virtual DeclTy *ActOnIvar(Scope *S, SourceLocation DeclStart,
|
|
|
|
Declarator &D, ExprTy *BitfieldWidth,
|
2008-04-12 00:55:42 +08:00
|
|
|
tok::ObjCKeywordKind visibility);
|
2008-04-11 07:32:45 +08:00
|
|
|
|
2007-09-15 07:09:53 +08:00
|
|
|
// This is used for both record definitions and ObjC interface declarations.
|
2007-09-29 08:54:24 +08:00
|
|
|
virtual void ActOnFields(Scope* S,
|
2007-10-30 05:38:07 +08:00
|
|
|
SourceLocation RecLoc, DeclTy *TagDecl,
|
|
|
|
DeclTy **Fields, unsigned NumFields,
|
2008-04-11 07:32:45 +08:00
|
|
|
SourceLocation LBrac, SourceLocation RBrac);
|
2007-09-16 02:49:24 +08:00
|
|
|
virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl,
|
2007-06-11 09:28:17 +08:00
|
|
|
DeclTy *LastEnumConstant,
|
2007-01-25 15:29:02 +08:00
|
|
|
SourceLocation IdLoc, IdentifierInfo *Id,
|
|
|
|
SourceLocation EqualLoc, ExprTy *Val);
|
2007-09-16 02:49:24 +08:00
|
|
|
virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
|
2007-01-25 15:29:02 +08:00
|
|
|
DeclTy **Elements, unsigned NumElements);
|
2007-03-15 05:52:03 +08:00
|
|
|
private:
|
2008-04-04 14:12:32 +08:00
|
|
|
/// Set the current declaration context until it gets popped.
|
2008-04-23 02:39:57 +08:00
|
|
|
void PushDeclContext(DeclContext *DC);
|
2008-04-06 12:47:34 +08:00
|
|
|
void PopDeclContext();
|
2008-06-28 14:07:14 +08:00
|
|
|
|
|
|
|
/// CurFunctionDecl - If inside of a function body, this returns a pointer to
|
|
|
|
/// the function decl for the function being parsed.
|
|
|
|
FunctionDecl *getCurFunctionDecl() {
|
|
|
|
return dyn_cast<FunctionDecl>(CurContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// CurMethodDecl - If inside of a method body, this returns a pointer to
|
|
|
|
/// the method decl for the method being parsed.
|
|
|
|
ObjCMethodDecl *getCurMethodDecl() {
|
|
|
|
return dyn_cast<ObjCMethodDecl>(CurContext);
|
|
|
|
}
|
2008-04-04 14:12:32 +08:00
|
|
|
|
2008-04-12 08:47:19 +08:00
|
|
|
/// Add this decl to the scope shadowed decl chains.
|
|
|
|
void PushOnScopeChains(NamedDecl *D, Scope *S);
|
|
|
|
|
2008-02-21 09:07:18 +08:00
|
|
|
/// Subroutines of ActOnDeclarator().
|
2007-11-14 14:34:38 +08:00
|
|
|
TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
|
|
|
|
ScopedDecl *LastDecl);
|
2008-04-02 07:04:06 +08:00
|
|
|
TypedefDecl *MergeTypeDefDecl(TypedefDecl *New, Decl *Old);
|
2008-04-21 10:02:58 +08:00
|
|
|
FunctionDecl *MergeFunctionDecl(FunctionDecl *New, Decl *Old,
|
|
|
|
bool &Redeclaration);
|
2008-04-02 07:04:06 +08:00
|
|
|
VarDecl *MergeVarDecl(VarDecl *New, Decl *Old);
|
2008-04-08 12:40:51 +08:00
|
|
|
FunctionDecl *MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old);
|
|
|
|
|
|
|
|
/// Helpers for dealing with function parameters
|
|
|
|
bool CheckParmsForFunctionDef(FunctionDecl *FD);
|
2008-06-18 02:05:57 +08:00
|
|
|
ImplicitParamDecl *CreateImplicitParameter(Scope *S, IdentifierInfo *Id,
|
2008-04-08 12:40:51 +08:00
|
|
|
SourceLocation IdLoc, QualType Type);
|
|
|
|
void CheckCXXDefaultArguments(FunctionDecl *FD);
|
2008-05-07 12:49:29 +08:00
|
|
|
void CheckExtraCXXDefaultArguments(Declarator &D);
|
2007-03-16 08:33:25 +08:00
|
|
|
|
2007-03-15 05:52:03 +08:00
|
|
|
/// More parsing and symbol table subroutines...
|
2008-04-02 22:35:35 +08:00
|
|
|
Decl *LookupDecl(const IdentifierInfo *II, unsigned NSI, Scope *S,
|
|
|
|
bool enableLazyBuiltinCreation = true);
|
2008-01-08 03:49:32 +08:00
|
|
|
ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *Id);
|
2008-04-02 22:35:35 +08:00
|
|
|
ScopedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
|
|
|
|
Scope *S);
|
2007-09-17 00:16:00 +08:00
|
|
|
ScopedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
|
2007-03-15 05:52:03 +08:00
|
|
|
Scope *S);
|
2007-06-11 08:35:03 +08:00
|
|
|
// Decl attributes - this routine is the top level dispatcher.
|
2008-06-29 08:16:31 +08:00
|
|
|
void ProcessDeclAttributes(Decl *D, const Declarator &PD);
|
2008-06-29 07:58:55 +08:00
|
|
|
void ProcessDeclAttributeList(Decl *D, const AttributeList *AttrList);
|
2008-02-04 10:31:56 +08:00
|
|
|
|
|
|
|
/// HandleAddressSpaceTypeAttribute - this attribute is only applicable to
|
|
|
|
/// objects without automatic storage duration.
|
|
|
|
/// The raw attribute contains 1 argument, the id of the address space
|
|
|
|
/// for the type.
|
|
|
|
QualType HandleAddressSpaceTypeAttribute(QualType curType,
|
2008-06-29 07:36:30 +08:00
|
|
|
const AttributeList &Attr);
|
2008-02-16 08:29:18 +08:00
|
|
|
|
2008-02-11 05:38:56 +08:00
|
|
|
void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
|
|
|
|
bool &IncompleteImpl);
|
|
|
|
|
2007-09-30 01:14:55 +08:00
|
|
|
/// CheckProtocolMethodDefs - This routine checks unimpletented methods
|
|
|
|
/// Declared in protocol, and those referenced by it.
|
2008-02-09 06:06:17 +08:00
|
|
|
void CheckProtocolMethodDefs(SourceLocation ImpLoc,
|
|
|
|
ObjCProtocolDecl *PDecl,
|
2007-10-03 04:06:01 +08:00
|
|
|
bool& IncompleteImpl,
|
2007-10-09 05:05:34 +08:00
|
|
|
const llvm::DenseSet<Selector> &InsMap,
|
2007-10-06 04:15:24 +08:00
|
|
|
const llvm::DenseSet<Selector> &ClsMap);
|
2007-09-30 01:14:55 +08:00
|
|
|
|
2007-10-03 05:43:37 +08:00
|
|
|
/// CheckImplementationIvars - This routine checks if the instance variables
|
|
|
|
/// listed in the implelementation match those listed in the interface.
|
2008-01-08 03:49:32 +08:00
|
|
|
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
|
|
|
|
ObjCIvarDecl **Fields, unsigned nIvars,
|
2008-02-11 05:38:56 +08:00
|
|
|
SourceLocation Loc);
|
2007-10-03 05:43:37 +08:00
|
|
|
|
2007-09-30 01:14:55 +08:00
|
|
|
/// ImplMethodsVsClassMethods - This is main routine to warn if any method
|
|
|
|
/// remains unimplemented in the @implementation class.
|
2008-01-08 03:49:32 +08:00
|
|
|
void ImplMethodsVsClassMethods(ObjCImplementationDecl* IMPDecl,
|
|
|
|
ObjCInterfaceDecl* IDecl);
|
2007-09-30 01:14:55 +08:00
|
|
|
|
2007-10-03 00:38:50 +08:00
|
|
|
/// ImplCategoryMethodsVsIntfMethods - Checks that methods declared in the
|
|
|
|
/// category interface is implemented in the category @implementation.
|
2008-01-08 03:49:32 +08:00
|
|
|
void ImplCategoryMethodsVsIntfMethods(ObjCCategoryImplDecl *CatImplDecl,
|
|
|
|
ObjCCategoryDecl *CatClassDecl);
|
2007-10-06 02:00:57 +08:00
|
|
|
/// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
|
|
|
|
/// true, or false, accordingly.
|
2008-01-08 03:49:32 +08:00
|
|
|
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
|
|
|
|
const ObjCMethodDecl *PrevMethod);
|
2007-10-11 05:53:07 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
/// isBuiltinObjCType - Returns true of the type is "id", "SEL", "Class"
|
2007-12-07 08:18:54 +08:00
|
|
|
/// or "Protocol".
|
2008-01-08 03:49:32 +08:00
|
|
|
bool isBuiltinObjCType(TypedefDecl *TD);
|
2008-01-04 08:27:46 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
/// isObjCObjectPointerType - Returns true if type is an objective-c pointer
|
2008-01-04 08:27:46 +08:00
|
|
|
/// to an object type; such as "id", "Class", Intf*, id<P>, etc.
|
2008-01-08 03:49:32 +08:00
|
|
|
bool isObjCObjectPointerType(QualType type) const;
|
2007-10-31 10:53:19 +08:00
|
|
|
|
2007-10-14 08:58:41 +08:00
|
|
|
/// AddInstanceMethodToGlobalPool - All instance methods in a translation
|
|
|
|
/// unit are added to a global pool. This allows us to efficiently associate
|
|
|
|
/// a selector with a method declaraation for purposes of typechecking
|
|
|
|
/// messages sent to "id" (where the class of the object is unknown).
|
2008-01-08 03:49:32 +08:00
|
|
|
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method);
|
2007-10-14 08:58:41 +08:00
|
|
|
|
|
|
|
/// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
|
2008-01-08 03:49:32 +08:00
|
|
|
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method);
|
2006-11-03 14:42:29 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2006-11-10 13:29:30 +08:00
|
|
|
// Statement Parsing Callbacks: SemaStmt.cpp.
|
2007-03-15 05:52:03 +08:00
|
|
|
public:
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnExprStmt(ExprTy *Expr);
|
2007-06-27 13:38:08 +08:00
|
|
|
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnNullStmt(SourceLocation SemiLoc);
|
|
|
|
virtual StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
|
2007-09-01 05:49:55 +08:00
|
|
|
StmtTy **Elts, unsigned NumElts,
|
|
|
|
bool isStmtExpr);
|
2008-03-13 14:29:04 +08:00
|
|
|
virtual StmtResult ActOnDeclStmt(DeclTy *Decl, SourceLocation StartLoc,
|
|
|
|
SourceLocation EndLoc);
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
|
2006-11-05 08:19:50 +08:00
|
|
|
SourceLocation DotDotDotLoc, ExprTy *RHSVal,
|
|
|
|
SourceLocation ColonLoc, StmtTy *SubStmt);
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
|
2007-07-18 10:28:47 +08:00
|
|
|
SourceLocation ColonLoc, StmtTy *SubStmt,
|
|
|
|
Scope *CurScope);
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
|
2006-11-05 08:19:50 +08:00
|
|
|
SourceLocation ColonLoc, StmtTy *SubStmt);
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
|
2006-11-03 14:42:29 +08:00
|
|
|
StmtTy *ThenVal, SourceLocation ElseLoc,
|
|
|
|
StmtTy *ElseVal);
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnStartOfSwitchStmt(ExprTy *Cond);
|
2007-10-06 04:15:24 +08:00
|
|
|
virtual StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
|
|
|
|
StmtTy *Switch, ExprTy *Body);
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
|
2006-11-05 04:40:44 +08:00
|
|
|
StmtTy *Body);
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body,
|
2006-11-05 04:40:44 +08:00
|
|
|
SourceLocation WhileLoc, ExprTy *Cond);
|
|
|
|
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnForStmt(SourceLocation ForLoc,
|
2006-11-05 04:18:38 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
StmtTy *First, ExprTy *Second, ExprTy *Third,
|
|
|
|
SourceLocation RParenLoc, StmtTy *Body);
|
2008-01-08 03:49:32 +08:00
|
|
|
virtual StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
|
2008-01-04 01:55:25 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
StmtTy *First, ExprTy *Second,
|
|
|
|
SourceLocation RParenLoc, StmtTy *Body);
|
|
|
|
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
|
2006-11-05 09:46:01 +08:00
|
|
|
SourceLocation LabelLoc,
|
|
|
|
IdentifierInfo *LabelII);
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
|
2006-11-05 09:46:01 +08:00
|
|
|
SourceLocation StarLoc,
|
|
|
|
ExprTy *DestExp);
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
|
2006-11-10 13:17:58 +08:00
|
|
|
Scope *CurScope);
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnBreakStmt(SourceLocation GotoLoc, Scope *CurScope);
|
2006-11-05 04:18:38 +08:00
|
|
|
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual StmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
|
2006-11-03 14:42:29 +08:00
|
|
|
ExprTy *RetValExp);
|
|
|
|
|
2007-11-21 03:21:03 +08:00
|
|
|
virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
|
2008-02-06 07:03:50 +08:00
|
|
|
bool IsSimple,
|
2007-11-24 07:12:25 +08:00
|
|
|
bool IsVolatile,
|
2007-11-22 09:36:19 +08:00
|
|
|
unsigned NumOutputs,
|
|
|
|
unsigned NumInputs,
|
|
|
|
std::string *Names,
|
|
|
|
ExprTy **Constraints,
|
|
|
|
ExprTy **Exprs,
|
2007-11-21 03:21:03 +08:00
|
|
|
ExprTy *AsmString,
|
2007-11-22 09:36:19 +08:00
|
|
|
unsigned NumClobbers,
|
|
|
|
ExprTy **Clobbers,
|
2007-10-29 12:04:16 +08:00
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
|
2007-11-02 07:59:59 +08:00
|
|
|
SourceLocation RParen, StmtTy *Parm,
|
|
|
|
StmtTy *Body, StmtTy *CatchList);
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
virtual StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
|
2007-11-02 08:18:53 +08:00
|
|
|
StmtTy *Body);
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
virtual StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
|
2007-11-02 23:39:31 +08:00
|
|
|
StmtTy *Try,
|
|
|
|
StmtTy *Catch, StmtTy *Finally);
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
virtual StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
|
2007-11-07 10:00:49 +08:00
|
|
|
StmtTy *Throw);
|
2008-01-30 03:14:59 +08:00
|
|
|
virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
|
|
|
|
ExprTy *SynchExpr,
|
|
|
|
StmtTy *SynchBody);
|
2007-11-07 10:00:49 +08:00
|
|
|
|
2006-11-03 14:42:29 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2006-11-10 13:29:30 +08:00
|
|
|
// Expression Parsing Callbacks: SemaExpr.cpp.
|
2006-11-03 14:42:29 +08:00
|
|
|
|
|
|
|
// Primary Expressions.
|
2007-09-16 02:49:24 +08:00
|
|
|
virtual ExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
|
2006-11-20 14:49:47 +08:00
|
|
|
IdentifierInfo &II,
|
|
|
|
bool HasTrailingLParen);
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnPreDefinedExpr(SourceLocation Loc,
|
2006-11-03 14:42:29 +08:00
|
|
|
tok::TokenKind Kind);
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnNumericConstant(const Token &);
|
|
|
|
virtual ExprResult ActOnCharacterConstant(const Token &);
|
|
|
|
virtual ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
|
2006-11-03 14:42:29 +08:00
|
|
|
ExprTy *Val);
|
2006-11-09 14:32:27 +08:00
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
/// ActOnStringLiteral - The specified tokens were lexed as pasted string
|
2006-11-09 14:32:27 +08:00
|
|
|
/// fragments (e.g. "foo" "bar" L"baz").
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnStringLiteral(const Token *Toks, unsigned NumToks);
|
2006-11-09 14:32:27 +08:00
|
|
|
|
2006-11-03 14:42:29 +08:00
|
|
|
// Binary/Unary Operators. 'Tok' is the token for the operator.
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
|
2006-11-03 14:42:29 +08:00
|
|
|
ExprTy *Input);
|
|
|
|
virtual ExprResult
|
2007-09-16 11:34:24 +08:00
|
|
|
ActOnSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
|
2006-11-03 14:42:29 +08:00
|
|
|
SourceLocation LParenLoc, TypeTy *Ty,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnPostfixUnaryOp(SourceLocation OpLoc,
|
2006-11-03 14:42:29 +08:00
|
|
|
tok::TokenKind Kind, ExprTy *Input);
|
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
|
2006-11-03 14:42:29 +08:00
|
|
|
ExprTy *Idx, SourceLocation RLoc);
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc,
|
2006-11-03 14:42:29 +08:00
|
|
|
tok::TokenKind OpKind,
|
|
|
|
SourceLocation MemberLoc,
|
|
|
|
IdentifierInfo &Member);
|
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
/// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
|
2006-11-03 14:42:29 +08:00
|
|
|
/// This provides the location of the left/right parens and a list of comma
|
|
|
|
/// locations.
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
|
2006-11-03 14:42:29 +08:00
|
|
|
ExprTy **Args, unsigned NumArgs,
|
|
|
|
SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
|
2006-11-03 14:42:29 +08:00
|
|
|
SourceLocation RParenLoc, ExprTy *Op);
|
2007-07-19 09:06:55 +08:00
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
|
2007-07-19 09:06:55 +08:00
|
|
|
SourceLocation RParenLoc, ExprTy *Op);
|
2006-11-03 14:42:29 +08:00
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnInitList(SourceLocation LParenLoc,
|
2007-07-19 09:06:55 +08:00
|
|
|
ExprTy **InitList, unsigned NumInit,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
|
2006-11-03 14:42:29 +08:00
|
|
|
ExprTy *LHS,ExprTy *RHS);
|
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
/// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
|
2006-11-03 14:42:29 +08:00
|
|
|
/// in the case of a the GNU conditional expr extension.
|
2007-09-16 11:34:24 +08:00
|
|
|
virtual ExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
|
2006-11-03 14:42:29 +08:00
|
|
|
SourceLocation ColonLoc,
|
|
|
|
ExprTy *Cond, ExprTy *LHS, ExprTy *RHS);
|
2006-12-05 02:06:35 +08:00
|
|
|
|
2007-09-16 22:56:35 +08:00
|
|
|
/// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
|
|
|
|
virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
|
2007-05-28 14:56:27 +08:00
|
|
|
IdentifierInfo *LabelII);
|
|
|
|
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual ExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt,
|
2007-07-25 00:58:17 +08:00
|
|
|
SourceLocation RPLoc); // "({..})"
|
2007-08-31 01:45:32 +08:00
|
|
|
|
|
|
|
/// __builtin_offsetof(type, a.b[123][456].c)
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual ExprResult ActOnBuiltinOffsetOf(SourceLocation BuiltinLoc,
|
2007-08-31 01:45:32 +08:00
|
|
|
SourceLocation TypeLoc, TypeTy *Arg1,
|
|
|
|
OffsetOfComponent *CompPtr,
|
|
|
|
unsigned NumComponents,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2007-08-02 06:05:33 +08:00
|
|
|
// __builtin_types_compatible_p(type1, type2)
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
|
2007-08-02 06:05:33 +08:00
|
|
|
TypeTy *arg1, TypeTy *arg2,
|
|
|
|
SourceLocation RPLoc);
|
2007-08-04 05:21:27 +08:00
|
|
|
|
|
|
|
// __builtin_choose_expr(constExpr, expr1, expr2)
|
2007-09-16 22:56:35 +08:00
|
|
|
virtual ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
|
2007-08-04 05:21:27 +08:00
|
|
|
ExprTy *cond, ExprTy *expr1, ExprTy *expr2,
|
|
|
|
SourceLocation RPLoc);
|
2007-07-25 00:58:17 +08:00
|
|
|
|
2008-01-18 01:46:27 +08:00
|
|
|
// __builtin_overload(...)
|
|
|
|
virtual ExprResult ActOnOverloadExpr(ExprTy **Args, unsigned NumArgs,
|
|
|
|
SourceLocation *CommaLocs,
|
|
|
|
SourceLocation BuiltinLoc,
|
|
|
|
SourceLocation RParenLoc);
|
2008-03-08 04:04:22 +08:00
|
|
|
|
2007-10-16 04:28:48 +08:00
|
|
|
// __builtin_va_arg(expr, type)
|
|
|
|
virtual ExprResult ActOnVAArg(SourceLocation BuiltinLoc,
|
|
|
|
ExprTy *expr, TypeTy *type,
|
|
|
|
SourceLocation RPLoc);
|
|
|
|
|
2008-04-27 21:50:30 +08:00
|
|
|
// Act on C++ namespaces
|
|
|
|
virtual DeclTy *ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
|
|
|
|
IdentifierInfo *Ident,
|
|
|
|
SourceLocation LBrace);
|
|
|
|
virtual void ActOnFinishNamespaceDef(DeclTy *Dcl, SourceLocation RBrace);
|
|
|
|
|
2007-09-16 22:56:35 +08:00
|
|
|
/// ActOnCXXCasts - Parse {dynamic,static,reinterpret,const}_cast's.
|
|
|
|
virtual ExprResult ActOnCXXCasts(SourceLocation OpLoc, tok::TokenKind Kind,
|
2006-12-05 02:06:35 +08:00
|
|
|
SourceLocation LAngleBracketLoc, TypeTy *Ty,
|
|
|
|
SourceLocation RAngleBracketLoc,
|
|
|
|
SourceLocation LParenLoc, ExprTy *E,
|
|
|
|
SourceLocation RParenLoc);
|
2007-02-13 09:51:42 +08:00
|
|
|
|
2007-09-16 22:56:35 +08:00
|
|
|
/// ActOnCXXBoolLiteral - Parse {true,false} literals.
|
|
|
|
virtual ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc,
|
2007-02-14 04:09:46 +08:00
|
|
|
tok::TokenKind Kind);
|
2007-08-22 01:43:55 +08:00
|
|
|
|
2008-02-26 08:51:44 +08:00
|
|
|
//// ActOnCXXThrow - Parse throw expressions.
|
|
|
|
virtual ExprResult ActOnCXXThrow(SourceLocation OpLoc,
|
|
|
|
ExprTy *expr);
|
|
|
|
|
2007-08-22 01:43:55 +08:00
|
|
|
// ParseObjCStringLiteral - Parse Objective-C string literals.
|
2007-12-12 09:04:12 +08:00
|
|
|
virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
|
|
|
|
ExprTy **Strings,
|
|
|
|
unsigned NumStrings);
|
2007-08-22 23:14:15 +08:00
|
|
|
virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
|
2007-10-17 06:51:17 +08:00
|
|
|
SourceLocation EncodeLoc,
|
2007-08-22 23:14:15 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
TypeTy *Ty,
|
|
|
|
SourceLocation RParenLoc);
|
2007-10-17 04:40:23 +08:00
|
|
|
|
|
|
|
// ParseObjCSelectorExpression - Build selector expression for @selector
|
|
|
|
virtual ExprResult ParseObjCSelectorExpression(Selector Sel,
|
|
|
|
SourceLocation AtLoc,
|
2007-10-17 07:21:02 +08:00
|
|
|
SourceLocation SelLoc,
|
2007-10-17 04:40:23 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc);
|
2007-08-22 23:14:15 +08:00
|
|
|
|
2007-10-18 00:58:11 +08:00
|
|
|
// ParseObjCProtocolExpression - Build protocol expression for @protocol
|
|
|
|
virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
|
|
|
|
SourceLocation AtLoc,
|
|
|
|
SourceLocation ProtoLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc);
|
2008-04-14 05:30:24 +08:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Classes
|
|
|
|
//
|
|
|
|
/// ActOnBaseSpecifier - Parsed a base specifier
|
|
|
|
virtual void ActOnBaseSpecifier(DeclTy *classdecl, SourceRange SpecifierRange,
|
|
|
|
bool Virtual, AccessSpecifier Access,
|
|
|
|
DeclTy *basetype, SourceLocation BaseLoc);
|
2007-10-18 00:58:11 +08:00
|
|
|
|
2008-04-14 05:30:24 +08:00
|
|
|
|
2007-09-07 05:24:23 +08:00
|
|
|
// Objective-C declarations.
|
2007-10-11 01:32:04 +08:00
|
|
|
virtual DeclTy *ActOnStartClassInterface(
|
2008-02-21 06:57:40 +08:00
|
|
|
SourceLocation AtInterafceLoc,
|
2007-09-07 05:24:23 +08:00
|
|
|
IdentifierInfo *ClassName, SourceLocation ClassLoc,
|
|
|
|
IdentifierInfo *SuperName, SourceLocation SuperLoc,
|
|
|
|
IdentifierInfo **ProtocolNames, unsigned NumProtocols,
|
2007-10-30 10:23:23 +08:00
|
|
|
SourceLocation EndProtoLoc, AttributeList *AttrList);
|
2007-10-12 07:42:27 +08:00
|
|
|
|
|
|
|
virtual DeclTy *ActOnCompatiblityAlias(
|
|
|
|
SourceLocation AtCompatibilityAliasLoc,
|
|
|
|
IdentifierInfo *AliasName, SourceLocation AliasLocation,
|
|
|
|
IdentifierInfo *ClassName, SourceLocation ClassLocation);
|
2007-09-07 05:24:23 +08:00
|
|
|
|
2007-10-11 01:32:04 +08:00
|
|
|
virtual DeclTy *ActOnStartProtocolInterface(
|
2008-02-21 06:57:40 +08:00
|
|
|
SourceLocation AtProtoInterfaceLoc,
|
2007-09-18 05:07:36 +08:00
|
|
|
IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
|
2007-10-30 10:23:23 +08:00
|
|
|
IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs,
|
|
|
|
SourceLocation EndProtoLoc);
|
2007-09-18 05:07:36 +08:00
|
|
|
|
2007-10-11 01:32:04 +08:00
|
|
|
virtual DeclTy *ActOnStartCategoryInterface(
|
2008-02-21 06:57:40 +08:00
|
|
|
SourceLocation AtInterfaceLoc,
|
2007-09-19 04:26:58 +08:00
|
|
|
IdentifierInfo *ClassName, SourceLocation ClassLoc,
|
|
|
|
IdentifierInfo *CategoryName, SourceLocation CategoryLoc,
|
2007-10-30 21:30:57 +08:00
|
|
|
IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs,
|
|
|
|
SourceLocation EndProtoLoc);
|
2007-09-19 04:26:58 +08:00
|
|
|
|
2007-10-11 01:32:04 +08:00
|
|
|
virtual DeclTy *ActOnStartClassImplementation(
|
2008-02-21 06:57:40 +08:00
|
|
|
SourceLocation AtClassImplLoc,
|
2007-09-26 02:38:09 +08:00
|
|
|
IdentifierInfo *ClassName, SourceLocation ClassLoc,
|
|
|
|
IdentifierInfo *SuperClassname,
|
|
|
|
SourceLocation SuperClassLoc);
|
|
|
|
|
2007-10-11 01:32:04 +08:00
|
|
|
virtual DeclTy *ActOnStartCategoryImplementation(
|
2007-10-03 00:38:50 +08:00
|
|
|
SourceLocation AtCatImplLoc,
|
|
|
|
IdentifierInfo *ClassName,
|
|
|
|
SourceLocation ClassLoc,
|
|
|
|
IdentifierInfo *CatName,
|
|
|
|
SourceLocation CatLoc);
|
|
|
|
|
2007-10-11 01:32:04 +08:00
|
|
|
virtual DeclTy *ActOnForwardClassDeclaration(SourceLocation Loc,
|
2007-10-03 06:39:18 +08:00
|
|
|
IdentifierInfo **IdentList,
|
|
|
|
unsigned NumElts);
|
|
|
|
|
2007-10-11 01:32:04 +08:00
|
|
|
virtual DeclTy *ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
|
2007-10-03 06:39:18 +08:00
|
|
|
IdentifierInfo **IdentList,
|
|
|
|
unsigned NumElts);
|
2007-10-06 05:01:53 +08:00
|
|
|
|
2007-10-11 08:55:41 +08:00
|
|
|
virtual void FindProtocolDeclaration(SourceLocation TypeLoc,
|
|
|
|
IdentifierInfo **ProtocolId,
|
|
|
|
unsigned NumProtocols,
|
|
|
|
llvm::SmallVector<DeclTy *, 8> &
|
|
|
|
Protocols);
|
2008-05-01 08:03:38 +08:00
|
|
|
|
|
|
|
void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
|
|
|
|
ObjCPropertyDecl *SuperProperty,
|
2008-05-03 03:17:30 +08:00
|
|
|
const char *Name);
|
2008-05-01 08:03:38 +08:00
|
|
|
void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl);
|
2008-04-25 03:58:34 +08:00
|
|
|
|
2008-05-03 03:17:30 +08:00
|
|
|
void MergeProtocolPropertiesIntoClass(ObjCInterfaceDecl *IDecl,
|
|
|
|
DeclTy *MergeProtocols);
|
|
|
|
|
|
|
|
void MergeOneProtocolPropertiesIntoClass(ObjCInterfaceDecl *IDecl,
|
|
|
|
ObjCProtocolDecl *PDecl);
|
|
|
|
|
2007-11-12 01:19:15 +08:00
|
|
|
virtual void ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
|
|
|
|
DeclTy **allMethods = 0, unsigned allNum = 0,
|
|
|
|
DeclTy **allProperties = 0, unsigned pNum = 0);
|
2007-09-27 02:27:25 +08:00
|
|
|
|
2008-04-15 07:36:35 +08:00
|
|
|
virtual DeclTy *ActOnProperty(Scope *S, SourceLocation AtLoc,
|
2008-05-06 02:51:55 +08:00
|
|
|
FieldDeclarator &FD, ObjCDeclSpec &ODS,
|
2008-05-07 02:09:04 +08:00
|
|
|
Selector GetterSel, Selector SetterSel,
|
2008-05-06 02:51:55 +08:00
|
|
|
tok::ObjCKeywordKind MethodImplKind);
|
|
|
|
|
2008-04-18 08:19:30 +08:00
|
|
|
virtual DeclTy *ActOnPropertyImplDecl(SourceLocation AtLoc,
|
|
|
|
SourceLocation PropertyLoc,
|
|
|
|
bool ImplKind, DeclTy *ClassImplDecl,
|
|
|
|
IdentifierInfo *PropertyId,
|
|
|
|
IdentifierInfo *PropertyIvar);
|
|
|
|
|
2007-10-27 04:53:56 +08:00
|
|
|
virtual DeclTy *ActOnMethodDeclaration(
|
|
|
|
SourceLocation BeginLoc, // location of the + or -.
|
|
|
|
SourceLocation EndLoc, // location of the ; or {.
|
2007-11-10 03:52:12 +08:00
|
|
|
tok::TokenKind MethodType,
|
2008-01-08 03:49:32 +08:00
|
|
|
DeclTy *ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
|
2007-11-01 07:53:01 +08:00
|
|
|
Selector Sel,
|
Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.
#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.
#3: It results in many API simplifications. Here are some highlights:
- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).
I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.
Thanks to Chris for talking this through with me and suggesting this approach.
llvm-svn: 42395
2007-09-27 22:38:14 +08:00
|
|
|
// optional arguments. The number of types/arguments is obtained
|
|
|
|
// from the Sel.getNumArgs().
|
2008-01-08 03:49:32 +08:00
|
|
|
ObjCDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
|
2007-11-15 20:35:21 +08:00
|
|
|
AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind,
|
|
|
|
bool isVariadic = false);
|
2007-10-17 07:12:48 +08:00
|
|
|
|
Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.
#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.
#3: It results in many API simplifications. Here are some highlights:
- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).
I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.
Thanks to Chris for talking this through with me and suggesting this approach.
llvm-svn: 42395
2007-09-27 22:38:14 +08:00
|
|
|
// ActOnClassMessage - used for both unary and keyword messages.
|
|
|
|
// ArgExprs is optional - if it is present, the number of expressions
|
2007-11-15 21:05:42 +08:00
|
|
|
// is obtained from NumArgs.
|
Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.
#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.
#3: It results in many API simplifications. Here are some highlights:
- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).
I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.
Thanks to Chris for talking this through with me and suggesting this approach.
llvm-svn: 42395
2007-09-27 22:38:14 +08:00
|
|
|
virtual ExprResult ActOnClassMessage(
|
2007-11-13 04:13:27 +08:00
|
|
|
Scope *S,
|
2007-09-29 06:22:11 +08:00
|
|
|
IdentifierInfo *receivingClassName, Selector Sel,
|
2007-11-15 21:05:42 +08:00
|
|
|
SourceLocation lbrac, SourceLocation rbrac,
|
|
|
|
ExprTy **ArgExprs, unsigned NumArgs);
|
Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.
#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.
#3: It results in many API simplifications. Here are some highlights:
- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).
I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.
Thanks to Chris for talking this through with me and suggesting this approach.
llvm-svn: 42395
2007-09-27 22:38:14 +08:00
|
|
|
|
|
|
|
// ActOnInstanceMessage - used for both unary and keyword messages.
|
|
|
|
// ArgExprs is optional - if it is present, the number of expressions
|
2007-11-15 21:05:42 +08:00
|
|
|
// is obtained from NumArgs.
|
Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.
#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.
#3: It results in many API simplifications. Here are some highlights:
- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).
I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.
Thanks to Chris for talking this through with me and suggesting this approach.
llvm-svn: 42395
2007-09-27 22:38:14 +08:00
|
|
|
virtual ExprResult ActOnInstanceMessage(
|
2007-09-29 06:22:11 +08:00
|
|
|
ExprTy *receiver, Selector Sel,
|
2007-11-15 21:05:42 +08:00
|
|
|
SourceLocation lbrac, SourceLocation rbrac,
|
|
|
|
ExprTy **ArgExprs, unsigned NumArgs);
|
2007-03-22 05:08:52 +08:00
|
|
|
private:
|
2008-01-17 03:17:22 +08:00
|
|
|
/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
|
|
|
|
/// cast. If there is already an implicit cast, merge into the existing one.
|
|
|
|
void ImpCastExprToType(Expr *&Expr, QualType Type);
|
|
|
|
|
2007-06-05 06:22:31 +08:00
|
|
|
// UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
|
2007-12-28 13:29:59 +08:00
|
|
|
// functions and arrays to their respective pointers (C99 6.3.2.1).
|
|
|
|
Expr *UsualUnaryConversions(Expr *&expr);
|
2008-05-27 11:33:27 +08:00
|
|
|
|
|
|
|
// UsualUnaryConversionType - Same as UsualUnaryConversions, but works
|
|
|
|
// on types instead of expressions
|
|
|
|
QualType UsualUnaryConversionType(QualType Ty);
|
2007-07-17 05:54:35 +08:00
|
|
|
|
|
|
|
// DefaultFunctionArrayConversion - converts functions and arrays
|
|
|
|
// to their respective pointers (C99 6.3.2.1).
|
|
|
|
void DefaultFunctionArrayConversion(Expr *&expr);
|
2007-07-14 07:32:42 +08:00
|
|
|
|
2007-08-29 07:30:39 +08:00
|
|
|
// DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
|
|
|
|
// do not have a prototype. Integer promotions are performed on each
|
|
|
|
// argument, and arguments that have type float are promoted to double.
|
2007-12-28 13:29:59 +08:00
|
|
|
void DefaultArgumentPromotion(Expr *&Expr);
|
2007-08-29 07:30:39 +08:00
|
|
|
|
2007-06-05 06:22:31 +08:00
|
|
|
// UsualArithmeticConversions - performs the UsualUnaryConversions on it's
|
|
|
|
// operands and then handles various conversions that are common to binary
|
|
|
|
// operators (C99 6.3.1.8). If both operands aren't arithmetic, this
|
|
|
|
// routine returns the first non-arithmetic type found. The client is
|
|
|
|
// responsible for emitting appropriate error diagnostics.
|
2007-08-25 03:07:16 +08:00
|
|
|
QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
|
|
|
|
bool isCompAssign = false);
|
2008-01-05 02:22:42 +08:00
|
|
|
|
|
|
|
/// AssignConvertType - All of the 'assignment' semantic checks return this
|
|
|
|
/// enum to indicate whether the assignment was allowed. These checks are
|
|
|
|
/// done for simple assignments, as well as initialization, return from
|
|
|
|
/// function, argument passing, etc. The query is phrased in terms of a
|
|
|
|
/// source and destination type.
|
2008-01-05 02:04:52 +08:00
|
|
|
enum AssignConvertType {
|
2008-01-05 02:22:42 +08:00
|
|
|
/// Compatible - the types are compatible according to the standard.
|
2007-05-04 05:03:48 +08:00
|
|
|
Compatible,
|
2008-01-05 02:22:42 +08:00
|
|
|
|
|
|
|
/// PointerToInt - The assignment converts a pointer to an int, which we
|
|
|
|
/// accept as an extension.
|
|
|
|
PointerToInt,
|
|
|
|
|
|
|
|
/// IntToPointer - The assignment converts an int to a pointer, which we
|
|
|
|
/// accept as an extension.
|
|
|
|
IntToPointer,
|
|
|
|
|
|
|
|
/// FunctionVoidPointer - The assignment is between a function pointer and
|
|
|
|
/// void*, which the standard doesn't allow, but we accept as an extension.
|
2008-01-04 06:56:36 +08:00
|
|
|
FunctionVoidPointer,
|
2008-01-05 02:22:42 +08:00
|
|
|
|
|
|
|
/// IncompatiblePointer - The assignment is between two pointers types that
|
|
|
|
/// are not compatible, but we accept them as an extension.
|
2007-05-11 12:00:31 +08:00
|
|
|
IncompatiblePointer,
|
2008-01-05 02:22:42 +08:00
|
|
|
|
|
|
|
/// CompatiblePointerDiscardsQualifiers - The assignment discards
|
|
|
|
/// c/v/r qualifiers, which we accept as an extension.
|
|
|
|
CompatiblePointerDiscardsQualifiers,
|
|
|
|
|
|
|
|
/// Incompatible - We reject this conversion outright, it is invalid to
|
|
|
|
/// represent it in the AST.
|
|
|
|
Incompatible
|
2007-05-04 05:03:48 +08:00
|
|
|
};
|
2008-01-05 02:04:52 +08:00
|
|
|
|
|
|
|
/// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
|
|
|
|
/// assignment conversion type specified by ConvTy. This returns true if the
|
|
|
|
/// conversion was invalid or false if the conversion was accepted.
|
|
|
|
bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
|
|
|
|
SourceLocation Loc,
|
|
|
|
QualType DstType, QualType SrcType,
|
|
|
|
Expr *SrcExpr, const char *Flavor);
|
|
|
|
|
|
|
|
/// CheckAssignmentConstraints - Perform type checking for assignment,
|
|
|
|
/// argument passing, variable initialization, and function return values.
|
|
|
|
/// This routine is only used by the following two methods. C99 6.5.16.
|
|
|
|
AssignConvertType CheckAssignmentConstraints(QualType lhs, QualType rhs);
|
2007-07-14 07:32:42 +08:00
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
// CheckSingleAssignmentConstraints - Currently used by ActOnCallExpr,
|
2007-09-16 22:56:35 +08:00
|
|
|
// CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
|
2007-07-14 07:32:42 +08:00
|
|
|
// this routine performs the default function/array converions.
|
2008-01-05 02:04:52 +08:00
|
|
|
AssignConvertType CheckSingleAssignmentConstraints(QualType lhs,
|
|
|
|
Expr *&rExpr);
|
2007-07-14 07:32:42 +08:00
|
|
|
// CheckCompoundAssignmentConstraints - Type check without performing any
|
|
|
|
// conversions. For compound assignments, the "Check...Operands" methods
|
|
|
|
// perform the necessary conversions.
|
2008-01-05 02:04:52 +08:00
|
|
|
AssignConvertType CheckCompoundAssignmentConstraints(QualType lhs,
|
|
|
|
QualType rhs);
|
2007-07-14 07:32:42 +08:00
|
|
|
|
2007-06-07 02:38:38 +08:00
|
|
|
// Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1)
|
2008-01-05 02:04:52 +08:00
|
|
|
AssignConvertType CheckPointerTypesForAssignment(QualType lhsType,
|
|
|
|
QualType rhsType);
|
2007-05-03 05:58:15 +08:00
|
|
|
|
2007-05-09 05:09:37 +08:00
|
|
|
/// the following "Check" methods will return a valid/converted QualType
|
|
|
|
/// or a null QualType (indicating an error diagnostic was issued).
|
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
/// type checking binary operators (subroutines of ActOnBinOp).
|
2007-12-12 13:47:28 +08:00
|
|
|
inline QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
|
2007-07-14 00:58:59 +08:00
|
|
|
inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex);
|
Bug #:
Submitted by:
Reviewed by:
Implemented type checking for compound assignments (*=, /=, etc.).
This encouraged me to do a fairly dramatic refactoring of the Check* functions.
(since I wanted to reuse the existing work, rather than duplicate the logic).
For example, I changed all the Check* functions to return a QualType (instead
of returning an Expr). This had a very nice side benefit...there is now
only one instantiation point for BinaryOperator()! (A property I've always
wanted...separating type checking from AST building is *much* nicer). Another
change is to remove "code" from all the Check* functions (this allowed
me to remove the weird comment about enums/unsigned:-). Removing the
code forced me to add a few functions, however. For example,
< ExprResult CheckAdditiveOperands( // C99 6.5.6
< Expr *lex, Expr *rex, SourceLocation OpLoc, unsigned OpCode);
> inline QualType CheckAdditionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
> inline QualType CheckSubtractionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
While this isn't as terse, it more closely reflects the differences in
the typechecking logic. For example, I disliked having to check the code again
in CheckMultiplicativeOperands/CheckAdditiveOperands.
Created the following helper functions:
- Expr::isNullPointerConstant().
- SemaExpr.cpp: static inline BinaryOperator::Opcode ConvertTokenKindToBinaryOpcode().
This was purely asethetic, since ParseBinOp() is now larger. I didn't feel
like looking at 2 huge switch statements. ParseBinOp() now avoids using
any of the BinaryOperator predicates (since I switched to a switch statement:-)
Only one regret (minor). I couldn't figure out how to avoid having two assign functions,
CheckCompoundAssignmentOperands, CheckSimpleAssignmentOperands. Conceptually,
the two functions make sense. Unfortunately, their implementation contains a lot of
duplication (thought they aren't that be in the first place).
llvm-svn: 39433
2007-05-05 05:54:46 +08:00
|
|
|
inline QualType CheckMultiplyDivideOperands( // C99 6.5.5
|
2007-08-25 03:07:16 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
|
Bug #:
Submitted by:
Reviewed by:
Implemented type checking for compound assignments (*=, /=, etc.).
This encouraged me to do a fairly dramatic refactoring of the Check* functions.
(since I wanted to reuse the existing work, rather than duplicate the logic).
For example, I changed all the Check* functions to return a QualType (instead
of returning an Expr). This had a very nice side benefit...there is now
only one instantiation point for BinaryOperator()! (A property I've always
wanted...separating type checking from AST building is *much* nicer). Another
change is to remove "code" from all the Check* functions (this allowed
me to remove the weird comment about enums/unsigned:-). Removing the
code forced me to add a few functions, however. For example,
< ExprResult CheckAdditiveOperands( // C99 6.5.6
< Expr *lex, Expr *rex, SourceLocation OpLoc, unsigned OpCode);
> inline QualType CheckAdditionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
> inline QualType CheckSubtractionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
While this isn't as terse, it more closely reflects the differences in
the typechecking logic. For example, I disliked having to check the code again
in CheckMultiplicativeOperands/CheckAdditiveOperands.
Created the following helper functions:
- Expr::isNullPointerConstant().
- SemaExpr.cpp: static inline BinaryOperator::Opcode ConvertTokenKindToBinaryOpcode().
This was purely asethetic, since ParseBinOp() is now larger. I didn't feel
like looking at 2 huge switch statements. ParseBinOp() now avoids using
any of the BinaryOperator predicates (since I switched to a switch statement:-)
Only one regret (minor). I couldn't figure out how to avoid having two assign functions,
CheckCompoundAssignmentOperands, CheckSimpleAssignmentOperands. Conceptually,
the two functions make sense. Unfortunately, their implementation contains a lot of
duplication (thought they aren't that be in the first place).
llvm-svn: 39433
2007-05-05 05:54:46 +08:00
|
|
|
inline QualType CheckRemainderOperands( // C99 6.5.5
|
2007-08-25 03:07:16 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
|
Bug #:
Submitted by:
Reviewed by:
Implemented type checking for compound assignments (*=, /=, etc.).
This encouraged me to do a fairly dramatic refactoring of the Check* functions.
(since I wanted to reuse the existing work, rather than duplicate the logic).
For example, I changed all the Check* functions to return a QualType (instead
of returning an Expr). This had a very nice side benefit...there is now
only one instantiation point for BinaryOperator()! (A property I've always
wanted...separating type checking from AST building is *much* nicer). Another
change is to remove "code" from all the Check* functions (this allowed
me to remove the weird comment about enums/unsigned:-). Removing the
code forced me to add a few functions, however. For example,
< ExprResult CheckAdditiveOperands( // C99 6.5.6
< Expr *lex, Expr *rex, SourceLocation OpLoc, unsigned OpCode);
> inline QualType CheckAdditionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
> inline QualType CheckSubtractionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
While this isn't as terse, it more closely reflects the differences in
the typechecking logic. For example, I disliked having to check the code again
in CheckMultiplicativeOperands/CheckAdditiveOperands.
Created the following helper functions:
- Expr::isNullPointerConstant().
- SemaExpr.cpp: static inline BinaryOperator::Opcode ConvertTokenKindToBinaryOpcode().
This was purely asethetic, since ParseBinOp() is now larger. I didn't feel
like looking at 2 huge switch statements. ParseBinOp() now avoids using
any of the BinaryOperator predicates (since I switched to a switch statement:-)
Only one regret (minor). I couldn't figure out how to avoid having two assign functions,
CheckCompoundAssignmentOperands, CheckSimpleAssignmentOperands. Conceptually,
the two functions make sense. Unfortunately, their implementation contains a lot of
duplication (thought they aren't that be in the first place).
llvm-svn: 39433
2007-05-05 05:54:46 +08:00
|
|
|
inline QualType CheckAdditionOperands( // C99 6.5.6
|
2007-08-25 03:07:16 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
|
Bug #:
Submitted by:
Reviewed by:
Implemented type checking for compound assignments (*=, /=, etc.).
This encouraged me to do a fairly dramatic refactoring of the Check* functions.
(since I wanted to reuse the existing work, rather than duplicate the logic).
For example, I changed all the Check* functions to return a QualType (instead
of returning an Expr). This had a very nice side benefit...there is now
only one instantiation point for BinaryOperator()! (A property I've always
wanted...separating type checking from AST building is *much* nicer). Another
change is to remove "code" from all the Check* functions (this allowed
me to remove the weird comment about enums/unsigned:-). Removing the
code forced me to add a few functions, however. For example,
< ExprResult CheckAdditiveOperands( // C99 6.5.6
< Expr *lex, Expr *rex, SourceLocation OpLoc, unsigned OpCode);
> inline QualType CheckAdditionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
> inline QualType CheckSubtractionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
While this isn't as terse, it more closely reflects the differences in
the typechecking logic. For example, I disliked having to check the code again
in CheckMultiplicativeOperands/CheckAdditiveOperands.
Created the following helper functions:
- Expr::isNullPointerConstant().
- SemaExpr.cpp: static inline BinaryOperator::Opcode ConvertTokenKindToBinaryOpcode().
This was purely asethetic, since ParseBinOp() is now larger. I didn't feel
like looking at 2 huge switch statements. ParseBinOp() now avoids using
any of the BinaryOperator predicates (since I switched to a switch statement:-)
Only one regret (minor). I couldn't figure out how to avoid having two assign functions,
CheckCompoundAssignmentOperands, CheckSimpleAssignmentOperands. Conceptually,
the two functions make sense. Unfortunately, their implementation contains a lot of
duplication (thought they aren't that be in the first place).
llvm-svn: 39433
2007-05-05 05:54:46 +08:00
|
|
|
inline QualType CheckSubtractionOperands( // C99 6.5.6
|
2007-08-25 03:07:16 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
|
Bug #:
Submitted by:
Reviewed by:
Implemented type checking for compound assignments (*=, /=, etc.).
This encouraged me to do a fairly dramatic refactoring of the Check* functions.
(since I wanted to reuse the existing work, rather than duplicate the logic).
For example, I changed all the Check* functions to return a QualType (instead
of returning an Expr). This had a very nice side benefit...there is now
only one instantiation point for BinaryOperator()! (A property I've always
wanted...separating type checking from AST building is *much* nicer). Another
change is to remove "code" from all the Check* functions (this allowed
me to remove the weird comment about enums/unsigned:-). Removing the
code forced me to add a few functions, however. For example,
< ExprResult CheckAdditiveOperands( // C99 6.5.6
< Expr *lex, Expr *rex, SourceLocation OpLoc, unsigned OpCode);
> inline QualType CheckAdditionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
> inline QualType CheckSubtractionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
While this isn't as terse, it more closely reflects the differences in
the typechecking logic. For example, I disliked having to check the code again
in CheckMultiplicativeOperands/CheckAdditiveOperands.
Created the following helper functions:
- Expr::isNullPointerConstant().
- SemaExpr.cpp: static inline BinaryOperator::Opcode ConvertTokenKindToBinaryOpcode().
This was purely asethetic, since ParseBinOp() is now larger. I didn't feel
like looking at 2 huge switch statements. ParseBinOp() now avoids using
any of the BinaryOperator predicates (since I switched to a switch statement:-)
Only one regret (minor). I couldn't figure out how to avoid having two assign functions,
CheckCompoundAssignmentOperands, CheckSimpleAssignmentOperands. Conceptually,
the two functions make sense. Unfortunately, their implementation contains a lot of
duplication (thought they aren't that be in the first place).
llvm-svn: 39433
2007-05-05 05:54:46 +08:00
|
|
|
inline QualType CheckShiftOperands( // C99 6.5.7
|
2007-08-25 03:07:16 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
|
2007-08-26 09:18:55 +08:00
|
|
|
inline QualType CheckCompareOperands( // C99 6.5.8/9
|
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isRelational);
|
Bug #:
Submitted by:
Reviewed by:
Implemented type checking for compound assignments (*=, /=, etc.).
This encouraged me to do a fairly dramatic refactoring of the Check* functions.
(since I wanted to reuse the existing work, rather than duplicate the logic).
For example, I changed all the Check* functions to return a QualType (instead
of returning an Expr). This had a very nice side benefit...there is now
only one instantiation point for BinaryOperator()! (A property I've always
wanted...separating type checking from AST building is *much* nicer). Another
change is to remove "code" from all the Check* functions (this allowed
me to remove the weird comment about enums/unsigned:-). Removing the
code forced me to add a few functions, however. For example,
< ExprResult CheckAdditiveOperands( // C99 6.5.6
< Expr *lex, Expr *rex, SourceLocation OpLoc, unsigned OpCode);
> inline QualType CheckAdditionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
> inline QualType CheckSubtractionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
While this isn't as terse, it more closely reflects the differences in
the typechecking logic. For example, I disliked having to check the code again
in CheckMultiplicativeOperands/CheckAdditiveOperands.
Created the following helper functions:
- Expr::isNullPointerConstant().
- SemaExpr.cpp: static inline BinaryOperator::Opcode ConvertTokenKindToBinaryOpcode().
This was purely asethetic, since ParseBinOp() is now larger. I didn't feel
like looking at 2 huge switch statements. ParseBinOp() now avoids using
any of the BinaryOperator predicates (since I switched to a switch statement:-)
Only one regret (minor). I couldn't figure out how to avoid having two assign functions,
CheckCompoundAssignmentOperands, CheckSimpleAssignmentOperands. Conceptually,
the two functions make sense. Unfortunately, their implementation contains a lot of
duplication (thought they aren't that be in the first place).
llvm-svn: 39433
2007-05-05 05:54:46 +08:00
|
|
|
inline QualType CheckBitwiseOperands( // C99 6.5.[10...12]
|
2007-08-25 03:07:16 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
|
Bug #:
Submitted by:
Reviewed by:
Implemented type checking for compound assignments (*=, /=, etc.).
This encouraged me to do a fairly dramatic refactoring of the Check* functions.
(since I wanted to reuse the existing work, rather than duplicate the logic).
For example, I changed all the Check* functions to return a QualType (instead
of returning an Expr). This had a very nice side benefit...there is now
only one instantiation point for BinaryOperator()! (A property I've always
wanted...separating type checking from AST building is *much* nicer). Another
change is to remove "code" from all the Check* functions (this allowed
me to remove the weird comment about enums/unsigned:-). Removing the
code forced me to add a few functions, however. For example,
< ExprResult CheckAdditiveOperands( // C99 6.5.6
< Expr *lex, Expr *rex, SourceLocation OpLoc, unsigned OpCode);
> inline QualType CheckAdditionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
> inline QualType CheckSubtractionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
While this isn't as terse, it more closely reflects the differences in
the typechecking logic. For example, I disliked having to check the code again
in CheckMultiplicativeOperands/CheckAdditiveOperands.
Created the following helper functions:
- Expr::isNullPointerConstant().
- SemaExpr.cpp: static inline BinaryOperator::Opcode ConvertTokenKindToBinaryOpcode().
This was purely asethetic, since ParseBinOp() is now larger. I didn't feel
like looking at 2 huge switch statements. ParseBinOp() now avoids using
any of the BinaryOperator predicates (since I switched to a switch statement:-)
Only one regret (minor). I couldn't figure out how to avoid having two assign functions,
CheckCompoundAssignmentOperands, CheckSimpleAssignmentOperands. Conceptually,
the two functions make sense. Unfortunately, their implementation contains a lot of
duplication (thought they aren't that be in the first place).
llvm-svn: 39433
2007-05-05 05:54:46 +08:00
|
|
|
inline QualType CheckLogicalOperands( // C99 6.5.[13,14]
|
2007-07-14 00:58:59 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc);
|
2007-05-07 08:24:15 +08:00
|
|
|
// CheckAssignmentOperands is used for both simple and compound assignment.
|
|
|
|
// For simple assignment, pass both expressions and a null converted type.
|
|
|
|
// For compound assignment, pass both expressions and the converted type.
|
|
|
|
inline QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
|
2007-08-25 06:33:52 +08:00
|
|
|
Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType);
|
Bug #:
Submitted by:
Reviewed by:
Implemented type checking for compound assignments (*=, /=, etc.).
This encouraged me to do a fairly dramatic refactoring of the Check* functions.
(since I wanted to reuse the existing work, rather than duplicate the logic).
For example, I changed all the Check* functions to return a QualType (instead
of returning an Expr). This had a very nice side benefit...there is now
only one instantiation point for BinaryOperator()! (A property I've always
wanted...separating type checking from AST building is *much* nicer). Another
change is to remove "code" from all the Check* functions (this allowed
me to remove the weird comment about enums/unsigned:-). Removing the
code forced me to add a few functions, however. For example,
< ExprResult CheckAdditiveOperands( // C99 6.5.6
< Expr *lex, Expr *rex, SourceLocation OpLoc, unsigned OpCode);
> inline QualType CheckAdditionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
> inline QualType CheckSubtractionOperands( // C99 6.5.6
> Expr *lex, Expr *rex, SourceLocation OpLoc);
While this isn't as terse, it more closely reflects the differences in
the typechecking logic. For example, I disliked having to check the code again
in CheckMultiplicativeOperands/CheckAdditiveOperands.
Created the following helper functions:
- Expr::isNullPointerConstant().
- SemaExpr.cpp: static inline BinaryOperator::Opcode ConvertTokenKindToBinaryOpcode().
This was purely asethetic, since ParseBinOp() is now larger. I didn't feel
like looking at 2 huge switch statements. ParseBinOp() now avoids using
any of the BinaryOperator predicates (since I switched to a switch statement:-)
Only one regret (minor). I couldn't figure out how to avoid having two assign functions,
CheckCompoundAssignmentOperands, CheckSimpleAssignmentOperands. Conceptually,
the two functions make sense. Unfortunately, their implementation contains a lot of
duplication (thought they aren't that be in the first place).
llvm-svn: 39433
2007-05-05 05:54:46 +08:00
|
|
|
inline QualType CheckCommaOperands( // C99 6.5.17
|
2007-07-14 00:58:59 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc);
|
2007-05-16 04:29:32 +08:00
|
|
|
inline QualType CheckConditionalOperands( // C99 6.5.15
|
2007-07-14 00:58:59 +08:00
|
|
|
Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
|
2007-03-31 07:47:58 +08:00
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
/// type checking unary operators (subroutines of ActOnUnaryOp).
|
2007-05-28 07:58:33 +08:00
|
|
|
/// C99 6.5.3.1, 6.5.3.2, 6.5.3.4
|
2007-05-19 06:53:50 +08:00
|
|
|
QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc);
|
|
|
|
QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc);
|
|
|
|
QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc);
|
|
|
|
QualType CheckSizeOfAlignOfOperand(QualType type, SourceLocation loc,
|
|
|
|
bool isSizeof);
|
2007-08-25 05:41:10 +08:00
|
|
|
QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc);
|
2007-07-28 06:15:19 +08:00
|
|
|
|
|
|
|
/// type checking primary expressions.
|
2008-04-19 07:10:10 +08:00
|
|
|
QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
|
2007-07-28 06:15:19 +08:00
|
|
|
IdentifierInfo &Comp, SourceLocation CmpLoc);
|
|
|
|
|
2007-09-02 10:04:30 +08:00
|
|
|
/// type checking declaration initializers (C99 6.7.8)
|
2008-05-02 06:18:59 +08:00
|
|
|
friend class InitListChecker;
|
2008-01-11 06:15:12 +08:00
|
|
|
bool CheckInitializerTypes(Expr *&simpleInit_or_initList, QualType &declType);
|
|
|
|
bool CheckSingleInitializer(Expr *&simpleInit, QualType declType);
|
|
|
|
bool CheckForConstantInitializer(Expr *e, QualType t);
|
2008-05-20 21:48:25 +08:00
|
|
|
bool CheckArithmeticConstantExpression(const Expr* e);
|
|
|
|
bool CheckAddressConstantExpression(const Expr* e);
|
|
|
|
bool CheckAddressConstantExpressionLValue(const Expr* e);
|
2007-12-11 06:44:33 +08:00
|
|
|
|
2008-01-22 08:55:40 +08:00
|
|
|
StringLiteral *IsStringLiteralInit(Expr *Init, QualType DeclType);
|
|
|
|
bool CheckStringLiteralInit(StringLiteral *strLiteral, QualType &DeclT);
|
|
|
|
|
2007-11-27 15:16:40 +08:00
|
|
|
// CheckVectorCast - check type constraints for vectors.
|
|
|
|
// Since vectors are an extension, there are no C standard reference for this.
|
|
|
|
// We allow casting between vectors and integer datatypes of the same size.
|
2007-11-27 13:51:55 +08:00
|
|
|
// returns true if the cast is invalid
|
|
|
|
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty);
|
|
|
|
|
2007-10-17 07:12:48 +08:00
|
|
|
// returns true if there were any incompatible arguments.
|
|
|
|
bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
|
2008-01-08 03:49:32 +08:00
|
|
|
ObjCMethodDecl *Method);
|
2007-10-17 07:12:48 +08:00
|
|
|
|
2007-08-23 13:46:52 +08:00
|
|
|
/// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
|
|
|
|
/// the specified width and sign. If an overflow occurs, detect it and emit
|
|
|
|
/// the specified diagnostic.
|
|
|
|
void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
|
|
|
|
unsigned NewWidth, bool NewSign,
|
|
|
|
SourceLocation Loc, unsigned DiagID);
|
|
|
|
|
2008-04-07 13:30:13 +08:00
|
|
|
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS,
|
|
|
|
bool ForCompare);
|
|
|
|
|
|
|
|
|
2007-10-16 04:28:48 +08:00
|
|
|
void InitBuiltinVaListType();
|
2008-06-04 05:01:11 +08:00
|
|
|
|
|
|
|
// Helper method to turn variable array types into
|
|
|
|
// constant array types in certain situations which would otherwise
|
|
|
|
// be errors
|
|
|
|
QualType TryFixInvalidVariablyModifiedType(QualType T);
|
2007-10-16 04:28:48 +08:00
|
|
|
|
2007-08-11 04:18:51 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Extra semantic analysis beyond the C type system
|
2007-12-28 13:29:59 +08:00
|
|
|
private:
|
2008-05-15 03:38:39 +08:00
|
|
|
Action::ExprResult CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall);
|
2007-12-28 13:29:59 +08:00
|
|
|
bool CheckBuiltinCFStringArgument(Expr* Arg);
|
|
|
|
bool SemaBuiltinVAStart(CallExpr *TheCall);
|
|
|
|
bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
|
2008-05-20 16:23:37 +08:00
|
|
|
bool SemaBuiltinStackAddress(CallExpr *TheCall);
|
2008-05-15 03:38:39 +08:00
|
|
|
Action::ExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
|
2007-12-28 13:29:59 +08:00
|
|
|
void CheckPrintfArguments(CallExpr *TheCall,
|
|
|
|
bool HasVAListArg, unsigned format_idx);
|
2007-08-18 00:46:58 +08:00
|
|
|
void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
|
|
|
|
SourceLocation ReturnLoc);
|
2007-11-25 08:58:00 +08:00
|
|
|
void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex);
|
2006-11-03 14:42:29 +08:00
|
|
|
};
|
|
|
|
|
2008-05-02 06:18:59 +08:00
|
|
|
class InitListChecker {
|
|
|
|
Sema *SemaRef;
|
|
|
|
bool hadError;
|
|
|
|
|
|
|
|
void CheckImplicitInitList(InitListExpr *ParentIList, QualType T,
|
|
|
|
unsigned &Index);
|
2008-05-06 08:23:44 +08:00
|
|
|
void CheckExplicitInitList(InitListExpr *IList, QualType &T,
|
2008-05-02 06:18:59 +08:00
|
|
|
unsigned &Index);
|
|
|
|
|
2008-05-20 03:16:24 +08:00
|
|
|
void CheckListElementTypes(InitListExpr *IList, QualType &DeclType,
|
|
|
|
unsigned &Index);
|
|
|
|
void CheckSubElementType(InitListExpr *IList, QualType ElemType,
|
|
|
|
unsigned &Index);
|
2008-05-02 06:18:59 +08:00
|
|
|
// FIXME: Does DeclType need to be a reference type?
|
|
|
|
void CheckScalarType(InitListExpr *IList, QualType &DeclType,
|
|
|
|
unsigned &Index);
|
|
|
|
void CheckVectorType(InitListExpr *IList, QualType DeclType, unsigned &Index);
|
|
|
|
void CheckStructUnionTypes(InitListExpr *IList, QualType DeclType,
|
2008-05-20 03:16:24 +08:00
|
|
|
unsigned &Index);
|
2008-05-02 06:18:59 +08:00
|
|
|
void CheckArrayType(InitListExpr *IList, QualType &DeclType, unsigned &Index);
|
|
|
|
|
|
|
|
int numArrayElements(QualType DeclType);
|
|
|
|
int numStructUnionElements(QualType DeclType);
|
|
|
|
public:
|
|
|
|
InitListChecker(Sema *S, InitListExpr *IL, QualType &T);
|
|
|
|
bool HadError() { return hadError; }
|
|
|
|
};
|
|
|
|
|
2006-11-03 14:42:29 +08:00
|
|
|
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|