Commit Graph

4006 Commits

Author SHA1 Message Date
Fariborz Jahanian 257eac6d0c Cleanup objc's gc attributes code no longer needed.
This make warn-weak-field.m to fail (subject of
a followup patch). 
attr-objc-gc.m no passes.

llvm-svn: 64925
2009-02-18 17:52:36 +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
Douglas Gregor 220cac5e89 Update Parser::ParseTypeName to return a TypeResult, which also tells
us whether there was an error in trying to parse a type-name (type-id
in C++). This allows propagation of errors further in the compiler,
suppressing more bogus error messages.

llvm-svn: 64922
2009-02-18 17:45:20 +00:00
Ted Kremenek ab89bc8ca1 Revise comment. Comparing pointer values in 'Range' wasn't the performance issue I thought it was, but it is still worth ordering Range objects by their APSInt values.
llvm-svn: 64921
2009-02-18 17:42:44 +00:00
Douglas Gregor c5c0488338 Add an unavailable __tg_promote function to attract incorrect uses of type-generic macros, rom Howard Hinnant.
llvm-svn: 64919
2009-02-18 17:23:05 +00:00
Chris Lattner 1fa74d9509 nothing says "ted was here" like a random url dropped in a header :)
llvm-svn: 64903
2009-02-18 07:09:44 +00:00
Douglas Gregor 94349fd8cb Allow "overloadable" functions in C to be declared as variadic without
any named parameters, e.g., this is accepted in C:

  void f(...) __attribute__((overloadable));

although this would be rejected:

  void f(...);

To do this, moved the checking of the "ellipsis without any named
arguments" condition from the parser into Sema (where it belongs anyway).

llvm-svn: 64902
2009-02-18 07:07:28 +00:00
Chris Lattner 112c2a914f teach child iterators to walk into the child string of an ObjCStringLiteral,
so it shows up in -ast-dump.

llvm-svn: 64901
2009-02-18 06:53:08 +00:00
Chris Lattner 163ffd22c3 fix the ownership issues and location tracking in
Sema::ParseObjCStringLiteral.

llvm-svn: 64900
2009-02-18 06:48:40 +00:00
Chris Lattner f83b5afb7b privatize all of the string literal memory allocation/creation
stuff behind a private static function.

llvm-svn: 64898
2009-02-18 06:40:38 +00:00
Douglas Gregor b2809a0a1b Don't allow calls to functions marked "unavailable". There's more work
to do in this area, since there are other places that reference
FunctionDecls.

Don't allow "overloadable" functions (in C) to be declared without a
prototype.

llvm-svn: 64897
2009-02-18 06:34:51 +00:00
Chris Lattner d7670d9a96 add some comments describing what is happening here.
llvm-svn: 64896
2009-02-18 06:13:04 +00:00
Chris Lattner fffd6a7e38 simplify the code used to compute the type of an objc string. This makes
it faster in the common case when NSConstantString is around.

llvm-svn: 64895
2009-02-18 06:06:56 +00:00
Chris Lattner 6436fb6acb rename CheckBuiltinCFStringArgument -> CheckObjCString
llvm-svn: 64894
2009-02-18 06:01:06 +00:00
Chris Lattner d3b5d5d1df simplify some code.
llvm-svn: 64893
2009-02-18 05:56:09 +00:00
Chris Lattner 630970ddb8 change the StringLiteral AST node to track all of the SourceLocations of
the various PPTokens that are pasted together to make it.  In the course
of working on this, I discovered ParseObjCStringLiteral which needs some
work.  I'll tackle it next.

llvm-svn: 64892
2009-02-18 05:49:11 +00:00
Ted Kremenek c2c0bdb880 Fix performance bug in RangeConstraintManager (that I introduced):
When comparing if one Range is "less" than another, compare the actual APSInt
  numeric values instead of their pointer addresses. This ensures that the
  ImmutableSet in RangeSet always has a consistent ordering between Ranges. This
  is critical for generating the same digest/hash for the contents of the sets.
  This was a serious performance bug because it would often cause state caching
  to be disabled along complicated paths.
  
Along the way:
 - Put Range and RangeSet in the "anonymous namespace" and mark them hidden

llvm-svn: 64890
2009-02-18 05:22:01 +00:00
Fariborz Jahanian e27e934d45 Representation of objc gc's attribute using ExtQualType.
Note that one test attr-objc-gc.m fails. I will fix this
after removing these attributes from the Decl nodes.

llvm-svn: 64889
2009-02-18 05:09:49 +00:00
Chris Lattner 2c4866057d fix rdar://6597252: two exactly identical pointer types are always
compatible, even if they are weird implicit objc pointer types like
Class.

llvm-svn: 64885
2009-02-18 04:38:20 +00:00
Chris Lattner 432cff5bf4 rename some variables, no functionality change.
llvm-svn: 64884
2009-02-18 04:28:32 +00:00
Ted Kremenek 48d1645179 Hooked up the necessary machinery to allow the retain/release checker reference
back to the summary used when evaluating the statement associated with a
simulation node. This is now being used to help improve the checker's
diagnostics. To get things started, the checker now emits a path diagnostic
indicating that 'autorelease' is a no-op in GC mode.

Some of these changes are exposing further grossness in the interface between
BugReporter and the ExplodedGraph::Trim facilities. These really need to be
cleaned up one day.

llvm-svn: 64881
2009-02-18 03:48:14 +00:00
Daniel Dunbar 617e89231d x86_64 ABI: Two bug fixes.
1. Return of _Complex long double used wrong type.

2. va_arg of types passed in two SSE registers didn't account for
extra space in register save area.

Down to 18 failures on gcc/compat/x86_64. Combined 32/64 results are:
--
		=== gcc Summary ===

# of expected passes		1292
# of unexpected failures	34
# of unsupported tests		2
--

llvm-svn: 64880
2009-02-18 03:44:19 +00:00
Ted Kremenek d84fff6524 retain/release checker: Record the summary used to generate a given node.
llvm-svn: 64876
2009-02-18 02:00:25 +00:00
Daniel Dunbar 4750e63486 isICE was evaluating ?: incorrectly with missing-gcc-LHS extension.
Add assert to isICE that, on success, result must be the same as
EvaluateAsInt()... this enforces a minimum level of sanity.

llvm-svn: 64865
2009-02-18 00:47:45 +00:00
Daniel Dunbar 62347a0c55 Convert isIntegerConstantExpr to use ASTContext::MakeIntValue.
- This idiom ensures that the result will have the right width and
   type.

 - Tested on most of x86_64/llvm-test to satisfy my paranoia.

 - This fixes at least the following bugs:
   o UnaryTypeTraitExpr wasn't setting the width correctly.
   o Arithmetic on _Bool wasn't setting the width correctly.

   And probably a number more.

llvm-svn: 64864
2009-02-18 00:32:53 +00:00
Chris Lattner 970f245439 stop searching GCC install directories for standard C headers (but
keep searching for C++ headers when in C++ mode).  In theory clang
should be able to find all of its own headers now.  If not, the
CPATH or C_INCLUDE_PATH environment variables can be specified to
add a include path.

llvm-svn: 64862
2009-02-18 00:25:15 +00:00
Ted Kremenek fa1840b25e Add panic function.
llvm-svn: 64852
2009-02-17 23:27:17 +00:00
Mike Stump eecd39f2d7 Avoid getNameAsCString when the decl doesn't have a name.
Build of the parm list with the iterator, not end().

llvm-svn: 64851
2009-02-17 23:25:52 +00:00
Daniel Dunbar 491812cd76 Rename UnaryTypeTraitExpr::Evaluate to EvaluateTrait to not collide
with Expr::Evaluate().

llvm-svn: 64850
2009-02-17 23:20:26 +00:00
Chris Lattner 976fdefe2f gcc spells it "warn_unused_result" (already supported) not "warnunusedresult"
llvm-svn: 64849
2009-02-17 23:20:10 +00:00
Douglas Gregor 67a6564091 Implement basic parsing and semantic analysis for explicit
specialization of class templates, e.g.,

  template<typename T> class X;

  template<> class X<int> { /* blah */ };

Each specialization is a different *Decl node (naturally), and can
have different members. We keep track of forward declarations and
definitions as for other class/struct/union types.

