Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 1 | //===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Chris Lattner and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the Sema class, which performs semantic analysis and |
| 11 | // builds ASTs. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CLANG_AST_SEMA_H |
| 16 | #define LLVM_CLANG_AST_SEMA_H |
| 17 | |
| 18 | #include "clang/Parse/Action.h" |
| 19 | #include "llvm/ADT/DenseMap.h" |
| 20 | #include "llvm/ADT/SmallVector.h" |
| 21 | #include <vector> |
| 22 | #include <string> |
| 23 | |
Chris Lattner | 3429a81 | 2007-08-23 05:46:52 +0000 | [diff] [blame] | 24 | namespace llvm { |
| 25 | class APSInt; |
| 26 | } |
| 27 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 28 | namespace clang { |
| 29 | class ASTContext; |
| 30 | class Preprocessor; |
| 31 | class Decl; |
Steve Naroff | d21bc0d | 2007-09-13 18:10:37 +0000 | [diff] [blame] | 32 | class ScopedDecl; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 33 | class Expr; |
Steve Naroff | 9091f3f | 2007-09-02 15:34:30 +0000 | [diff] [blame] | 34 | class InitListExpr; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 35 | class VarDecl; |
| 36 | class ParmVarDecl; |
| 37 | class TypedefDecl; |
| 38 | class FunctionDecl; |
| 39 | class QualType; |
Chris Lattner | 3496d52 | 2007-09-04 02:45:27 +0000 | [diff] [blame] | 40 | struct LangOptions; |
| 41 | struct DeclaratorChunk; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 42 | class Token; |
| 43 | class IntegerLiteral; |
| 44 | class ArrayType; |
| 45 | class LabelStmt; |
| 46 | class SwitchStmt; |
Steve Naroff | 1b8a46c | 2007-07-27 22:15:19 +0000 | [diff] [blame] | 47 | class OCUVectorType; |
Steve Naroff | 82113e3 | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 48 | class TypedefDecl; |
Fariborz Jahanian | 0c5affb | 2007-09-29 00:54:24 +0000 | [diff] [blame^] | 49 | class ObjcInterfaceDecl; |
Steve Naroff | 82113e3 | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 50 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 51 | /// Sema - This implements semantic analysis and AST building for C. |
| 52 | class Sema : public Action { |
| 53 | Preprocessor &PP; |
| 54 | |
| 55 | ASTContext &Context; |
| 56 | |
| 57 | /// CurFunctionDecl - If inside of a function body, this contains a pointer to |
| 58 | /// the function decl for the function being parsed. |
| 59 | FunctionDecl *CurFunctionDecl; |
| 60 | |
| 61 | /// LastInGroupList - This vector is populated when there are multiple |
| 62 | /// declarators in a single decl group (e.g. "int A, B, C"). In this case, |
| 63 | /// all but the last decl will be entered into this. This is used by the |
| 64 | /// ASTStreamer. |
| 65 | std::vector<Decl*> &LastInGroupList; |
| 66 | |
| 67 | /// LabelMap - This is a mapping from label identifiers to the LabelStmt for |
| 68 | /// it (which acts like the label decl in some ways). Forward referenced |
| 69 | /// labels have a LabelStmt created for them with a null location & SubStmt. |
| 70 | llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap; |
| 71 | |
| 72 | llvm::SmallVector<SwitchStmt*, 8> SwitchStack; |
Steve Naroff | 82113e3 | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 73 | |
| 74 | /// OCUVectorDecls - This is a list all the OCU vector types. This allows |
| 75 | /// us to associate a raw vector type with one of the OCU type names. |
| 76 | /// This is only necessary for issuing pretty diagnostics. |
| 77 | llvm::SmallVector<TypedefDecl*, 24> OCUVectorDecls; |
Chris Lattner | 2e64c07 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 78 | |
| 79 | // Enum values used by KnownFunctionIDs (see below). |
| 80 | enum { |
| 81 | id_printf, |
| 82 | id_fprintf, |
| 83 | id_sprintf, |
| 84 | id_snprintf, |
Chris Lattner | 2e64c07 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 85 | id_asprintf, |
Ted Kremenek | 2d7e953 | 2007-08-10 21:13:51 +0000 | [diff] [blame] | 86 | id_vsnprintf, |
Chris Lattner | 2e64c07 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 87 | id_vasprintf, |
| 88 | id_vfprintf, |
| 89 | id_vsprintf, |
| 90 | id_vprintf, |
| 91 | id_num_known_functions |
| 92 | }; |
| 93 | |
| 94 | /// KnownFunctionIDs - This is a list of IdentifierInfo objects to a set |
| 95 | /// of known functions used by the semantic analysis to do various |
| 96 | /// kinds of checking (e.g. checking format string errors in printf calls). |
| 97 | /// This list is populated upon the creation of a Sema object. |
| 98 | IdentifierInfo* KnownFunctionIDs[ id_num_known_functions ]; |
| 99 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 100 | public: |
| 101 | Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup); |
| 102 | |
| 103 | const LangOptions &getLangOptions() const; |
| 104 | |
| 105 | /// The primitive diagnostic helpers - always returns true, which simplifies |
| 106 | /// error handling (i.e. less code). |
| 107 | bool Diag(SourceLocation Loc, unsigned DiagID); |
| 108 | bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg); |
| 109 | bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, |
| 110 | const std::string &Msg2); |
| 111 | |
| 112 | /// More expressive diagnostic helpers for expressions (say that 6 times:-) |
| 113 | bool Diag(SourceLocation Loc, unsigned DiagID, SourceRange R1); |
| 114 | bool Diag(SourceLocation Loc, unsigned DiagID, |
| 115 | SourceRange R1, SourceRange R2); |
| 116 | bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, |
| 117 | SourceRange R1); |
| 118 | bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, |
| 119 | SourceRange R1, SourceRange R2); |
| 120 | bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, |
| 121 | const std::string &Msg2, SourceRange R1); |
| 122 | bool Diag(SourceLocation Loc, unsigned DiagID, |
| 123 | const std::string &Msg1, const std::string &Msg2, |
| 124 | SourceRange R1, SourceRange R2); |
Fariborz Jahanian | 0c5affb | 2007-09-29 00:54:24 +0000 | [diff] [blame^] | 125 | |
Chris Lattner | b26b7ad | 2007-08-31 04:53:24 +0000 | [diff] [blame] | 126 | virtual void DeleteExpr(ExprTy *E); |
| 127 | virtual void DeleteStmt(StmtTy *S); |
| 128 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 129 | //===--------------------------------------------------------------------===// |
| 130 | // Type Analysis / Processing: SemaType.cpp. |
| 131 | // |
| 132 | QualType GetTypeForDeclarator(Declarator &D, Scope *S); |
| 133 | |
Steve Naroff | 0acc9c9 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 134 | virtual TypeResult ActOnTypeName(Scope *S, Declarator &D); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 135 | |
Steve Naroff | 0acc9c9 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 136 | virtual TypeResult ActOnParamDeclaratorType(Scope *S, Declarator &D); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 137 | private: |
| 138 | //===--------------------------------------------------------------------===// |
| 139 | // Symbol table / Decl tracking callbacks: SemaDecl.cpp. |
| 140 | // |
| 141 | virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const; |
Steve Naroff | 0acc9c9 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 142 | virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup); |
Steve Naroff | 6a0e209 | 2007-09-12 14:07:44 +0000 | [diff] [blame] | 143 | void AddInitializerToDecl(DeclTy *dcl, ExprTy *init); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 144 | virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group); |
| 145 | |
| 146 | virtual DeclTy *ParseStartOfFunctionDef(Scope *S, Declarator &D); |
| 147 | virtual DeclTy *ParseFunctionDefBody(DeclTy *Decl, StmtTy *Body); |
| 148 | virtual void PopScope(SourceLocation Loc, Scope *S); |
| 149 | |
| 150 | /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with |
| 151 | /// no declarator (e.g. "struct foo;") is parsed. |
| 152 | virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS); |
| 153 | |
Steve Naroff | 0acc9c9 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 154 | virtual DeclTy *ActOnTag(Scope *S, unsigned TagType, TagKind TK, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 155 | SourceLocation KWLoc, IdentifierInfo *Name, |
| 156 | SourceLocation NameLoc, AttributeList *Attr); |
Steve Naroff | 0acc9c9 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 157 | virtual DeclTy *ActOnField(Scope *S, DeclTy *TagDecl,SourceLocation DeclStart, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 158 | Declarator &D, ExprTy *BitfieldWidth); |
Steve Naroff | ffeaa55 | 2007-09-14 23:09:53 +0000 | [diff] [blame] | 159 | |
| 160 | // This is used for both record definitions and ObjC interface declarations. |
Fariborz Jahanian | 0c5affb | 2007-09-29 00:54:24 +0000 | [diff] [blame^] | 161 | virtual void ActOnFields(Scope* S, |
| 162 | SourceLocation RecLoc, DeclTy *TagDecl, |
Steve Naroff | ffeaa55 | 2007-09-14 23:09:53 +0000 | [diff] [blame] | 163 | DeclTy **Fields, unsigned NumFields, |
| 164 | tok::ObjCKeywordKind *visibility = 0); |
Steve Naroff | 0acc9c9 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 165 | virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 166 | DeclTy *LastEnumConstant, |
| 167 | SourceLocation IdLoc, IdentifierInfo *Id, |
| 168 | SourceLocation EqualLoc, ExprTy *Val); |
Steve Naroff | 0acc9c9 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 169 | virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 170 | DeclTy **Elements, unsigned NumElements); |
| 171 | private: |
Steve Naroff | 0acc9c9 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 172 | /// Subroutines of ActOnDeclarator()... |
Steve Naroff | 2591e1b | 2007-09-13 23:52:58 +0000 | [diff] [blame] | 173 | TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, ScopedDecl *LastDecl); |
Steve Naroff | cb59747 | 2007-09-13 21:41:19 +0000 | [diff] [blame] | 174 | TypedefDecl *MergeTypeDefDecl(TypedefDecl *New, ScopedDecl *Old); |
| 175 | FunctionDecl *MergeFunctionDecl(FunctionDecl *New, ScopedDecl *Old); |
| 176 | VarDecl *MergeVarDecl(VarDecl *New, ScopedDecl *Old); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 177 | /// AddTopLevelDecl - called after the decl has been fully processed. |
| 178 | /// Allows for bookkeeping and post-processing of each declaration. |
| 179 | void AddTopLevelDecl(Decl *current, Decl *last); |
| 180 | |
| 181 | /// More parsing and symbol table subroutines... |
| 182 | ParmVarDecl *ParseParamDeclarator(DeclaratorChunk &FI, unsigned ArgNo, |
| 183 | Scope *FnBodyScope); |
Steve Naroff | d21bc0d | 2007-09-13 18:10:37 +0000 | [diff] [blame] | 184 | ScopedDecl *LookupScopedDecl(IdentifierInfo *II, unsigned NSI, |
| 185 | SourceLocation IdLoc, Scope *S); |
Fariborz Jahanian | 0c5affb | 2007-09-29 00:54:24 +0000 | [diff] [blame^] | 186 | ObjcInterfaceDecl *getObjCInterfaceDecl(Scope *S, |
| 187 | IdentifierInfo *Id, SourceLocation IdLoc); |
Steve Naroff | d21bc0d | 2007-09-13 18:10:37 +0000 | [diff] [blame] | 188 | ScopedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S); |
Steve Naroff | f0c31dd | 2007-09-16 16:16:00 +0000 | [diff] [blame] | 189 | ScopedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 190 | Scope *S); |
| 191 | // Decl attributes - this routine is the top level dispatcher. |
| 192 | void HandleDeclAttributes(Decl *New, AttributeList *declspec_prefix, |
| 193 | AttributeList *declarator_postfix); |
| 194 | void HandleDeclAttribute(Decl *New, AttributeList *rawAttr); |
| 195 | |
| 196 | // HandleVectorTypeAttribute - this attribute is only applicable to |
| 197 | // integral and float scalars, although arrays, pointers, and function |
| 198 | // return values are allowed in conjunction with this construct. Aggregates |
| 199 | // with this attribute are invalid, even if they are of the same size as a |
| 200 | // corresponding scalar. |
| 201 | // The raw attribute should contain precisely 1 argument, the vector size |
| 202 | // for the variable, measured in bytes. If curType and rawAttr are well |
| 203 | // formed, this routine will return a new vector type. |
| 204 | QualType HandleVectorTypeAttribute(QualType curType, AttributeList *rawAttr); |
Steve Naroff | 82113e3 | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 205 | void HandleOCUVectorTypeAttribute(TypedefDecl *d, AttributeList *rawAttr); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 206 | |
| 207 | //===--------------------------------------------------------------------===// |
| 208 | // Statement Parsing Callbacks: SemaStmt.cpp. |
| 209 | public: |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 210 | virtual StmtResult ActOnExprStmt(ExprTy *Expr); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 211 | |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 212 | virtual StmtResult ActOnNullStmt(SourceLocation SemiLoc); |
| 213 | virtual StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, |
Chris Lattner | f2b0757 | 2007-08-31 21:49:55 +0000 | [diff] [blame] | 214 | StmtTy **Elts, unsigned NumElts, |
| 215 | bool isStmtExpr); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 216 | virtual StmtResult ActOnDeclStmt(DeclTy *Decl); |
| 217 | virtual StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 218 | SourceLocation DotDotDotLoc, ExprTy *RHSVal, |
| 219 | SourceLocation ColonLoc, StmtTy *SubStmt); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 220 | virtual StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 221 | SourceLocation ColonLoc, StmtTy *SubStmt, |
| 222 | Scope *CurScope); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 223 | virtual StmtResult ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 224 | SourceLocation ColonLoc, StmtTy *SubStmt); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 225 | virtual StmtResult ActOnIfStmt(SourceLocation IfLoc, ExprTy *CondVal, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 226 | StmtTy *ThenVal, SourceLocation ElseLoc, |
| 227 | StmtTy *ElseVal); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 228 | virtual StmtResult ActOnStartOfSwitchStmt(ExprTy *Cond); |
| 229 | virtual StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtTy *Switch, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 230 | ExprTy *Body); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 231 | virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 232 | StmtTy *Body); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 233 | virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 234 | SourceLocation WhileLoc, ExprTy *Cond); |
| 235 | |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 236 | virtual StmtResult ActOnForStmt(SourceLocation ForLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 237 | SourceLocation LParenLoc, |
| 238 | StmtTy *First, ExprTy *Second, ExprTy *Third, |
| 239 | SourceLocation RParenLoc, StmtTy *Body); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 240 | virtual StmtResult ActOnGotoStmt(SourceLocation GotoLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 241 | SourceLocation LabelLoc, |
| 242 | IdentifierInfo *LabelII); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 243 | virtual StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 244 | SourceLocation StarLoc, |
| 245 | ExprTy *DestExp); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 246 | virtual StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 247 | Scope *CurScope); |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 248 | virtual StmtResult ActOnBreakStmt(SourceLocation GotoLoc, Scope *CurScope); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 249 | |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 250 | virtual StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 251 | ExprTy *RetValExp); |
| 252 | |
| 253 | //===--------------------------------------------------------------------===// |
| 254 | // Expression Parsing Callbacks: SemaExpr.cpp. |
| 255 | |
| 256 | // Primary Expressions. |
Steve Naroff | 0acc9c9 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 257 | virtual ExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 258 | IdentifierInfo &II, |
| 259 | bool HasTrailingLParen); |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 260 | virtual ExprResult ActOnPreDefinedExpr(SourceLocation Loc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 261 | tok::TokenKind Kind); |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 262 | virtual ExprResult ActOnNumericConstant(const Token &); |
| 263 | virtual ExprResult ActOnCharacterConstant(const Token &); |
| 264 | virtual ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 265 | ExprTy *Val); |
| 266 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 267 | /// ActOnStringLiteral - The specified tokens were lexed as pasted string |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 268 | /// fragments (e.g. "foo" "bar" L"baz"). |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 269 | virtual ExprResult ActOnStringLiteral(const Token *Toks, unsigned NumToks); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 270 | |
| 271 | // Binary/Unary Operators. 'Tok' is the token for the operator. |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 272 | virtual ExprResult ActOnUnaryOp(SourceLocation OpLoc, tok::TokenKind Op, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 273 | ExprTy *Input); |
| 274 | virtual ExprResult |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 275 | ActOnSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 276 | SourceLocation LParenLoc, TypeTy *Ty, |
| 277 | SourceLocation RParenLoc); |
| 278 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 279 | virtual ExprResult ActOnPostfixUnaryOp(SourceLocation OpLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 280 | tok::TokenKind Kind, ExprTy *Input); |
| 281 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 282 | virtual ExprResult ActOnArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 283 | ExprTy *Idx, SourceLocation RLoc); |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 284 | virtual ExprResult ActOnMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 285 | tok::TokenKind OpKind, |
| 286 | SourceLocation MemberLoc, |
| 287 | IdentifierInfo &Member); |
| 288 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 289 | /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 290 | /// This provides the location of the left/right parens and a list of comma |
| 291 | /// locations. |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 292 | virtual ExprResult ActOnCallExpr(ExprTy *Fn, SourceLocation LParenLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 293 | ExprTy **Args, unsigned NumArgs, |
| 294 | SourceLocation *CommaLocs, |
| 295 | SourceLocation RParenLoc); |
| 296 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 297 | virtual ExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 298 | SourceLocation RParenLoc, ExprTy *Op); |
| 299 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 300 | virtual ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 301 | SourceLocation RParenLoc, ExprTy *Op); |
| 302 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 303 | virtual ExprResult ActOnInitList(SourceLocation LParenLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 304 | ExprTy **InitList, unsigned NumInit, |
| 305 | SourceLocation RParenLoc); |
| 306 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 307 | virtual ExprResult ActOnBinOp(SourceLocation TokLoc, tok::TokenKind Kind, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 308 | ExprTy *LHS,ExprTy *RHS); |
| 309 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 310 | /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 311 | /// in the case of a the GNU conditional expr extension. |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 312 | virtual ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 313 | SourceLocation ColonLoc, |
| 314 | ExprTy *Cond, ExprTy *LHS, ExprTy *RHS); |
| 315 | |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 316 | /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo". |
| 317 | virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 318 | IdentifierInfo *LabelII); |
| 319 | |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 320 | virtual ExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 321 | SourceLocation RPLoc); // "({..})" |
Chris Lattner | 0d9bcea | 2007-08-30 17:45:32 +0000 | [diff] [blame] | 322 | |
| 323 | /// __builtin_offsetof(type, a.b[123][456].c) |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 324 | virtual ExprResult ActOnBuiltinOffsetOf(SourceLocation BuiltinLoc, |
Chris Lattner | 0d9bcea | 2007-08-30 17:45:32 +0000 | [diff] [blame] | 325 | SourceLocation TypeLoc, TypeTy *Arg1, |
| 326 | OffsetOfComponent *CompPtr, |
| 327 | unsigned NumComponents, |
| 328 | SourceLocation RParenLoc); |
| 329 | |
Steve Naroff | 63bad2d | 2007-08-01 22:05:33 +0000 | [diff] [blame] | 330 | // __builtin_types_compatible_p(type1, type2) |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 331 | virtual ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc, |
Steve Naroff | 63bad2d | 2007-08-01 22:05:33 +0000 | [diff] [blame] | 332 | TypeTy *arg1, TypeTy *arg2, |
| 333 | SourceLocation RPLoc); |
Steve Naroff | 93c5301 | 2007-08-03 21:21:27 +0000 | [diff] [blame] | 334 | |
| 335 | // __builtin_choose_expr(constExpr, expr1, expr2) |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 336 | virtual ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, |
Steve Naroff | 93c5301 | 2007-08-03 21:21:27 +0000 | [diff] [blame] | 337 | ExprTy *cond, ExprTy *expr1, ExprTy *expr2, |
| 338 | SourceLocation RPLoc); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 339 | |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 340 | /// ActOnCXXCasts - Parse {dynamic,static,reinterpret,const}_cast's. |
| 341 | virtual ExprResult ActOnCXXCasts(SourceLocation OpLoc, tok::TokenKind Kind, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 342 | SourceLocation LAngleBracketLoc, TypeTy *Ty, |
| 343 | SourceLocation RAngleBracketLoc, |
| 344 | SourceLocation LParenLoc, ExprTy *E, |
| 345 | SourceLocation RParenLoc); |
| 346 | |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 347 | /// ActOnCXXBoolLiteral - Parse {true,false} literals. |
| 348 | virtual ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 349 | tok::TokenKind Kind); |
Anders Carlsson | a66cad4 | 2007-08-21 17:43:55 +0000 | [diff] [blame] | 350 | |
| 351 | // ParseObjCStringLiteral - Parse Objective-C string literals. |
| 352 | virtual ExprResult ParseObjCStringLiteral(ExprTy *string); |
Anders Carlsson | 8be1d40 | 2007-08-22 15:14:15 +0000 | [diff] [blame] | 353 | virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, |
| 354 | SourceLocation LParenLoc, |
| 355 | TypeTy *Ty, |
| 356 | SourceLocation RParenLoc); |
| 357 | |
Steve Naroff | 81f1bba | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 358 | // Objective-C declarations. |
Fariborz Jahanian | c091b5d | 2007-09-25 18:38:09 +0000 | [diff] [blame] | 359 | virtual DeclTy *ObjcStartClassInterface(Scope* S, |
| 360 | SourceLocation AtInterafceLoc, |
Steve Naroff | 81f1bba | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 361 | IdentifierInfo *ClassName, SourceLocation ClassLoc, |
| 362 | IdentifierInfo *SuperName, SourceLocation SuperLoc, |
| 363 | IdentifierInfo **ProtocolNames, unsigned NumProtocols, |
| 364 | AttributeList *AttrList); |
| 365 | |
Fariborz Jahanian | c091b5d | 2007-09-25 18:38:09 +0000 | [diff] [blame] | 366 | virtual DeclTy *ObjcStartProtoInterface(Scope* S, |
| 367 | SourceLocation AtProtoInterfaceLoc, |
Fariborz Jahanian | 63ca8ae | 2007-09-17 21:07:36 +0000 | [diff] [blame] | 368 | IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, |
| 369 | IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs); |
| 370 | |
Fariborz Jahanian | 0c5affb | 2007-09-29 00:54:24 +0000 | [diff] [blame^] | 371 | virtual DeclTy *ObjcStartCatInterface(Scope* S, |
| 372 | SourceLocation AtInterfaceLoc, |
Fariborz Jahanian | f25220e | 2007-09-18 20:26:58 +0000 | [diff] [blame] | 373 | IdentifierInfo *ClassName, SourceLocation ClassLoc, |
| 374 | IdentifierInfo *CategoryName, SourceLocation CategoryLoc, |
| 375 | IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs); |
| 376 | |
Fariborz Jahanian | c091b5d | 2007-09-25 18:38:09 +0000 | [diff] [blame] | 377 | virtual DeclTy *ObjcStartClassImplementation(Scope* S, |
| 378 | SourceLocation AtClassImplLoc, |
| 379 | IdentifierInfo *ClassName, SourceLocation ClassLoc, |
| 380 | IdentifierInfo *SuperClassname, |
| 381 | SourceLocation SuperClassLoc); |
| 382 | |
Steve Naroff | 81f1bba | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 383 | virtual DeclTy *ObjcClassDeclaration(Scope *S, SourceLocation AtClassLoc, |
| 384 | IdentifierInfo **IdentList, |
| 385 | unsigned NumElts); |
Fariborz Jahanian | c716c94 | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 386 | |
| 387 | virtual DeclTy *ObjcForwardProtocolDeclaration(Scope *S, |
| 388 | SourceLocation AtProtocolLoc, |
| 389 | IdentifierInfo **IdentList, |
| 390 | unsigned NumElts); |
Steve Naroff | 81f1bba | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 391 | |
Fariborz Jahanian | 0c5affb | 2007-09-29 00:54:24 +0000 | [diff] [blame^] | 392 | virtual void ObjcAddMethodsToClass(Scope* S, DeclTy *ClassDecl, |
Steve Naroff | 7549489 | 2007-09-11 21:17:26 +0000 | [diff] [blame] | 393 | DeclTy **allMethods, unsigned allNum); |
Fariborz Jahanian | d34caf9 | 2007-09-26 18:27:25 +0000 | [diff] [blame] | 394 | |
| 395 | virtual void ActOnImpleIvarVsClassIvars(DeclTy *ClassDecl, |
| 396 | DeclTy **Fields, unsigned NumFields); |
| 397 | |
Fariborz Jahanian | 8b5ab6f | 2007-09-18 00:25:23 +0000 | [diff] [blame] | 398 | virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc, |
Steve Naroff | 6cb1d36 | 2007-09-28 22:22:11 +0000 | [diff] [blame] | 399 | tok::TokenKind MethodType, TypeTy *ReturnType, Selector Sel, |
Steve Naroff | 4ed9d66 | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 400 | // optional arguments. The number of types/arguments is obtained |
| 401 | // from the Sel.getNumArgs(). |
| 402 | TypeTy **ArgTypes, IdentifierInfo **ArgNames, |
| 403 | AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind); |
Steve Naroff | d3f5ee4 | 2007-09-17 21:01:15 +0000 | [diff] [blame] | 404 | |
Steve Naroff | 4ed9d66 | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 405 | // ActOnClassMessage - used for both unary and keyword messages. |
| 406 | // ArgExprs is optional - if it is present, the number of expressions |
| 407 | // is obtained from Sel.getNumArgs(). |
| 408 | virtual ExprResult ActOnClassMessage( |
Steve Naroff | 6cb1d36 | 2007-09-28 22:22:11 +0000 | [diff] [blame] | 409 | IdentifierInfo *receivingClassName, Selector Sel, |
Steve Naroff | 4ed9d66 | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 410 | SourceLocation lbrac, SourceLocation rbrac, ExprTy **ArgExprs); |
| 411 | |
| 412 | // ActOnInstanceMessage - used for both unary and keyword messages. |
| 413 | // ArgExprs is optional - if it is present, the number of expressions |
| 414 | // is obtained from Sel.getNumArgs(). |
| 415 | virtual ExprResult ActOnInstanceMessage( |
Steve Naroff | 6cb1d36 | 2007-09-28 22:22:11 +0000 | [diff] [blame] | 416 | ExprTy *receiver, Selector Sel, |
Steve Naroff | 4ed9d66 | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 417 | SourceLocation lbrac, SourceLocation rbrac, ExprTy **ArgExprs); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 418 | private: |
| 419 | // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts |
| 420 | // functions and arrays to their respective pointers (C99 6.3.2.1). |
| 421 | void UsualUnaryConversions(Expr *&expr); |
| 422 | |
| 423 | // DefaultFunctionArrayConversion - converts functions and arrays |
| 424 | // to their respective pointers (C99 6.3.2.1). |
| 425 | void DefaultFunctionArrayConversion(Expr *&expr); |
| 426 | |
Steve Naroff | db65e05 | 2007-08-28 23:30:39 +0000 | [diff] [blame] | 427 | // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that |
| 428 | // do not have a prototype. Integer promotions are performed on each |
| 429 | // argument, and arguments that have type float are promoted to double. |
| 430 | void DefaultArgumentPromotion(Expr *&expr); |
| 431 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 432 | // UsualArithmeticConversions - performs the UsualUnaryConversions on it's |
| 433 | // operands and then handles various conversions that are common to binary |
| 434 | // operators (C99 6.3.1.8). If both operands aren't arithmetic, this |
| 435 | // routine returns the first non-arithmetic type found. The client is |
| 436 | // responsible for emitting appropriate error diagnostics. |
Steve Naroff | 8f70836 | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 437 | QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr, |
| 438 | bool isCompAssign = false); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 439 | enum AssignmentCheckResult { |
| 440 | Compatible, |
| 441 | Incompatible, |
| 442 | PointerFromInt, |
| 443 | IntFromPointer, |
| 444 | IncompatiblePointer, |
| 445 | CompatiblePointerDiscardsQualifiers |
| 446 | }; |
| 447 | // CheckAssignmentConstraints - Perform type checking for assignment, |
| 448 | // argument passing, variable initialization, and function return values. |
| 449 | // This routine is only used by the following two methods. C99 6.5.16. |
| 450 | AssignmentCheckResult CheckAssignmentConstraints(QualType lhs, QualType rhs); |
| 451 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 452 | // CheckSingleAssignmentConstraints - Currently used by ActOnCallExpr, |
Steve Naroff | 5cbb02f | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 453 | // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking, |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 454 | // this routine performs the default function/array converions. |
| 455 | AssignmentCheckResult CheckSingleAssignmentConstraints(QualType lhs, |
| 456 | Expr *&rExpr); |
| 457 | // CheckCompoundAssignmentConstraints - Type check without performing any |
| 458 | // conversions. For compound assignments, the "Check...Operands" methods |
| 459 | // perform the necessary conversions. |
| 460 | AssignmentCheckResult CheckCompoundAssignmentConstraints(QualType lhs, |
| 461 | QualType rhs); |
| 462 | |
| 463 | // Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1) |
| 464 | AssignmentCheckResult CheckPointerTypesForAssignment(QualType lhsType, |
| 465 | QualType rhsType); |
| 466 | |
| 467 | /// the following "Check" methods will return a valid/converted QualType |
| 468 | /// or a null QualType (indicating an error diagnostic was issued). |
| 469 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 470 | /// type checking binary operators (subroutines of ActOnBinOp). |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 471 | inline void InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex); |
| 472 | inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex); |
| 473 | inline QualType CheckMultiplyDivideOperands( // C99 6.5.5 |
Steve Naroff | 8f70836 | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 474 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 475 | inline QualType CheckRemainderOperands( // C99 6.5.5 |
Steve Naroff | 8f70836 | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 476 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 477 | inline QualType CheckAdditionOperands( // C99 6.5.6 |
Steve Naroff | 8f70836 | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 478 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 479 | inline QualType CheckSubtractionOperands( // C99 6.5.6 |
Steve Naroff | 8f70836 | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 480 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 481 | inline QualType CheckShiftOperands( // C99 6.5.7 |
Steve Naroff | 8f70836 | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 482 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Chris Lattner | 254f3bc | 2007-08-26 01:18:55 +0000 | [diff] [blame] | 483 | inline QualType CheckCompareOperands( // C99 6.5.8/9 |
| 484 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isRelational); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 485 | inline QualType CheckBitwiseOperands( // C99 6.5.[10...12] |
Steve Naroff | 8f70836 | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 486 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 487 | inline QualType CheckLogicalOperands( // C99 6.5.[13,14] |
| 488 | Expr *&lex, Expr *&rex, SourceLocation OpLoc); |
| 489 | // CheckAssignmentOperands is used for both simple and compound assignment. |
| 490 | // For simple assignment, pass both expressions and a null converted type. |
| 491 | // For compound assignment, pass both expressions and the converted type. |
| 492 | inline QualType CheckAssignmentOperands( // C99 6.5.16.[1,2] |
Steve Naroff | 0f32f43 | 2007-08-24 22:33:52 +0000 | [diff] [blame] | 493 | Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 494 | inline QualType CheckCommaOperands( // C99 6.5.17 |
| 495 | Expr *&lex, Expr *&rex, SourceLocation OpLoc); |
| 496 | inline QualType CheckConditionalOperands( // C99 6.5.15 |
| 497 | Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc); |
| 498 | |
Steve Naroff | 87d58b4 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 499 | /// type checking unary operators (subroutines of ActOnUnaryOp). |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 500 | /// C99 6.5.3.1, 6.5.3.2, 6.5.3.4 |
| 501 | QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc); |
| 502 | QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc); |
| 503 | QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc); |
| 504 | QualType CheckSizeOfAlignOfOperand(QualType type, SourceLocation loc, |
| 505 | bool isSizeof); |
Chris Lattner | 5110ad5 | 2007-08-24 21:41:10 +0000 | [diff] [blame] | 506 | QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc); |
Steve Naroff | 1b8a46c | 2007-07-27 22:15:19 +0000 | [diff] [blame] | 507 | |
| 508 | /// type checking primary expressions. |
| 509 | QualType CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc, |
| 510 | IdentifierInfo &Comp, SourceLocation CmpLoc); |
| 511 | |
Steve Naroff | e14e554 | 2007-09-02 02:04:30 +0000 | [diff] [blame] | 512 | /// type checking declaration initializers (C99 6.7.8) |
Steve Naroff | e6a8c9b | 2007-09-04 14:36:54 +0000 | [diff] [blame] | 513 | bool CheckInitializer(Expr *&simpleInit_or_initList, QualType &declType, |
Steve Naroff | 1c9de71 | 2007-09-03 01:24:23 +0000 | [diff] [blame] | 514 | bool isStatic); |
Steve Naroff | e6a8c9b | 2007-09-04 14:36:54 +0000 | [diff] [blame] | 515 | bool CheckSingleInitializer(Expr *&simpleInit, QualType declType); |
| 516 | bool CheckInitExpr(Expr *expr, InitListExpr *IList, unsigned slot, |
| 517 | bool isStatic, QualType ElementType); |
Steve Naroff | 509d0b5 | 2007-09-04 02:20:04 +0000 | [diff] [blame] | 518 | void CheckVariableInitList(QualType DeclType, InitListExpr *IList, |
| 519 | QualType ElementType, bool isStatic, |
| 520 | int &nInitializers, bool &hadError); |
| 521 | void CheckConstantInitList(QualType DeclType, InitListExpr *IList, |
| 522 | QualType ElementType, bool isStatic, |
| 523 | int &nInitializers, bool &hadError); |
| 524 | |
Chris Lattner | 3429a81 | 2007-08-23 05:46:52 +0000 | [diff] [blame] | 525 | /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have |
| 526 | /// the specified width and sign. If an overflow occurs, detect it and emit |
| 527 | /// the specified diagnostic. |
| 528 | void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal, |
| 529 | unsigned NewWidth, bool NewSign, |
| 530 | SourceLocation Loc, unsigned DiagID); |
| 531 | |
Chris Lattner | 2e64c07 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 532 | //===--------------------------------------------------------------------===// |
| 533 | // Extra semantic analysis beyond the C type system |
| 534 | private: |
| 535 | |
Anders Carlsson | e7e7aa2 | 2007-08-17 05:31:46 +0000 | [diff] [blame] | 536 | bool CheckFunctionCall(Expr *Fn, |
Ted Kremenek | 081ed87 | 2007-08-14 17:39:48 +0000 | [diff] [blame] | 537 | SourceLocation LParenLoc, SourceLocation RParenLoc, |
| 538 | FunctionDecl *FDecl, |
Chris Lattner | 2e64c07 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 539 | Expr** Args, unsigned NumArgsInCall); |
| 540 | |
Ted Kremenek | 081ed87 | 2007-08-14 17:39:48 +0000 | [diff] [blame] | 541 | void CheckPrintfArguments(Expr *Fn, |
| 542 | SourceLocation LParenLoc, SourceLocation RParenLoc, |
| 543 | bool HasVAListArg, FunctionDecl *FDecl, |
Ted Kremenek | 3059654 | 2007-08-10 21:21:05 +0000 | [diff] [blame] | 544 | unsigned format_idx, Expr** Args, |
| 545 | unsigned NumArgsInCall); |
Ted Kremenek | 45925ab | 2007-08-17 16:46:58 +0000 | [diff] [blame] | 546 | |
| 547 | void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType, |
| 548 | SourceLocation ReturnLoc); |
| 549 | |
Anders Carlsson | e7e7aa2 | 2007-08-17 05:31:46 +0000 | [diff] [blame] | 550 | |
| 551 | bool CheckBuiltinCFStringArgument(Expr* Arg); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 552 | }; |
| 553 | |
| 554 | |
| 555 | } // end namespace clang |
| 556 | |
| 557 | #endif |