Граф коммитов

7101 Коммитов

Автор SHA1 Сообщение Дата
Fariborz Jahanian d8e987bee9 objc -arse: Use DeclGroup for forward class declarations;
as in @class foo, bar. More cleanup to follow.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138567 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-25 17:47:31 +00:00
Caitlin Sadowski 940b97f524 Thread safety: Fix a few typos in last commit -- use LockID instead of Lock in comments and start a couple methods with a lowercase letter
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138460 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-24 18:46:20 +00:00
Ted Kremenek 0f3b4ca176 Start reworking -Wunreachable-code. The original analysis had serious flaws with how it
handled SCC's of dead code, or simply having false negatives by overly suppressing warnings.

WIP.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138410 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 23:05:11 +00:00
Ted Kremenek f1d10d9397 Constify the result of CFGStmt::getStmt().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138408 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 23:05:04 +00:00
Eli Friedman f40fd6bbb2 Refactor and fix checking for initialization of flexible array members. The old version had the checks scattered across the code, missed some checks, and had a couple nasty bugs in existing checks.
Fixes PR10648 and another similar accepts-invalid bug.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138398 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 22:24:57 +00:00
Eli Friedman 629f118e69 Remove function parameter which always used the default value.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138368 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 20:17:13 +00:00
Caitlin Sadowski 3ac1fbc303 Thread-safety analysis: adding in a basic lockset tracking system. This
system flags an error when unlocking a lock which was not held, locking
the same lock twice, having a different lockset on each iteration of a
loop, or going out of scope while still holding a lock. In order to
successfully use the lockset, this patch also makes sure that attribute
arguments are attached correctly for later parsing.

This patch was also worked on by DeLesley Hutchins.

Note: This patch has been reviewed by Chandler Carruth and Jeffrey
Yasskin. Feel free to provide post-commit review comments for a
subsequent patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138350 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 18:46:34 +00:00
Matt Beaumont-Gay 903d6dc86b Fix an incorrect note.
For the test case added to function-redecl.cpp, we were previously complaining
about a mismatch in the parameter types, since the definition used the
typedef'd type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138318 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 01:35:51 +00:00
Fariborz Jahanian 7939418cbd objc - use existing API for temporary switch of
objc's decl context.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138267 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-22 20:15:24 +00:00
Ted Kremenek 4eb14ca3de Do not perform check for missing '[super dealloc]' under ARC as calling -dealloc is illegal in that mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138261 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-22 19:07:43 +00:00
Fariborz Jahanian 58a764940d objc - minor comment fix up and cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138253 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-22 18:34:22 +00:00
Nico Weber 9a1ecf0522 Warn on missing [super dealloc] calls.
This matches gcc's logic. Half of PR10661.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138240 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-22 17:25:57 +00:00
Fariborz Jahanian a28948f348 Restore patch I reversed in r138040. Known buildbot
failures are resolved.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138234 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-22 15:54:49 +00:00
Matt Beaumont-Gay 5c5218e188 Improve the correctness and accuracy of the message for -Wdynamic-class-memaccess
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138074 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 20:40:18 +00:00
Fariborz Jahanian bc03aea4be objc-arc: @property definitions should default to (strong) when not
specified. // rdar://9971982


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138062 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 19:28:44 +00:00
Fariborz Jahanian e6f07f538f Revers r138040. Need to look at a few buildbot failures.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138049 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 18:02:47 +00:00
Fariborz Jahanian 3dbf2f5f00 objective-c: Bring objective-c handling of decl context
to modernity. Instead of passing down individual
context objects from parser to sema, establish decl
context in parser and have sema access current context
as needed. I still need to take of Doug's comment for
minor cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138040 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 16:06:57 +00:00
Benjamin Kramer 7d23b4a6e8 Reflow code. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138032 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 04:18:11 +00:00
Chandler Carruth 3d095febaa Fix the rest of the indent goofiness here.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138024 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 01:40:11 +00:00
Chandler Carruth 47eb2b6baf Fix an egregious formatting goof.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138023 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 01:38:33 +00:00
Ted Kremenek 8f7462237f Enhance -Wstrl-incorrect-size to not report a FIXIT for destinations that are flexible arrays or have size 1.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138004 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 22:48:41 +00:00
Kaelyn Uhrain d2c8972726 Don't accept a typo correction if the corrected identifier is the same as the
uncorrected identifier. Fixes a problem pointed out by Eli.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137987 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 21:57:36 +00:00
Ted Kremenek bd5da9d1a7 Reapply r137903, but fix the definition of size_t in the test case to use __SIZE_TYPE__ (and hence be portable).
Also, change the warning to -Wstrl-incorrect-size.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137980 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 20:55:45 +00:00
Argyrios Kyrtzidis 5c5f03e402 [libclang] Support code-completion inside macro arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137973 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 19:41:28 +00:00
Kaelyn Uhrain 5161163080 Rework DiagnoseInvalidRedeclaration to add the ability to correct typos when
diagnosing invalid function redeclarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137966 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 18:19:12 +00:00
Chandler Carruth 80f5b16efb Always mark friend function declarations in class templates as
implicitly instantiable, even if we don't see a body on the friend
function declaration. The body may simply have not yet been attached.
This fixes PR10666.

There may be an alternate, preferred implementation strategy, see my
FIXME. Review would definitely be appreciated Doug. =D

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137934 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 09:09:59 +00:00
Ted Kremenek 1cb4f664fd Revert r137903, "Add experimental -Wstrlcpy-size warning that looks to see if the size argument for strlcpy/strlcat is the size of the *source*, and not the size of the *destination*. This warning is off by default (for now)."
This currently doesn't work on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137920 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 02:18:02 +00:00
Chandler Carruth 5440bfaff6 Remove the last FIXMEs on -Wunused-comparison since it got moved to
entirely use the existing -Wunused-value infrastructure. This also fixes
a few missed cases for -Wunused in general.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137916 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 02:04:29 +00:00
Francois Pichet b0a58cd0d6 Downgrade "err_init_list_variable_narrowing" into a warning in Microsoft mode even if c++0x is enabled. This necessary to parse MSVC code in C++0x mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137904 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 00:04:08 +00:00
Ted Kremenek 4b53117c99 Add experimental -Wstrlcpy-size warning that looks to see if the size argument for strlcpy/strlcat is the size of the *source*, and not the size of the *destination*. This warning is off by default (for now).
Warning logic provided by Geoff Keating.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137903 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 23:40:36 +00:00
John McCall 0a7efe1142 Reorganize the return-type vs. expression checking code in
block returns; no functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137884 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 22:09:46 +00:00
John McCall d963c37eb9 Gather cleanups correctly in block return statements.
Thanks to Ted for finding this with magic tools.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137877 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 21:34:14 +00:00
Argyrios Kyrtzidis 75cf3e86d3 Mark objc methods that are implicitly declared for properties (not user-declared) as implicit.
This results in libclang ignoring such methods.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137852 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 19:25:08 +00:00
Chandler Carruth ec8058f64b Treating the unused equality comparisons as something other than part of
-Wunused was a mistake. It resulted in duplicate warnings and lots of
other hacks. Instead, this should be a special sub-category to
-Wunused-value, much like -Wunused-result is.