This is only the basic framework: we still have to deal with checking
the template headers properly, improving recovery when there are
failures, handling nested name specifiers, etc.

llvm-svn: 64848
2009-02-17 23:15:12 +00:00
Ted Kremenek 2620a06fe7 Attribute 'iboutlet' can be applied to Objective-C property declarations.
llvm-svn: 64831
2009-02-17 22:20:20 +00:00
Daniel Dunbar 43a5d9e409 Eek! getDeclAlign sometimes returned alignment in bits.
- Renamed to getDeclAlignInBytes since most other query functions
   work in bits.

 - Fun to track down as isIntegerConstantExpr was getting it right,
   but Evaluate() was getting it wrong. Maybe we should assert they
   compute the same thing when they succeed?

llvm-svn: 64828
2009-02-17 22:16:19 +00:00
Chris Lattner abbd427cd0 initial reimplement tgmath.h, written by Howard Hinnant!
llvm-svn: 64826
2009-02-17 22:14:32 +00:00
Fariborz Jahanian 37b43cd89c Simplified ExtQualType per Chris's feedback.
llvm-svn: 64820
2009-02-17 21:45:36 +00:00
Argyrios Kyrtzidis 8c80735929 Remove one more redundant dyn_cast.
llvm-svn: 64808
2009-02-17 20:46:25 +00:00
Argyrios Kyrtzidis 84d8fae3be Move DeclContext::getParent and getLexicalParent in-line.
llvm-svn: 64806
2009-02-17 20:26:05 +00:00
Argyrios Kyrtzidis 50c0ff1f43 Currently all DeclContexts are Decls as well; use cast<Decl> instead of dyn_cast.
llvm-svn: 64805
2009-02-17 20:24:53 +00:00
Argyrios Kyrtzidis 4b4f67ac0a Remove some redundant Decl -> Decl castings.
llvm-svn: 64804
2009-02-17 20:23:54 +00:00
Argyrios Kyrtzidis 13c9cc8b37 Now that ObjC decls have DeclContexts too, remove an ugly hack from IdentifierResolver.
llvm-svn: 64802
2009-02-17 20:21:51 +00:00
Argyrios Kyrtzidis 0cf6625ff8 All Decls have a DeclContext now, hooray! Fans of consistency rejoice.
Pass the DeclContext to ObjCIvarDecls as well.

llvm-svn: 64801
2009-02-17 20:20:37 +00:00
Fariborz Jahanian 19c44508a1 Added support for objc's gc attribute in ExtQualType.
llvm-svn: 64800
2009-02-17 20:16:45 +00:00
Ted Kremenek 3189f495de Revised RangeConstraintManager based on several discussions with Ben Laurie and
Zhongxing Xu. The resultant code is less than 1/2 the size of the original.

Key highlights:

- All CouldBeXXX methods have been removed. Checking for feasibility is now just
  done in the AddXXX methods.

- RangeSets now represent "all possible values" explicitly as the range set {
  [min, max] } instead of the empty set. The empty set now represents "no
  feasible values". This change consolidated much of the core algorithm to only
  have one code path instead of alternate paths that considered the empty set to
  represent "all possible falues."

llvm-svn: 64787
2009-02-17 19:28:04 +00:00
Daniel Dunbar 38ad1e6138 Change EmitConstantExpr to allow failure.
IRgen no longer relies on isConstantInitializer, instead we just try
to emit the constant. If that fails then in C we emit an error
unsupported (this occurs when Sema accepted something that it doesn't
know how to fold, and IRgen doesn't know how to emit) and in C++ we
emit a guarded initializer.

This ends up handling a few more cases, because IRgen was actually
able to emit some of the constants Sema accepts but can't Evaluate().
For example, PR3398.

llvm-svn: 64780
2009-02-17 18:43:32 +00:00
Daniel Dunbar 3d926cbf79 80-cols.
llvm-svn: 64779
2009-02-17 18:31:04 +00:00
Fariborz Jahanian ece8582ca2 Renamed ASQualType to ExtQualType to reflect its more
general use; as for, objc2's gc type attributes. No
change in functionality.

llvm-svn: 64778
2009-02-17 18:27:45 +00:00
Ted Kremenek 852882ca97 Add '_assert' to list of known panic functions.
llvm-svn: 64772
2009-02-17 17:48:52 +00:00
Ben Laurie 54a06ce437 Handle fatal errors.
llvm-svn: 64770
2009-02-17 17:32:22 +00:00
Mike Stump 03868f4ea0 Be sure to initialize Name.
llvm-svn: 64769
2009-02-17 17:18:36 +00:00
Mike Stump c6ea7c1812 Fixup spacing a little.
llvm-svn: 64768
2009-02-17 17:00:02 +00:00
Douglas Gregor 7a0febe66d Remove the error about redefining library functions. It's causing too
much pain when compiling the Linux kernel (PR3592).

llvm-svn: 64767
2009-02-17 16:03:01 +00:00
Chris Lattner 7b60a164b1 As an experimental hack, emit "instantiated from" information in
diagnostics.  I'm not sure I want to keep this, but hey, it's easy
and could be useful or something, even if guarded by a 
-fshow-me-tons-of-details option.  A silly example is:

#define A B
#define C A
#define D C

int y = D;

We now emit:

t.c:11:9: error: use of undeclared identifier 'B'
int y = D;
        ^
t.c:9:11: note: instantiated from:
#define D C
          ^
t.c:8:11: note: instantiated from:
#define C A
          ^
t.c:7:11: note: instantiated from:
#define A B
          ^

A more useful example is from tgmath:

t.c:4:9: error: no matching function for call to '__tg_acos'
 return acos(x);
        ^~~~~~~
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:51:17: note: instantiated from:
#define acos(x) __tg_acos(x)
                ^
... candidate set follows ...

This does not yet print ranges in instantiation info, (e.g. highlighting the
range "__tg_acos(x)" in the last example), but that could be added if we 
decide this is a good idea :).

Thoughts and bug reports welcome!

llvm-svn: 64761
2009-02-17 08:44:50 +00:00
Chris Lattner a6f037cee1 add an accessor.
llvm-svn: 64760
2009-02-17 08:39:06 +00:00
Chris Lattner 709322b8df emit:
t.c:4:9: error: invalid type 'short *' to __real operator
                         __tg_choose (__real__(z), C##f(z), (C)(z), C##l(z)), 
                                      ^
instead of:
t.c:4:9: error: invalid type 'short *' to __real or __imag operator
                         __tg_choose (__real__(z), C##f(z), (C)(z), C##l(z)),
                                      ^

fixing a fixme.  It would be even fancier to get the spelling of the token, but I
don't care *that* much :)

llvm-svn: 64759
2009-02-17 08:12:06 +00:00
Chris Lattner 8ad52d5068 add an accessor.
llvm-svn: 64758
2009-02-17 08:04:48 +00:00
Daniel Dunbar c9feeb54a5 Spell __always_inline__ correctly.
llvm-svn: 64757
2009-02-17 07:57:58 +00:00
Daniel Dunbar 0ee13255ee x86_64 ABI: Fix assert on return of _Complex long double.
llvm-svn: 64756
2009-02-17 07:55:55 +00:00
Chris Lattner 5abfe97bf1 sink a call to getInstantiationLoc to eliminate an assertion.
llvm-svn: 64755
2009-02-17 07:54:55 +00:00
Chris Lattner d22603cef0 break down EmitCaretDiagnostic to use more primitive calls.
llvm-svn: 64754
2009-02-17 07:51:53 +00:00
Chris Lattner 30ad173bd1 add some files to fix the cmake build, patch by Piotr Rak!
llvm-svn: 64752
2009-02-17 07:40:10 +00:00
Chris Lattner 2cf68c1e96 split caret diagnostic printing out into its own function.
llvm-svn: 64751
2009-02-17 07:38:37 +00:00
Chris Lattner 11a2a433b2 simplify some code.
llvm-svn: 64750
2009-02-17 07:34:34 +00:00
Chris Lattner 45d9d6001c remove "; candidates are/is:" from various ambiguity diagnostics.
2 out of 2 people on irc prefer them gone :)

llvm-svn: 64749
2009-02-17 07:29:20 +00:00
Chris Lattner 9ee10ea535 fix a minor bug with my previous patch
llvm-svn: 64747
2009-02-17 06:52:20 +00:00
Chris Lattner d2a2c13474 fix notes so that they are always filtered with the same logic
as the last non-note diagnostic that preceeded them.  This ensures
that diagnostics in main files which have notes with locations in 
system headers get all the bits and pieces emitted or not in a 
unit.  This fixes PR3215.

llvm-svn: 64746
2009-02-17 06:49:55 +00:00
Chris Lattner b42700f555 If a source range comes through a function-like macro expansion,
highlight the arguments to the macro as well as the identifier.

Before:

t.c:3:9: error: no matching function for call to '__tg_acos'; candidates are:
 return acos(x);
        ^~~~

after:

t.c:3:9: error: no matching function for call to '__tg_acos'; candidates are:
 return acos(x);
        ^~~~~~~

llvm-svn: 64743
2009-02-17 05:19:10 +00:00
Douglas Gregor a908e7fccc Static variables and functions won't collide with standard library
functions, so if we're declaring a static we should implicitly declare
a library function by the same name (e.g., malloc, strdup). Fixes PR3592.

llvm-svn: 64736
2009-02-17 03:23:10 +00:00
Anders Carlsson b317efdf81 Add SSSE3 header
llvm-svn: 64735
2009-02-17 03:05:04 +00:00
Daniel Dunbar 7f0e2368bb x86_64 ABI: Implement classification for bit-fields.
llvm-svn: 64727
2009-02-17 02:45:44 +00:00
Chris Lattner 325dec7343 remove dead macros
llvm-svn: 64725
2009-02-17 02:42:31 +00:00
Chris Lattner 2ca19c7ee7 explicitly cast integers to double. This a) silences any
possible future "data loss" warnings, and b) makes it intensely
obvious to the user what the impl of these functions do in a
ambiguity error.

