Commit Graph

4006 Commits

Author SHA1 Message Date
Anders Carlsson 0756c97dae Emit the correct diagnostics when we constant fold an array size to a negative value.
llvm-svn: 65023
2009-02-19 06:30:50 +00:00
Chris Lattner b5d8416b90 don't new[] an empty array when an AttributeList has
zero expression arguments.  This eliminates 2579 1-byte
mallocs when parsing Cocoa.h.

llvm-svn: 65022
2009-02-19 06:25:12 +00:00
Daniel Dunbar b2f4cdb233 Emission of global variable initialializer was broken in rare
situation where a tentative decl was emitted *after* the actual
initialization. This occurs in some rare situations with static decls.
 - PR3613.

 - I'm not particularly happy with this fix, but I don't see a simpler
   or more elegant solution yet.

llvm-svn: 65018
2009-02-19 05:36:41 +00:00
Anders Carlsson ef56fbaa39 Handle the GNU void* and function pointer arithmetic extensions for constant expressions as well.
llvm-svn: 65013
2009-02-19 04:55:58 +00:00
Chris Lattner 45d26bd00d PR3614: "ignoring nonexistent directory" should print the -isysroot
mapped path, not the requested path.

llvm-svn: 65009
2009-02-19 04:48:57 +00:00
Chris Lattner ec5a332e46 fix another typo gabor noticed
llvm-svn: 65006
2009-02-19 04:44:58 +00:00
Ted Kremenek 66d9edc346 Implemented simple check in <rdar://problem/6600344>: When the receiver of a
message expression is nil and the return type is struct then the returned value
is undefined or potentially garbage.

llvm-svn: 65003
2009-02-19 04:06:22 +00:00
Mike Stump 4e1f26aad0 Fit 80col and fix indentation.
llvm-svn: 65000
2009-02-19 03:04:26 +00:00
Mike Stump 82191d0413 Fix spacing.
llvm-svn: 64998
2009-02-19 02:54:59 +00:00
Mike Stump 5d2534ada7 More codegen for blocks. The type of block literals should be better.
The size calculation is improved.

llvm-svn: 64994
2009-02-19 01:01:04 +00:00
Douglas Gregor 0f3dd9a86b Provide a proper source location when building an implicit dereference. Fixes PR3600
llvm-svn: 64993
2009-02-19 00:52:42 +00:00
Fariborz Jahanian 83e3eea5fc Some code simplification. ir gen for gc'able array
of objects in objc.

llvm-svn: 64992
2009-02-19 00:48:05 +00:00
Howard Hinnant 9c788c081c testing (reverted)
llvm-svn: 64991
2009-02-19 00:27:58 +00:00
Howard Hinnant 2d12fbdc2e testing
llvm-svn: 64990
2009-02-19 00:25:33 +00:00
Fariborz Jahanian d29fecd746 Couple of helpers for objc's gc attributes.
No change in functionality.

llvm-svn: 64989
2009-02-19 00:22:47 +00:00
Douglas Gregor 5f361c9f1e Address Chris's comments regarding C++ name mangling.
llvm-svn: 64984
2009-02-18 23:53:56 +00:00
Ted Kremenek 84e7c1e2ff retain/release checker: Place the leak diagnostic after the last statement that
references the tracked object.

llvm-svn: 64980
2009-02-18 23:28:26 +00:00
Chris Lattner 1b2cd9aca9 fariborz already fixed this.
llvm-svn: 64975
2009-02-18 23:00:57 +00:00
Ted Kremenek 6692f45829 Remove unused variable.
llvm-svn: 64974
2009-02-18 22:59:38 +00:00
Ted Kremenek 75a96ed40a Remove logic for computing 'display hint'.
llvm-svn: 64973
2009-02-18 22:59:04 +00:00
Chris Lattner 6805ac6ab0 minor name changes, no functionality change.
llvm-svn: 64972
2009-02-18 22:58:38 +00:00
Ted Kremenek 551747fe3a More fun with retain checker diagnostics:
- Fix some grammar.
- Fix a bug where a "reference count incremented" diagnostic would not be shown
  if the previous typestate was "Released" (only happens in GC mode).

llvm-svn: 64971
2009-02-18 22:57:22 +00:00
Chris Lattner d60183d29f fix some subtle bugs handling the mix of cvr qualifiers, addr spaces,
and gc attrs.  Add an assert to check that we never 
get ExtQualType(ExtQualType(T)).

