Commit Graph

1606 Commits

Author SHA1 Message Date
Fariborz Jahanian a599c1352b Diagnose that ivars in current and super class may not
be duplicates and a test case.

llvm-svn: 61068
2008-12-16 01:08:35 +00:00
Douglas Gregor 29e174cc58 Make name lookup when we're inside a declarator's scope, such as ClassName::func, work with the new unqualified name lookup code. Test it with default arguments in out-of-line member definitions
llvm-svn: 61060
2008-12-16 00:38:16 +00:00
Douglas Gregor dd12c786a0 Added a test for default arguments added to out-of-line member
functions. They work except that name lookup within the default
arguments needs to be deferred until the class definition is complete
(see FIXME in the test).

llvm-svn: 61059
2008-12-16 00:08:34 +00:00
Douglas Gregor ad590506a7 Diagnose erroneous uses of out-of-line member definitions and scope
specifiers. Specifically: 
  * Determine when an out-of-line function definition does not match
    any declaration within the class or namespace (including coping
    with overloaded functions).
  * Complain about typedefs and parameters that have scope specifiers.
  * Complain about out-of-line declarations that aren't also
  definitions.
  * Complain about non-static data members being declared out-of-line.
  * Allow cv-qualifiers on out-of-line member function definitions.

llvm-svn: 61058
2008-12-15 23:53:10 +00:00
Eli Friedman bb2b3be9e1 Make error handling for va_start a bit more robust. Fixes PR3213.
llvm-svn: 61055
2008-12-15 22:05:35 +00:00
Douglas Gregor 1349b457ee Place constructors and destructors into the DeclContext of the class,
just like all other members, and remove the special variables in
CXXRecordDecl to store them. This eliminates a lot of special-case
code for constructors and destructors, including
ActOnConstructor/ActOnDeclarator and special lookup rules in
LookupDecl. The result is far more uniform and manageable.

Diagnose the redeclaration of member functions.

llvm-svn: 61048
2008-12-15 21:24:18 +00:00
Fariborz Jahanian cfac794a5c And a test case for my previous patch.
llvm-svn: 61044
2008-12-15 20:39:58 +00:00
Ted Kremenek 4299d5d2d8 Fix regression in handling sizeof(void) in the static analyzer.
llvm-svn: 61039
2008-12-15 18:51:00 +00:00
Douglas Gregor c811d8f055 Create new EnumDecl nodes for redeclarations of enums, linking them
together in the same way that we link RecordDecl/CXXRecordDecl nodes. 

Unify ActOnTag and ActOnTagStruct.

Fixes PR clang/2753.

llvm-svn: 61034
2008-12-15 16:32:14 +00:00
Ted Kremenek b5670fd555 MemRegion:
- Overhauled the notion of "types" for TypedRegions.  We now distinguish between the "lvalue" of a region (via getLValueRegion()) and the "rvalue" of a region (va getRValueRegion()).  Since a region represents a chunk of memory it has both, but we were conflating these concepts in some cases, leading to some insidious bugs.
- Removed AnonPointeeType, partially because it is unused and because it doesn't have a clear notion of lvalue vs rvalue type.  We can add it back once there is a need for it and we can resolve its role with these concepts.

StoreManager:
- Overhauled StoreManager::CastRegion.  It expects an *lvalue* type for a region.  This is actually what motivated the overhaul to the MemRegion type mechanism.  It also no longer returns an SVal; we can just return a MemRegion*.
- BasicStoreManager::CastRegion now overlays an "AnonTypedRegion" for pointer-pointer casts.  This matches with the MemRegion changes.
- Similar changes to RegionStore, except I've added a bunch of FIXMEs where it wasn't 100% clear where we should use TypedRegion::getRValueRegion() or TypedRegion::getLValueRegion().

AuditCFNumberCreate check:
- Now blasts through AnonTypedRegions that may layer the original memory region, thus checking if the actually memory block is of the appropriate type.  This change was needed to work with the changes to StoreManager::CastRegion.

GRExprEngine::VisitCast:
- Conform to the new interface of StoreManager::CastRegion.

Tests:
- None of the analysis tests fail now for using the "basic store".
- Disabled the tests 'array-struct.c' and 'rdar-6442306-1.m' pending further testing and bug fixing.

llvm-svn: 60995
2008-12-13 21:49:13 +00:00
Ted Kremenek 1c89be0216 Temporarily XFAIL these tests.
llvm-svn: 60991
2008-12-13 19:27:01 +00:00
Ted Kremenek f065b15f7d A series of cleanups/fixes motivated by <rdar://problem/6442306>:
GRExprEngine (VisitCast):
- When using StoreManager::CastRegion, always use the state and value it returns to generate the next node.  Failure to do so means that region values returned that don't require the state to be modified will get ignored.