llvm-svn: 64724
2009-02-17 02:41:36 +00:00
Chris Lattner 0021110773 asin support. No we don't care about complex int :)
llvm-svn: 64723
2009-02-17 02:37:35 +00:00
Chris Lattner dd0c64b102 hand macro expand this to make "candidate" set printing more useful. However,
Now no candidates are printed because the 'notes' are in a system header. :(

#include <tgmath-sofar.h>
 double foo2(short *x) {
  return acos(x);
}

t.c:10:10: error: no matching function for call to '__tg_acos'; candidates are:
  return acos(x);
         ^~~~
1 diagnostic generated.

llvm-svn: 64722
2009-02-17 02:30:54 +00:00
Chris Lattner bde5bd46b3 add support for integers to tgmath functions. I apparently need to provide
all the integer types other than char/short to avoid overload ambiguities.

llvm-svn: 64721
2009-02-17 02:22:33 +00:00
Chris Lattner 4e843feddc start converting over to attr(overloadable). Unfortunately, this
produces really horrible diagnostics when overload ambiguities
happen:

t.c:10:10: error: call to '__tg_acos' is ambiguous; candidates are:
  return acos(x);
         ^~~~
In file included from t.c:1:
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^

A possible fix is to just not use macros for this, which I'll probably go for,
but it would be nice to emit the type at the call, so we know what we asked for!

llvm-svn: 64720
2009-02-17 02:14:31 +00:00
Chris Lattner 31180bbfb4 Make PragmaPackStack be a private class in SemaAttr and make its
instance in Sema be a pimpl.

llvm-svn: 64718
2009-02-17 01:09:29 +00:00
Douglas Gregor 264ec4f237 Added ClassTemplateSpecializationDecl, which is a subclass of
CXXRecordDecl that is used to represent class template
specializations. These are canonical declarations that can refer to
either an actual class template specialization in the code, e.g.,

  template<> class vector<bool> { };

or to a template instantiation. However, neither of these features is
actually implemented yet, so really we're just using (and uniqing) the
declarations to make sure that, e.g., A<int> is a different type from
A<float>. Note that we carefully distinguish between what the user
wrote in the source code (e.g., "A<FLOAT>") and the semantic entity it
represents (e.g., "A<float, int>"); the former is in the sugared Type,
the latter is an actual Decl.

llvm-svn: 64716
2009-02-17 01:05:43 +00:00
Chris Lattner 01c3d23814 copying and assignment of sema seem unwise :)
llvm-svn: 64712
2009-02-17 00:58:30 +00:00
Chris Lattner 2eccbc1e5d move attribute(packed) sema support out of SemaDecl into a new SemaAttr.cpp file.
llvm-svn: 64711
2009-02-17 00:57:29 +00:00
Chris Lattner 8cad67b8a4 simplify this code and make it use highlight range. This
makes -emit-html do nice things for code like:

#define FOO(X) y

int FOO(4
);

highlighting the FOO instance as well as the ) on the next line properly.

llvm-svn: 64710
2009-02-17 00:51:07 +00:00
Daniel Dunbar f2c6198eef x86_64 ABI: Handle va_arg arguments with alignment > 8.
llvm-svn: 64701
2009-02-16 23:38:56 +00:00
Daniel Dunbar 6e8c07d0ea Diagnose non-power-of-2 arguments to attribute aligned.
llvm-svn: 64700
2009-02-16 23:37:57 +00:00
Anders Carlsson 9ab53d120e Add support for throwing exceptions to the nonfragile ABI
llvm-svn: 64692
2009-02-16 22:59:18 +00:00
Fariborz Jahanian 06292955d0 Added implementation of objc2's gc API calls for
nonfragile abi.

llvm-svn: 64690
2009-02-16 22:52:32 +00:00
Daniel Dunbar 8eb018ab9c Support IRgen of sqrt -> llvm.sqrt, pow -> llvm.pow.
- Define pow[lf]?, sqrt[lf]? as builtins.

 - Add -fmath-errno option which binds to LangOptions.MathErrno

 - Add new builtin flag Builtin::Context::isConstWithoutErrno for
   functions which can be marked as const if errno isn't respected for
   math functions. Sema automatically marks these functions as const
   when they are defined, if MathErrno=0.

 - IRgen uses const attribute on sqrt and pow library functions to
   decide if it can use the llvm intrinsic.

llvm-svn: 64689
2009-02-16 22:43:43 +00:00
Daniel Dunbar 45a2a20384 Unbreak clang.
Doug: please verify that it is expected that LastIdx can be less that
NumInits. And perhaps add a comment so that Chris doesn't break your
code. :)

llvm-svn: 64688
2009-02-16 22:42:44 +00:00
Douglas Gregor 5978cdb5ef Make "implicit int" an error in C++ (unless we're allowing Microsoft
extensions). This caught a couple bugs in our test suite :)

llvm-svn: 64686
2009-02-16 22:38:20 +00:00
Chris Lattner 8ba22471a2 fix long lines.
llvm-svn: 64684
2009-02-16 22:33:34 +00:00
Chris Lattner e084c01124 fix volatile handling with ExtVectorElementExpr, so that we
emit two volatile loads for:
typedef __attribute__(( ext_vector_type(4) )) float float4;

float test(volatile float4 *P) {
  return P->x+P->y;
}

llvm-svn: 64683
2009-02-16 22:25:49 +00:00
Chris Lattner b8211f6436 introduce and use a new ExtVectorElementExpr::isArrow method, at Eli's suggestion
llvm-svn: 64681
2009-02-16 22:14:05 +00:00
Fariborz Jahanian f95039cd58 Use isa<...> instead of dyn_cast<...> where result is not needed.
llvm-svn: 64680
2009-02-16 22:09:26 +00:00
Chris Lattner a377833888 diagnose uses of deprecated typenames and tags.
We now pass all the deprecation tests in the objc.dg suite.

llvm-svn: 64679
2009-02-16 22:07:16 +00:00
Douglas Gregor 9eebd9709a Supply the header corresponding to a library builtin as a separate argument to the LIBBUILTIN macro
llvm-svn: 64676
2009-02-16 21:58:21 +00:00
Daniel Dunbar e28b359881 Fix IRgen of __builtin_memset.
- Fix test case to not only have negative tests.