llvm-svn: 64970
2009-02-18 22:53:11 +00:00
Daniel Dunbar a228a67637 Add anti-FIXME.
llvm-svn: 64969
2009-02-18 22:52:09 +00:00
Daniel Dunbar 8cdb9dae45 i386 ABI: Offset computation in va_arg was incorrect for sizeof(Ty)>4.
We are down to only failing gcc.dg/compat/vector-[12] (8 tests total).

llvm-svn: 64967
2009-02-18 22:28:45 +00:00
Douglas Gregor ac3865c387 Remove pointless backslash
llvm-svn: 64965
2009-02-18 22:24:55 +00:00
Douglas Gregor 1cba5fe1d1 Downgrade the "excess elements in initializer" errors to warnings *in
C*. They're required errors in C++.

llvm-svn: 64964
2009-02-18 22:23:55 +00:00
Daniel Dunbar e60ec0abca x86_64 ABI: Fix thinko in computation of bound for "passed in SSE regs" test.
Two more gcc/x86_64 failures down.

llvm-svn: 64963
2009-02-18 22:19:44 +00:00
Ted Kremenek a790c8dcac Fix diagnostics bugs when computing ranges for the retain/release checker.
llvm-svn: 64962
2009-02-18 22:17:20 +00:00
Chris Lattner d7cfc246f6 rip out __builtin_overload
llvm-svn: 64961
2009-02-18 22:14:55 +00:00
Ted Kremenek ea3a9e270c HTMLDiagnostics: Always display diagnostics *below* the line in question.
llvm-svn: 64959
2009-02-18 22:10:00 +00:00
Daniel Dunbar e3bba6e3d0 x86_64 ABI: "is passed in regs" computation for va_arg was broken for
things passed in mixed registers.

This knocks out 8 x86_64 failures.

llvm-svn: 64958
2009-02-18 22:05:01 +00:00
Douglas Gregor 222e5e4ad2 Return true on errors, return true on errors, return true on errors
llvm-svn: 64957
2009-02-18 22:00:45 +00:00
Ted Kremenek 1045289881 retain/release checker: We now emit fancy diagnostics telling users about the
semantics of CFMakeCollectable and friends.

llvm-svn: 64956
2009-02-18 21:57:45 +00:00
Douglas Gregor 171c45ab0c Downgrade complaints about calling unavailable functions to a warning
(as GCC does), except when we've performed overload resolution and
found an unavailable function: in this case, we actually error.

Merge the checking of unavailable functions with the checking for
deprecated functions. This unifies a bit of code, and makes sure that
we're checking for unavailable functions in the right places. Also,
this check can cause an error. We may, eventually, want an option to
make "unavailable" warnings into errors.

Implement much of the logic needed for C++0x deleted functions, which
are effectively the same as "unavailable" functions (but always cause
an error when referenced). However, we don't have the syntax to
specify deleted functions yet :)

llvm-svn: 64955
2009-02-18 21:56:37 +00:00
Fariborz Jahanian 9620769901 Some refactoring and simplificaiotn of objc's gc
ir gen.

llvm-svn: 64954
2009-02-18 21:49:28 +00:00
Mike Stump 8dbf1dbdb8 Codegen for int (^bp)(int) = 0;
llvm-svn: 64951
2009-02-18 21:44:49 +00:00
Daniel Dunbar aac5bf19a5 __attribute__((aligned)) was being ignored!
This knocks out another 8 gcc/compat/i386 & x86_64 failures.

llvm-svn: 64947
2009-02-18 20:06:09 +00:00
Daniel Dunbar b1c22fe9b7 Add Type::isSpecificBuiltinType as a shortcut.
llvm-svn: 64946
2009-02-18 19:59:32 +00:00
Daniel Dunbar 216f64379f Simplify.
llvm-svn: 64944
2009-02-18 19:45:21 +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 57a09cfcbc update comment.
llvm-svn: 64939
2009-02-18 18:56:29 +00:00
Ted Kremenek f68490a3f7 retain/release checker: Distinguish in the function summaries between
retain/releases performed via [... release] and CFRetain(). The former are
no-ops in GC. The checker already handled this, but now we emit nice diagnostics
to the user telling them that these are no-ops.

llvm-svn: 64937
2009-02-18 18:54:33 +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
Fariborz Jahanian 9959eee95d Start generating gc'able code using the new
objc gc type attributes.

llvm-svn: 64935
2009-02-18 18:52:41 +00:00
Chris Lattner 24eb28bcf8 tidy up
llvm-svn: 64934
2009-02-18 18:50:45 +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
Fariborz Jahanian d35c792ebb Make warn-weak-field.m test pass again.
llvm-svn: 64927
2009-02-18 18:14:41 +00:00
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