blob: 7eae1822d2eaf0764ce59be4720017e461233148 [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
123 //===--------------------------------------------------------------------===//
124 // Type Analysis / Processing: SemaType.cpp.
125 //
126 QualType GetTypeForDeclarator(Declarator &D, Scope *S);
127
128 virtual TypeResult ParseTypeName(Scope *S, Declarator &D);
129
130 virtual TypeResult ParseParamDeclaratorType(Scope *S, Declarator &D);
131private:
132 //===--------------------------------------------------------------------===//
133 // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
134 //
135 virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const;
136 virtual DeclTy *ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
137 DeclTy *LastInGroup);
138 virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group);
139
140 virtual DeclTy *ParseStartOfFunctionDef(Scope *S, Declarator &D);
141 virtual DeclTy *ParseFunctionDefBody(DeclTy *Decl, StmtTy *Body);
142 virtual void PopScope(SourceLocation Loc, Scope *S);
143
144 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
145 /// no declarator (e.g. "struct foo;") is parsed.
146 virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS);
147
148 virtual DeclTy *ParseTag(Scope *S, unsigned TagType, TagKind TK,
149 SourceLocation KWLoc, IdentifierInfo *Name,
150 SourceLocation NameLoc, AttributeList *Attr);
151 virtual DeclTy *ParseField(Scope *S, DeclTy *TagDecl,SourceLocation DeclStart,
152 Declarator &D, ExprTy *BitfieldWidth);
153 virtual void ParseRecordBody(SourceLocation RecLoc, DeclTy *TagDecl,
154 DeclTy **Fields, unsigned NumFields);
155 virtual DeclTy *ParseEnumConstant(Scope *S, DeclTy *EnumDecl,
156 DeclTy *LastEnumConstant,
157 SourceLocation IdLoc, IdentifierInfo *Id,
158 SourceLocation EqualLoc, ExprTy *Val);
159 virtual void ParseEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
160 DeclTy **Elements, unsigned NumElements);
161private:
162 /// Subroutines of ParseDeclarator()...
163 TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, Decl *LastDeclarator);
164 TypedefDecl *MergeTypeDefDecl(TypedefDecl *New, Decl *Old);
165 FunctionDecl *MergeFunctionDecl(FunctionDecl *New, Decl *Old);
166 VarDecl *MergeVarDecl(VarDecl *New, Decl *Old);
167 /// AddTopLevelDecl - called after the decl has been fully processed.
168 /// Allows for bookkeeping and post-processing of each declaration.
169 void AddTopLevelDecl(Decl *current, Decl *last);
170
171 /// More parsing and symbol table subroutines...
172 ParmVarDecl *ParseParamDeclarator(DeclaratorChunk &FI, unsigned ArgNo,
173 Scope *FnBodyScope);
174 Decl *LookupScopedDecl(IdentifierInfo *II, unsigned NSI, SourceLocation IdLoc,
175 Scope *S);
176 Decl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S);
177 Decl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
178 Scope *S);
179 // Decl attributes - this routine is the top level dispatcher.
180 void HandleDeclAttributes(Decl *New, AttributeList *declspec_prefix,
181 AttributeList *declarator_postfix);
182 void HandleDeclAttribute(Decl *New, AttributeList *rawAttr);
183
184 // HandleVectorTypeAttribute - this attribute is only applicable to
185 // integral and float scalars, although arrays, pointers, and function
186 // return values are allowed in conjunction with this construct. Aggregates
187 // with this attribute are invalid, even if they are of the same size as a
188 // corresponding scalar.
189 // The raw attribute should contain precisely 1 argument, the vector size
190 // for the variable, measured in bytes. If curType and rawAttr are well
191 // formed, this routine will return a new vector type.
192 QualType HandleVectorTypeAttribute(QualType curType, AttributeList *rawAttr);
Steve Naroff82113e32007-07-29 16:33:31 +0000193 void HandleOCUVectorTypeAttribute(TypedefDecl *d, AttributeList *rawAttr);
Chris Lattner4b009652007-07-25 00:24:17 +0000194
195 //===--------------------------------------------------------------------===//
196 // Statement Parsing Callbacks: SemaStmt.cpp.
197public:
198 virtual StmtResult ParseExprStmt(ExprTy *Expr);
199
200 virtual StmtResult ParseNullStmt(SourceLocation SemiLoc);
201 virtual StmtResult ParseCompoundStmt(SourceLocation L, SourceLocation R,
202 StmtTy **Elts, unsigned NumElts);
203 virtual StmtResult ParseDeclStmt(DeclTy *Decl);
204 virtual StmtResult ParseCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
205 SourceLocation DotDotDotLoc, ExprTy *RHSVal,
206 SourceLocation ColonLoc, StmtTy *SubStmt);
207 virtual StmtResult ParseDefaultStmt(SourceLocation DefaultLoc,
208 SourceLocation ColonLoc, StmtTy *SubStmt,
209 Scope *CurScope);
210 virtual StmtResult ParseLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
211 SourceLocation ColonLoc, StmtTy *SubStmt);
212 virtual StmtResult ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
213 StmtTy *ThenVal, SourceLocation ElseLoc,
214 StmtTy *ElseVal);
215 virtual StmtResult StartSwitchStmt(ExprTy *Cond);
216 virtual StmtResult FinishSwitchStmt(SourceLocation SwitchLoc, StmtTy *Switch,
217 ExprTy *Body);
218 virtual StmtResult ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
219 StmtTy *Body);
220 virtual StmtResult ParseDoStmt(SourceLocation DoLoc, StmtTy *Body,
221 SourceLocation WhileLoc, ExprTy *Cond);
222
223 virtual StmtResult ParseForStmt(SourceLocation ForLoc,
224 SourceLocation LParenLoc,
225 StmtTy *First, ExprTy *Second, ExprTy *Third,
226 SourceLocation RParenLoc, StmtTy *Body);
227 virtual StmtResult ParseGotoStmt(SourceLocation GotoLoc,
228 SourceLocation LabelLoc,
229 IdentifierInfo *LabelII);
230 virtual StmtResult ParseIndirectGotoStmt(SourceLocation GotoLoc,
231 SourceLocation StarLoc,
232 ExprTy *DestExp);
233 virtual StmtResult ParseContinueStmt(SourceLocation ContinueLoc,
234 Scope *CurScope);
235 virtual StmtResult ParseBreakStmt(SourceLocation GotoLoc, Scope *CurScope);
236
237 virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
238 ExprTy *RetValExp);
239
240 //===--------------------------------------------------------------------===//
241 // Expression Parsing Callbacks: SemaExpr.cpp.
242
243 // Primary Expressions.
244 virtual ExprResult ParseIdentifierExpr(Scope *S, SourceLocation Loc,
245 IdentifierInfo &II,
246 bool HasTrailingLParen);
247 virtual ExprResult ParsePreDefinedExpr(SourceLocation Loc,
248 tok::TokenKind Kind);
249 virtual ExprResult ParseNumericConstant(const Token &);
250 virtual ExprResult ParseCharacterConstant(const Token &);
251 virtual ExprResult ParseParenExpr(SourceLocation L, SourceLocation R,
252 ExprTy *Val);
253
254 /// ParseStringLiteral - The specified tokens were lexed as pasted string
255 /// fragments (e.g. "foo" "bar" L"baz").
256 virtual ExprResult ParseStringLiteral(const Token *Toks, unsigned NumToks);
257
258 // Binary/Unary Operators. 'Tok' is the token for the operator.
259 virtual ExprResult ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
260 ExprTy *Input);
261 virtual ExprResult
262 ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
263 SourceLocation LParenLoc, TypeTy *Ty,
264 SourceLocation RParenLoc);
265
266 virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc,
267 tok::TokenKind Kind, ExprTy *Input);
268
269 virtual ExprResult ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
270 ExprTy *Idx, SourceLocation RLoc);
271 virtual ExprResult ParseMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc,
272 tok::TokenKind OpKind,
273 SourceLocation MemberLoc,
274 IdentifierInfo &Member);
275
276 /// ParseCallExpr - Handle a call to Fn with the specified array of arguments.
277 /// This provides the location of the left/right parens and a list of comma
278 /// locations.
279 virtual ExprResult ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
280 ExprTy **Args, unsigned NumArgs,
281 SourceLocation *CommaLocs,
282 SourceLocation RParenLoc);
283
284 virtual ExprResult ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
285 SourceLocation RParenLoc, ExprTy *Op);
286
287 virtual ExprResult ParseCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
288 SourceLocation RParenLoc, ExprTy *Op);
289
290 virtual ExprResult ParseInitList(SourceLocation LParenLoc,
291 ExprTy **InitList, unsigned NumInit,
292 SourceLocation RParenLoc);
293
294 virtual ExprResult ParseBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
295 ExprTy *LHS,ExprTy *RHS);
296
297 /// ParseConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
298 /// in the case of a the GNU conditional expr extension.
299 virtual ExprResult ParseConditionalOp(SourceLocation QuestionLoc,
300 SourceLocation ColonLoc,
301 ExprTy *Cond, ExprTy *LHS, ExprTy *RHS);
302
303 /// ParseAddrLabel - Parse the GNU address of label extension: "&&foo".
304 virtual ExprResult ParseAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
305 IdentifierInfo *LabelII);
306
307 virtual ExprResult ParseStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt,
308 SourceLocation RPLoc); // "({..})"
Steve Naroff63bad2d2007-08-01 22:05:33 +0000309
310 // __builtin_types_compatible_p(type1, type2)
Steve Naroff5b528922007-08-01 23:45:51 +0000311 virtual ExprResult ParseTypesCompatibleExpr(SourceLocation BuiltinLoc,
Steve Naroff63bad2d2007-08-01 22:05:33 +0000312 TypeTy *arg1, TypeTy *arg2,
313 SourceLocation RPLoc);
Steve Naroff93c53012007-08-03 21:21:27 +0000314
315 // __builtin_choose_expr(constExpr, expr1, expr2)
316 virtual ExprResult ParseChooseExpr(SourceLocation BuiltinLoc,
317 ExprTy *cond, ExprTy *expr1, ExprTy *expr2,
318 SourceLocation RPLoc);
Chris Lattner4b009652007-07-25 00:24:17 +0000319
320 /// ParseCXXCasts - Parse {dynamic,static,reinterpret,const}_cast's.
321 virtual ExprResult ParseCXXCasts(SourceLocation OpLoc, tok::TokenKind Kind,
322 SourceLocation LAngleBracketLoc, TypeTy *Ty,
323 SourceLocation RAngleBracketLoc,
324 SourceLocation LParenLoc, ExprTy *E,
325 SourceLocation RParenLoc);
326
327 /// ParseCXXBoolLiteral - Parse {true,false} literals.
328 virtual ExprResult ParseCXXBoolLiteral(SourceLocation OpLoc,
329 tok::TokenKind Kind);
Anders Carlssona66cad42007-08-21 17:43:55 +0000330
331 // ParseObjCStringLiteral - Parse Objective-C string literals.
332 virtual ExprResult ParseObjCStringLiteral(ExprTy *string);
Anders Carlsson8be1d402007-08-22 15:14:15 +0000333 virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
334 SourceLocation LParenLoc,
335 TypeTy *Ty,
336 SourceLocation RParenLoc);
337
Chris Lattner4b009652007-07-25 00:24:17 +0000338private:
339 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
340 // functions and arrays to their respective pointers (C99 6.3.2.1).
341 void UsualUnaryConversions(Expr *&expr);
342
343 // DefaultFunctionArrayConversion - converts functions and arrays
344 // to their respective pointers (C99 6.3.2.1).
345 void DefaultFunctionArrayConversion(Expr *&expr);
346
347 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
348 // operands and then handles various conversions that are common to binary
349 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
350 // routine returns the first non-arithmetic type found. The client is
351 // responsible for emitting appropriate error diagnostics.
Steve Naroff8f708362007-08-24 19:07:16 +0000352 QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
353 bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000354 enum AssignmentCheckResult {
355 Compatible,
356 Incompatible,
357 PointerFromInt,
358 IntFromPointer,
359 IncompatiblePointer,
360 CompatiblePointerDiscardsQualifiers
361 };
362 // CheckAssignmentConstraints - Perform type checking for assignment,
363 // argument passing, variable initialization, and function return values.
364 // This routine is only used by the following two methods. C99 6.5.16.
365 AssignmentCheckResult CheckAssignmentConstraints(QualType lhs, QualType rhs);
366
367 // CheckSingleAssignmentConstraints - Currently used by ParseCallExpr,
368 // CheckAssignmentOperands, and ParseReturnStmt. Prior to type checking,
369 // this routine performs the default function/array converions.
370 AssignmentCheckResult CheckSingleAssignmentConstraints(QualType lhs,
371 Expr *&rExpr);
372 // CheckCompoundAssignmentConstraints - Type check without performing any
373 // conversions. For compound assignments, the "Check...Operands" methods
374 // perform the necessary conversions.
375 AssignmentCheckResult CheckCompoundAssignmentConstraints(QualType lhs,
376 QualType rhs);
377
378 // Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1)
379 AssignmentCheckResult CheckPointerTypesForAssignment(QualType lhsType,
380 QualType rhsType);
381
382 /// the following "Check" methods will return a valid/converted QualType
383 /// or a null QualType (indicating an error diagnostic was issued).
384
385 /// type checking binary operators (subroutines of ParseBinOp).
386 inline void InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
387 inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex);
388 inline QualType CheckMultiplyDivideOperands( // C99 6.5.5
Steve Naroff8f708362007-08-24 19:07:16 +0000389 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000390 inline QualType CheckRemainderOperands( // C99 6.5.5
Steve Naroff8f708362007-08-24 19:07:16 +0000391 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000392 inline QualType CheckAdditionOperands( // C99 6.5.6
Steve Naroff8f708362007-08-24 19:07:16 +0000393 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000394 inline QualType CheckSubtractionOperands( // C99 6.5.6
Steve Naroff8f708362007-08-24 19:07:16 +0000395 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000396 inline QualType CheckShiftOperands( // C99 6.5.7
Steve Naroff8f708362007-08-24 19:07:16 +0000397 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000398 inline QualType CheckRelationalOperands( // C99 6.5.8
399 Expr *&lex, Expr *&rex, SourceLocation OpLoc);
400 inline QualType CheckEqualityOperands( // C99 6.5.9
401 Expr *&lex, Expr *&rex, SourceLocation OpLoc);
402 inline QualType CheckBitwiseOperands( // C99 6.5.[10...12]
Steve Naroff8f708362007-08-24 19:07:16 +0000403 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Chris Lattner4b009652007-07-25 00:24:17 +0000404 inline QualType CheckLogicalOperands( // C99 6.5.[13,14]
405 Expr *&lex, Expr *&rex, SourceLocation OpLoc);
406 // CheckAssignmentOperands is used for both simple and compound assignment.
407 // For simple assignment, pass both expressions and a null converted type.
408 // For compound assignment, pass both expressions and the converted type.
409 inline QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
410 Expr *lex, Expr *rex, SourceLocation OpLoc, QualType convertedType);
411 inline QualType CheckCommaOperands( // C99 6.5.17
412 Expr *&lex, Expr *&rex, SourceLocation OpLoc);
413 inline QualType CheckConditionalOperands( // C99 6.5.15
414 Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
415
416 /// type checking unary operators (subroutines of ParseUnaryOp).
417 /// C99 6.5.3.1, 6.5.3.2, 6.5.3.4
418 QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc);
419 QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc);
420 QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc);
421 QualType CheckSizeOfAlignOfOperand(QualType type, SourceLocation loc,
422 bool isSizeof);
Chris Lattner5110ad52007-08-24 21:41:10 +0000423 QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc);
Steve Naroff1b8a46c2007-07-27 22:15:19 +0000424
425 /// type checking primary expressions.
426 QualType CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc,
427 IdentifierInfo &Comp, SourceLocation CmpLoc);
428
Chris Lattner4b009652007-07-25 00:24:17 +0000429 /// C99: 6.7.5p3: Used by ParseDeclarator/ParseField to make sure we have
430 /// a constant expression of type int with a value greater than zero. If the
431 /// array has an incomplete type or a valid constant size, return false,
432 /// otherwise emit a diagnostic and return true.
Chris Lattner2e64c072007-08-10 20:18:51 +0000433 bool VerifyConstantArrayType(const ArrayType *ary, SourceLocation loc);
434
Chris Lattner3429a812007-08-23 05:46:52 +0000435 /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
436 /// the specified width and sign. If an overflow occurs, detect it and emit
437 /// the specified diagnostic.
438 void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
439 unsigned NewWidth, bool NewSign,
440 SourceLocation Loc, unsigned DiagID);
441
Chris Lattner2e64c072007-08-10 20:18:51 +0000442 //===--------------------------------------------------------------------===//
443 // Extra semantic analysis beyond the C type system
444 private:
445
Anders Carlssone7e7aa22007-08-17 05:31:46 +0000446 bool CheckFunctionCall(Expr *Fn,
Ted Kremenek081ed872007-08-14 17:39:48 +0000447 SourceLocation LParenLoc, SourceLocation RParenLoc,
448 FunctionDecl *FDecl,
Chris Lattner2e64c072007-08-10 20:18:51 +0000449 Expr** Args, unsigned NumArgsInCall);
450
Ted Kremenek081ed872007-08-14 17:39:48 +0000451 void CheckPrintfArguments(Expr *Fn,
452 SourceLocation LParenLoc, SourceLocation RParenLoc,
453 bool HasVAListArg, FunctionDecl *FDecl,
Ted Kremenek30596542007-08-10 21:21:05 +0000454 unsigned format_idx, Expr** Args,
455 unsigned NumArgsInCall);
Ted Kremenek45925ab2007-08-17 16:46:58 +0000456
457 void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
458 SourceLocation ReturnLoc);
459
Anders Carlssone7e7aa22007-08-17 05:31:46 +0000460
461 bool CheckBuiltinCFStringArgument(Expr* Arg);
Chris Lattner4b009652007-07-25 00:24:17 +0000462};
463
464
465} // end namespace clang
466
467#endif