Commit Graph

97 Commits

Author SHA1 Message Date
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Chris Lattner 870158eebf reject returning a block expr even when it has parens and casts in the way.
llvm-svn: 81176
2009-09-08 00:36:37 +00:00
Douglas Gregor f405d7e6f1 Eliminate CXXAdornedMemberExpr entirely. Instead, optionally allocate
space within the MemberExpr for the nested-name-specifier and its
source range. We'll do the same thing with explicitly-specified
template arguments, assuming I don't flip-flop again.

llvm-svn: 80642
2009-08-31 23:41:50 +00:00
Douglas Gregor 96ee789d33 Rename CXXQualifiedMemberExpr -> CXXAdornedMemberExpr, since we will
also be adding explicit template arguments as an additional
"adornment". No functionality change.

llvm-svn: 80628
2009-08-31 21:41:48 +00:00
Eli Friedman 7e4faaccda PR4836, part 1: add Sema support for __builtin_isnan and friends; they
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
2009-08-31 20:06:00 +00:00
Douglas Gregor c190523d7a When a member reference expression includes a qualifier on the member
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
2009-08-26 22:36:53 +00:00
Fariborz Jahanian 1cec0c4c94 update to CXXFunctionalCastExpr to support ir-gen for
type convesions of class objects [class.conv]. WIP.

llvm-svn: 80127
2009-08-26 18:55:36 +00:00
David Chisnall 9f57c29053 Initial patch to support definitions of id and Class from headers in 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
2009-08-17 16:35:33 +00:00
Anders Carlsson bc4c107836 Move builtin call checking out into a separate function, make CheckFunctionCall and CheckBlockCall return bool instead. No intended functionality change.
llvm-svn: 79157
2009-08-16 01:56:34 +00:00
Nate Begeman f485fb55d8 Fix a fixme by allocating ShuffleVectorExprs in the Context
llvm-svn: 78780
2009-08-12 02:10:25 +00:00
Anders Carlsson f10e414e4e More CastKind work.
llvm-svn: 78415
2009-08-07 22:21:05 +00:00
Ryan Flynn aa5e5fd2f4 add support for FreeBSD's format(printf0,x,y) attribute; allows null format string.
llvm-svn: 78276
2009-08-06 03:00:50 +00:00
Mike Stump 12b8ce168d Canonicalize else.
llvm-svn: 78102
2009-08-04 21:02:39 +00:00
Anders Carlsson a076d14514 Add CK_DerivedToBase and use it PerformObjectMemberConversion.
llvm-svn: 77652
2009-07-31 01:23:52 +00:00
Ted Kremenek c23c7e6a51 Change uses of:
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
2009-07-29 21:53:49 +00:00
Ted Kremenek 8a286fbdb9 Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methods
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
2009-07-17 17:50:17 +00:00
Ted Kremenek e3fb4b6524 Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
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
2009-07-16 19:58:26 +00:00
Argyrios Kyrtzidis b4b64ca752 Remove the ASTContext parameter from the attribute-related methods of Decl.
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
2009-06-30 02:34:44 +00:00
Anders Carlsson b012ca92ac Move the check for vprintf* functions inside of SemaCheckStringLiteral. Fixes PR4470.
llvm-svn: 74413
2009-06-28 19:55:58 +00:00
Anders Carlsson f0a7f3b089 Implement support for the format_arg attribute. Fixes PR4442.
llvm-svn: 74369
2009-06-27 04:05:33 +00:00
Douglas Gregor 78bd61f661 Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.
llvm-svn: 73702
2009-06-18 16:11:24 +00:00
Eli Friedman 9baa191f31 PR4142: Add %m format string specifier.
llvm-svn: 72726
2009-06-02 08:36:19 +00:00
Chris Lattner 23464b8f14 tweak non-null check to put the caret on the function, but underline the
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
2009-05-25 18:23:36 +00:00
Fariborz Jahanian cd1a88da02 Check on null arguments in the presense of nonnull attribute.
llvm-svn: 72219
2009-05-21 18:48:51 +00:00
Zhongxing Xu 050379b865 add header to be built by gcc 4.3 on Linux.
llvm-svn: 72158
2009-05-20 01:55:10 +00:00
Douglas Gregor c25f766065 Template instantiation for __builtin_shufflevector.
llvm-svn: 72139
2009-05-19 22:10:17 +00:00
Fariborz Jahanian c1585be6bd more printf attribute on block declaration and
checking when block is envoked. In progress.