MemRegion:
- Tighten the interface for ElementRegion.  Now ElementRegion can only be created with a super region that is a 'TypedRegion' instead of any MemRegion.  Code in BasicStoreManager/RegionStoreManager already assumed this, but it would result in a dynamic assertion check (and crash) rather than just having the compiler forbid the construction of such regions.
- Added ElementRegion::getArrayRegion() to return the 'typed version' of an ElementRegion's super region.
- Removed bogus assertion in ElementRegion::getType() that assumed that the super region was an AnonTypedRegion.  All that matters is that it is a TypedRegion, which is now true all the time by design.

BasicStore:
- Modified getLValueElement() to check if the 'array' region is a TypedRegion before creating an ElementRegion.  This conforms to the updated interface for ElementRegion.

RegionStore:
- In ArrayToPointer() gracefully handle things we don't reason about, and only create an ElementRegion if the array region is indeed a TypedRegion.

llvm-svn: 60990
2008-12-13 19:24:37 +00:00
Sebastian Redl 19ed30be38 stdlib.h is the wrong header for printf, and introduces test-breaking definitions of inlines on Linux
llvm-svn: 60981
2008-12-13 15:31:28 +00:00
Chris Lattner 6bf1db148c fix a buggy fall through that caused a crash-on-invalid. rdar://6248081
llvm-svn: 60961
2008-12-12 19:20:14 +00:00
Daniel Dunbar a4daf203fe Add test case for using mmintrin (and making sure that inlining is
working with and without debug info).

llvm-svn: 60960
2008-12-12 19:12:02 +00:00
Chris Lattner 04397358ec Implement the final (hopefully) wrinkle to i-c-e + builtin_constant_p
processing: it allows arbitrary foldable constants as the operand of ?: when
builtin_constant_p is the condition.

llvm-svn: 60954
2008-12-12 18:00:51 +00:00
Douglas Gregor 4287b37389 Enable out-of-line definitions of C++ constructors and destructors
llvm-svn: 60947
2008-12-12 08:25:50 +00:00
Chris Lattner e141a9e225 rdar://6060752 - don't warn about trigraphs in bcpl-style comments
llvm-svn: 60942
2008-12-12 07:34:39 +00:00
Douglas Gregor b9d2380204 Add test of enumerator types
llvm-svn: 60940
2008-12-12 07:27:10 +00:00
Chris Lattner 4bf85ffe83 merge these testcases into one file.
llvm-svn: 60936
2008-12-12 07:01:24 +00:00
Chris Lattner 85b25bc344 implement rdar://6091492 - ?: with __builtin_constant_p as the operand is an i-c-e.
llvm-svn: 60934
2008-12-12 06:55:44 +00:00
Chris Lattner fce12fdf6f rename recovery-3 to recovery.c
llvm-svn: 60931
2008-12-12 06:21:41 +00:00
Chris Lattner 5b3ddc8ef9 merge recovery-1 into recovery-3.
llvm-svn: 60930
2008-12-12 06:21:18 +00:00
Chris Lattner bc2d77cdf2 merge recovery-2.c into recovery-3.c.
Substantially improve error recovery after broken if conditions by
parsing the full if when we have a semantic error instead of using
parser recovery techniques to recover from a semantic error.

This fixes rdar://6094870 - spurious error after invalid 'if' condition

llvm-svn: 60929
2008-12-12 06:19:11 +00:00
Chris Lattner dca17ceb19 add expected diag
llvm-svn: 60927
2008-12-12 05:59:56 +00:00
Chris Lattner 053441f39d Fix rdar://6095061 - gcc allows __builtin_choose_expr as an lvalue
llvm-svn: 60924
2008-12-12 05:35:08 +00:00
Chris Lattner 54139445ba Testcase for something that already works. Clang agrees with Comeau,
and this makes sense.  likely a gcc bug that it doesn't diagnose the bad
restrict.

llvm-svn: 60923
2008-12-12 05:25:55 +00:00
Chris Lattner f45c5ecb3b fix rdar://6097892 - gcc incompat: clang rejects __func__, __FUNCTION__, and __PRETTY_FUNCTION__ outside func
Yeah, this is "useful".

llvm-svn: 60921
2008-12-12 05:05:20 +00:00
Chris Lattner 81ed6805db Implement rdar://6138816 - [sema] named bitfields cannot have 0 width
llvm-svn: 60920
2008-12-12 04:56:04 +00:00
Douglas Gregor 1d248c53ab In C++, set the type of each of the enumerators in an enumeration to
the type of the enumeration once the enumeration has been defined.

Fix the overloading test-case to properly create enums that promote
the way we want them to.

Implement C++0x promotions from enumeration types to long
long/unsigned long long. We're using these promotions in Carbon.h
(since long long is a common extension).

Fixes PR clang/2954: http://llvm.org/bugs/show_bug.cgi?id=2954