Moved to -Wunused-comparison, moved the implementation to piggy back on
the -Wunused-value implementation instead of rolling its own, different
mechanism for catching all of the "interesting" statements.

I like the unused-value mechanism for this better, but its currently
missing several top-level statements. For now, I've FIXME-ed out those
test cases. I'll enhance the generic infrastructure to catch these
statements in a subsequent patch.

This patch also removes the cast-to-void fixit hint. This hint isn't
available on any of the other -Wunused-value diagnostics, and if we want
it to be, we should add it generically rather than in one specific case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137822 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 09:34:37 +00:00
Chandler Carruth 50bf68fc96 Don't suggest assignment in implausible situation. We still warn, as the
code is very likely to be buggy, but its going to require more
significant changes on the part of the user to correct it in this case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137820 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 08:38:11 +00:00
Chandler Carruth 9d8eb3b2a8 Introduce a new warning, -Wtop-level-comparison. This warning is
a complement to the warnings we provide in condition expressions. Much
like we warn on conditions such as:

  int x, y;
  ...
  if (x = y) ... // Almost always a typo of '=='

This warning applies the complementary logic to "top-level" statements,
or statements whose value is not consumed or used in some way:

  int x, y;
  ...
  x == y; // Almost always a type for '='

We also mirror the '!=' vs. '|=' logic.

The warning is designed to fire even for overloaded operators for two reasons:

1) Especially in the presence of widespread templates that assume
   operator== and operator!= perform the expected comparison operations,
   it seems unreasonable to suppress warnings on the offchance that
   a user has written a class that abuses these operators, embedding
   side-effects or other magic within them.
2) There is a trivial source modification to silence the warning for
   truly exceptional cases:

     (void)(x == y); // No warning

A (greatly reduced) form of this warning has already caught a number of
bugs in our codebase, so there is precedent for it actually firing. That
said, its currently off by default, but enabled under -Wall.

There are several fixmes left here that I'm working on in follow-up
patches, including de-duplicating warnings from -Wunused, sharing code
with -Wunused's implementation (and creating a nice place to hook
diagnostics on "top-level" statements), and handling cases where a proxy
object with a bool conversion is returned, hiding the operation in the
cleanup AST nodes.

Suggestions for any of this code more than welcome. Also, I'd really
love suggestions for better naming than "top-level".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137819 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 08:38:04 +00:00
Chandler Carruth b33c19fef2 Switch this code to use the more idiomatic 'dyn_cast' pattern.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137780 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 22:30:10 +00:00
Richard Smith af1fc7af35 Track in the AST whether a function is constexpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137653 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 21:04:07 +00:00
Matt Beaumont-Gay 9b127f3b44 Add fixit notes for -Wconstant-logical-operand.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137620 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 17:50:06 +00:00
Douglas Gregor f20d27288c Teach reference initialization from the result of a user-defined
conversion to initialize the standard conversion *after* the
user-defined conversion properly. Fixes PR10644.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137608 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 13:59:46 +00:00
Francois Pichet af0f4d0b2e Implement function template specialization at class scope extension in Microsoft mode. A new AST node is introduced: ClassScopeFunctionSpecialization. This node holds a FunctionDecl that is not yet specialized; then during the class template instantiation the ClassScopeFunctionSpecialization will spawn the actual function specialization.
Example:
template <class T>
class A {
public:
  template <class U> void f(U p) {  }
  template <> void f(int p) {  } // <== class scope specialization
};

This extension is necessary to parse MSVC standard C++ headers, MFC and ATL code.
BTW, with this feature in, clang can parse (-fsyntax-only) all the MSVC 2010 standard header files without any error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137573 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-14 03:52:19 +00:00
Jeffrey Yasskin 6d0ee8d77b Conversions to bool count as integer conversions for the purposes of
the C++0x narrowing error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137512 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 20:56:43 +00:00
Richard Smith 37bee67ea7 Fix some comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137491 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 18:44:32 +00:00
Douglas Gregor f80b0db7b1 Overriding the predefined Protocol isn't something that's actually
done and is likely to not work well anyway; take away this unnecessary
complexity.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137465 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 17:09:30 +00:00
Douglas Gregor 772eeaefef Switch the __int128_t and __uint128_t types over to predefined types
in the AST format, which are built lazily by the ASTContext when
requested.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137437 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 06:49:56 +00:00
Douglas Gregor 7a27ea52b7 Switch the Objective-C 'SEL' type over to a predefined type in the
AST file format, lazily generating the actual declaration in
ASTContext as needed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137434 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 06:17:30 +00:00
Douglas Gregor 79d6726921 Switch the Objective-C 'Class' type over to a predefined type in the
AST file format, lazily generating the actual declaration in
ASTContext as needed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137431 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 05:59:41 +00:00
Douglas Gregor 4dfd02a17c Move the creation of the predefined typedef for Objective-C's 'id'
type over into the AST context, then make that declaration a
predefined declaration in the AST format. This ensures that different
AST files will at least agree on the (global) declaration ID for 'id',
and eliminates one of the "special" types in the AST file format.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137429 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 05:46:01 +00:00
Richard Trieu 79e610a99b The current warning in -Wnull-arithmetic for comparisons between NULL and non-pointers is not very helpful. This patch will update the wording to be more helpful to users.
Old warning:

warning: use of NULL in arithmetic operation [-Wnull-arithmetic]
  return 10 <= NULL;
            ^  ~~~~

New warning:

warning: comparison between NULL and non-pointer ('int' and NULL) [-Wnull-arithmetic]
  return 10 <= NULL;
         ~~ ^  ~~~~


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137377 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-11 22:38:21 +00:00
Douglas Gregor 01a4cf1177 Encapsulate the Objective-C id/Class/SEL "redefinition" types in
ASTContext with accessors/mutators. The only functional change is that
the AST writer won't bother writing the id/Class/SEL redefinition type
if it hasn't been explicitly set; previously, it ended up being
written as a synonym for the built-in id/Class/SEL.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137349 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-11 20:58:55 +00:00
Richard Trieu 70979d4de8 Refactoring of DiagnoseBitwisePrecedence() in SemaExpr.cpp to reduce code duplication.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137259 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 22:41:34 +00:00
Douglas Gregor a6d1e7623a When performing the lookup in the current scope for a member access to
a member template, e.g.,

  x.f<int>

if we have found a template in the type of x, but the lookup in the
current scope is ambiguous, just ignore the lookup in the current
scope.  Fixes <rdar://problem/9915664>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137255 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 21:59:45 +00:00
Kaelyn Uhrain d10f4bc5a0 Add a test case for the divide-by-zero fix in r137234
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137240 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 19:47:25 +00:00
Kaelyn Uhrain 18f169770d Make sure ptrarith_typesize is at least 1 to avoid division by zero
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137234 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 18:49:28 +00:00
Fariborz Jahanian 730cfb1846 objective-c: Using existing infrastructure for finding
overridden  methods to diagnose their type mismatch.
This is a general solution for previous fixes
for // rdar://6191214 and // rdar://9352731
and removes lots of duplicate code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137222 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 17:16:30 +00:00
Douglas Gregor 136da1c432 When adding the base and member initializers for an implicitly-defined
special member function, make sure to classify an explicitly-defaulted
copy constructor as a "copy" operation. Fixes PR10622.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137219 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 16:51:53 +00:00
Douglas Gregor c90df6a0ad Update a comment to match the recently-changed code
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137216 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 16:09:55 +00:00
Douglas Gregor 3b6b7accb5 For the availability attribute, allow a declaration to be deprecated
in the same version that it is introduced. Stuff happens.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137214 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 15:31:35 +00:00
Douglas Gregor 4dc41c9b76 Rewrite default initialization of anonymous structs/unions within a
constructor. Previously, we did some bogus recursion into the fields
of anonymous structs (recursively), which ended up building invalid
ASTs that would cause CodeGen to crash due to invalid GEPs.

Now, we instead build the default initializations based on the
indirect field declarations at the top level, which properly generates
the sequence of GEPs needed to initialize the proper member. Fixes
PR10512 and <rdar://problem/9924046>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137212 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 15:22:55 +00:00
John McCall a19950edd9 Change an assert into a check. I'm pretty sure there was a point
in time when this assert was valid, but it's not valid now.
Also teach this code to correctly introduce function-to-pointer
decay.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137201 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 04:12:23 +00:00
Caitlin Sadowski b51e0315d4 Thread Safety: Added basic argument parsing for all new attributes.
This patch special cases the parser for thread safety attributes so that all
attribute arguments are put in the argument list (instead of a special
parameter) since arguments may not otherwise resolve correctly without two-token
lookahead.

This patch also adds checks to make sure that attribute arguments are
lockable objects.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137130 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 17:59:31 +00:00
Douglas Gregor 6b63f551b1 Make sure to canonicalize the argument type of a non-type template
argument of enumeration type when checking template arguments. Fixes PR10579.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137101 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 01:55:14 +00:00
Fariborz Jahanian 6b167f4fc4 Don't emit memcpy for copying fields of arrays of volatile elements.
Use the the path that generates a loop. This fixes
bogus error that clang puts out. // rdar://9894548



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137080 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 00:26:11 +00:00
Fariborz Jahanian 2112190efa objective-c: diagnose protocol inconsistencies in following
situation. When a class explicitly or implicitly (through inheritance) 
"conformsTo" two protocols which conflict (have methods which conflict).
This patch fixes the previous patch where warnings were coming out in
non-deterministic order.  This is 2nd part of // rdar://6191214.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137055 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-08 18:03:17 +00:00
Kaelyn Uhrain adc7a73930 Make sure FunctionDecls aren't considered during overload resolution if there
are explicit template args.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137054 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-08 17:35:31 +00:00
David Chisnall 7ca13ef641 Silence the category-replacing-class-method warning for +load: category
implementations of +load do not replace the class definition in a meaningful
sense, they are run when the category loads, the +load method for class is run
when the class is loaded.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137053 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-08 17:32:19 +00:00
John McCall a8e0cd8cde Do l-value conversion, etc., on a switch condition expression in
ActOnStartOfSwitchStmt (i.e. before binding up a full-expression)
instead of ActOnFinishSwitchStmt.

Among other things, this means that property l-values are properly
converted inside the full-expression.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137014 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-06 07:30:58 +00:00
Benjamin Kramer 22d4fed17d Only look at decls after the current one when checking if it's the last field in a record.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137009 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-06 03:04:42 +00:00
Ted Kremenek 270ba59c41 Revert 136984 and 136927.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136998 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-05 23:31:22 +00:00
Kaelyn Uhrain d6c8865e6f Perform array bounds checking in more situations and properly handle special
case situations with the unary operators & and *. Also extend the array bounds
checking to work with pointer arithmetic; the pointer arithemtic checking can
be turned on using -Warray-bounds-pointer-arithmetic.

The changes to where CheckArrayAccess gets called is based on some trial &
error and a bunch of digging through source code and gdb backtraces in order
to have the check performed under as many situations as possible (such as for
variable initializers, arguments to function calls, and within conditional in
addition to the simpler cases of the operands to binary and unary operator)
while not being called--and triggering warnings--more than once for a given
ArraySubscriptExpr.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136997 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-05 23:18:04 +00:00
Roman Divacky 8e68f1c8a2 Let attribute((cdecl)) and company override -mrtd default calling convention.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136971 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-05 16:37:22 +00:00
Chandler Carruth c268434b33 Flesh out the -Warray-bounds detection of C89 tail-padded one-element
arrays. This now suppresses the warning only in the case of
a one-element array as the last field in a struct where the array size
is a literal '1' rather than any macro expansion or template parameter.

This doesn't distinguish between the language standard in use to allow
code which dates from C89 era to compile without the warning even in C99
and C++ builds. We could add a separate warning (under a different flag)
with fixit hints to switch to a flexible array, but its not clear that
this would be desirable. Much of the code using this idiom is striving
for maximum portability.

