Commit Graph

10577 Commits

Author SHA1 Message Date
John McCall 84d8767c15 Implement redeclaration checking and hiding semantics for using declarations. There
are a couple of O(n^2) operations in this, some analogous to the usual O(n^2)
redeclaration problem and some not.  In particular, retroactively removing
shadow declarations when they're hidden by later decls is pretty unfortunate.
I'm not yet convinced it's worse than the alternative, though.

llvm-svn: 91045
2009-12-10 09:41:52 +00:00
Eli Friedman e919e382a4 Fix for PR5515: allow "merging" array bounds both forwards and backwards.
llvm-svn: 91044
2009-12-10 08:54:47 +00:00
Anders Carlsson bf56946073 Mangle static variables inside Objective-C methods in Objective-C++. We currently mangle them the same way as gcc does.
llvm-svn: 91042
2009-12-10 03:14:39 +00:00
Eli Friedman d5bc94e2eb Get rid of static variable.
llvm-svn: 91041
2009-12-10 02:21:21 +00:00
Chris Lattner 3c674cf804 If we enter parens, colons can become un-sacred, allowing us to emit
a better diagnostic in the second example.

llvm-svn: 91040
2009-12-10 02:08:07 +00:00
Chris Lattner 244b96ba0a fix a more evil case of : / :: confusion arising in ?:.
llvm-svn: 91039
2009-12-10 02:02:58 +00:00
Chris Lattner 17c3b1f278 fix incorrect parsing of bitfields pointed out by Doug. I chose
to use ColonProtectionRAIIObject in the C codepath even though it
won't matter for consistency.

llvm-svn: 91037
2009-12-10 01:59:24 +00:00
Anders Carlsson fefc7b8e7b Actually store the pointer into the global variable, spotted by Eli.
llvm-svn: 91036
2009-12-10 01:58:33 +00:00
Mike Stump 3c6a12ca65 Setup cleanup on eh edge out of the construction of the cleanup object
during throw to deallocate the exception object.  WIP.

llvm-svn: 91035
2009-12-10 01:52:30 +00:00
Chris Lattner 399df12fb1 minimal fix for PR5743
llvm-svn: 91032
2009-12-10 01:38:15 +00:00
Anders Carlsson a72ddd4609 Handle emitting static variables that have reference type.
llvm-svn: 91027
2009-12-10 01:05:11 +00:00
Anders Carlsson 364051c6a6 Separate generating code for static variables and global variables.
llvm-svn: 91026
2009-12-10 00:57:45 +00:00
Chris Lattner b2434d558d Second half of r91023, saving files is good.
llvm-svn: 91024
2009-12-10 00:45:15 +00:00
Chris Lattner 5701386620 move GreaterThanIsOperatorScope into RAIIObjectsForParser. Add some more
TODOs for other classes that could be moved out of Parser.h.  I don't plan
to do these in the near term though.

llvm-svn: 91023
2009-12-10 00:44:03 +00:00
Chris Lattner 125c0ee5c7 fix PR5740: a colon is sacred when parsing case statement expressions!
llvm-svn: 91016
2009-12-10 00:38:54 +00:00
Chris Lattner d5c1c9d0ae refactor the 'ColonIsSacred' argument to ParseOptionalCXXScopeSpecifier
to be a bool in Parser that is twiddled by the ColonProtectionRAIIObject
class.  No functionality change.