llvm-svn: 72039
2009-05-18 21:05:18 +00:00
Ted Kremenek 4554f9b134 Fix <rdar://problem/6880975> [format string] Assertion failed: (Arg < 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
2009-05-13 16:06:05 +00:00
Chris Lattner 94578cba76 add support for __sync_nand_and_fetch and __sync_fetch_and_nand,
rdar://6880573

llvm-svn: 71636
2009-05-13 04:37:52 +00:00
Chris Lattner 5b9241b2a6 Fix the atomics sema code to convert operands to the argument types
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
2009-05-08 15:36:58 +00:00
Chris Lattner dc04654697 reimplement __sync_* builtins to be variadic and to follow the same
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
2009-05-08 06:58:22 +00:00
Eli Friedman c97d014a9a Fix silly mistake that was breaking tests. Sorry for any inconvenience.
llvm-svn: 70664
2009-05-03 06:04:26 +00:00
Eli Friedman eed8ad2057 Add Sema support for __builtin_setjmp/__builtin_longjmp. The primary
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
2009-05-03 04:46:36 +00:00
Chris Lattner cc5d1c2e4e implement -Wformat-security properly, which is enabled by default.
This enables one specific class of non-literal format warnings.

llvm-svn: 70368
2009-04-29 04:59:47 +00:00
Chris Lattner e009a881ea code simplification, no functionality change.
llvm-svn: 70367
2009-04-29 04:49:34 +00:00
Chris Lattner e3fa5aa91c minor code cleanup
llvm-svn: 70361
2009-04-29 04:12:34 +00:00
Mike Stump 5c3285b6fb Fixup semantic analysis for nested blocks, and allow block literal
expressions that can be of static duration to be returned.
Radar 6786551

llvm-svn: 69331
2009-04-17 00:09:41 +00:00
Steve Naroff 439a3e4106 Fix <rdar://problem/6786597> varargs not supported for Blocks under clang.
Teach Sema::SemaBuiltinVAStart() about blocks.

llvm-svn: 69201
2009-04-15 19:33:47 +00:00
Steve Naroff fb46e8658c Move/update recent FIXME (wrt UTF-8 checking for ObjC @-strings).
llvm-svn: 68982
2009-04-13 20:26:29 +00:00
Steve Naroff 8d816d6cb5 CodeGenModule::GetAddrOfConstantCFString():
- 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
2009-04-01 21:16:31 +00:00
Ted Kremenek dfd72c2b44 Fix <rdar://problem/6704086> by allowing the format string checking in Sema to
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
2009-03-20 21:35:28 +00:00
Ted Kremenek 9723bcf60f When checking printf-arguments for functions with '__attribute__ ((format (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
2009-02-27 17:58:43 +00:00
Douglas Gregor deaad8cc34 Create a new TypeNodes.def file that enumerates all of the types,
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
2009-02-26 23:50:07 +00:00
Daniel Dunbar 96f8677e11 Arguments to unordered comparison builtins may need implicit casts.
- <rdar://problem/6094103> sema fails to promote type arguments to __builtin_isgreater (and friends)

llvm-svn: 65059
2009-02-19 19:28:43 +00:00
Chris Lattner 3dd56f96c3 final string diagnostic issue (that I know about):
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
2009-02-18 19:26:42 +00:00
Chris Lattner ddb7191920 Next step toward making string diagnostics correct: handle
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
2009-02-18 19:21:10 +00:00
Chris Lattner ec396b5114 Fix some issues handling sub-token locations that come from macro expansions.
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
2009-02-18 18:52:52 +00:00
Chris Lattner 259971431d only get the spelling of a token to get its length if
it needs cleaning.

llvm-svn: 64932
2009-02-18 18:40:20 +00:00
Chris Lattner f638b97fe0 use the full spelling of a string literal token so that trigraphs
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
2009-02-18 18:34:12 +00:00
Chris Lattner a26fb347a0 Start improving diagnostics that relate to subcharacters of string literals.
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
2009-02-18 17:49:48 +00:00