Tests were also fleshed out a bit, and the diagnostic itself tweaked to
be more pretty w.r.t. single elment arrays. This is more ugly than
I would like due to APInt's not being supported by the diagnostic
rendering engine.

A pseudo-patch for this was proposed by Nicola Gigante, but I reworked
it both for several correctness issues and for code style.

Sorry this was so long in coming.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136965 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-05 09:10:50 +00:00
Chandler Carruth ba44712b0e Finally getting around to re-working this to more accurately white-list
1-element character arrays which are serving as flexible arrays. This is
the initial step, which is to restrict the 1-element array whitelist to
arrays that are member declarations. I'll refine it from here based on
the proposed patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136964 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-05 08:07:29 +00:00
Matt Beaumont-Gay cc2f30c4ed Extend memset/memcpy/memmove checking to include memcmp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136950 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-05 00:22:34 +00:00
Kaelyn Uhrain ace5e76e5c Have the typo correction in DiagnoseEmptyLookup properly handle template
functions when performing function overload resolution.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136948 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-05 00:09:52 +00:00
Kaelyn Uhrain 844d572855 Fix a small bug where DiagnoseEmptyLookup would no longer print any messages
when performing typo correction involving any overloaded template functions.

The added test cases, while currently demontrating sub-optimal behavior, will
not trigger any messages without the 1-line change to SemaExpr.cpp.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136943 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 23:30:54 +00:00
Matt Beaumont-Gay 42d7b2d25b Specialize diag::warn_unused_call for the "warn_unused_result" attribute, so
it can be controlled with a distinct flag.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136941 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 23:11:04 +00:00
Fariborz Jahanian 6a3bec320e objective-c: diagnose protocol inconsistencies in following
situation. When a class explicitly or implicitly (through inheritance) 
"conformsTo" two protocols which conflict (have methods which conflict).
This is 2nd part of // rdar://6191214.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136927 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 21:28:44 +00:00
Kaelyn Uhrain 4d9d157afb Match type names and give more info for out-of-line function definition errors.
Having a function declaration and definition with different types for a
parameter where the types have same (textual) name can occur when an unqualified
type name resolves to types in different namespaces in each location.

The error messages have been extended by adding notes that point to the first
parameter of the function definition that doesn't match the declaration, instead
of a generic "member declaration nearly matches". The generic message is still
used in cases where the mismatch is not in the paramenter list, such as
mismatched cv qualifiers on the member function itself.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136891 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 17:40:00 +00:00
Fariborz Jahanian a56a992cbe Refactoring of my last patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136841 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 23:44:01 +00:00
Kaelyn Uhrain f0c1d8f804 Improve overloaded function handling in the typo correction code.
Change TypoCorrection to store a set of NamedDecls instead of a single
NamedDecl. Also add initial support for performing function overload
resolution to Sema::DiagnoseEmptyLookup.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136807 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 20:36:05 +00:00
Fariborz Jahanian 74133075f5 objective-c: Methods declared in methods must type match
those declated in its protocols. First half or // rdar://6191214


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136794 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 18:21:12 +00:00
Douglas Gregor 0bbea1b87e Make the type of the IntegerLiteral for bitfield paddings an actual
integer, and initialise its TypeSourceInfo. The initialisation fixes a
crash when using pre-compiled preambles with C++ code-completion. From
Erik Verbruggen! Fixes PR10511.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136786 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 16:26:46 +00:00
John McCall fc4b191b07 In ARC, don't try to reclaim the result of a call to performSelector
unless done in a context where the value is used retained.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136769 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 07:02:44 +00:00
Chris Lattner 9e6a1caf18 disable array bounds overflow warning for cases where an array
has a single element.  This disables the warning in cases where
there is a clear bug, but this is really rare (who uses arrays
with one element?) and it also silences a large class of false
positive issues with C89 code that is using tail padding in structs.