llvm-svn: 60917
2008-12-12 02:00:36 +00:00
Chris Lattner ece9ae718b add annotation
llvm-svn: 60907
2008-12-11 23:11:52 +00:00
Douglas Gregor 91f84216f7 Unifies the name-lookup mechanisms used in various parts of the AST
and separates lexical name lookup from qualified name lookup. In
particular:
  * Make DeclContext the central data structure for storing and
    looking up declarations within existing declarations, e.g., members
    of structs/unions/classes, enumerators in C++0x enums, members of
    C++ namespaces, and (later) members of Objective-C
    interfaces/implementations. DeclContext uses a lazily-constructed
    data structure optimized for fast lookup (array for small contexts,
    hash table for larger contexts). 

  * Implement C++ qualified name lookup in terms of lookup into
    DeclContext.

  * Implement C++ unqualified name lookup in terms of
    qualified+unqualified name lookup (since unqualified lookup is not
    purely lexical in C++!)

  * Limit the use of the chains of declarations stored in
    IdentifierInfo to those names declared lexically.

  * Eliminate CXXFieldDecl, collapsing its behavior into
    FieldDecl. (FieldDecl is now a ScopedDecl).

  * Make RecordDecl into a DeclContext and eliminates its
    Members/NumMembers fields (since one can just iterate through the
    DeclContext to get the fields).

llvm-svn: 60878
2008-12-11 16:49:14 +00:00
Anders Carlsson 591b2224cb Add another complex promotion test.
llvm-svn: 60863
2008-12-10 23:57:51 +00:00
Anders Carlsson b05961c700 Make sure to promote expressions of the form (floating point + complex integer) correctly, to (complex floating point + complex floating point)
llvm-svn: 60862
2008-12-10 23:30:05 +00:00
Douglas Gregor 85970ca84c Added a warning when referencing an if's condition variable in the
"else" clause, e.g.,

  if (int X = foo()) {
  } else {
    if (X) { // warning: X is always zero in this context
    }
  }

Fixes rdar://6425550 and lets me think about something other than
DeclContext.

llvm-svn: 60858
2008-12-10 23:01:14 +00:00
Steve Naroff c68cfcfd03 The "real" fix for <rdar://problem/6424347> clang on xcode: Assertion failed: (0 && "unexpected type"), function mergeTypes,
Commit r60845 was premature.

llvm-svn: 60852
2008-12-10 22:14:21 +00:00
Douglas Gregor 9aa8b55d10 Fix PR clang/3175: CheckAddressOfOperand does not handle references to class vars
llvm-svn: 60849
2008-12-10 21:26:49 +00:00
Steve Naroff 13ac125edf Fix <rdar://problem/6424347> clang on xcode: Assertion failed: (0 && "unexpected type"), function mergeTypes,
llvm-svn: 60845
2008-12-10 20:07:25 +00:00
Steve Naroff 68e167df8e Fix <rdar://problem/6418623> Bogus block type compatibility warning.
llvm-svn: 60842
2008-12-10 17:49:55 +00:00
Fariborz Jahanian 7572ac5614 Patch to allow a getter call using property dot-syntax notation.
llvm-svn: 60816
2008-12-10 00:21:50 +00:00
Fariborz Jahanian ea831ee11c Prevent bogus warning on unimplemented setter/getter when user
has added declaration of these methods in its @interface.

llvm-svn: 60803
2008-12-09 22:43:22 +00:00
Steve Naroff 70cb0071c9 Add testcase for commit r60781.
llvm-svn: 60793
2008-12-09 20:59:16 +00:00
Fariborz Jahanian 3d8552a75d Support for implementation of property in the case where
the synthesis is in an implementation of s subclass of
a super class where the property has been declared.

llvm-svn: 60792
2008-12-09 20:23:04 +00:00
Steve Naroff 08628db9d2 Fix <rdar://problem/6429113> clang ObjC rewriter: crash rewriting file with Blocks and properties
More fancy footwork to cope with rewriting property 'setters'.

llvm-svn: 60760
2008-12-09 12:56:34 +00:00
Ted Kremenek c28ce29a12 [static analyzer] Extend VLA size checking to look for undefined sizes.
llvm-svn: 60734
2008-12-09 00:44:16 +00:00
Ted Kremenek d7266bf20a Add zero-sized VLA check test case.
llvm-svn: 60731
2008-12-09 00:14:48 +00:00
Ted Kremenek 223005f35a Incorporate MissingDealloc_IBOutlet.m test case into MissingDealloc.m
llvm-svn: 60722
2008-12-08 22:05:43 +00:00
Ted Kremenek 1f9dd45f57 Incorporate MissingDeallc_SEL.m test case into MissingDealloc.m
llvm-svn: 60721
2008-12-08 22:01:50 +00:00
Ted Kremenek 8f5c0ede0f Add test case for <rdar://problem/6380411>.
llvm-svn: 60720
2008-12-08 21:59:21 +00:00
Chris Lattner 46415261ee Fix PR3172: if we see an eof or } at the top level, reject it.
This is important because ParseDeclarationOrFunctionDefinition
skips to, but does not consume, an } on error.

llvm-svn: 60719
2008-12-08 21:59:01 +00:00