llvm-svn: 64674
2009-02-16 21:52:05 +00:00
Chris Lattner 58b0589d73 random cleanup
llvm-svn: 64673
2009-02-16 21:43:00 +00:00
Fariborz Jahanian 1dd6094517 Fixes a bug in property type encoding.
llvm-svn: 64672
2009-02-16 21:41:04 +00:00
Chris Lattner e404d0ba05 warn about interfaces that inherit from deprecated classes.
llvm-svn: 64671
2009-02-16 21:33:09 +00:00
Chris Lattner ced903b793 warn about categories that implement deprecated interfaces.
llvm-svn: 64670
2009-02-16 21:30:01 +00:00
Chris Lattner 9018ca8df8 early exit on error. This code is creating an invalid decl on error. This is
dubious, but at least mark it as an invalid decl.

llvm-svn: 64668
2009-02-16 21:26:43 +00:00
Chris Lattner 6c7ce109e0 enhance ExtVectorElementExpr to allow V->xxyy to work like (*V).xxyy
llvm-svn: 64667
2009-02-16 21:11:58 +00:00
Douglas Gregor bfdd607372 When merging from a function with a prototype to a function without a
prototype, synthesize ParmVarDecls for prototype-less FunctionDecl.

llvm-svn: 64666
2009-02-16 20:58:07 +00:00
Fariborz Jahanian 8827046dd3 Remove an unused variable (which caused a warning).
llvm-svn: 64660
2009-02-16 19:40:26 +00:00
Chris Lattner 46d6b13448 do not warn about uses of deprecated decls when in an out-of-line objc method
whose declaration was declared as deprecated.

llvm-svn: 64658
2009-02-16 19:35:30 +00:00
Fariborz Jahanian 7a855e33df Remove FindIvarDeclaration. Use lookupInstanceVariable is is functionally
the same.

llvm-svn: 64657
2009-02-16 19:35:27 +00:00
Douglas Gregor f15f5d3e9f When inside an Objective-C++ method, name lookup should look into the
interface for ivars before assuming that this is an unresolved
function name.

Fixes <rdar://problem/6590445>.

llvm-svn: 64653
2009-02-16 19:28:42 +00:00
Chris Lattner 1598a3a1a9 add assertion
llvm-svn: 64652
2009-02-16 19:27:54 +00:00
Chris Lattner 99a83317b7 code cleanup
llvm-svn: 64651
2009-02-16 19:25:52 +00:00
Chris Lattner aab70d2963 wrap long lines.
llvm-svn: 64650
2009-02-16 19:24:31 +00:00
Daniel Dunbar d73ea816af assert/ErrorUnsupported in unimplemented stub functions instead of
miscompiling.

llvm-svn: 64647
2009-02-16 18:48:45 +00:00
Ted Kremenek 6ae3eaf5a8 Add pretty-printing (for GraphViz) support for RangeConstraintManager.
llvm-svn: 64646
2009-02-16 18:42:56 +00:00
Chris Lattner 43df556ab5 Add support for deprecating ObjC properties. Unlike GCC, we warn that the
property is deprecated, not the getter/setter if the attribute is on
the property.

llvm-svn: 64644
2009-02-16 18:35:08 +00:00
Chris Lattner 41fd42e782 propagate attributes onto property decls.
llvm-svn: 64643
2009-02-16 18:32:47 +00:00
Fariborz Jahanian eb209e7dbd define __OBJC2__ for objc's nonfragile abi.
llvm-svn: 64642
2009-02-16 18:28:48 +00:00
Douglas Gregor bcbf86399f When a function with a prototype is redeclared without a prototype,
merge the prototype into the redeclaration (and make a note in the
declaration). Fixes PR3588.