A better version of this patch would detect when an array is in
a tail position in a struct, but at least patch fixes the huge
false positives that are hitting postgres and other code.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136724 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 21:44:23 +00:00
Benjamin Kramer 39997fc2b8 Make helper functions static.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136679 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 04:50:49 +00:00
Richard Trieu 67e29334f2 Fix formatting of SemaExpr.cpp, mainly fixing lines greater than 80 characters.
No functional change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136678 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 04:35:43 +00:00
Fariborz Jahanian 7898005b35 objective-c: reverse patch for // rdar://9818354
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136658 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 22:39:49 +00:00
Douglas Gregor f78c4e5712 Introduce a Fix-It for the "missing sentinel" warning, adding an
appropriate sentinel at the end of the argument list. Also, put the
sentinel warnings under -Wsentinel. Fixes <rdar://problem/8764236>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136566 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 08:57:03 +00:00
Douglas Gregor d2d8be6a27 Add code completion to produce "else" blocks after an "if"
statement. Fixes <rdar://problem/9229438>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136564 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 08:36:53 +00:00
Douglas Gregor e424470212 When producing code completion results for variadic macros, fold the
variadic bit (", ..." or ", args...") into the prior placeholder, like
we do with functions and methods. Fixes <rdar://problem/9740808>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136563 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 08:17:44 +00:00
Douglas Gregor 6fa14dde4c Add the various parameter-passing keywords for Distributed Objects
(such as in, inout, byref, and oneway) to code completion
results. Fixes <rdar://problem/8844158>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136562 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 07:55:26 +00:00
Douglas Gregor 0f91c8ccb3 When performing code completion after at @interface, allow both
already-defined and forward-declared results. Already-defined results
are fine because they could be the start of a category. Fixes
<rdar://problem/9811691>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136559 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 06:55:39 +00:00
Douglas Gregor 4eb7522e70 When complaining about a non-POD second argument to va_arg, use a
special diagnostic for ARC ownership-qualified types. We wouldn't want
to expose Objective-C programmers to the term "POD", would we? Fixes
<rdar://problem/9772982>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136558 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 06:45:27 +00:00
Peter Collingbourne 9aab148986 Fix an inconsistency in Sema::ConvertArgumentsForCall in that
the callee note diagnostic was not emitted in the case where
there were too few arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136437 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 00:24:42 +00:00
Fariborz Jahanian fefe91e601 objective-c: warn if implementation of a method in category
masks an existing method in its primary class, class extensions,
and primary class's non-optional protocol methods; as primary
class, or one of its subclass's will implement this method.
This warning has potential of being noisy so it has its own
group.  // rdar://7020493


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136426 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 23:19:50 +00:00
Anna Zaks d5612a235f Add a fixit for removal of unused label.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136389 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 20:52:06 +00:00
Caitlin Sadowski db33e14661 Added basic parsing for all remaining attributes, thread safety
analysis. This includes checking that the attributes are applied in the
correct contexts and with the correct number of arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136383 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 20:12:35 +00:00
Anna Zaks 6722155dfe Add */& mismatch fixit generation to the Sema::DiagnoseAssignmentResult().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136379 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 19:51:27 +00:00
Douglas Gregor 6e4a3f5c59 Make the deserialization of Sema::PendingInstantiations lazy. At this
point, ASTReader::InitializeSema() has very little interesting work,
*except* issues stemming from preloaded declarations. That's something
we'll still need to cope with.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136378 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 19:49:54 +00:00
Anna Zaks f3546eeef1 Refactor the */& mismatch fixit generation out of SemaOverload and provide a simple conversion checking function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136376 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 19:46:48 +00:00
Douglas Gregor dfe6543e12 Lazily deserialize Sema::VTableUses. Plus, fix the utterly and
completely broken deserialization mapping code we had for VTableUses,
which would have broken horribly as soon as our local-to-global ID
mapping became interesting.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136371 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 19:11:31 +00:00
Douglas Gregor 31e37b2d7b Make Sema::WeakUndeclaredIdentifiers lazily deserialized.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136368 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 18:09:57 +00:00
Caitlin Sadowski fdde9e719a Added parsing for guarded_var, pt_guarded_var, lockable,
scoped_lockable, and no_thread_safety_analysis attributes, all for thread safety analysis

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136364 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 17:21:07 +00:00
Douglas Gregor 5b9dc7caae Make Sema::ReferencedSelectors lazily deserialized.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136357 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 14:54:22 +00:00
Douglas Gregor ec12ce2f6d Make Sema::LocallyScopedExternalDecls lazily deserialized. In theory,
we could turn this into an on-disk hash table so we don't load the
whole thing the first time we need it. However, it tends to be very,
very small (i.e., empty) for most precompiled headers, so it isn't all
that interesting.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136352 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 14:20:37 +00:00
Douglas Gregor a126f17ca8 Switch Sema::DynamicClasses over to LazyVector
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136317 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 00:53:40 +00:00
Douglas Gregor d58a0a55e6 Switch Sema::ExtVectorDecls over to LazyVector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136314 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 00:39:29 +00:00
Douglas Gregor 0129b561a1 Turn Sema::DelegatingCtorDecls into a LazyVector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136273 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 21:57:17 +00:00
John McCall 07524039dc The lock operand to an @synchronized statement is also
supposed to be a full-expression;  make it so.  In ARC, make sure
we retain the lock for the entire protected block. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136271 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 21:50:02 +00:00
Douglas Gregor a2ee20aa96 Switch Sema::UnusedFileScopedDecls over to a LazyVector.
- Added LazyVector::erase() to support this use case.
  - Factored out the LazyDecl-of-Decls to RecordData translation in
  the ASTWriter. There is still a pile of code duplication here to
  eliminate.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136270 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 21:45:57 +00:00
Douglas Gregor a862320972 Introduce a new data structure, LazyVector, which is a vector whose
contents are lazily loaded on demand from an external source (e.g., an
ExternalASTSource or ExternalSemaSource). The "loaded" entities are
kept separate from the "local" entities, so that the two can grow
independently.

Switch Sema::TentativeDefinitions from a normal vector that is eagerly
populated by the ASTReader into one of these LazyVectors, making the
ASTReader a bit more like me (i.e., lazy).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136262 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 20:58:46 +00:00
Peter Collingbourne 020972d5d6 Forbid address-space-qualified function types, per TR 18037
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136257 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 20:30:05 +00:00
Peter Collingbourne 29e3ef8df8 Fix TR 18037 citation in SemaType.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136256 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 20:29:53 +00:00
Douglas Gregor 5cee119558 Add support for C++0x unicode string and character literals, from Craig Topper!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136210 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 05:40:30 +00:00
John McCall 990567cb60 Clean up the analysis of the collection operand to ObjC
for-in statements;  specifically, make sure to close over any
temporaries or cleanups it might require.  In ARC, this has
implications for the lifetime of the collection, so emit it
with a retain and release it upon exit from the loop.

rdar://problem/9817306



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136204 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 01:07:15 +00:00
Francois Pichet dfb6ae1d8d In Microsoft mode, if we are within a templated function and we can't resolve Identifier during BuildCXXNestedNameSpecifier, then extend the SS with Identifier. This will have the effect of resolving Identifier during template instantiation. The goal is to be able to resolve a function call whose nested-name-specifier is located inside a dependent base class.
class C {
public:
    static void foo2() {  }
};

template <class T> class A {
public:
   typedef C D;
};

template <class T> class B : public A<T> {
public:
  void foo() { D::foo2(); }
};

Note that this won't work if the NestedNameSpecifier refers to a type.
This fixes 1 error when parsing the MSVC 2010 standard headers file with clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136203 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 01:05:24 +00:00
Eli Friedman ef8c79c522 Re-fix r136172 so it isn't an error; apparently, some people are fond of their undefined behavior.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136183 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 23:27:24 +00:00
Jeffrey Yasskin 191591336f This patch implements as much of the narrowing conversion error specified by
[dcl.init.list] as is possible without generalized initializer lists or full
constant expression support, and adds a c++0x-compat warning in C++98 mode.

The FixIt currently uses a typedef's basename without qualification, which is
likely to be incorrect on some code.  If it's incorrect on too much code, we
should write a function to get the string that refers to a type from a
particular context.

The warning is currently off by default. I'll fix LLVM and clang before turning
it on.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136181 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 23:20:30 +00:00
Eli Friedman e33f643230 Diagnose trying to delete a pointer to an abstract class with a non-virtual destructor. PR10504.
I'm not completely sure the standard allows us to reject this, but if it doesn't, it should. :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136172 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 22:50:18 +00:00
Eli Friedman e52c91478a A couple minor issues with Sema for delete:
1. Attempting to delete an expression of incomplete class type should be an error, not a warning.

2. If someone tries to delete a pointer to an incomplete class type, make sure we actually emit
the delete expression after we warn.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136161 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 22:25:31 +00:00
Argyrios Kyrtzidis 473506bd9d In ARC we emit an error when compiling:
@interface Foo : NSObject
@property (readonly) id myProp;
@end

