summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR4836, part 1: add Sema support for __builtin_isnan and friends; they Eli Friedman2009-08-311-0/+35
| | | | | | | are apparently used by Solaris libc despite the fact that clang claims to be compatible with gcc 4.2, which doesn't support them. llvm-svn: 80610
* When a member reference expression includes a qualifier on the memberDouglas Gregor2009-08-261-1/+2
| | | | | | | | | | | | | | | | | name, e.g., x->Base::f() retain the qualifier (and its source range information) in a new subclass of MemberExpr called CXXQualifiedMemberExpr. Provide construction, transformation, profiling, printing, etc., for this new expression type. When a virtual function is called via a qualified name, don't emit a virtual call. Instead, call that function directly. Mike, could you add a CodeGen test for this, too? llvm-svn: 80167
* update to CXXFunctionalCastExpr to support ir-gen forFariborz Jahanian2009-08-261-1/+3
| | | | | | type convesions of class objects [class.conv]. WIP. llvm-svn: 80127
* Initial patch to support definitions of id and Class from headers in ↵David Chisnall2009-08-171-1/+1
| | | | | | | | | | Objective-C code. This currently breaks test/SemaObjC/id-isa-ref.m and issues some spurious warnings when you attempt to assign a struct objc_class* value to a Class variable. The test case probably should fail as it's written, because without the definition of Class the compiler should not assume struct objc_class* is a valid receiver type, but it's left broken because it would be nice if we could get that passing too for the special case of isa. Approved by snaroff. llvm-svn: 79248
* Move builtin call checking out into a separate function, make ↵Anders Carlsson2009-08-161-43/+49
| | | | | | CheckFunctionCall and CheckBlockCall return bool instead. No intended functionality change. llvm-svn: 79157
* Fix a fixme by allocating ShuffleVectorExprs in the ContextNate Begeman2009-08-121-2/+2
| | | | llvm-svn: 78780
* More CastKind work.Anders Carlsson2009-08-071-3/+3
| | | | llvm-svn: 78415
* add support for FreeBSD's format(printf0,x,y) attribute; allows null format ↵Ryan Flynn2009-08-061-2/+17
| | | | | | string. llvm-svn: 78276
* Canonicalize else.Mike Stump2009-08-041-7/+4
| | | | llvm-svn: 78102
* Add CK_DerivedToBase and use it PerformObjectMemberConversion.Anders Carlsson2009-07-311-2/+4
| | | | llvm-svn: 77652
* Change uses of:Ted Kremenek2009-07-291-4/+4
| | | | | | | | | | | | | | | | | | | | Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsRecordType() -> Type::getAs<RecordType>() Type::getAsPointerType() -> Type::getAs<PointerType>() Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>() Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>() Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>() Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>() Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsTagType() -> Type::getAs<TagType>() And remove Type::getAsReferenceType(), etc. This change is similar to one I made a couple weeks ago, but that was partly reverted pending some additional design discussion. With Doug's pending smart pointer changes for Types, it seemed natural to take this approach. llvm-svn: 77510
* Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methodsTed Kremenek2009-07-171-4/+4
| | | | | | | | | until Doug Gregor's Type smart pointer code lands (or more discussion occurs). These methods just call the new Type::getAs<XXX> methods, so we still have reduced implementation redundancy. Having explicit getAsXXXType() methods makes it easier to set breakpoints in the debugger. llvm-svn: 76193
* Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.Ted Kremenek2009-07-161-4/+4
| | | | | | | | | | | | | | | | | | | | | This method is intended to eventually replace the individual Type::getAsXXXType<> methods. The motivation behind this change is twofold: 1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of them are basically copy-and-paste. 2) By centralizing the implementation of the getAs<Type> logic we can more smoothly move over to Doug Gregor's proposed canonical type smart pointer scheme. Along with this patch: a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>. b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>. llvm-svn: 76098
* Remove the ASTContext parameter from the attribute-related methods of Decl.Argyrios Kyrtzidis2009-06-301-4/+4
| | | | | | | | | The implementations of these methods can Use Decl::getASTContext() to get the ASTContext. This commit touches a lot of files since call sites for these methods are everywhere. I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it. llvm-svn: 74501
* Move the check for vprintf* functions inside of SemaCheckStringLiteral. ↵Anders Carlsson2009-06-281-25/+22
| | | | | | Fixes PR4470. llvm-svn: 74413
* Implement support for the format_arg attribute. Fixes PR4442.Anders Carlsson2009-06-271-0/+21
| | | | llvm-svn: 74369
* Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.Douglas Gregor2009-06-181-3/+4
| | | | llvm-svn: 73702
* PR4142: Add %m format string specifier.Eli Friedman2009-06-021-0/+5
| | | | llvm-svn: 72726
* tweak non-null check to put the caret on the function, but underline theChris Lattner2009-05-251-2/+3
| | | | | | | | | | | | | | | | | | argument. This avoids the argument from being silenced when the argument is the NULL macro, which is defined in a system header. This also makes the output a bit nicer, e.g.: t.c:8:3: warning: null passed to a callee which requires a non-null argument func1(NULL, cp2, i1); ^ ~~~~ vs something like: t.c:8:10: warning: argument is null where non-null is required func1(NULL, cp2, i1); ^ llvm-svn: 72393
* Check on null arguments in the presense of nonnull attribute.Fariborz Jahanian2009-05-211-0/+14
| | | | llvm-svn: 72219
* add header to be built by gcc 4.3 on Linux.Zhongxing Xu2009-05-201-0/+1
| | | | llvm-svn: 72158
* Template instantiation for __builtin_shufflevector.Douglas Gregor2009-05-191-33/+69
| | | | llvm-svn: 72139
* more printf attribute on block declaration andFariborz Jahanian2009-05-181-0/+28
| | | | | | checking when block is envoked. In progress. llvm-svn: 72039
* Fix <rdar://problem/6880975> [format string] Assertion failed: (Arg < ↵Ted Kremenek2009-05-131-25/+27
| | | | | | | | | NumArgs && "Arg access out of range!"). For format string checking, only check the type of the format specifier for non-vararg functions. llvm-svn: 71672
* add support for __sync_nand_and_fetch and __sync_fetch_and_nand,Chris Lattner2009-05-131-9/+15
| | | | | | rdar://6880573 llvm-svn: 71636
* Fix the atomics sema code to convert operands to the argument typesChris Lattner2009-05-081-8/+19
| | | | | | | | | of the underlying _N builtin, not the the type of the pointee of the actual type. This ensures that atomics involving pointers end up using the correct integer type when they are resolved, avoiding aborts in codegen. llvm-svn: 71218
* reimplement __sync_* builtins to be variadic and to follow the sameChris Lattner2009-05-081-0/+184
| | | | | | | | | semantic rules that gcc and icc use. This implements the variadic and concrete versions as builtins and has sema do the disambiguation. There are probably a bunch of details to finish up but this seems like a large monotonic step forward :) llvm-svn: 71212
* Fix silly mistake that was breaking tests. Sorry for any inconvenience.Eli Friedman2009-05-031-1/+3
| | | | llvm-svn: 70664
* Add Sema support for __builtin_setjmp/__builtin_longjmp. The primary Eli Friedman2009-05-031-0/+15
| | | | | | | | | | | reason for adding these is to error out in CodeGen when trying to generate them instead of silently emitting a call to a non-existent function. (Note that it is not valid to lower these to setjmp/longjmp; in addition to that lowering being different from the intent, setjmp and longjmp require a larger buffer.) llvm-svn: 70658
* implement -Wformat-security properly, which is enabled by default.Chris Lattner2009-04-291-3/+10
| | | | | | This enables one specific class of non-literal format warnings. llvm-svn: 70368
* code simplification, no functionality change.Chris Lattner2009-04-291-33/+30
| | | | llvm-svn: 70367
* minor code cleanupChris Lattner2009-04-291-2/+2
| | | | llvm-svn: 70361
* Fixup semantic analysis for nested blocks, and allow block literalMike Stump2009-04-171-2/+3
| | | | | | | expressions that can be of static duration to be returned. Radar 6786551 llvm-svn: 69331
* Fix <rdar://problem/6786597> varargs not supported for Blocks under clang.Steve Naroff2009-04-151-2/+6
| | | | | | Teach Sema::SemaBuiltinVAStart() about blocks. llvm-svn: 69201
* Move/update recent FIXME (wrt UTF-8 checking for ObjC @-strings).Steve Naroff2009-04-131-0/+5
| | | | llvm-svn: 68982
* CodeGenModule::GetAddrOfConstantCFString():Steve Naroff2009-04-011-7/+0
| | | | | | | | | | - Finish up support for converting UTF8->UTF16 to support ObjC @"string" constants. Remove warning from CheckObjCString. As the FIXME in the test case indicates, I still have a bug to work out (apparently with \u handling). llvm-svn: 68245
* Fix <rdar://problem/6704086> by allowing the format string checking in Sema toTed Kremenek2009-03-201-21/+56
| | | | | | | | allow non-literal format strings that are variables that (a) permanently bind to a string constant and (b) whose string constants are resolvable within the same translation unit. llvm-svn: 67404
* When checking printf-arguments for functions with '__attribute__ ((format ↵Ted Kremenek2009-02-271-4/+6
| | | | | | | | | | (printf, X, Y)))' set HasVAListArg to true when 'Y' is 0 (i.e., ignore the data arguments). This fixes <rdar://problem/6623513>. llvm-svn: 65642
* Create a new TypeNodes.def file that enumerates all of the types,Douglas Gregor2009-02-261-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | giving them rough classifications (normal types, never-canonical types, always-dependent types, abstract type representations) and making it far easier to make sure that we've hit all of the cases when decoding types. Switched some switch() statements on the type class over to using this mechanism, and filtering out those things we don't care about. For example, CodeGen should never see always-dependent or non-canonical types, while debug info generation should never see always-dependent types. More switch() statements on the type class need to be moved over to using this approach, so that we'll get warnings when we add a new type then fail to account for it somewhere in the compiler. As part of this, some types have been renamed: TypeOfExpr -> TypeOfExprType FunctionTypeProto -> FunctionProtoType FunctionTypeNoProto -> FunctionNoProtoType There shouldn't be any functionality change... llvm-svn: 65591
* Arguments to unordered comparison builtins may need implicit casts.Daniel Dunbar2009-02-191-0/+6
| | | | | | - <rdar://problem/6094103> sema fails to promote type arguments to __builtin_isgreater (and friends) llvm-svn: 65059
* final string diagnostic issue (that I know about):Chris Lattner2009-02-181-16/+3
| | | | | | | | | | | | | | | | | we used to not account for escapes in strings with string concat. Before: t.m:5:20: warning: field width should have type 'int', but argument has type 'unsigned int' printf("\n\n" "\n\n%*d", (unsigned) 1, 1); ^ ~~~~~~~~~~~~ after: t.m:5:23: warning: field width should have type 'int', but argument has type 'unsigned int' printf("\n\n" "\n\n%*d", (unsigned) 1, 1); ^ ~~~~~~~~~~~~ llvm-svn: 64941
* Next step toward making string diagnostics correct: handleChris Lattner2009-02-181-5/+8
| | | | | | | | | | | | | escapes in the string for subtoken positioning. This gives us working examples like: t.m:5:16: warning: field width should have type 'int', but argument has type 'unsigned int' printf("\n\n%*d", (unsigned) 1, 1); ^ ~~~~~~~~~~~~ where before the caret pointed two spaces to the left. llvm-svn: 64940
* Fix some issues handling sub-token locations that come from macro expansions.Chris Lattner2009-02-181-8/+3
| | | | | | | | | | | | | | | We now emit: t.m:6:15: warning: field width should have type 'int', but argument has type 'unsigned int' printf(STR, (unsigned) 1, 1); ^ ~~~~~~~~~~~~ t.m:3:18: note: instantiated from: #define STR "abc%*ddef" ^ which has the correct location in the string literal in the note line. llvm-svn: 64936
* only get the spelling of a token to get its length if Chris Lattner2009-02-181-5/+12
| | | | | | it needs cleaning. llvm-svn: 64932
* use the full spelling of a string literal token so that trigraphsChris Lattner2009-02-181-1/+8
| | | | | | | | | | | | | | | | | | | | | and escaped newlines don't throw off the offset computation. On this testcase: printf("abc\ def" "%*d", (unsigned) 1, 1); Before: t.m:5:5: warning: field width should have type 'int', but argument has type 'unsigned int' def" ^ after: t.m:6:12: warning: field width should have type 'int', but argument has type 'unsigned int' "%*d", (unsigned) 1, 1); ^ ~~~~~~~~~~~~ llvm-svn: 64930
* Start improving diagnostics that relate to subcharacters of string literals.Chris Lattner2009-02-181-17/+80
| | | | | | | | | | | | | | | | | | | | First step, handle diagnostics in StringLiteral's that are due to token pasting. For example, we now handle: id str2 = @"foo" "bar" @"baz" " b\0larg"; // expected-warning {{literal contains NUL character}} Correctly: test/SemaObjC/exprs.m:17:15: warning: CFString literal contains NUL character " b\0larg"; // expected-warning {{literal contains NUL character}} ~~~^~~~~~~ There are several other related issues still to be done. llvm-svn: 64924
* rename CheckBuiltinCFStringArgument -> CheckObjCStringChris Lattner2009-02-181-4/+3
| | | | llvm-svn: 64894
* Add hook to add attributes to function declarations that we knowDouglas Gregor2009-02-141-33/+26
| | | | | | | | | | | | | | | | about, whether they are builtins or not. Use this to add the appropriate "format" attribute to NSLog, NSLogv, asprintf, and vasprintf, and to translate builtin attributes (from Builtins.def) into actual attributes on the function declaration. Use the "printf" format attribute on function declarations to determine whether we should do format string checking, rather than looking at an ad hoc list of builtins and "known" function names. Be a bit more careful about when we consider a function a "builtin" in C++. llvm-svn: 64561
* Make it possible for builtins to expression FILE* arguments, so thatDouglas Gregor2009-02-141-4/+2
| | | | | | | | we can define builtins such as fprintf, vfprintf, and __builtin___fprintf_chk. Give a nice error message when we need to implicitly declare a function like fprintf. llvm-svn: 64526
* Extend builtin "attribute" syntax to include a notation forDouglas Gregor2009-02-141-31/+21
| | | | | | | | | | | | | | | | | | | | | printf-like functions, both builtin functions and those in the C library. The function-call checker now queries this attribute do determine if we have a printf-like function, rather than scanning through the list of "known functions IDs". However, there are 5 functions they are not yet "builtins", so the function-call checker handles them specifically still: - fprintf and vfprintf: the builtins mechanism cannot (yet) express FILE* arguments, so these can't be encoded. - NSLog: the builtins mechanism cannot (yet) express NSString* arguments, so this (and NSLogv) can't be encoded. - asprintf and vasprintf: these aren't part of the C99 standard library, so we really shouldn't be defining them as builtins in the general case (and we don't seem to have the machinery to make them builtins only on certain targets and depending on whether extensions are enabled). llvm-svn: 64512
OpenPOWER on IntegriCloud