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