@implementation Foo
@synthesize myProp;
@end

t.m:9:13: error: ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute
@synthesize myProp;
            ^

which is fine, we want the ownership of the synthesized ivar to be explicit. But we should _not_ emit an error
for the following cases, because we can get the ownership either from the declared ivar or from the property type:

@interface Foo : NSObject {
	__weak id _myProp1;
	id myProp2;
}
@property (readonly) id myProp1;
@property (readonly) id myProp2;
@property (readonly) __strong id myProp3;
@end

@implementation Foo
@synthesize myProp1 = _myProp1;
@synthesize myProp2;
@synthesize myProp3;
@end

rdar://9844006.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136155 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 21:48:26 +00:00
Kaelyn Uhrain 2760455396 Revert r136046 while fixing handling of e.g. &foo[index_one_past_size]
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136113 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 18:36:36 +00:00
Fariborz Jahanian 8eaefdc6ae Provide fixit for static use of objective-c type
in few more places and in each instance, fix up
the type to the expected type. // rdar://9603056


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136103 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 17:58:54 +00:00
Benjamin Kramer a0651c5f5d Eliminate a bunch of temporary strings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136092 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 16:59:25 +00:00
Douglas Gregor 0a47d69af8 Add new libclang API, clang_codeCompleteGetObjCSelector(), which
provides the partial Objective-C selector used in a code
completion. From Connor Wakamo!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136084 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 15:24:30 +00:00
Douglas Gregor 2ad63cf714 When we decide not to rebuild an instantiated C++ 'new' expression
that allocates an array of objects with a non-trivial destructor, be
sure to mark the destructor is "used". Fixes PR10480 /
<rdar://problem/9834317>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136081 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 15:11:03 +00:00
Douglas Gregor da8b24961a Objective-C++ ARC: When performing template argument deduction for a
lifetime-qualified template parameter, ensure that the deduced
template argument is a lifetime type. Fixes <rdar://problem/9828157>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136078 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 14:53:44 +00:00
Chandler Carruth 108f756beb Cleanup the stray comments and variables I could dig out of Sema to
refer to 'expansion' instead of 'instantiation'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136060 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 05:40:03 +00:00
Kaelyn Uhrain b48f7c059e Expand array bounds checking to work in the presence of unary & and *,
and to work with pointer arithmetic in addition to array indexing.

The new pointer arithmetic porition of the array bounds checking can be
turned on by -Warray-bounds-pointer-arithmetic (and is off by default).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136046 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 01:52:28 +00:00
Kaelyn Uhrain 22f7bb7e77 Test commit
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136044 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 01:42:22 +00:00
Fariborz Jahanian dcf1011876 objective-c: Provide a 'fixit' when class was used
to declare a static object. // rdar://9603056


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135970 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 21:12:27 +00:00
Douglas Gregor 430d7a1a62 Added clang_getCursorReferenceNameRange to libclang to to retrieve parts of
a cursor reference, from Erik Verbruggen!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135920 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 17:48:11 +00:00
Chandler Carruth 402785357a Mechanically rename SourceManager::getInstantiationLoc and
FullSourceLoc::getInstantiationLoc to ...::getExpansionLoc. This is part
of the API and documentation update from 'instantiation' as the term for
macros to 'expansion'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135914 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 16:49:02 +00:00
Fariborz Jahanian eee3ef177a objc: clang should warn if redeclaration of methods
declared in protocol in the class qualified by the
protocol have type conflicts. To reduce amount of
noise, this is done when class is implemented.
// rdar://9352731


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135890 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-24 20:53:26 +00:00
Douglas Gregor bf6e3179ea Tests for explicit conversion operators, along with a fix to avoid
considering explicit conversion operators when determining surrogate
functions. Fixes PR10453. Note that there are a few test cases where
Clang is still wrong because it does not implement DR899; see PR10456.

Patch by Jonathan Sauer!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135857 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 18:59:35 +00:00
Chris Lattner 2d3ba4f5a9 Move ArrayRef to LLVM.h and eliminate now-redundant qualifiers, patch by Jon Mulder!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135855 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 17:14:25 +00:00
Chris Lattner 5f9e272e63 remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135852 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 10:55:15 +00:00
David Majnemer 0ad9231485 kill a FIXME in IsIntegralPromotion
IsIntegralPromotion should consider the signedness of FromType when
calculating promotions. This, as of now, cannot be exercised on any
platform so there is no corresponding test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135803 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 21:09:04 +00:00
John McCall dc7c5ad7a1 Document the existing objc_precise_lifetime attribute.
Introduce and document a new objc_returns_inner_pointer
attribute, and consume it by performing a retain+autorelease
on message receivers when they're not immediately loaded from
an object with precise lifetime.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135764 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 08:53:00 +00:00
Chandler Carruth d837c0dc36 Move duplicate uninitialized warning suppression into the
AnalysisBasedWarnings Sema layer and out of the Analysis library itself.
This returns the uninitialized values analysis to a more pure form,
allowing its original logic to correctly detect some categories of
definitely uninitialized values. Fixes PR10358 (again).

Thanks to Ted for reviewing and updating this patch after his rewrite of
several portions of this analysis.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135748 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 05:27:52 +00:00
John McCall da6d976b0f Move this ObjCImplementationDecl member function into libAST
where it belongs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135746 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 04:15:06 +00:00
John McCall 6c2c250db1 In Objective-C, pull arbitrary attributes from overridden
methods, including indirectly overridden methods like those
declared in protocols and categories.  There are mismatches
that we would like to diagnose but aren't yet, but this   
is fine for now.