llvm-svn: 91014
2009-12-10 00:32:41 +00:00
Anders Carlsson 633c6f6f36 Move more decl related functions to CGDeclCXX.cpp
llvm-svn: 91012
2009-12-10 00:30:05 +00:00
Chris Lattner 8a9a97a660 rename ExtensionRAIIObject.h -> RAIIObjectsForParser.h
llvm-svn: 91008
2009-12-10 00:21:05 +00:00
Anders Carlsson bc49cfed84 Add CGDeclCXX.cpp and move EmitCXXGlobalVarDeclInit there.
llvm-svn: 91006
2009-12-10 00:16:00 +00:00
Nuno Lopes 221c1fd63e spread 'const' love to some variables. this considerably reduces the amount of dirty data around.
llvm-svn: 91002
2009-12-10 00:07:02 +00:00
Mike Stump 75546b8c88 Fixup spacing.
llvm-svn: 91001
2009-12-10 00:06:18 +00:00
Mike Stump 2600491817 Fix spacing.
llvm-svn: 91000
2009-12-10 00:05:14 +00:00
Mike Stump f5cbb08c4b Ensure we only generate one terminate handler.
llvm-svn: 90998
2009-12-10 00:02:42 +00:00
Mike Stump 3b60f034f9 Remove obsolete FIXME and some dead fallback code.
llvm-svn: 90997
2009-12-09 23:52:09 +00:00
Mike Stump 102530719f Add terminate handler to cleanups on exceptional edges.
llvm-svn: 90996
2009-12-09 23:49:53 +00:00
Fariborz Jahanian 531c16f9fb Code gen for ObjCIsaExpr AST used as lvalue.
(fixes radar 7457534).

llvm-svn: 90995
2009-12-09 23:35:29 +00:00
Mike Stump 25b20fc2ae Add terminate handler for copy constructors for thrown objects. WIP.
llvm-svn: 90994
2009-12-09 23:31:35 +00:00
Ted Kremenek 8573913760 Fix null dereference in OSAtomicChecker and special case SymbolicRegions. We still aren't handling them correctly; I've added to failing test cases to test/Analysis/NSString-failed-cases.m that should pass and then be merged in to test/Analysis/NSString.m.
llvm-svn: 90993
2009-12-09 23:29:55 +00:00
Douglas Gregor 3e1e527826 Reimplement reference initialization (C++ [dcl.init.ref]) using the
new notion of an "initialization sequence", which encapsulates the
computation of the initialization sequence along with diagnostic
information and the capability to turn the computed sequence into an
expression. At present, I've only switched one CheckReferenceInit
callers over to this new mechanism; more will follow.

Aside from (hopefully) being much more true to the standard, the
diagnostics provided by this reference-initialization code are a bit
better than before. Some examples:

p5-var.cpp:54:12: error: non-const lvalue reference to type 'struct
Derived'
      cannot bind to a value of unrelated type 'struct Base'
  Derived &dr2 = b; // expected-error{{non-const lvalue reference to
  ...
           ^     ~
p5-var.cpp:55:9: error: binding of reference to type 'struct Base' to
a value of
      type 'struct Base const' drops qualifiers
  Base &br3 = bc; // expected-error{{drops qualifiers}}
        ^     ~~

p5-var.cpp:57:15: error: ambiguous conversion from derived class
      'struct Diamond' to base class 'struct Base':
    struct Diamond -> struct Derived -> struct Base
    struct Diamond -> struct Derived2 -> struct Base
  Base &br5 = diamond; // expected-error{{ambiguous conversion from
      ...
              ^~~~~~~
p5-var.cpp:59:9: error: non-const lvalue reference to type 'long'
      cannot bind to
      a value of unrelated type 'int'
  long &lr = i; // expected-error{{non-const lvalue reference to type
      ...
        ^    ~

p5-var.cpp:74:9: error: non-const lvalue reference to type 'struct
Base' cannot
      bind to a temporary of type 'struct Base'
  Base &br1 = Base(); // expected-error{{non-const lvalue reference to
  ...
        ^     ~~~~~~

p5-var.cpp:102:9: error: non-const reference cannot bind to bit-field
'i'
  int & ir1 = (ib.i); // expected-error{{non-const reference cannot
  ...
        ^     ~~~~~~
p5-var.cpp:98:7: note: bit-field is declared here
  int i : 17; // expected-note{{bit-field is declared here}}
      ^

llvm-svn: 90992
2009-12-09 23:02:17 +00:00
Mike Stump 2b488873bf Break out code for reuse. WIP.
llvm-svn: 90991
2009-12-09 22:59:31 +00:00
Fariborz Jahanian 26de2e594b Fixes a bogus error when declaring an extern "C" array.
(fixes radar 7457109).