llvm-svn: 64641
2009-02-16 18:20:44 +00:00
Douglas Gregor 75a45ba2a4 Adopt a more principled approach to invalid declarations:
- If a declaration is an invalid redeclaration of an existing name,
    complain about the invalid redeclaration then avoid adding it to
    the AST (we can still parse the definition or initializer, if any).
  - If the declaration is invalid but there is no prior declaration
    with that name, introduce the invalid declaration into the AST
    (for later error recovery).
  - If the declaration is an invalid redeclaration of a builtin that
    starts with __builtin_, we produce an error and drop the
    redeclaration. If it is an invalid redeclaration of a library
    builtin (e.g., malloc, printf), warn (don't error!) and drop the
    redeclaration.

If a user attempts to define a builtin, produce an error and (if it's
a library builtin like malloc) suggest -ffreestanding.

This addresses <rdar://problem/6097585> and PR2892. However, PR3588 is
still going to cause some problems when builtins are redeclared
without a prototype.

llvm-svn: 64639
2009-02-16 17:45:42 +00:00
Chris Lattner 50afe31b43 add support for deprecated objc ivars.
llvm-svn: 64637
2009-02-16 17:19:12 +00:00
Chris Lattner ee4b5235e3 Add support for deprecated members of RecordDecls (e.g. struct fields).
llvm-svn: 64634
2009-02-16 17:07:21 +00:00
Argyrios Kyrtzidis afe24c8818 DeclContext had its "casting machinery" inside the class definition so that if a new declaration context Decl appeared, the necessary changes
would be in one place. Since, now, only DeclNodes.def needs to be modified, move things out-of-line and simplify the DeclContext class.

llvm-svn: 64630
2009-02-16 14:29:28 +00:00
Argyrios Kyrtzidis ac152f1a1a Make DeclContexts maintenance a bit easier.
-In DeclNodes.def, only mark as DeclContexts the top classes that directly derive from DeclContext. If the Decl has subclasses,
 it should be marked with DECL_CONTEXT_BASE.

-Use DeclNodes.def to automate the DeclContext::classof and DeclContext::CastTo definitions.

llvm-svn: 64629
2009-02-16 14:28:33 +00:00
Ben Laurie 7b1c6c09f7 Untabify.
llvm-svn: 64628
2009-02-16 09:18:41 +00:00
Ted Kremenek fa95ce412c Do not register 'RangeConstraintManager' as the default ConstraintManager.
llvm-svn: 64627
2009-02-16 04:54:20 +00:00
Nate Begeman a6b47a4142 Don't allow taking the address of an element in an ext_vector
llvm-svn: 64614
2009-02-15 22:45:20 +00:00
Chris Lattner 4576b2eebd lots of trailing whitespace
llvm-svn: 64613
2009-02-15 22:44:22 +00:00
Chris Lattner 4bf74fdd90 Refactor the deprecated and unavailable checks into a new
DiagnoseUseOfDeprecatedDecl method.  This ensures that they
are treated consistently.  This gets us 'unavailable' support
on a few new types of decls, and makes sure we consistently
silence deprecated when the caller is also deprecated.

llvm-svn: 64612
2009-02-15 22:43:40 +00:00
Chris Lattner 8510b902fb implement gcc/testsuite/objc.dg/method-attribute-3.m, by improving error recovery.
llvm-svn: 64609
2009-02-15 22:24:30 +00:00
Chris Lattner 0629c8f4e4 don't pass a random english string in as a string argument to Diag.
llvm-svn: 64608
2009-02-15 22:21:03 +00:00
Chris Lattner 20cf43010a fix a fixme in -emit-html output: highlight the entire range of a macro
instantiation, which highlights the arguments of a function like macro
as well as its identifier.

llvm-svn: 64607
2009-02-15 21:32:34 +00:00
Chris Lattner f52c0b261c add a new SourceManager::getInstantiationRange helper method.
llvm-svn: 64606
2009-02-15 21:26:50 +00:00
Chris Lattner 641f1eab77 fix build on systems where uint64_t != unsigned long long
llvm-svn: 64605
2009-02-15 21:20:13 +00:00
Chris Lattner 5a2e9cb42d fix PR3579: __LINE__ expands to the presumed location of the
*end* of a macro instantiation, not the start of it.  This is
really all about bug-for-bug compatibility with GCC, but not
doing this breaks the FreeBSD kernel.

llvm-svn: 64604
2009-02-15 21:06:39 +00:00
Chris Lattner 9dc9c206d3 track "just a little more" location information for macro instantiations.
Now instead of just tracking the expansion history, also track the full
range of the macro that got replaced.  For object-like macros, this doesn't
change anything.  For _Pragma and function-like macros, this means we track
the locations of the ')'.

This is required for PR3579 because apparently GCC uses the line of the ')'
of a function-like macro as the location to expand __LINE__ to.

llvm-svn: 64601
2009-02-15 20:52:18 +00:00
Ted Kremenek d9849254ab Remove accidental duplication of content in .h file.
llvm-svn: 64596
2009-02-15 18:24:51 +00:00
Daniel Dunbar bb025312f3 Fix pasto noticed by Anders Johnsen.
llvm-svn: 64595
2009-02-15 18:23:07 +00:00
Chris Lattner 37959570af implement support for attribute(unavailable) on objc methods.
This implements gcc/testsuite/objc.dg/method-attribute-1.m

llvm-svn: 64581
2009-02-15 07:50:52 +00:00
Daniel Dunbar 8de90f0a92 Obj-C non-fragile ABI: Fix types of a few globals; these were not
creating valid LLVM structures (although they work fined).

llvm-svn: 64580
2009-02-15 07:36:20 +00:00
Chris Lattner 4c6ea8612a allow implementations of deprecated functions to use deprecated symbols.
llvm-svn: 64572
2009-02-15 01:38:09 +00:00
Mike Stump 0e7d7b68c8 Use getNameAsCString instead of getNameAsString and reflow the type.
Thanks Anders.

llvm-svn: 64571
2009-02-14 22:49:33 +00:00
Mike Stump 2d5a2878d4 Generate the helper function for blocks. Now basic codegen is
starting to work for blocks.

llvm-svn: 64570
2009-02-14 22:16:35 +00:00
Fariborz Jahanian 35afdfc36e Fixed a bad ir-gen bug which caused a dejagnu test to fail.
Now we are pretty close to be in sync with objc's classic 
abi when it comes to passing dejagnu objc executable tests.

llvm-svn: 64569
2009-02-14 21:25:36 +00:00
Douglas Gregor 2563d0fa08 Add a test case for -ffreestanding that redefines malloc.
Warn that complex numbers are an extension in a freestanding C99
implementation.

llvm-svn: 64568
2009-02-14 21:06:05 +00:00
Douglas Gregor 69c7951c8e Add -ffreestanding to suppress the implicit declaration of library builtins like printf and malloc. Fixes PR3586
llvm-svn: 64566
2009-02-14 20:49:29 +00:00
Cedric Venet 08438133da Add svn:eol-style=native to some files
Correct two files with inconsistent lines endings.

llvm-svn: 64564
2009-02-14 20:20:19 +00:00
Fariborz Jahanian 99bed6fd21 Fixed a problem caused by foreward @class use
which consequently caused a Seg fault. during meta-data
generation. It also addresses an issue related to
late binding of newly synthesize ivars (when we support it).

llvm-svn: 64563
2009-02-14 20:13:28 +00:00
Anders Carlsson b6ba4682b5 Add support for deprecated Obj-C methods. The semantics mostly match what gcc has.
llvm-svn: 64562
2009-02-14 19:08:58 +00:00
Douglas Gregor e711f7052e Add hook to add attributes to function declarations that we know
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
2009-02-14 18:57:46 +00:00
Anders Carlsson 978f08d9b4 Pass the location of the start of the selector to ActOnClassMessage/ActOnInstanceMessage.
llvm-svn: 64560
2009-02-14 18:21:46 +00:00
Mike Stump eff0cc98cf Fix 80col violations.
llvm-svn: 64559
2009-02-14 18:02:21 +00:00
Ted Kremenek 7efe43db99 Patch by Ben Laurie:
ConstraintManager:
- constify getSymVal()

BasicConstraintManager:
- Pull out logic that would be common to ConstraintManagers of a similar nature
  and put them in a parent class called 'SimpleConstraintManager'.

RangeConstraintManager:
- Added a new prototype ConstraintManager to track ranges of variables! This
  ConstraintManager keeps tracks of ranges of concrete integers that a symbolic
  integer may have.

AnalysisConsumer:
- Add driver option to use RangeConstraintManager with GRExprEngine-based
  analyses.

llvm-svn: 64558
2009-02-14 17:08:39 +00:00
Anton Korobeynikov 7e96595f11 Define __ELF__ on FreeBSD. Patch by Roman Divacky!
llvm-svn: 64557
2009-02-14 16:42:50 +00:00
Cedric Venet d3c80de95f Fix the build on win32.
llvm-svn: 64556
2009-02-14 16:15:20 +00:00
Argyrios Kyrtzidis d831cac2a7 Define __ELF__ for linux systems.
llvm-svn: 64553
2009-02-14 15:02:45 +00:00
Chris Lattner 7320f9c9ad simplify some code.
llvm-svn: 64548
2009-02-14 08:22:25 +00:00
Chris Lattner 62bf958247 just ignore hte format_arg attribute for now, it doesn't have any semantic implications.
llvm-svn: 64547
2009-02-14 08:12:47 +00:00
Chris Lattner 677a35804f add parser and type checking support for attribute((objc_exception)).
We don't have "zero cost" exceptions for ObjC yet, so there is no codegen
support required.

llvm-svn: 64546
2009-02-14 08:09:34 +00:00
Chris Lattner 237f27573f Several related changes:
1) implement parser and sema support for reading and verifying attribute(warnunusedresult).
2) rename hasLocalSideEffect to isUnusedResultAWarning, inverting the sense
   of its result.
3) extend isUnusedResultAWarning to directly return the loc and range 
   info that should be reported to the user.  Make it substantially more
   precise in some cases than what was previously reported.
4) teach isUnusedResultAWarning about CallExpr to decls that are 
   pure/const/warnunusedresult, fixing a fixme.
5) change warn_attribute_wrong_decl_type to not pass in english strings, instead,
   pass in integers and use %select.

llvm-svn: 64543
2009-02-14 07:37:35 +00:00
Chris Lattner 3a23073918 reduce nesting.
llvm-svn: 64542
2009-02-14 07:22:29 +00:00
Ted Kremenek d25fb7a613 GRExprEngine: Handle empty statement expressions.
llvm-svn: 64541
2009-02-14 05:55:08 +00:00
Anders Carlsson 0ed56a1b9f Don't ignore the const attribute - we even have CG support for that. Do ignore the malloc attribute however.
llvm-svn: 64538
2009-02-14 04:12:57 +00:00
Anders Carlsson 11352f9d63 Fix more xmmintrin.h typos
llvm-svn: 64537
2009-02-14 04:01:38 +00:00
Chris Lattner b12f4f8731 ignore the const attribute for now.
llvm-svn: 64536
2009-02-14 03:51:44 +00:00
Ted Kremenek 4e9d4b5d48 Added GRStateManager::scanReachableSymbols(), a method which scans the reachable
symbols from an SVal.

- Fixed a bug in EnvironmentManager::RemoveDeadBindings() where it did not mark
  live all the symbols reachable from a live block-level expression.

- Fixed a bug in the retain/release checker where it did not stop tracking
  symbols that 'escaped' via compound literals being assigned to something the
  BasicStoreManager didn't reason about.

llvm-svn: 64534
2009-02-14 03:16:10 +00:00
Daniel Dunbar 3d88672f64 x86_64 ABI: Need to use canonical types when comparing against
ASTContext types.

llvm-svn: 64533
2009-02-14 02:45:45 +00:00
Daniel Dunbar 019ef0bbfe x86_64 ABI: Pass simple types directly when possible. This is
important for both keeping the generated LLVM simple and for ensuring
that integer types are passed/promoted correctly.

llvm-svn: 64529
2009-02-14 02:09:24 +00:00
Ted Kremenek 13363538ca Use GRTransferFuncs::EvalBind when processing variable initializations.
llvm-svn: 64527
2009-02-14 01:54:57 +00:00
Douglas Gregor 538c3d8459 Make it possible for builtins to expression FILE* arguments, so that
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
2009-02-14 01:52:53 +00:00
Ted Kremenek e68c0fcfb2 Static analyzer:
- Added a new 'node builder' class called GRStmtNodeBuilderRef (name may
  change). This is essentially a smart reference to a GRStmtNodeBuilder object
  that keeps track of the current context (predecessor node, GRExprEngine
  object, etc.) The idea is to gradually simplify the interface between
  GRExprEngine and GRTransferFuncs using this new builder (i.e., passing 1
  argument instead of 5). It also handles some of the "auto-transition" for node
  creation, simplifying some of the logic in GRExprEngine itself.