I looked at approaches that avoided doing this lookup 
unless we needed it, but the infer-related-result-type
checks were doing it anyway, so I left it with the same
fast-path check for no previous declartions of that 
selector.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135743 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 02:45:48 +00:00
Jordy Rose db8264e4c5 Add a const overload for ObjCInterfaceDecl::all_declared_ivar_begin.
This was previously not-const only because it has to lazily construct a chain
of ivars the first time it is called (and after the chain is invalidated).
In practice, all the clients were just const_casting their const Decls;
all those now-unnecessary const_casts have been removed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135741 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 02:08:32 +00:00
Fariborz Jahanian 527eec86ce objective-c: Any use of @synthesize or @dynamic lexically after a method (or C function) implementation
will be rejected with a compilation error in ARC mode, and a compiler warning otherwise.
This may cause breakage in non-arc (and arc) tests which don't expect warning/error. Feel free
to fix the tests, or reverse the patch, if I am unavailable. // rdar://9818354 - WIP


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135740 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 01:06:53 +00:00
Fariborz Jahanian feb4fa165c Add FixIt hint for missing 'id' type.
// rdar://9615045


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135685 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 17:38:14 +00:00
Fariborz Jahanian aab24a616d objc - Diagnose missing method return type specifier under
a warning flag. // rdar://9615045


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135681 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 17:00:47 +00:00
Eric Christopher 4110e1399b Speculatively revert 135649 to bring back the g++ testing bots.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135668 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 05:34:24 +00:00
Ted Kremenek bc5cb8a5fe Simplify passing of CFGBuildOptions around for AnalysisContext. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135666 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 05:22:47 +00:00
Richard Trieu 5254161b26 Remove warning for conditional operands of differend signedness from -Wsign-compare. Cases that previously warn on this will have a different warning emitted from -Wsign-conversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135664 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 02:46:28 +00:00
Douglas Gregor e081a61bb0 New libclang API to expose container type for code completion, from
Connor Wakamo!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135651 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 01:05:26 +00:00
Sean Hunt 98c6bda3be When copping out on a friend template declaration, be sure to mark its
access specifier as public.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135649 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 00:59:23 +00:00
Anna Zaks ffe9edd45f Addressing code review comments for commit 135509 - Add FixItHints in case a C++ function call is missing * or & operators on
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135643 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 00:34:39 +00:00
Fariborz Jahanian f2dd68fb37 objc-arc: Fixes a crash @throw'ing an objc message.
// pr10411


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135638 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 23:39:56 +00:00
Fariborz Jahanian 909bcb37c4 arc-objc++: Issue an arc specific diagnostic when overload resolution
fails because of lifetime differences of parameter and argument type.
// rdar://9790531


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135593 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 17:14:09 +00:00
Chris Lattner 686775deca now that we have a centralized place to do so, add some using declarations for
some common llvm types: stringref and smallvector.  This cleans up the codebase
quite a bit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135576 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 06:58:45 +00:00
Richard Smith 0ff6f8f038 Replace r134583's fix for PR10290 with one which also works for non-value-dependent cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135543 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 00:12:52 +00:00
Anna Zaks b89fe6b04c Add FixItHints in case a C++ function call is missing * or & operators on one/several of it's parameters (addresses http://llvm.org/PR5941).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135509 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-19 19:49:12 +00:00
Ted Kremenek 0c8e5a0f70 Reduce -Wuninitialized time by 22% (on sqlite) by removing the recursive AST crawl.
This is accomplished by forcing the needed expressions for -Wuninitialized to always be CFGElements in the CFG.
This allows us to remove a fair amount of the code for -Wuninitialized.

Some fallout:
- AnalysisBasedWarnings.cpp now specifically toggles the CFGBuilder to create a CFG that is suitable for -Wuninitialized.  This
is a layering violation, since the logic for -Wuninitialized is in libAnalysis.  This can be fixed with the proper refactoring.
- Some of the source locations for -Wunreachable-code warnings have shifted.  While not ideal, this is okay because that analysis
already needs some serious reworking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135480 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-19 14:18:48 +00:00
Chris Lattner b5f65475d2 Use the new llvm::TinyPtrVector class, which implements exactly what
ShadowMapEntry was.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135368 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-18 01:54:02 +00:00
Benjamin Kramer 12efd57ee4 Zero this struct in a way that neither depends on the size of the struct nor triggers warnings from GCC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135351 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-16 20:13:06 +00:00
Fariborz Jahanian 57080fbac1 Remove a gcc warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135348 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-16 18:31:33 +00:00
Fariborz Jahanian 1e159bc43c Fix a typo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135328 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-16 00:08:33 +00:00
Tanya Lattner 61b4bc80e9 This handles the missing cases of opencl vector literals.
Test cases provided by Anton Lokhmot.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135322 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 23:07:01 +00:00
Jeffrey Yasskin 3e1ef78498 Use the new APFloat::convertToInt(APSInt) function to simplify uses of
convertToInt(integerParts*) and make them more reliable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135279 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 17:03:07 +00:00
Douglas Gregor 5b8968cc59 Store bracket locations for array subscript expressions, from Erik Verbruggen!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135275 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 16:25:15 +00:00
Douglas Gregor 91ae6b43b3 When creating a property in a class extension, make sure to check its
attributes. Fixes <rdar://problem/9561076>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135273 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 15:30:21 +00:00
John McCall 4e9272de54 Restore the C-style cast hack for enum template arguments,
which is required given the current setup for template
argument deduction substitution validation, and add a test
case to make sure we don't break it in the future.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135262 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 07:47:58 +00:00
John McCall 91a5755ad7 Create a new expression node, SubstNonTypeTemplateParmExpr,
to represent a fully-substituted non-type template parameter.
This should improve source fidelity, as well as being generically
useful for diagnostics and such.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135243 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 05:09:51 +00:00
Richard Trieu e5adf59d3a Remove warnings of constant operands of logical operators from template instantiations. Upon instantiation of template, value-dependent parameters are replaced by equivalent literals, so code like:
template<unsigned int A, unsigned int B> struct S {
  int foo() {
    int x = A && B;
  }
}

will not warn on A && B on every instantiation.  This will still warn on other cases inside templates, which will be caught on checking the template definition.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135222 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 00:00:51 +00:00
Rafael Espindola 12ce0a085f Revert 135177 to fix PR10363.
Revert "For C++11, do more checking of initializer lists up-front, enabling some subset of the final functionality. C just leaves the function early. C++98 runs through the same code path, but has no changed functionality either."