llvm-svn: 90986
2009-12-09 21:39:38 +00:00
Mike Stump f16b8c30d9 Add throw support. WIP.
llvm-svn: 90982
2009-12-09 19:24:08 +00:00
Fariborz Jahanian a5fee26d28 Codegen. support for ObjCIsaExpr AST which until now
was not needed (fixes radar 7453430).

llvm-svn: 90981
2009-12-09 19:05:56 +00:00
Anders Carlsson 538af0906d Add DeclContext::dump.
llvm-svn: 90974
2009-12-09 17:27:46 +00:00
Zhongxing Xu 1042bf4ae2 Refactor OSAtomic evaluation logic into OSAtomicChecker.
llvm-svn: 90968
2009-12-09 12:23:28 +00:00
Zhongxing Xu 8cca37fae0 Use a temporary destination set such that we can clear fake auto transitions.
Otherwise, even when real evaluation occurs, the previous fake auto 
transitions would still be in the destination set, causing fake state 
bifurcation.

llvm-svn: 90967
2009-12-09 12:16:07 +00:00
John McCall 5677499fbf First pass at implementing C++ enum semantics: calculate (and store) an
"integer promotion" type associated with an enum decl, and use this type to
determine which type to promote to.  This type obeys C++ [conv.prom]p2 and
is therefore generally signed unless the range of the enumerators forces
it to be unsigned.

Kills off a lot of false positives from -Wsign-compare in C++, addressing
rdar://7455616

llvm-svn: 90965
2009-12-09 09:09:27 +00:00
Zhongxing Xu 1d153328be OSAtomic simulation: use the original region as the location to load from,
instead of the ElementRegion obtained from casts.

Test cast: the leak cannot occur bacause the true branch cannot be taken.

llvm-svn: 90964
2009-12-09 08:32:57 +00:00
Anders Carlsson c50b340108 Look through using declarations when searching for allocation overloads.
llvm-svn: 90961
2009-12-09 07:39:44 +00:00
Zhongxing Xu f5448561ed remove dead code.
llvm-svn: 90953
2009-12-09 05:52:12 +00:00
Zhongxing Xu d1dee7e71a Insert instead of assign to the dest node set, since we use the dest node set
repeatedly.

llvm-svn: 90952
2009-12-09 05:48:53 +00:00
Eli Friedman f7195532ee Fix for PR5730: make sure to consistently call
PerformObjectArgumentInitialization from BuildCXXMemberCallExpr.

llvm-svn: 90950
2009-12-09 04:53:56 +00:00
Eli Friedman a958a01e9f Whitespace fix.
llvm-svn: 90949
2009-12-09 04:52:43 +00:00
Anders Carlsson f9812782b7 In CXXRecordDecl::forallBases, add the base to the "queue", so we walk more than one heirarchy of classes. John, please review.
llvm-svn: 90948
2009-12-09 04:26:02 +00:00
Ted Kremenek 06ba78d07d Fix crash in DisplayFunction(). ObjCInterfaceDecls can also get passed to this function, but we don't want to display them.
llvm-svn: 90944
2009-12-09 03:45:19 +00:00
Anders Carlsson a038825b1c Don't warn about function templates or function template specializations.
llvm-svn: 90943
2009-12-09 03:44:46 +00:00
Mike Stump aff69af918 Add cleanups for exceptional edges. WIP.
llvm-svn: 90940
2009-12-09 03:35:49 +00:00
John McCall daa3d6bb50 Rename Sema::IsOverload to Sema::CheckOverload. Teach it to ignore unresolved
using value decls;  we optimistically assume they won't turn into conflicts.
Teach it to tell the caller *why* the function doesn't overload with the returned
decl;  this will be useful for using hiding.

llvm-svn: 90939
2009-12-09 03:35:25 +00:00
Anders Carlsson 31c7e88667 Move the missing prototypes checking out into a new function. Don't warn about inline functions. Add a test.
llvm-svn: 90938
2009-12-09 03:30:09 +00:00
Eli Friedman 4f678f3de1 Fix for PR5709: use the computed type of the declaration instead of the
type of the builtin when generating the function declaration for a builtin
library call.

llvm-svn: 90936
2009-12-09 03:05:59 +00:00