- Used GRStmtBuilderRef to replace GRTransferFuncs::EvalStore with
  GRTransferFuncs::EvalBind. The new EvalBind method will be used at any
  arbitrary places where a binding between a location and value takes place.
  Moreover, GRTransferFuncs no longer has the responsibility to request
  StoreManager to do the binding; this is now in GRExprEngine::EvalBind. All
  GRTransferFuncs::EvalBind does is checker-specific logic (which can be a
  no-op).

llvm-svn: 64525
2009-02-14 01:43:44 +00:00
Anders Carlsson 30c22d86e8 Fix an error in _mm_loaddup_pd that Eli noticed.
llvm-svn: 64522
2009-02-14 01:06:58 +00:00
Anders Carlsson 823c02eaab Add the nodebug attribute to intrinsics
llvm-svn: 64519
2009-02-14 01:00:11 +00:00
Douglas Gregor ac5d4c5f8e Extend builtin "attribute" syntax to include a notation for
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
2009-02-14 00:32:47 +00:00
Chris Lattner cd7bc144f6 fix rdar://6586493, a bug in codegen of the GNU
missing-?:-true-value extension.

llvm-svn: 64505
2009-02-13 23:35:32 +00:00
Douglas Gregor b9063fc1b3 Implicitly declare certain C library functions (malloc, strcpy, memmove,
etc.) when we perform name lookup on them. This ensures that we
produce the correct signature for these functions, which has two
practical impacts:

  1) When we're supporting the "implicit function declaration" feature
  of C99, these functions will be implicitly declared with the right
  signature rather than as a function returning "int" with no
  prototype. See PR3541 for the reason why this is important (hint:
  GCC always predeclares these functions).
 
  2) If users attempt to redeclare one of these library functions with
  an incompatible signature, we produce a hard error.

This patch does a little bit of work to give reasonable error
messages. For example, when we hit case #1 we complain that we're
implicitly declaring this function with a specific signature, and then
we give a note that asks the user to include the appropriate header
(e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In
case #2, we show the type of the implicit builtin that was incorrectly
declared, so the user can see the problem. We could do better here:
for example, when displaying this latter error message we say
something like:

  'strcpy' was implicitly declared here with type 'char *(char *, char
  const *)'

but we should really print out a fake code line showing the
declaration, like this:

  'strcpy' was implicitly declared here as:

    char *strcpy(char *, char const *)

This would also be good for printing built-in candidates with C++
operator overloading.

The set of C library functions supported by this patch includes all
functions from the C99 specification's <stdlib.h> and <string.h> that
(a) are predefined by GCC and (b) have signatures that could cause
codegen issues if they are treated as functions with no prototype
returning and int. Future work could extend this set of functions to
other C library functions that we know about.

llvm-svn: 64504
2009-02-13 23:20:09 +00:00
Chris Lattner 190f64e9b8 add an assertion from Alexei Svitkine!
llvm-svn: 64503
2009-02-13 23:06:48 +00:00
Daniel Dunbar f9f039865f Set constant bit on static block vars as well. Patch by Anders Johnson!q
llvm-svn: 64502
2009-02-13 22:58:39 +00:00
Daniel Dunbar 5db3ef6fbb Simplify predicate.
llvm-svn: 64500
2009-02-13 22:49:13 +00:00
Daniel Dunbar 311bf2916b Warn about attribute used ignored on "extern int a
__attribute__((used))".

llvm-svn: 64499
2009-02-13 22:48:56 +00:00
Chris Lattner 39bb0182bd anders johnson points out that some software depends on the
definition of __intptr_t_defined when stdint.h defines intptr_t.

llvm-svn: 64497
2009-02-13 22:43:13 +00:00
Chris Lattner 7e4c81c8c6 Give TargetInfo a new IntPtrType to hold the intptr_t type for
a target.

Make Preprocessor.cpp define a new __INTPTR_TYPE__ macro based on this.

On linux/32, set intptr_t to int, instead of long.  This fixes PR3563.

llvm-svn: 64495
2009-02-13 22:28:55 +00:00
Daniel Dunbar 128a138a57 IRgen support for attribute used.
- PR3566

llvm-svn: 64492
2009-02-13 22:08:43 +00:00
Chris Lattner 303284acfc If x is an invalid field decl, don't construct an expression for P->x,
just silently return an error to avoid bogus diagnostics.

llvm-svn: 64491
2009-02-13 22:08:30 +00:00
Ted Kremenek 2fd18ec43a PTH: Cache directory and negative 'stat' calls. This gives us a 1% performance improvement on Cocoa.h (fsyntax-only+PTH).
llvm-svn: 64490
2009-02-13 22:07:44 +00:00
Daniel Dunbar 6b8720e723 Pull MayDeferGeneration out of EmitGlobal.
- Fix emission of static functions with constructor attribute while I
   was here.
<rdar://problem/6140899> [codegen] "static" and attribute-constructor interact poorly

llvm-svn: 64488
2009-02-13 21:18:01 +00:00
Daniel Dunbar 08b26a0587 Rename EmitStatics (etc) to EmitDeferred; provide basic infrastructure
for attribute used support.  
- No functionality change.

llvm-svn: 64487
2009-02-13 20:29:50 +00:00
Mike Stump 499ae7ec91 Let the backend unique these.
llvm-svn: 64486
2009-02-13 20:17:16 +00:00
Mike Stump 52d9c49d88 Fix spelling.
llvm-svn: 64482
2009-02-13 19:38:12 +00:00
Mike Stump 2c867aec40 Move DescriptorUniqueCount into CGM.
llvm-svn: 64481
2009-02-13 19:36:03 +00:00
Chris Lattner 9ef847be12 Fix rdar://6562329, a static analyzer crash Ted noticed on
wine sources.  This was happening because HighlightMacros was 
calling EnterMainFile multiple times on the same preprocessor
object and getting an assert due to the new #line stuff (the
file in question was bison output with #line directives).

The fix for this is to not reenter the file.  Instead, 
relex the tokens in raw mode, swizzle them a bit and repreprocess
the token stream.  An added bonus of this is that rewrite macros
will now hilight the macro definition as well as its uses.  Woo.

llvm-svn: 64480
2009-02-13 19:33:24 +00:00
Mike Stump 7ab278db06 Move NSConcreteStackBlock into CGM.
llvm-svn: 64479
2009-02-13 19:29:27 +00:00
Daniel Dunbar fee07a0b47 Sema/AST support for attribute used. Patch by Anders Johnson (with small tweaks & test case)!
llvm-svn: 64478
2009-02-13 19:23:53 +00:00
Ted Kremenek 29942a349c Add some boilerplate to the PTH file to prepare for the caching of stats for directories (and negative stats too).
llvm-svn: 64477
2009-02-13 19:13:46 +00:00
Douglas Gregor 10a451cb36 Eliminate an unused variable
llvm-svn: 64476
2009-02-13 19:13:32 +00:00
Mike Stump 1676c5b2d8 Reflow to 80col.
llvm-svn: 64475
2009-02-13 19:12:34 +00:00
Douglas Gregor 4feb36de04 Remove DeclGroupOwningRef, since we intend for declarations to be owned
by DeclContexts (always) rather than by statements. 

DeclContext currently goes out of its way to avoid destroying any
Decls that might be owned by a DeclGroupOwningRef. However, in an
error-recovery situation, a failure in a declaration statement can
cause all of the decls in a DeclGroupOwningRef to be destroyed after
they've already be added into the DeclContext. Hence, DeclContext is
left with already-destroyed declarations, and bad things happen. This
problem was causing failures that showed up as assertions on x86 Linux
in test/Parser/objc-forcollection-neg-2.m.

llvm-svn: 64474
2009-02-13 19:06:18 +00:00
Mike Stump 9319db8a11 Move GlobalUniqueCount up into CGM.
llvm-svn: 64473
2009-02-13 18:36:05 +00:00
Fariborz Jahanian d8fc1053ab Fixed a 64bit code gen bug of a cateogory
implementation with no category declaration!

llvm-svn: 64470
2009-02-13 17:52:22 +00:00
Daniel Dunbar abe6ef932f x86_64 ABI: Support va_arg passed in mixed registers.
- Now at 1274 passes on gcc compat suite vs 1262.