This reverts commit ac420c5053.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135210 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 22:58:04 +00:00
John McCall 00fe761849 Teach -Wconversion, -Wsign-compare etc. about division and remainder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135208 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 22:39:48 +00:00
Sebastian Redl ac420c5053 For C++11, do more checking of initializer lists up-front, enabling some subset of the final functionality. C just leaves the function early. C++98 runs through the same code path, but has no changed functionality either.
This is a first baby step towards supporting generalized initializer lists. This also removes an aggregate
test case that was just plain wrong, assuming that non-aggregates couldn't be initialized with initializer lists
in C++11 mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135177 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 19:08:10 +00:00
Sebastian Redl 3b80232b50 Remove InitializationSequence::ReferenceBinding, the last redundant sequence kind.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135175 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 19:07:55 +00:00
Douglas Gregor 3a348c86ff Add a hackaround to avoid the crash in PR10355. However, our recovery
is still terrible here because typo correction is not behaving well in
the presence of overloaded functions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135128 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 04:54:23 +00:00
Richard Smith 87c1f1f7c4 PR8800: When building a conversion to A& using a member operatorA&(), do not require A to be a complete type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135101 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 22:53:21 +00:00
Douglas Gregor 90ebed0734 Add 'mutable' to the function declarator chunk, to be used when
parsing lambda expressions, from John Freeman!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135090 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 21:47:47 +00:00
Douglas Gregor 1255aaf102 Fix an incorrect namespace typo-correction diagnostic, from Kaelyn
Uhrain! Fixes PR10318.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135086 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 21:36:26 +00:00
John McCall 84ff0fccb1 Enforce access control for the destructor in a new[] expression and mark
it as used.  Otherwise, we can fail to instantiate or validate the destructor,
which can lead to crashes in IR gen like PR10351.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135073 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 20:12:57 +00:00
Fariborz Jahanian 4c91d89453 With -Wselector, don't warn about unimplemented optional method
used in @selector expression because, well, their implementation 
is optional. // rdar://9545564


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135057 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 19:05:43 +00:00
John McCall 48218c60d6 In debugger mode, make ObjC message sends to unknown selectors return
__unknown_anytype, and rewrite such message sends correctly.

I had to bite the bullet and actually add a debugger support mode for this
one, which is a bit unfortunate, but there really isn't anything else
I could imagine doing;  this is clearly just debugger-specific behavior.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135051 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 17:56:40 +00:00
Fariborz Jahanian 8beb6a2426 objc++: Some level of covariance is allowed in ObjC properties.
Make it also available in ObjC++ propeties. Use common code for
objc and objc++ so they don't diverge. // rdar://9740328


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135050 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 17:55:01 +00:00
John McCall 862ff87c0d Make the integer-range analysis recognize ^= correctly,
and (while I'm at it) teach it to grok the results of simple
assignments.

The first is PR10336.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135034 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 06:35:24 +00:00
Douglas Gregor e7003b72e6 Eliminate an incomplete/incorrect attempt to provide support for C++0x
unrestricted unions, which ended up attempting to initialize objects
in a union (which CodeGen isn't prepared for). Fixes PR9683.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135027 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 02:14:02 +00:00
Fariborz Jahanian c286f3835e objc++: Some level of covariance is allowed in ObjC properties.
Make it also available in ObjC++ propeties. // rdar://9740328


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135001 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 22:05:16 +00:00
Fariborz Jahanian 98a5403ecf Fix a bug where a local variable named 'self' is causing
implicit ivar accesses to go through the 'self' variable
rather than the real 'self' for the method. // rdar://9730771


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134992 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 17:16:56 +00:00
Benjamin Kramer d248619cd1 Pop block scope after reading from it.
Found by valgrind.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134983 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 14:11:05 +00:00
Hans Wennborg 701d1e77ac Fix typo correction crash on overloaded functions, pr10283.
It would be cool if we could do overload resolution to suggest
the right function, but at least this fixes the crashing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134976 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 08:45:31 +00:00
Douglas Gregor 79e6bd3797 Centralize the getCanonicalType() calls in the Itanium C++ mangling
code so that they only occur in a single place. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134961 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 04:42:08 +00:00
Argyrios Kyrtzidis 0a68dc7f04 [ARC] Complain about property without storage attribute when @synthesizing it, not at its declaration.
For this sample:

@interface Foo
@property id x;
@end

we get:

t.m:2:1: error: ARC forbids properties of Objective-C objects with unspecified storage attribute
@property  id x;
^
1 error generated.

The error should be imposed on the implementor of the interface, not the user. If the user uses
a header of a non-ARC library whose source code he does not have, we are basically asking him to
go change the header of the library (bad in general), possible overriding how the property is
implemented if he gets confused and says "Oh I'll just add 'copy' then" (even worse).

Second issue is that we don't emit any error for 'readonly' properties, e.g:

@interface Foo
@property (readonly) id x; // no error  here
@end

@implementation Foo
@synthesize x; // no error here too
@end

We should give an error when the implementor is @synthesizing a property which doesn't have
any storage specifier; this is when the explicit specifier is important, because we are
going to create an ivar and we want its ownership to be explicit.

Related improvements:
-OBJC_PR_unsafe_unretained turned out to not fit in ObjCPropertyDecl's bitfields, fix it.
-For properties of extension classes don't drop PropertyAttributesAsWritten values.
-Have PropertyAttributesAsWritten actually only reflect what the user wrote

rdar://9756610.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134960 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 04:30:16 +00:00
Chandler Carruth 56aeb40b1c Style tweak to the more idiomatic 'assert(!bad_state())'.
Patch by Caitlin Sadowski.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134938 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 23:33:05 +00:00
Chandler Carruth 1731e202b2 Hoist the logic for checking the number of arguments to an attribute
into a static helper.

Original patch by Caitlin Sadowski, style tweaks by me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134937 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 23:30:35 +00:00
Eli Friedman 46d37c1040 Add diagnostic for constructs like "va_arg(l, float)" which have undefined behavior. PR10201.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134926 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 21:45:59 +00:00
Fariborz Jahanian 4e7c7f2b78 objc-arc: Diagnose when captured variable in block literals
require destruction and there is possibility of that without
construction. Thanks Johnm for review and suggestions offline.
// rdar://9535237.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134906 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 18:04:54 +00:00
Douglas Gregor 15be9b0e50 Don't complain about missing return statements for naked
functions. Fixes <rdar://problem/9731999>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134897 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 15:24:01 +00:00
Abramo Bagnara cdb8076dd9 Fixed PR10243.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134892 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 08:52:40 +00:00
Benjamin Kramer 54cf341bd4 Initialize all the AnalysisBasedWarnings statistics to zero.
Found by valgrind.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134733 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 20:38:53 +00:00
Benjamin Kramer 5b4a40a9d7 Remove unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134731 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 20:20:17 +00:00
Fariborz Jahanian 82007c3a3f objc++-arc: more diagnosis of converting a weak-unavailable
object to a __weak object type. // rdar://9732636


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134706 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 17:41:42 +00:00
Francois Pichet 59e7c56806 Random cleanup:
- fix a comment.
- Remove an unnecessary { } block.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134690 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 06:21:47 +00:00