| Chris Lattner | cc67ec1 | 2006-11-09 06:54:47 +0000 | [diff] [blame] | 1 | //===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===// |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 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 | // |
| Chris Lattner | cc67ec1 | 2006-11-09 06:54:47 +0000 | [diff] [blame] | 10 | // This file defines the Sema class, which performs semantic analysis and |
| 11 | // builds ASTs. |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| Chris Lattner | cc67ec1 | 2006-11-09 06:54:47 +0000 | [diff] [blame] | 15 | #ifndef LLVM_CLANG_AST_SEMA_H |
| 16 | #define LLVM_CLANG_AST_SEMA_H |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 17 | |
| 18 | #include "clang/Parse/Action.h" |
| 19 | #include <vector> |
| Chris Lattner | eaafe122 | 2006-11-10 05:17:58 +0000 | [diff] [blame] | 20 | #include <string> |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
| 23 | namespace clang { |
| Chris Lattner | cb6a382 | 2006-11-10 06:20:45 +0000 | [diff] [blame] | 24 | class ASTContext; |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 25 | class Preprocessor; |
| 26 | class Decl; |
| Steve Naroff | 7840336 | 2007-04-02 22:55:05 +0000 | [diff] [blame] | 27 | class Expr; |
| Chris Lattner | c5cdf4d | 2007-01-21 07:42:07 +0000 | [diff] [blame] | 28 | class VarDecl; |
| Chris Lattner | 01564d9 | 2007-01-27 19:27:06 +0000 | [diff] [blame] | 29 | class TypedefDecl; |
| 30 | class FunctionDecl; |
| Steve Naroff | e5aa9be | 2007-04-05 22:36:20 +0000 | [diff] [blame] | 31 | class QualType; |
| Chris Lattner | ac18be9 | 2006-11-20 06:49:47 +0000 | [diff] [blame] | 32 | class LangOptions; |
| Chris Lattner | c5cdf4d | 2007-01-21 07:42:07 +0000 | [diff] [blame] | 33 | class DeclaratorChunk; |
| Steve Naroff | 8160ea2 | 2007-03-06 01:09:46 +0000 | [diff] [blame] | 34 | class LexerToken; |
| Steve Naroff | 35d8515 | 2007-05-07 00:24:15 +0000 | [diff] [blame] | 35 | class IntegerLiteral; |
| Steve Naroff | 8eeeb13 | 2007-05-08 21:09:37 +0000 | [diff] [blame^] | 36 | class ArrayType; |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 37 | |
| Chris Lattner | cc67ec1 | 2006-11-09 06:54:47 +0000 | [diff] [blame] | 38 | /// Sema - This implements semantic analysis and AST building for C. |
| 39 | class Sema : public Action { |
| Steve Naroff | 38d31b4 | 2007-02-28 01:22:02 +0000 | [diff] [blame] | 40 | Preprocessor &PP; |
| 41 | |
| Chris Lattner | cb6a382 | 2006-11-10 06:20:45 +0000 | [diff] [blame] | 42 | ASTContext &Context; |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 43 | |
| Chris Lattner | 229ce60 | 2006-11-21 01:21:07 +0000 | [diff] [blame] | 44 | /// CurFunctionDecl - If inside of a function body, this contains a pointer to |
| 45 | /// the function decl for the function being parsed. |
| 46 | FunctionDecl *CurFunctionDecl; |
| 47 | |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 48 | /// LastInGroupList - This vector is populated when there are multiple |
| 49 | /// declarators in a single decl group (e.g. "int A, B, C"). In this case, |
| 50 | /// all but the last decl will be entered into this. This is used by the |
| 51 | /// ASTStreamer. |
| 52 | std::vector<Decl*> &LastInGroupList; |
| Steve Naroff | 35d8515 | 2007-05-07 00:24:15 +0000 | [diff] [blame] | 53 | |
| 54 | /// Constant for "1" |
| 55 | IntegerLiteral *constantOne; |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 56 | public: |
| Steve Naroff | 2c055d2 | 2007-02-28 19:32:13 +0000 | [diff] [blame] | 57 | Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup); |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 58 | |
| Chris Lattner | ac18be9 | 2006-11-20 06:49:47 +0000 | [diff] [blame] | 59 | const LangOptions &getLangOptions() const; |
| 60 | |
| Steve Naroff | f1e5369 | 2007-03-23 22:27:02 +0000 | [diff] [blame] | 61 | /// always returns true, which simplifies error handling (i.e. less code). |
| 62 | bool Diag(SourceLocation Loc, unsigned DiagID, |
| Chris Lattner | eaafe122 | 2006-11-10 05:17:58 +0000 | [diff] [blame] | 63 | const std::string &Msg = std::string()); |
| Steve Naroff | f1e5369 | 2007-03-23 22:27:02 +0000 | [diff] [blame] | 64 | bool Diag(const LexerToken &Tok, unsigned DiagID, |
| Steve Naroff | 8160ea2 | 2007-03-06 01:09:46 +0000 | [diff] [blame] | 65 | const std::string &M = std::string()); |
| Steve Naroff | e5aa9be | 2007-04-05 22:36:20 +0000 | [diff] [blame] | 66 | bool Diag(SourceLocation Loc, unsigned DiagID, QualType t); |
| Chris Lattner | eaafe122 | 2006-11-10 05:17:58 +0000 | [diff] [blame] | 67 | |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 68 | //===--------------------------------------------------------------------===// |
| Chris Lattner | f84a79c | 2006-11-11 22:59:23 +0000 | [diff] [blame] | 69 | // Type Analysis / Processing: SemaType.cpp. |
| 70 | // |
| Steve Naroff | e5aa9be | 2007-04-05 22:36:20 +0000 | [diff] [blame] | 71 | QualType GetTypeForDeclarator(Declarator &D, Scope *S); |
| Chris Lattner | f84a79c | 2006-11-11 22:59:23 +0000 | [diff] [blame] | 72 | |
| Chris Lattner | 33e8a55 | 2006-11-19 01:48:02 +0000 | [diff] [blame] | 73 | virtual TypeResult ParseTypeName(Scope *S, Declarator &D); |
| Chris Lattner | f84a79c | 2006-11-11 22:59:23 +0000 | [diff] [blame] | 74 | |
| Chris Lattner | 216d865 | 2006-12-02 06:47:41 +0000 | [diff] [blame] | 75 | virtual TypeResult ParseParamDeclaratorType(Scope *S, Declarator &D); |
| Steve Naroff | 26c8ea5 | 2007-03-21 21:08:52 +0000 | [diff] [blame] | 76 | private: |
| Chris Lattner | f84a79c | 2006-11-11 22:59:23 +0000 | [diff] [blame] | 77 | //===--------------------------------------------------------------------===// |
| Chris Lattner | e168f76 | 2006-11-10 05:29:30 +0000 | [diff] [blame] | 78 | // Symbol table / Decl tracking callbacks: SemaDecl.cpp. |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 79 | // |
| Chris Lattner | 2ebe4bb | 2006-11-20 01:29:42 +0000 | [diff] [blame] | 80 | virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const; |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 81 | virtual DeclTy *ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init, |
| 82 | DeclTy *LastInGroup); |
| Chris Lattner | c5cdf4d | 2007-01-21 07:42:07 +0000 | [diff] [blame] | 83 | virtual DeclTy *ParseStartOfFunctionDef(Scope *S, Declarator &D); |
| Chris Lattner | 229ce60 | 2006-11-21 01:21:07 +0000 | [diff] [blame] | 84 | virtual DeclTy *ParseFunctionDefBody(DeclTy *Decl, StmtTy *Body); |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 85 | virtual void PopScope(SourceLocation Loc, Scope *S); |
| Chris Lattner | 01564d9 | 2007-01-27 19:27:06 +0000 | [diff] [blame] | 86 | |
| Chris Lattner | 200bdc3 | 2006-11-19 02:43:37 +0000 | [diff] [blame] | 87 | /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with |
| 88 | /// no declarator (e.g. "struct foo;") is parsed. |
| 89 | virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS); |
| 90 | |
| Chris Lattner | 7b9ace6 | 2007-01-23 20:11:08 +0000 | [diff] [blame] | 91 | virtual DeclTy *ParseTag(Scope *S, unsigned TagType, TagKind TK, |
| Chris Lattner | f34c4da | 2007-01-23 04:08:05 +0000 | [diff] [blame] | 92 | SourceLocation KWLoc, IdentifierInfo *Name, |
| 93 | SourceLocation NameLoc); |
| Chris Lattner | 1300fb9 | 2007-01-23 23:42:53 +0000 | [diff] [blame] | 94 | virtual DeclTy *ParseField(Scope *S, DeclTy *TagDecl,SourceLocation DeclStart, |
| 95 | Declarator &D, ExprTy *BitfieldWidth); |
| 96 | virtual void ParseRecordBody(SourceLocation RecLoc, DeclTy *TagDecl, |
| 97 | DeclTy **Fields, unsigned NumFields); |
| Chris Lattner | c1915e2 | 2007-01-25 07:29:02 +0000 | [diff] [blame] | 98 | virtual DeclTy *ParseEnumConstant(Scope *S, DeclTy *EnumDecl, |
| 99 | SourceLocation IdLoc, IdentifierInfo *Id, |
| 100 | SourceLocation EqualLoc, ExprTy *Val); |
| 101 | virtual void ParseEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl, |
| 102 | DeclTy **Elements, unsigned NumElements); |
| Steve Naroff | 3273c22 | 2007-03-14 21:52:03 +0000 | [diff] [blame] | 103 | private: |
| 104 | /// Subroutines of ParseDeclarator()... |
| 105 | TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D); |
| 106 | TypedefDecl *MergeTypeDefDecl(TypedefDecl *New, Decl *Old); |
| 107 | FunctionDecl *MergeFunctionDecl(FunctionDecl *New, Decl *Old); |
| 108 | VarDecl *MergeVarDecl(VarDecl *New, Decl *Old); |
| Steve Naroff | 26c8ea5 | 2007-03-21 21:08:52 +0000 | [diff] [blame] | 109 | /// AddTopLevelDecl - called after the decl has been fully processed. |
| 110 | /// Allows for bookkeeping and post-processing of each declaration. |
| 111 | void AddTopLevelDecl(Decl *current, Decl *last); |
| Steve Naroff | 6fbf0dc | 2007-03-16 00:33:25 +0000 | [diff] [blame] | 112 | |
| Steve Naroff | 3273c22 | 2007-03-14 21:52:03 +0000 | [diff] [blame] | 113 | /// More parsing and symbol table subroutines... |
| 114 | VarDecl *ParseParamDeclarator(DeclaratorChunk &FI, unsigned ArgNo, |
| 115 | Scope *FnBodyScope); |
| 116 | Decl *LookupScopedDecl(IdentifierInfo *II, unsigned NSI, SourceLocation IdLoc, |
| 117 | Scope *S); |
| 118 | Decl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S); |
| 119 | Decl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, |
| 120 | Scope *S); |
| Chris Lattner | 1300fb9 | 2007-01-23 23:42:53 +0000 | [diff] [blame] | 121 | |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 122 | //===--------------------------------------------------------------------===// |
| Chris Lattner | e168f76 | 2006-11-10 05:29:30 +0000 | [diff] [blame] | 123 | // Statement Parsing Callbacks: SemaStmt.cpp. |
| Steve Naroff | 3273c22 | 2007-03-14 21:52:03 +0000 | [diff] [blame] | 124 | public: |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 125 | virtual StmtResult ParseCompoundStmt(SourceLocation L, SourceLocation R, |
| 126 | StmtTy **Elts, unsigned NumElts); |
| 127 | virtual StmtResult ParseExprStmt(ExprTy *Expr) { |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 128 | return Expr; // Exprs are Stmts. |
| 129 | } |
| Chris Lattner | 6c0ff13 | 2006-11-05 00:19:50 +0000 | [diff] [blame] | 130 | virtual StmtResult ParseCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal, |
| 131 | SourceLocation DotDotDotLoc, ExprTy *RHSVal, |
| 132 | SourceLocation ColonLoc, StmtTy *SubStmt); |
| 133 | virtual StmtResult ParseDefaultStmt(SourceLocation DefaultLoc, |
| 134 | SourceLocation ColonLoc, StmtTy *SubStmt); |
| 135 | virtual StmtResult ParseLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II, |
| 136 | SourceLocation ColonLoc, StmtTy *SubStmt); |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 137 | virtual StmtResult ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal, |
| 138 | StmtTy *ThenVal, SourceLocation ElseLoc, |
| 139 | StmtTy *ElseVal); |
| Chris Lattner | f2174b6 | 2006-11-04 20:59:27 +0000 | [diff] [blame] | 140 | virtual StmtResult ParseSwitchStmt(SourceLocation SwitchLoc, ExprTy *Cond, |
| 141 | StmtTy *Body); |
| Chris Lattner | 85ed873 | 2006-11-04 20:40:44 +0000 | [diff] [blame] | 142 | virtual StmtResult ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, |
| 143 | StmtTy *Body); |
| 144 | virtual StmtResult ParseDoStmt(SourceLocation DoLoc, StmtTy *Body, |
| 145 | SourceLocation WhileLoc, ExprTy *Cond); |
| 146 | |
| Chris Lattner | 71e23ce | 2006-11-04 20:18:38 +0000 | [diff] [blame] | 147 | virtual StmtResult ParseForStmt(SourceLocation ForLoc, |
| 148 | SourceLocation LParenLoc, |
| 149 | StmtTy *First, ExprTy *Second, ExprTy *Third, |
| 150 | SourceLocation RParenLoc, StmtTy *Body); |
| Chris Lattner | 16976d3 | 2006-11-05 01:46:01 +0000 | [diff] [blame] | 151 | virtual StmtResult ParseGotoStmt(SourceLocation GotoLoc, |
| 152 | SourceLocation LabelLoc, |
| 153 | IdentifierInfo *LabelII); |
| 154 | virtual StmtResult ParseIndirectGotoStmt(SourceLocation GotoLoc, |
| 155 | SourceLocation StarLoc, |
| 156 | ExprTy *DestExp); |
| Chris Lattner | eaafe122 | 2006-11-10 05:17:58 +0000 | [diff] [blame] | 157 | virtual StmtResult ParseContinueStmt(SourceLocation ContinueLoc, |
| 158 | Scope *CurScope); |
| 159 | virtual StmtResult ParseBreakStmt(SourceLocation GotoLoc, Scope *CurScope); |
| Chris Lattner | 71e23ce | 2006-11-04 20:18:38 +0000 | [diff] [blame] | 160 | |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 161 | virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc, |
| 162 | ExprTy *RetValExp); |
| 163 | |
| 164 | //===--------------------------------------------------------------------===// |
| Chris Lattner | e168f76 | 2006-11-10 05:29:30 +0000 | [diff] [blame] | 165 | // Expression Parsing Callbacks: SemaExpr.cpp. |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 166 | |
| 167 | // Primary Expressions. |
| Chris Lattner | ac18be9 | 2006-11-20 06:49:47 +0000 | [diff] [blame] | 168 | virtual ExprResult ParseIdentifierExpr(Scope *S, SourceLocation Loc, |
| 169 | IdentifierInfo &II, |
| 170 | bool HasTrailingLParen); |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 171 | virtual ExprResult ParseSimplePrimaryExpr(SourceLocation Loc, |
| 172 | tok::TokenKind Kind); |
| Steve Naroff | 8160ea2 | 2007-03-06 01:09:46 +0000 | [diff] [blame] | 173 | virtual ExprResult ParseNumericConstant(const LexerToken &); |
| Steve Naroff | ae4143e | 2007-04-26 20:39:23 +0000 | [diff] [blame] | 174 | virtual ExprResult ParseCharacterConstant(const LexerToken &); |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 175 | virtual ExprResult ParseParenExpr(SourceLocation L, SourceLocation R, |
| 176 | ExprTy *Val); |
| Chris Lattner | 697e5d6 | 2006-11-09 06:32:27 +0000 | [diff] [blame] | 177 | |
| Steve Naroff | df7855b | 2007-02-21 23:46:25 +0000 | [diff] [blame] | 178 | /// ParseStringLiteral - The specified tokens were lexed as pasted string |
| Chris Lattner | 697e5d6 | 2006-11-09 06:32:27 +0000 | [diff] [blame] | 179 | /// fragments (e.g. "foo" "bar" L"baz"). |
| Steve Naroff | df7855b | 2007-02-21 23:46:25 +0000 | [diff] [blame] | 180 | virtual ExprResult ParseStringLiteral(const LexerToken *Toks, unsigned NumToks); |
| Chris Lattner | 697e5d6 | 2006-11-09 06:32:27 +0000 | [diff] [blame] | 181 | |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 182 | // Binary/Unary Operators. 'Tok' is the token for the operator. |
| 183 | virtual ExprResult ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op, |
| 184 | ExprTy *Input); |
| 185 | virtual ExprResult |
| 186 | ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof, |
| 187 | SourceLocation LParenLoc, TypeTy *Ty, |
| 188 | SourceLocation RParenLoc); |
| 189 | |
| 190 | virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc, |
| 191 | tok::TokenKind Kind, ExprTy *Input); |
| 192 | |
| 193 | virtual ExprResult ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc, |
| 194 | ExprTy *Idx, SourceLocation RLoc); |
| 195 | virtual ExprResult ParseMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc, |
| 196 | tok::TokenKind OpKind, |
| 197 | SourceLocation MemberLoc, |
| 198 | IdentifierInfo &Member); |
| 199 | |
| 200 | /// ParseCallExpr - Handle a call to Fn with the specified array of arguments. |
| 201 | /// This provides the location of the left/right parens and a list of comma |
| 202 | /// locations. |
| 203 | virtual ExprResult ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc, |
| 204 | ExprTy **Args, unsigned NumArgs, |
| 205 | SourceLocation *CommaLocs, |
| 206 | SourceLocation RParenLoc); |
| 207 | |
| 208 | virtual ExprResult ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty, |
| 209 | SourceLocation RParenLoc, ExprTy *Op); |
| 210 | |
| 211 | virtual ExprResult ParseBinOp(SourceLocation TokLoc, tok::TokenKind Kind, |
| 212 | ExprTy *LHS,ExprTy *RHS); |
| 213 | |
| 214 | /// ParseConditionalOp - Parse a ?: operation. Note that 'LHS' may be null |
| 215 | /// in the case of a the GNU conditional expr extension. |
| 216 | virtual ExprResult ParseConditionalOp(SourceLocation QuestionLoc, |
| 217 | SourceLocation ColonLoc, |
| 218 | ExprTy *Cond, ExprTy *LHS, ExprTy *RHS); |
| Chris Lattner | 2937565 | 2006-12-04 18:06:35 +0000 | [diff] [blame] | 219 | |
| 220 | /// ParseCXXCasts - Parse {dynamic,static,reinterpret,const}_cast's. |
| 221 | virtual ExprResult ParseCXXCasts(SourceLocation OpLoc, tok::TokenKind Kind, |
| 222 | SourceLocation LAngleBracketLoc, TypeTy *Ty, |
| 223 | SourceLocation RAngleBracketLoc, |
| 224 | SourceLocation LParenLoc, ExprTy *E, |
| 225 | SourceLocation RParenLoc); |
| Bill Wendling | 4073ed5 | 2007-02-13 01:51:42 +0000 | [diff] [blame] | 226 | |
| 227 | /// ParseCXXBoolLiteral - Parse {true,false} literals. |
| 228 | virtual ExprResult ParseCXXBoolLiteral(SourceLocation OpLoc, |
| Bill Wendling | bf313b0 | 2007-02-13 20:09:46 +0000 | [diff] [blame] | 229 | tok::TokenKind Kind); |
| Steve Naroff | 26c8ea5 | 2007-03-21 21:08:52 +0000 | [diff] [blame] | 230 | private: |
| Steve Naroff | 1926c83 | 2007-04-24 00:23:05 +0000 | [diff] [blame] | 231 | QualType UsualUnaryConversion(QualType t); // C99 6.3 |
| 232 | QualType UsualArithmeticConversions(QualType t1, QualType t2); // C99 6.3.1.8 |
| 233 | |
| Steve Naroff | 17f76e0 | 2007-05-03 21:03:48 +0000 | [diff] [blame] | 234 | enum AssignmentConversionResult { |
| 235 | Compatible, |
| 236 | Incompatible, |
| 237 | PointerFromInt, |
| 238 | IntFromPointer, |
| 239 | IncompatiblePointer |
| 240 | }; |
| Steve Naroff | 218bc2b | 2007-05-04 21:54:46 +0000 | [diff] [blame] | 241 | // Conversions for assignment, argument passing, initialization, and |
| 242 | // function return values. UsualAssignmentConversions is currently used by |
| 243 | // CheckSimpleAssignment, CheckCompoundAssignment and ParseCallExpr. |
| 244 | QualType UsualAssignmentConversions(QualType lhs, QualType rhs, // C99 6.5.16 |
| Steve Naroff | 17f76e0 | 2007-05-03 21:03:48 +0000 | [diff] [blame] | 245 | AssignmentConversionResult &r); |
| Steve Naroff | 9eb2465 | 2007-05-02 21:58:15 +0000 | [diff] [blame] | 246 | |
| Steve Naroff | 8eeeb13 | 2007-05-08 21:09:37 +0000 | [diff] [blame^] | 247 | /// the following "Check" methods will return a valid/converted QualType |
| 248 | /// or a null QualType (indicating an error diagnostic was issued). |
| 249 | |
| Steve Naroff | 4750051 | 2007-04-19 23:00:49 +0000 | [diff] [blame] | 250 | /// type checking binary operators (subroutines of ParseBinOp). |
| Steve Naroff | 218bc2b | 2007-05-04 21:54:46 +0000 | [diff] [blame] | 251 | inline QualType CheckMultiplyDivideOperands( // C99 6.5.5 |
| 252 | Expr *lex, Expr *rex, SourceLocation OpLoc); |
| 253 | inline QualType CheckRemainderOperands( // C99 6.5.5 |
| 254 | Expr *lex, Expr *rex, SourceLocation OpLoc); |
| 255 | inline QualType CheckAdditionOperands( // C99 6.5.6 |
| 256 | Expr *lex, Expr *rex, SourceLocation OpLoc); |
| 257 | inline QualType CheckSubtractionOperands( // C99 6.5.6 |
| 258 | Expr *lex, Expr *rex, SourceLocation OpLoc); |
| 259 | inline QualType CheckShiftOperands( // C99 6.5.7 |
| 260 | Expr *lex, Expr *rex, SourceLocation OpLoc); |
| 261 | inline QualType CheckRelationalOperands( // C99 6.5.8 |
| 262 | Expr *lex, Expr *rex, SourceLocation OpLoc); |
| 263 | inline QualType CheckEqualityOperands( // C99 6.5.9 |
| 264 | Expr *lex, Expr *rex, SourceLocation OpLoc); |
| 265 | inline QualType CheckBitwiseOperands( // C99 6.5.[10...12] |
| 266 | Expr *lex, Expr *rex, SourceLocation OpLoc); |
| 267 | inline QualType CheckLogicalOperands( // C99 6.5.[13,14] |
| 268 | Expr *lex, Expr *rex, SourceLocation OpLoc); |
| Steve Naroff | 35d8515 | 2007-05-07 00:24:15 +0000 | [diff] [blame] | 269 | // CheckAssignmentOperands is used for both simple and compound assignment. |
| 270 | // For simple assignment, pass both expressions and a null converted type. |
| 271 | // For compound assignment, pass both expressions and the converted type. |
| 272 | inline QualType CheckAssignmentOperands( // C99 6.5.16.[1,2] |
| 273 | Expr *lex, Expr *rex, SourceLocation OpLoc, QualType convertedType); |
| Steve Naroff | 218bc2b | 2007-05-04 21:54:46 +0000 | [diff] [blame] | 274 | inline QualType CheckCommaOperands( // C99 6.5.17 |
| Steve Naroff | ae4143e | 2007-04-26 20:39:23 +0000 | [diff] [blame] | 275 | Expr *lex, Expr *rex, SourceLocation OpLoc); |
| Steve Naroff | 95af013 | 2007-03-30 23:47:58 +0000 | [diff] [blame] | 276 | |
| Steve Naroff | 4750051 | 2007-04-19 23:00:49 +0000 | [diff] [blame] | 277 | /// type checking unary operators (subroutines of ParseUnaryOp). |
| Steve Naroff | 35d8515 | 2007-05-07 00:24:15 +0000 | [diff] [blame] | 278 | QualType CheckIncrementDecrementOperand( // C99 6.5.3.1 |
| Steve Naroff | f633d09 | 2007-04-25 19:01:39 +0000 | [diff] [blame] | 279 | Expr *op, SourceLocation loc); |
| Steve Naroff | 35d8515 | 2007-05-07 00:24:15 +0000 | [diff] [blame] | 280 | QualType CheckAddressOfOperand( // C99 6.5.3.2 |
| 281 | Expr *op, SourceLocation loc); |
| 282 | QualType CheckIndirectionOperand( // C99 6.5.3.2 |
| Steve Naroff | f633d09 | 2007-04-25 19:01:39 +0000 | [diff] [blame] | 283 | Expr *op, SourceLocation loc); |
| Steve Naroff | 8eeeb13 | 2007-05-08 21:09:37 +0000 | [diff] [blame^] | 284 | |
| 285 | // C99: 6.7.5p3: Used by ParseDeclarator/ParseField to make sure we have |
| 286 | // a constant expression of type int with a value greater than zero. |
| 287 | bool isConstantArrayType(ArrayType *ary, SourceLocation loc); |
| Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 288 | }; |
| 289 | |
| 290 | |
| 291 | } // end namespace clang |
| 292 | } // end namespace llvm |
| 293 | |
| 294 | #endif |