llvm-svn: 64469
2009-02-13 17:46:31 +00:00
Mike Stump 971f9b6619 Condense NSConcreteGlobalBlock handling.
llvm-svn: 64461
2009-02-13 17:23:42 +00:00
Mike Stump 52197c7763 Calculate size correctly.
llvm-svn: 64459
2009-02-13 17:03:17 +00:00
Mike Stump c2c38331ca Size should be unsigned.
llvm-svn: 64458
2009-02-13 16:55:51 +00:00
Mike Stump 85284bacab Condense all the blocks code into CGBlocks.cpp.
llvm-svn: 64457
2009-02-13 16:19:19 +00:00
Mike Stump 92bbd6d435 Fixup types, the runtime uses int, not int32.
llvm-svn: 64456
2009-02-13 16:01:35 +00:00
Mike Stump 57d7354635 Fix cmake builds.
llvm-svn: 64455
2009-02-13 15:42:50 +00:00
Mike Stump b7074c0013 Fixup spacing a tad.
llvm-svn: 64454
2009-02-13 15:32:32 +00:00
Mike Stump 005c9a62b5 Move GenericBlockLiteralType into CGM.
llvm-svn: 64452
2009-02-13 15:25:34 +00:00
Mike Stump 650c932d80 Move BlockDescriptorType into CGM.
llvm-svn: 64451
2009-02-13 15:16:56 +00:00
Mike Stump 5b31ed3ff0 80col.
llvm-svn: 64450
2009-02-13 14:24:50 +00:00
Anders Carlsson 6ee8a7dac5 Start warning about unknown attributes.
llvm-svn: 64447
2009-02-13 08:22:04 +00:00
Anders Carlsson b4f3134ca3 Add a new Ignored attribute type, and use it for may_alias.
llvm-svn: 64446
2009-02-13 08:16:43 +00:00
Anders Carlsson 63784f4e5e Add CodeGen support for the nodebug attribute.
llvm-svn: 64445
2009-02-13 08:11:52 +00:00
Anders Carlsson 76187b4d68 Add sema support for the nodebug attribute.
llvm-svn: 64441
2009-02-13 06:46:13 +00:00
Eli Friedman 1efaaeaa69 Initial implementation of arbitrary fixed-width integer types.
Currently only used for 128-bit integers.

Note that we can't use the fixed-width integer types for other integer 
modes without other changes because glibc headers redefines (u)int*_t 
and friends using the mode attribute.  For example, this means that uint64_t
has to be compatible with unsigned __attribute((mode(DI))), and 
uint64_t is currently defined to long long.  And I have a feeling we'll 
run into issues if we try to define uint64_t as something which isn't 
either long or long long.

This doesn't get the alignment right in most cases, including 
the 128-bit integer case; I'll file a PR shortly.  The gist of the issue 
is that the targets don't really expose the information necessary to 
figure out the alignment outside of the target description, so there's a 
non-trivial amount of work involved in getting it working right.  That 
said, the alignment used is conservative, so the only issue with the 
current implementation is ABI compatibility.

This makes it trivial to add some sort of "bitwidth" attribute to make 
arbitrary-width integers; I'll do that in a followup.

We could also use this for stuff like the following for compatibility 
with gcc, but I have a feeling it would be a better idea for clang to be 
consistent between C and C++ modes rather than follow gcc's example for 
C mode.
struct {unsigned long long x : 33;} x;
unsigned long long a(void) {return x.x+1;}

llvm-svn: 64434
2009-02-13 02:31:07 +00:00
Ted Kremenek 17d541d40c GRExprEngine:
- Add 'EvalBind', which will be used by 'EvalStore' to pull much of the value binding logic out of GRTransferFuncs.
- Rename many cases of 'St' to 'state'.

llvm-svn: 64426
2009-02-13 01:45:31 +00:00
Douglas Gregor adb0201418 Add mangling for variadic functions and conversion functions
llvm-svn: 64425
2009-02-13 01:28:03 +00:00
Eli Friedman 159a7cbc36 Fix gcc warning: gcc correctly notes that const-qualifying the return
type doesn't do anything.

llvm-svn: 64424
2009-02-13 01:02:29 +00:00
Chris Lattner 837b990c53 make "floating macro bubble" output of -emit-html much prettier:
only insert spaces between tokens if the code had them or if they 
are actually required to avoid pasting.  This reuses the same
logic as -E mode.

llvm-svn: 64421
2009-02-13 00:51:30 +00:00
Chris Lattner 644d452de5 factor token concatenation avoidance logic out of
PrintPreprocessedOutput into its own file.  No functionality change.

llvm-svn: 64418
2009-02-13 00:46:04 +00:00
Douglas Gregor 633b73783f Tighten checking of the "overloadable" attribute. If any function by a
given name in a given scope is marked as "overloadable", every
function declaration and definition with that same name and in that
same scope needs to have the "overloadable" attribute. Essentially,
the "overloadable" attribute is not part of attribute merging, so it
must be specified even for redeclarations. This keeps users from
trying to be too sneaky for their own good:

  double sin(double) __attribute__((overloadable)); // too sneaky
  #include <math.h>

Previously, this would have made "sin" overloadable, and therefore
given it a mangled name. Now, we get an error inside math.h when we
see a (re)declaration of "sin" that doesn't have the "overloadable"
attribute.

llvm-svn: 64414
2009-02-13 00:26:38 +00:00
Douglas Gregor 5fec5b0495 Add basic support for C++ name mangling according to the Itanium C++
ABI to the CodeGen library. Since C++ code-generation is so
incomplete, we can't exercise much of this mangling code. However, a
few smoke tests show that it's doing the same thing as GCC. When C++
codegen matures, we'll extend the ABI tester to verify name-mangling
as well, and complete the implementation here.

At this point, the major client of name mangling is in the uses of the
new "overloadable" attribute in C, which allows overloading. Any
"overloadable" function in C (or in an extern "C" block in C++) will
be mangled the same way that the corresponding C++ function would be
mangled.

llvm-svn: 64413
2009-02-13 00:10:09 +00:00
Daniel Dunbar 53bf741208 Honor attribute section on static block var decls.
llvm-svn: 64411
2009-02-12 23:32:54 +00:00
Mike Stump 6b63074de9 Fix limits.h for linux, as glibc does a #include_next unless
_GCC_LIMITS_H_ is defined, when __GNUC__ is defined.

Also, we need to stay away from possible conflicts with header guards.
We should use CLANG_ to prefix all header guards.

llvm-svn: 64408
2009-02-12 23:06:31 +00:00
Daniel Dunbar ad027c7781 Fix assertion when input is an empty string.
llvm-svn: 64397
2009-02-12 19:31:53 +00:00
Steve Naroff 344e74a986 Fix <rdar://problem/6499801> clang does not detect objc type mismatch in conditional expr
llvm-svn: 64393
2009-02-12 19:05:07 +00:00
Douglas Gregor a9add4ea76 Fix a bug with designated initializers where we were stepping out of a
union subobject initialization before checking whether the next
initiailizer was actually a designated initializer. This led to
spurious "excess elements in union initializer" errors. Thanks to
rdivacky for reporting the bug!

llvm-svn: 64392
2009-02-12 19:00:39 +00:00
Fariborz Jahanian c335c40a4b Fix a bug whereby, an ivar used to synthesize a property belongs
to a base class (nonfragile abi ir gen bug).

llvm-svn: 64391
2009-02-12 18:51:23 +00:00
Mike Stump ab3afd8f2d Initial codegen for block literals. This is a work in progress. I've
tried to put FIXMEs on the most important things to fix up.  Lots left
to do including more codegen, more documentation and cleaning code and
style cleanups.

llvm-svn: 64390
2009-02-12 18:29:15 +00:00
Steve Naroff c49b22a5c8 Sema::ActOnObjCAtThrowStmt(): return from recently added errors. Thanks Chris!
llvm-svn: 64389
2009-02-12 18:09:32 +00:00
Anders Carlsson 6a60fa2428 Add a very basic implemenation of global blocks. This needs to be cleaned up.
llvm-svn: 64387
2009-02-12 17:55:02 +00:00
Fariborz Jahanian 13de253bd6 Make nonfragile-abi the default for darwin's 64bit
abi for objective-c programs.

