blob: a968dba88ad887d2e3ab60d9acd59e4c8731ea07 [file] [log] [blame]
Chris Lattner4b009652007-07-25 00:24:17 +00001//===--- 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 Lattner3429a812007-08-23 05:46:52 +000024namespace llvm {
25 class APSInt;
26}
27
Chris Lattner4b009652007-07-25 00:24:17 +000028namespace clang {
29 class ASTContext;
30 class Preprocessor;
31 class Decl;
32 class Expr;
33 class VarDecl;
34 class ParmVarDecl;
35 class TypedefDecl;
36 class FunctionDecl;
37 class QualType;
38 class LangOptions;
39 class DeclaratorChunk;
40 class Token;
41 class IntegerLiteral;
42 class ArrayType;
43 class LabelStmt;
44 class SwitchStmt;
Steve Naroff1b8a46c2007-07-27 22:15:19 +000045 class OCUVectorType;
Steve Naroff82113e32007-07-29 16:33:31 +000046 class TypedefDecl;
47
Chris Lattner4b009652007-07-25 00:24:17 +000048/// Sema - This implements semantic analysis and AST building for C.
49class Sema : public Action {
50 Preprocessor &PP;
51
52 ASTContext &Context;
53
54 /// CurFunctionDecl - If inside of a function body, this contains a pointer to
55 /// the function decl for the function being parsed.
56 FunctionDecl *CurFunctionDecl;
57
58 /// LastInGroupList - This vector is populated when there are multiple
59 /// declarators in a single decl group (e.g. "int A, B, C"). In this case,
60 /// all but the last decl will be entered into this. This is used by the
61 /// ASTStreamer.
62 std::vector<Decl*> &LastInGroupList;
63
64 /// LabelMap - This is a mapping from label identifiers to the LabelStmt for
65 /// it (which acts like the label decl in some ways). Forward referenced
66 /// labels have a LabelStmt created for them with a null location & SubStmt.
67 llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap;
68
69 llvm::SmallVector<SwitchStmt*, 8> SwitchStack;
Steve Naroff82113e32007-07-29 16:33:31 +000070
71 /// OCUVectorDecls - This is a list all the OCU vector types. This allows
72 /// us to associate a raw vector type with one of the OCU type names.
73 /// This is only necessary for issuing pretty diagnostics.
74 llvm::SmallVector<TypedefDecl*, 24> OCUVectorDecls;
Chris Lattner2e64c072007-08-10 20:18:51 +000075
76 // Enum values used by KnownFunctionIDs (see below).
77 enum {
78 id_printf,
79 id_fprintf,
80 id_sprintf,
81 id_snprintf,
Chris Lattner2e64c072007-08-10 20:18:51 +000082 id_asprintf,
Ted Kremenek2d7e9532007-08-10 21:13:51 +000083 id_vsnprintf,
Chris Lattner2e64c072007-08-10 20:18:51 +000084 id_vasprintf,
85 id_vfprintf,
86 id_vsprintf,
87 id_vprintf,
88 id_num_known_functions
89 };
90
91 /// KnownFunctionIDs - This is a list of IdentifierInfo objects to a set
92 /// of known functions used by the semantic analysis to do various
93 /// kinds of checking (e.g. checking format string errors in printf calls).
94 /// This list is populated upon the creation of a Sema object.
95 IdentifierInfo* KnownFunctionIDs[ id_num_known_functions ];
96
Chris Lattner4b009652007-07-25 00:24:17 +000097public:
98 Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup);
99
100 const LangOptions &getLangOptions() const;
101
102 /// The primitive diagnostic helpers - always returns true, which simplifies
103 /// error handling (i.e. less code).
104 bool Diag(SourceLocation Loc, unsigned DiagID);
105 bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg);
106 bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
107 const std::string &Msg2);
108
109 /// More expressive diagnostic helpers for expressions (say that 6 times:-)
110 bool Diag(SourceLocation Loc, unsigned DiagID, SourceRange R1);
111 bool Diag(SourceLocation Loc, unsigned DiagID,
112 SourceRange R1, SourceRange R2);
113 bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
114 SourceRange R1);
115 bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
116 SourceRange R1, SourceRange R2);
117 bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
118 const std::string &Msg2, SourceRange R1);
119 bool Diag(SourceLocation Loc, unsigned DiagID,
120 const std::string &Msg1, const std::string &Msg2,
121 SourceRange R1, SourceRange R2);
122
Chris Lattnerb26b7ad2007-08-31 04:53:24 +0000123 virtual void DeleteExpr(ExprTy *E);
124 virtual void DeleteStmt(StmtTy *S);
125
Chris Lattner4b009652007-07-25 00:24:17 +0000126 //===--------------------------------------------------------------------===//
127 // Type Analysis / Processing: SemaType.cpp.
128 //
129 QualType GetTypeForDeclarator(Declarator &D, Scope *S);
130
131 virtual TypeResult ParseTypeName(Scope *S, Declarator &D);
132
133 virtual TypeResult ParseParamDeclaratorType(Scope *S, Declarator &D);
134private:
135 //===--------------------------------------------------------------------===//
136 // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
137 //
138 virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const;
139 virtual DeclTy *ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
140 DeclTy *LastInGroup);
141 virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group);
142
143 virtual DeclTy *ParseStartOfFunctionDef(Scope *S, Declarator &D);
144 virtual DeclTy *ParseFunctionDefBody(DeclTy *Decl, StmtTy *Body);
145 virtual void PopScope(SourceLocation Loc, Scope *S);
146
147 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
148 /// no declarator (e.g. "struct foo;") is parsed.
149 virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS);
150
151 virtual DeclTy *ParseTag(Scope *S, unsigned TagType, TagKind TK,
152 SourceLocation KWLoc, IdentifierInfo *Name,
153 SourceLocation NameLoc, AttributeList *Attr);
154 virtual DeclTy *ParseField(Scope *S, DeclTy *TagDecl,SourceLocation DeclStart,
155 Declarator &D, ExprTy *BitfieldWidth);
156 virtual void ParseRecordBody(SourceLocation RecLoc, DeclTy *TagDecl,
157 DeclTy **Fields, unsigned NumFields);
158 virtual DeclTy *ParseEnumConstant(Scope *S, DeclTy *EnumDecl,
159 DeclTy *LastEnumConstant,
160 SourceLocation IdLoc, IdentifierInfo *Id,
161 SourceLocation EqualLoc, ExprTy *Val);
162 virtual void ParseEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
163 DeclTy **Elements, unsigned NumElements);
164private:
165 /// Subroutines of ParseDeclarator()...
166 TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, Decl *LastDeclarator);
167 TypedefDecl *MergeTypeDefDecl(TypedefDecl *New, Decl *Old);
168 FunctionDecl *MergeFunctionDecl(FunctionDecl *New, Decl *Old);
169 VarDecl *MergeVarDecl(VarDecl *New, Decl *Old);
170 /// AddTopLevelDecl - called after the decl has been fully processed.
171 /// Allows for bookkeeping and post-processing of each declaration.
172 void AddTopLevelDecl(Decl *current, Decl *last);
173
174 /// More parsing and symbol table subroutines...
175 ParmVarDecl *ParseParamDeclarator(DeclaratorChunk &FI, unsigned ArgNo,
176 Scope *FnBodyScope);
177 Decl *LookupScopedDecl(IdentifierInfo *II, unsigned NSI, SourceLocation IdLoc,
178 Scope *S);
179 Decl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S);
180 Decl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
181 Scope *S);
182 // Decl attributes - this routine is the top level dispatcher.
183 void HandleDeclAttributes(Decl *New, AttributeList *declspec_prefix,
184 AttributeList *declarator_postfix);
185 void HandleDeclAttribute(Decl *New, AttributeList *rawAttr);
186
187 // HandleVectorTypeAttribute - this attribute is only applicable to
188 // integral and float scalars, although arrays, pointers, and function
189 // return values are allowed in conjunction with this construct. Aggregates
190 // with this attribute are invalid, even if they are of the same size as a
191 // corresponding scalar.
192 // The raw attribute should contain precisely 1 argument, the vector size
193 // for the variable, measured in bytes. If curType and rawAttr are well
194 // formed, this routine will return a new vector type.
195 QualType HandleVectorTypeAttribute(QualType curType, AttributeList *rawAttr);
Steve Naroff82113e32007-07-29 16:33:31 +0000196 void HandleOCUVectorTypeAttribute(TypedefDecl *d, AttributeList *rawAttr);
Chris Lattner4b009652007-07-25 00:24:17 +0000197
198 //===--------------------------------------------------------------------===//
199 // Statement Parsing Callbacks: SemaStmt.cpp.
200public:
201 virtual StmtResult ParseExprStmt(ExprTy *Expr);
202
203 virtual StmtResult ParseNullStmt(SourceLocation SemiLoc);
204 virtual StmtResult ParseCompoundStmt(SourceLocation L, SourceLocation R,
205 StmtTy **Elts, unsigned NumElts);
206 virtual StmtResult ParseDeclStmt(DeclTy *Decl);
207 virtual StmtResult ParseCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
208 SourceLocation DotDotDotLoc, ExprTy *RHSVal,
209 SourceLocation ColonLoc, StmtTy *SubStmt);
210 virtual StmtResult ParseDefaultStmt(SourceLocation DefaultLoc,
211 SourceLocation ColonLoc, StmtTy *SubStmt,
212 Scope *CurScope);
213 virtual StmtResult ParseLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
214 SourceLocation ColonLoc, StmtTy *SubStmt);
215 virtual StmtResult ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
216 StmtTy *ThenVal, SourceLocation ElseLoc,
217 StmtTy *ElseVal);
218 virtual StmtResult StartSwitchStmt(ExprTy *Cond);
219 virtual StmtResult FinishSwitchStmt(SourceLocation SwitchLoc, StmtTy *Switch,
220 ExprTy *Body);
221 virtual StmtResult ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
222 StmtTy *Body);
223 virtual StmtResult ParseDoStmt(SourceLocation DoLoc, StmtTy *Body,
224 SourceLocation WhileLoc, ExprTy *Cond);
225
226 virtual StmtResult ParseForStmt(SourceLocation ForLoc,
227 SourceLocation LParenLoc,
228 StmtTy *First, ExprTy *Second, ExprTy *Third,
229 SourceLocation RParenLoc, StmtTy *Body);
230 virtual StmtResult ParseGotoStmt(SourceLocation GotoLoc,
231 SourceLocation LabelLoc,
232 IdentifierInfo *LabelII);
233 virtual StmtResult ParseIndirectGotoStmt(SourceLocation GotoLoc,
234 SourceLocation StarLoc,
235 ExprTy *DestExp);
236 virtual StmtResult ParseContinueStmt(SourceLocation ContinueLoc,
237 Scope *CurScope);
238 virtual StmtResult ParseBreakStmt(SourceLocation GotoLoc, Scope *CurScope);
239
240 virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
241 ExprTy *RetValExp);
242
243 //===--------------------------------------------------------------------===//
244 // Expression Parsing Callbacks: SemaExpr.cpp.
245
246 // Primary Expressions.
247 virtual ExprResult ParseIdentifierExpr(Scope *S, SourceLocation Loc,
248 IdentifierInfo &II,
249 bool HasTrailingLParen);
250 virtual ExprResult ParsePreDefinedExpr(SourceLocation Loc,
251 tok::TokenKind Kind);
252 virtual ExprResult ParseNumericConstant(const Token &);
253 virtual ExprResult ParseCharacterConstant(const Token &);
254 virtual ExprResult ParseParenExpr(SourceLocation L, SourceLocation R,
255 ExprTy *Val);
256
257 /// ParseStringLiteral - The specified tokens were lexed as pasted string
258 /// fragments (e.g. "foo" "bar" L"baz").
259 virtual ExprResult ParseStringLiteral(const Token *Toks, unsigned NumToks);
260
261 // Binary/Unary Operators. 'Tok' is the token for the operator.
262 virtual ExprResult ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
263 ExprTy *Input);
264 virtual ExprResult
265 ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
266 SourceLocation LParenLoc, TypeTy *Ty,
267 SourceLocation RParenLoc);
268
269 virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc,
270 tok::TokenKind Kind, ExprTy *Input);
271
272 virtual ExprResult ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
273 ExprTy *Idx, SourceLocation RLoc);
274 virtual ExprResult ParseMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc,
275 tok::TokenKind OpKind,
276 SourceLocation MemberLoc,
277 IdentifierInfo &Member);
278
279 /// ParseCallExpr - Handle a call to Fn with the specified array of arguments.
280 /// This provides the location of the left/right parens and a list of comma
281 /// locations.
282 virtual ExprResult ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
283 ExprTy **Args, unsigned NumArgs,
284 SourceLocation *CommaLocs,
285 SourceLocation RParenLoc);
286
287 virtual ExprResult ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
288 SourceLocation RParenLoc, ExprTy *Op);
289
290 virtual ExprResult ParseCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
291 SourceLocation RParenLoc, ExprTy *Op);
292
293 virtual ExprResult ParseInitList(SourceLocation LParenLoc,
294 ExprTy **InitList, unsigned NumInit,
295 SourceLocation RParenLoc);
296
297 virtual ExprResult ParseBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
298 ExprTy *LHS,ExprTy *RHS);
299
300 /// ParseConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
301 /// in the case of a the GNU conditional expr extension.
302 virtual ExprResult ParseConditionalOp(SourceLocation QuestionLoc,
303 SourceLocation ColonLoc,
304 ExprTy *Cond, ExprTy *LHS, ExprTy *RHS);
305
306 /// ParseAddrLabel - Parse the GNU address of label extension: "&&foo".
307 virtual ExprResult ParseAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
308 IdentifierInfo *LabelII);
309
310 virtual ExprResult ParseStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt,
311 SourceLocation RPLoc); // "({..})"
Chris Lattner0d9bcea2007-08-30 17:45:32 +0000312
313 /// __builtin_offsetof(type, a.b[123][456].c)
314 virtual ExprResult ParseBuiltinOffsetOf(SourceLocation BuiltinLoc,
315 SourceLocation TypeLoc, TypeTy *Arg1,
316 OffsetOfComponent *CompPtr,
317 unsigned NumComponents,
318 SourceLocation RParenLoc);
319
Steve Naroff63bad2d2007-08-01 22:05:33 +0000320 // __builtin_types_compatible_p(type1, type2)
Steve Naroff5b528922007-08-01 23:45:51 +0000321 virtual ExprResult ParseTypesCompatibleExpr(SourceLocation BuiltinLoc,
Steve Naroff63bad2d2007-08-01 22:05:33 +0000322 TypeTy *arg1, TypeTy *arg2,
323 SourceLocation RPLoc);
Steve Naroff93c53012007-08-03 21:21:27 +0000324
325 // __builtin_choose_expr(constExpr, expr1, expr2)
326 virtual ExprResult ParseChooseExpr(SourceLocation BuiltinLoc,
327 ExprTy *cond, ExprTy *expr1, ExprTy *expr2,
328 SourceLocation RPLoc);
Chris Lattner4b009652007-07-25 00:24:17 +0000329
330 /// ParseCXXCasts - Parse {dynamic,static,reinterpret,const}_cast's.
331 virtual ExprResult ParseCXXCasts(SourceLocation OpLoc, tok::TokenKind Kind,
332 SourceLocation LAngleBracketLoc, TypeTy *Ty,
333 SourceLocation RAngleBracketLoc,
334 SourceLocation LParenLoc, ExprTy *E,
335 SourceLocation RParenLoc);
336
337 /// ParseCXXBoolLiteral - Parse {true,false} literals.
338 virtual ExprResult ParseCXXBoolLiteral(SourceLocation OpLoc,
339 tok::TokenKind Kind);
Anders Carlssona66cad42007-08-21 17:43:55 +0000340
341 // ParseObjCStringLiteral - Parse Objective-C string literals.
342 virtual ExprResult ParseObjCStringLiteral(ExprTy *string);
Anders Carlsson8be1d402007-08-22 15:14:15 +0000343 virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
344 SourceLocation LParenLoc,
345 TypeTy *Ty,
346 SourceLocation RParenLoc);
347
Chris Lattner4b009652007-07-25 00:24:17 +0000348private:
349 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
350 // functions and arrays to their respective pointers (C99 6.3.2.1).
351 void UsualUnaryConversions(Expr *&expr);
352
353 // DefaultFunctionArrayConversion - converts functions and arrays
354 // to their respective pointers (C99 6.3.2.1).
355 void DefaultFunctionArrayConversion(Expr *&expr);
356
Steve Naroffdb65e052007-08-28 23:30:39 +0000357 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
358 // do not have a prototype. Integer promotions are performed on each
359 // argument, and arguments that have type float are promoted to double.
360 void DefaultArgumentPromotion(Expr *&expr);
361
Chris Lattner4b009652007-07-25 00:24:17 +0000362 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
363 // operands and then handles various conversions that are common to binary
364 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
365 // routine returns the first non-arithmetic type found. The client is
366 // responsible for emitting appropriate error diagnostics.
Steve Naroff8f708362007-08-24 19:07:16 +0000367 QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
368 bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000369 enum AssignmentCheckResult {
370 Compatible,
371 Incompatible,
372 PointerFromInt,
373 IntFromPointer,
374 IncompatiblePointer,
375 CompatiblePointerDiscardsQualifiers
376 };
377 // CheckAssignmentConstraints - Perform type checking for assignment,
378 // argument passing, variable initialization, and function return values.
379 // This routine is only used by the following two methods. C99 6.5.16.
380 AssignmentCheckResult CheckAssignmentConstraints(QualType lhs, QualType rhs);
381
382 // CheckSingleAssignmentConstraints - Currently used by ParseCallExpr,
383 // CheckAssignmentOperands, and ParseReturnStmt. Prior to type checking,
384 // this routine performs the default function/array converions.
385 AssignmentCheckResult CheckSingleAssignmentConstraints(QualType lhs,
386 Expr *&rExpr);
387 // CheckCompoundAssignmentConstraints - Type check without performing any
388 // conversions. For compound assignments, the "Check...Operands" methods
389 // perform the necessary conversions.
390 AssignmentCheckResult CheckCompoundAssignmentConstraints(QualType lhs,
391 QualType rhs);
392
393 // Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1)
394 AssignmentCheckResult CheckPointerTypesForAssignment(QualType lhsType,
395 QualType rhsType);
396
397 /// the following "Check" methods will return a valid/converted QualType
398 /// or a null QualType (indicating an error diagnostic was issued).
399
400 /// type checking binary operators (subroutines of ParseBinOp).
401 inline void InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
402 inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex);
403 inline QualType CheckMultiplyDivideOperands( // C99 6.5.5
Steve Naroff8f708362007-08-24 19:07:16 +0000404 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000405 inline QualType CheckRemainderOperands( // C99 6.5.5
Steve Naroff8f708362007-08-24 19:07:16 +0000406 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000407 inline QualType CheckAdditionOperands( // C99 6.5.6
Steve Naroff8f708362007-08-24 19:07:16 +0000408 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000409 inline QualType CheckSubtractionOperands( // C99 6.5.6
Steve Naroff8f708362007-08-24 19:07:16 +0000410 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000411 inline QualType CheckShiftOperands( // C99 6.5.7
Steve Naroff8f708362007-08-24 19:07:16 +0000412 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner254f3bc2007-08-26 01:18:55 +0000413 inline QualType CheckCompareOperands( // C99 6.5.8/9
414 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isRelational);
Chris Lattner4b009652007-07-25 00:24:17 +0000415 inline QualType CheckBitwiseOperands( // C99 6.5.[10...12]
Steve Naroff8f708362007-08-24 19:07:16 +0000416 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000417 inline QualType CheckLogicalOperands( // C99 6.5.[13,14]
418 Expr *&lex, Expr *&rex, SourceLocation OpLoc);
419 // CheckAssignmentOperands is used for both simple and compound assignment.
420 // For simple assignment, pass both expressions and a null converted type.
421 // For compound assignment, pass both expressions and the converted type.
422 inline QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
Steve Naroff0f32f432007-08-24 22:33:52 +0000423 Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType);
Chris Lattner4b009652007-07-25 00:24:17 +0000424 inline QualType CheckCommaOperands( // C99 6.5.17
425 Expr *&lex, Expr *&rex, SourceLocation OpLoc);
426 inline QualType CheckConditionalOperands( // C99 6.5.15
427 Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
428
429 /// type checking unary operators (subroutines of ParseUnaryOp).
430 /// C99 6.5.3.1, 6.5.3.2, 6.5.3.4
431 QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc);
432 QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc);
433 QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc);
434 QualType CheckSizeOfAlignOfOperand(QualType type, SourceLocation loc,
435 bool isSizeof);
Chris Lattner5110ad52007-08-24 21:41:10 +0000436 QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc);
Steve Naroff1b8a46c2007-07-27 22:15:19 +0000437
438 /// type checking primary expressions.
439 QualType CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc,
440 IdentifierInfo &Comp, SourceLocation CmpLoc);
441
Chris Lattner3429a812007-08-23 05:46:52 +0000442 /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
443 /// the specified width and sign. If an overflow occurs, detect it and emit
444 /// the specified diagnostic.
445 void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
446 unsigned NewWidth, bool NewSign,
447 SourceLocation Loc, unsigned DiagID);
448
Chris Lattner2e64c072007-08-10 20:18:51 +0000449 //===--------------------------------------------------------------------===//
450 // Extra semantic analysis beyond the C type system
451 private:
452
Anders Carlssone7e7aa22007-08-17 05:31:46 +0000453 bool CheckFunctionCall(Expr *Fn,
Ted Kremenek081ed872007-08-14 17:39:48 +0000454 SourceLocation LParenLoc, SourceLocation RParenLoc,
455 FunctionDecl *FDecl,
Chris Lattner2e64c072007-08-10 20:18:51 +0000456 Expr** Args, unsigned NumArgsInCall);
457
Ted Kremenek081ed872007-08-14 17:39:48 +0000458 void CheckPrintfArguments(Expr *Fn,
459 SourceLocation LParenLoc, SourceLocation RParenLoc,
460 bool HasVAListArg, FunctionDecl *FDecl,
Ted Kremenek30596542007-08-10 21:21:05 +0000461 unsigned format_idx, Expr** Args,
462 unsigned NumArgsInCall);
Ted Kremenek45925ab2007-08-17 16:46:58 +0000463
464 void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
465 SourceLocation ReturnLoc);
466
Anders Carlssone7e7aa22007-08-17 05:31:46 +0000467
468 bool CheckBuiltinCFStringArgument(Expr* Arg);
Chris Lattner4b009652007-07-25 00:24:17 +0000469};
470
471
472} // end namespace clang
473
474#endif