llvm-svn: 64386
2009-02-12 17:54:33 +00:00
Steve Naroff b76051534c Several cleanups:
- rename isObjCIdType/isObjCClassType -> isObjCIdStructType/isObjCClassStructType. The previous name didn't do what you would expect.
- add back isObjCIdType/isObjCClassType to do what you would expect. Not currently used, however many of the isObjCIdStructType/isObjCClassStructType clients could be converted over time.
- move static Sema function areComparableObjCInterfaces to ASTContext (renamed to areComparableObjCPointerTypes, since it now operates on pointer types).

llvm-svn: 64385
2009-02-12 17:52:19 +00:00
Daniel Dunbar 648bf78333 Support __attribute__(section(<name>))
llvm-svn: 64380
2009-02-12 17:28:23 +00:00
Steve Naroff 0fa412cc6d Turn warning into error. Minor incompatibility with GCC (for scalar types, GCC only produces a warning).
llvm-svn: 64375
2009-02-12 15:54:59 +00:00
Daniel Dunbar 6d0402d468 Fix va_arg bug noticed by Eli, __builtin_va_arg is not an l-value
designating an object.

llvm-svn: 64371
2009-02-12 09:21:08 +00:00
Daniel Dunbar 753cc07d13 x86_64: Initial varargs support.
- Doesn't yet handle case where values are passed in mixed (general
   purpose & floating point) registers; otherwise largely
   functional. Code still needs some cleaning.

Fixes:
MultiSource/Applications/lua/lua
MultiSource/Applications/siod/siod
MultiSource/Applications/sqlite3/sqlite3
SingleSource/Regression/C/PR640
SingleSource/UnitTests/2003-07-09-SignedArgs
SingleSource/UnitTests/2007-03-02-VaCopy

gcc compat test suite results (Darwin x86-32 & -64):
--
# of expected passes		1262
# of unexpected failures	56
# of unresolved testcases	34
# of unsupported tests		2

Compare to: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090209/012050.html

llvm-svn: 64370
2009-02-12 09:04:14 +00:00
Ted Kremenek b4c85ccaaa Re-enable PTH stat caching. All tests pass now.
llvm-svn: 64356
2009-02-12 03:45:39 +00:00
Ted Kremenek c6a2a37222 Fix bad reading of bytes in ReadUnalignedLE64() (copy-paste error).
llvm-svn: 64355
2009-02-12 03:39:55 +00:00
Ted Kremenek 3280145da4 Temporarily disable PTH stat caching as it appears to be failing on some machines.
llvm-svn: 64354
2009-02-12 03:36:54 +00:00
Ted Kremenek a5c2c27ebd PTH: Cache stat information for files in the PTH file. Hook up FileManager
to use this stat information in the PTH file using a 'StatSysCallCache' object.

Performance impact (Cocoa.h, PTH):
- number of stat calls reduces from 1230 to 425
- fsyntax-only: time improves by 4.2% 

We can reduce the number of stat calls to almost zero by caching negative stat
calls and directory stat calls in the PTH file as well.

llvm-svn: 64353
2009-02-12 03:26:59 +00:00
Ted Kremenek 5d7e2e1781 FileManager:
- set the 'StatSysCallCache' object using a setter method instead of
  FileManager's constructor. This allows the cache to be installed after the
  FileManager object is created.
- Add 'file mode' to FileEntry (useful for stat caching)

llvm-svn: 64351
2009-02-12 03:17:57 +00:00
Chris Lattner 882018b890 search and replaceo?
llvm-svn: 64348
2009-02-12 01:37:35 +00:00
Anders Carlsson 2437cbfa3b Add support for generating block call expressions.
llvm-svn: 64346
2009-02-12 00:39:25 +00:00
Ted Kremenek c8b740eade Add lightweight shim "clang::StatSysCallCache" that caches 'stat' system calls
for use by FileManager. FileManager now takes a StatSysCallCache* in its
constructor (which defaults to NULL). This will be used for evaluating whether
or not caching 'stat' system calls in PTH is a performance win. This shim adds
no observable performance impact in the case where the 'StatSysCallCache*' is
null.

llvm-svn: 64345
2009-02-12 00:39:05 +00:00
Douglas Gregor 6752502b81 Expand the definition of a complex promotion to include complex ->
complex conversions where the conversion between the real types is an
integral promotion. This is how G++ handles complex promotions for its
complex integer extension.

llvm-svn: 64344
2009-02-12 00:26:06 +00:00
Douglas Gregor 78ca74d81d Introduce _Complex conversions into the function overloading
system. Since C99 doesn't have overloading and C++ doesn't have
_Complex, there is no specification for    this. Here's what I think
makes sense.

Complex conversions come in several flavors:

  - Complex promotions:  a complex -> complex   conversion where the
    underlying real-type conversion is a floating-point promotion. GCC
    seems to call this a promotion, EDG does something else. This is
    given "promotion" rank for determining the best viable function.
  - Complex conversions: a complex -> complex conversion that is
    not a complex promotion. This is given "conversion" rank for
    determining the best viable   function.
  - Complex-real conversions: a real -> complex or complex -> real
    conversion. This is given "conversion" rank for determining the
    best viable function.

These rules are the same for C99 (when using the "overloadable"
attribute) and C++. However, there is one difference in the handling
of floating-point promotions: in C99, float -> long double and double
-> long double are considered promotions (so we give them "promotion" 
rank), while C++ considers these conversions ("conversion" rank).

llvm-svn: 64343
2009-02-12 00:15:05 +00:00
Fariborz Jahanian 77b6b5d6d8 Last @encode'ing fix for objc2's nonfragile abi.
All relevant dejagnu enocding tests pass in this mode.

llvm-svn: 64341
2009-02-11 23:59:18 +00:00
Ted Kremenek 4c1d41f2b1 PTH: Have meta data be at the beginning of the PTH file, not the end.
llvm-svn: 64338
2009-02-11 23:34:32 +00:00
Mike Stump c89c8e3225 Fix comment.
llvm-svn: 64337
2009-02-11 23:03:27 +00:00
Douglas Gregor 4e5cbdcbed Initial implementation of function overloading in C.
This commit adds a new attribute, "overloadable", that enables C++
function overloading in C. The attribute can only be added to function
declarations, e.g.,

  int *f(int) __attribute__((overloadable));

If the "overloadable" attribute exists on a function with a given
name, *all* functions with that name (and in that scope) must have the
"overloadable" attribute. Sets of overloaded functions with the
"overloadable" attribute then follow the normal C++ rules for
overloaded functions, e.g., overloads must have different
parameter-type-lists from each other.

When calling an overloaded function in C, we follow the same
overloading rules as C++, with three extensions to the set of standard
conversions:

  - A value of a given struct or union type T can be converted to the
    type T. This is just the identity conversion. (In C++, this would
    go through a copy constructor).
  - A value of pointer type T* can be converted to a value of type U*
    if T and U are compatible types. This conversion has Conversion
    rank (it's considered a pointer conversion in C).
  - A value of type T can be converted to a value of type U if T and U
    are compatible (and are not both pointer types). This conversion
    has Conversion rank (it's considered to be a new kind of
    conversion unique to C, a "compatible" conversion).

Known defects (and, therefore, next steps):
  1) The standard-conversion handling does not understand conversions
  involving _Complex or vector extensions, so it is likely to get
  these wrong. We need to add these conversions.
  2) All overloadable functions with the same name will have the same
  linkage name, which means we'll get a collision in the linker (if
  not sooner). We'll need to mangle the names of these functions.

llvm-svn: 64336
2009-02-11 23:02:49 +00:00
Fariborz Jahanian 1f0a9ebf72 Patch to fix encoding in 64bit abi. With this patch
all but one dejagnu encoding tests for darwin
pass in nonfragile abi mode.

llvm-svn: 64334
2009-02-11 22:31:45 +00:00
Daniel Dunbar e9fcadd2a6 Use EmitVAListRef instead of EmitLValue directly to handle array decay
case on x86_64.

llvm-svn: 64333
2009-02-11 22:25:55 +00:00
Ted Kremenek e5554deb45 PTH: Replace string identifier to persistent ID lookup with a hashtable. This is
actually *slightly* slower than the binary search. Since this is algorithmically
better, further performance tuning should be able to make this faster.

llvm-svn: 64326
2009-02-11 21:29:16 +00:00
Daniel Dunbar 8d9dc4a6d5 Support IRgen of va_arg of structure as l-value.
llvm-svn: 64325
2009-02-11 20:59:32 +00:00