Commit Graph

21200 Commits

Author SHA1 Message Date
David Blaikie d937bf13d4 Adding FixIts to static/inline main declaration diagnostics.
llvm-svn: 139282
2011-09-08 06:33:04 +00:00
Douglas Gregor bab8a96f2f Implement the Objective-C 'instancetype' type, which is an alias of
'id' that can be used (only!) via a contextual keyword as the result
type of an Objective-C message send. 'instancetype' then gives the
method a related result type, which we have already been inferring for
a variety of methods (new, alloc, init, self, retain). Addresses
<rdar://problem/9267640>.

llvm-svn: 139275
2011-09-08 01:46:34 +00:00
Chad Rosier c31e48d7e4 [driver] i386 kext preprocessor jobs also need their unsupported options
filtered.  This happenis when -save-temps is specified. 
<rdar://problem/10088387>

llvm-svn: 139269
2011-09-08 00:38:00 +00:00
Douglas Gregor af5c48490e Optimize the preprocessor's handling of the __import_module__
keyword. We now handle this keyword in HandleIdentifier, making a note
for ourselves when we've seen the __import_module__ keyword so that
the next lexed token can trigger a module import (if needed). This
greatly simplifies Preprocessor::Lex(), and completely erases the 5.5%
-Eonly slowdown Argiris noted when I originally implemented
__import_module__. Big thanks to Argiris for noting that horrible
regression!

llvm-svn: 139265
2011-09-07 23:11:54 +00:00
Richard Trieu 5f376f6d34 Change diagnoseAddressOfInvalidType() to use an enum to determine what error message to display. Also, move the function call into on location instead of having it spread among many places in the if/else statements.
llvm-svn: 139260
2011-09-07 21:46:33 +00:00
Douglas Gregor 5ca153f112 When parsing a function-try-block that does not have a
ctor-initializer, remember to call the Sema action to generate default
ctor-initializers. What a delightful little miscompile. Fixes PR10578
/ <rdar://problem/9877267>.

llvm-svn: 139253
2011-09-07 20:36:12 +00:00
Kaelyn Uhrain 5a43b461fc Fix Sema::CorrectTypo to ignore found but unresolved symbols
llvm-svn: 139252
2011-09-07 20:25:59 +00:00
Peter Collingbourne 2d7f219caf More missing dependencies picked up by Ninja.
llvm-svn: 139248
2011-09-07 19:12:36 +00:00
Fariborz Jahanian eebdb67420 objc-gc: More sema work for properties declared 'weak'
in GC mode. // rdar://10073896

llvm-svn: 139235
2011-09-07 16:24:21 +00:00
Chandler Carruth 3d45b23dfc Extract the emission of the diagnostic's location into a separate
function. This is really the beginning of the second phase of
refactorings here. The end goal is to have (roughly) three interfaces:

1) Base class to format a single diagnostic suitable for display on the
   console.
2) Extension of the base class which also displays a caret diagnostic
   suitable for display on the console.
3) An adaptor that implements the DiagnosticClient by delegating to #1
   and/or #2 as appropriate.

Once we have these, things like libclang's formatDiagnostic can use #1
and #2 to provide really well formatted (and consistently formatted!)
textual formatting of diagnostics.

Getting there is going to be quite a bit of shuffling. I'm basically
sketching out where the interface boundaries can be drawn for #1 and #2
within the existing classes. That lets me shuffle with a minimum of fuss
and delta. Once that's done, and any of the related interfaces that need
to change are updated, I'll hoist these into separate headers and
re-implement libclang in terms of their interfaces. Long WIP, but
comments at each step welcome. =D

llvm-svn: 139228
2011-09-07 08:05:58 +00:00
Chandler Carruth 9779830513 Move the HilightRange method from TextDiagnosticPrinter down to
CaretDiagnostic. It's completely generic, with nothing to do with the
diagnostic client or info APIs.

llvm-svn: 139227
2011-09-07 07:02:31 +00:00
Chandler Carruth e79ddf8c67 Hoist the tab expansion into a helper function.
llvm-svn: 139226
2011-09-07 05:36:50 +00:00
Chandler Carruth 0f1006a95a Don't compute the same line number in two places, once inside a loop.
llvm-svn: 139225
2011-09-07 05:01:10 +00:00
Eli Friedman ce3e2c85b1 Make sure the FunctionDecl's created by "#pragma weak" have correct ParmVarDecl's. PR10878.
llvm-svn: 139224
2011-09-07 04:05:06 +00:00
Richard Trieu f9bd0f5d99 Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
DiagnoseLogicalAndInLogicalOrLHS()
DiagnoseBinOpPrecedence()
ActOnBinOp()
BuildBinOp()

llvm-svn: 139219
2011-09-07 02:02:10 +00:00
Richard Trieu 4a287fb926 Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
CreateBuiltinBinOp()
DiagnoseBitwisePrecedence()

llvm-svn: 139218
2011-09-07 01:49:20 +00:00
Chandler Carruth 773757a962 Switch the CharSourceRange array to a small vector. The array was
a stack array of a magical size with an assert() that we never
overflowed it. That seems incredibly risky. We also have a very nice API
for bundling up a vector we expect to usually have a small size without
loss of functionality or security if the size is excessive.

The fallout is to remove the last pointer+size parameter pair that are
traced through the recursive caret diagnostic emission.

llvm-svn: 139217
2011-09-07 01:47:09 +00:00
Eli Friedman e9f8113ec4 Switch clang over to using fence/atomicrmw/cmpxchg instead of the intrinsics (which will go away). LLVM CodeGen does almost exactly the same thing with these and the old intrinsics, so I'm reasonably confident this will not break anything.
There are still a few issues which need to be resolved with code generation for atomic load and store, so I'm not converting the places which need those for now.

I'm not entirely sure what to do about __builtin_llvm_memory_barrier: the fence instruction doesn't expose all the possibilities which can be expressed by __builtin_llvm_memory_barrier.  I would appreciate hearing from anyone who is using this intrinsic.

llvm-svn: 139216
2011-09-07 01:41:24 +00:00
Richard Trieu da4f43a609 Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
CheckAssignmentOperands()
DiagnoseSelfAssignment()
checkArithmeticNull()

llvm-svn: 139215
2011-09-07 01:33:52 +00:00
Richard Trieu bcce2f7189 Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
CheckVectorCompareOperands()
CheckBitwiseOperands()
CheckLogicalOperands()

llvm-svn: 139214
2011-09-07 01:19:57 +00:00
Richard Trieu aa5e256c20 Change the self-reference visitor (which gives the warning for self-reference oninitalization warning of -Wuninitialized) to exclude member variables that can decay into pointers. This will cause it to no longer warn on this code:
struct foo { char a[100], *e; } bar = { .e = bar.a };

llvm-svn: 139213
2011-09-07 00:58:53 +00:00
Fariborz Jahanian 5f2b703651 objc-gc: Don't force a __strong type'd property
to be 'weak'. This prevents a crash and should 
probably be flagged as error - later to come.

llvm-svn: 139211
2011-09-07 00:38:49 +00:00
Francois Pichet bcf6471010 In Microsoft mode, if we are inside a template class member function and we can't resolve a function call then create a type-dependent CallExpr even if the function has no type dependent arguments. The goal is to postpone name lookup to instantiation time to be able to search into type dependent base classes.
With this patch in, clang will generate only 37 errors (down from 212) when parsing a typical MFC source file.

llvm-svn: 139210
2011-09-07 00:14:57 +00:00
Chad Rosier e75ef40843 [driver] When clang crashes, don't try to generate diagnostics (i.e.,
preprocessor output) with multiple -arch options.

llvm-svn: 139207
2011-09-06 23:52:36 +00:00
Fariborz Jahanian 6dd3f39dae objc-gc: Adds support for "weak" property attribute under GC.
// rdar://10073896

llvm-svn: 139203
2011-09-06 23:32:40 +00:00
Chandler Carruth cf57ebfd4c Remove the doxyment for this now defunct parameter.
llvm-svn: 139197
2011-09-06 22:34:36 +00:00
Chandler Carruth 935574de2f Don't recompute the presumed loc twice in 5 lines of code... Spotted by
inspection.

llvm-svn: 139196
2011-09-06 22:34:33 +00:00
Chandler Carruth 1f28e6c7e3 Use ArrayRef for the fixit hint array rather than a pointer and a size.
Clean up loops over the hints to use the more idiomatic iterator form in
LLVM and Clang.

llvm-svn: 139195
2011-09-06 22:31:44 +00:00
Chandler Carruth 20bfaa0f68 Hoist the construction of the FixItHint line into a member function with
a defined interface. This isn't as nice as the previous one, but should
get better as I push through better data types in all these functions.

Also, I'm hoping to pull some aspects of this out into a common routine
(such as tab expansion).

Again, WIP, comments welcome as I'm going through.

llvm-svn: 139190
2011-09-06 22:01:04 +00:00
Richard Trieu b80728fe9a Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
CheckCompareOperands()

llvm-svn: 139187
2011-09-06 21:43:51 +00:00
Douglas Gregor e0e9630e07 When extracting the callee declaration from a call expression, be sure
to look through SubstNonTypeTemplateParmExprs. Then, update the IR
generation of CallExprs to actually use CallExpr::getCalleeDecl()
rather than attempting to mimick its behavior (badly).

Fixes <rdar://problem/10063539>.

llvm-svn: 139185
2011-09-06 21:41:04 +00:00
Richard Trieu 1762d7cc35 Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
checkEnumComparison()
diagnoseDistinctPointerComparison()
convertPointersToCompositeType()
diagnoseFunctionPointerToVoidComparison()

llvm-svn: 139184
2011-09-06 21:27:33 +00:00
Richard Trieu e4a19fbd0c Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
DiagnoseBadShiftValues()
CheckShiftOperands()

llvm-svn: 139183
2011-09-06 21:21:28 +00:00
Richard Trieu 4ae7e97667 Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
diagnoseArithmeticOnTwoVoidPointers()
checkArithmeticBinOpPointerOperands()
diagnosePointerIncompatibility()
CheckAdditionOperands()
CheckSubtractionOperands()

llvm-svn: 139182
2011-09-06 21:13:51 +00:00
Richard Trieu 859d23fa5e Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
CheckVectorOperands()
CheckMultiplyDivideOperands()
CheckRemainderOperands()

llvm-svn: 139181
2011-09-06 21:01:04 +00:00
Douglas Gregor 49695f078e Implement the Named Return Value Optimization (NRVO) for blocks.
llvm-svn: 139178
2011-09-06 20:46:03 +00:00
Richard Trieu eb29914c5d Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
CheckTransparentUnionArgumentConstraints()
CheckSingleAssignmentConstraints()
InvalidOperands()

llvm-svn: 139176
2011-09-06 20:40:12 +00:00
Douglas Gregor e3f3ea08a8 Implement the Named Return Value Optimization (NRVO) for Objective-C++
methods. Fixes PR10835 / <rdar://problem/10050178>.

llvm-svn: 139175
2011-09-06 20:33:37 +00:00
Richard Trieu de4958fb28 Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
CheckAssignmentConstraints()

llvm-svn: 139173
2011-09-06 20:30:53 +00:00
Richard Trieu a871b97da5 Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
checkPointerTypesForAssignment()
checkBlockPointerTypesForAssignment()
checkObjCPointerTypesForAssignment()
CheckAssignmentConstraints()

llvm-svn: 139170
2011-09-06 20:21:22 +00:00
Richard Trieu d33e46e943 Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
DiagnoseConditionalForNull()
CheckConditionalOperands()
IsArithmeticBinaryExpr()
DiagnoseConditionalPrecedence()

llvm-svn: 139167
2011-09-06 20:06:39 +00:00
Benjamin Kramer 499c68b5f6 Spelling.
llvm-svn: 139165
2011-09-06 19:57:14 +00:00
Richard Trieu 9a52fbb2d0 Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
handleIntegerConversion()
UsualArithmeticConversions()

llvm-svn: 139164
2011-09-06 19:52:52 +00:00
Ted Kremenek fed48af3de Don't emit -Wpadded warnings without a valid SourceLocation. This can happen when RecordLayoutBuilder is used by Codegen, not Sema.
llvm-svn: 139162
2011-09-06 19:40:45 +00:00
Eli Friedman cf9b1f6524 Rearrange code so that we pass the right pointer to delete[] when an exception is thrown constructing the array elements in an array new expression. Fixes PR10870.
llvm-svn: 139158
2011-09-06 18:53:03 +00:00
Richard Trieu cfe3f21cec Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
handleFloatConversion()
handleComplexIntConvsersion()

llvm-svn: 139153
2011-09-06 18:38:41 +00:00
Richard Trieu 5065cdd0ea Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS,
Expr *LHSExpr, *RHSExpr
QualType LHSType, RHSType

Functions changed:
handleComplexFloatToComplexFloatConverstion()
handleComplexFloatConversion()

llvm-svn: 139151
2011-09-06 18:25:09 +00:00
Richard Smith a8a5c402bb Advertise support for cxx_range_for as an extension in C++98 mode. Patch by Jean-Daniel Dupas!
Also provide a modicum of test coverage for ranged for in C++98.

llvm-svn: 139149
2011-09-06 18:03:41 +00:00
Douglas Gregor cd0d826001 Finish implementing (de-)serialization of the CXXDefinitionData bits
needed for implicit move constructors and move assignment
operators. Fixes PR10847.

llvm-svn: 139144
2011-09-06 16:38:46 +00:00
Douglas Gregor 146b8e9a58 When performing a derived-to-base cast on the right-hand side of the
synthesized move assignment within an implicitly-defined move
assignment operator, be sure to treat the derived-to-base cast as an
xvalue (rather than an lvalue). Otherwise, we'll end up getting the
wrong constructor.

Optimize a direct call to a trivial move assignment operator to an
aggregate copy, as we do for trivial copy assignment operators, and
update the the assertion in CodeGenFunction::EmitAggregateCopy() to
cope with this optimization.

Fixes PR10860.

llvm-svn: 139143
2011-09-06 16:26:56 +00:00
Peter Collingbourne 2e8201422d Add missing dependency
Spotted by Ninja.

llvm-svn: 139129
2011-09-06 02:08:40 +00:00
Peter Collingbourne fa9771ffec Add the resource directory to the search path for Driver::GetFilePath,
as well as the search path printed by -print-search-dirs.

The main purpose of this change is to cause -print-file-name=include
to print the path to the include directory under Clang's resource
directory, instead of the system compiler's include directory, whose
header files Clang may not be able to parse.  Some build scripts will
do something like:
  $(CC) -nostdinc -I`$(CC) -print-file-name=include`
to exclude all header paths except the compiler's.

llvm-svn: 139127
2011-09-06 02:08:31 +00:00
Benjamin Kramer 17ff23c708 Speed up BCPL comment lexing by looking aggressively for newlines and then scannig backwards to see if the newline is escaped.
3% speedup in preprocessing all of clang with -Eonly. Also includes a small testcase for coverage.

llvm-svn: 139116
2011-09-05 07:19:39 +00:00
Benjamin Kramer dbfb18a0a9 Use the Lexer's definition of whitespace here.
llvm-svn: 139115
2011-09-05 07:19:35 +00:00
Richard Smith a528507418 Implement the suggested resolution of WG21 N3307 issue 19: When determining whether a class is an aggregate in C++0x, treat all functions which are neither deleted nor defaulted as user-provided, not just special member functions. The wording of the standard only defines the term "user-provided" for special member functions, but the intent seems to be that any function can be user-provided.
llvm-svn: 139111
2011-09-05 02:13:09 +00:00
Francois Pichet 4391c7529a Pass 0 instead of a empty TemplateArgumentListInfo when creating a CXXDependentScopeMemberExpr to handle a "this->" fixit (lookup into dependent bases of class template)
Otherwise the fixit doesn't really work for subsequent lookup.

llvm-svn: 139105
2011-09-04 23:00:48 +00:00
Benjamin Kramer 60053cf547 Use const_cast to avoid warnings.
llvm-svn: 139104
2011-09-04 20:26:28 +00:00
Richard Smith 5065864151 PR10458: Last part of providing 'auto' type specifier as an extension in C++98: permit it within type-ids.
llvm-svn: 139103
2011-09-04 20:24:20 +00:00
Richard Smith 58c7433709 PR10458: Finesse behaviour of C++0x features when in pre-0x mode. Accept for-range and auto with an ExtWarn, and produce a -Wc++0x-compat warning in C++98 mode when auto is used as a storage class.
llvm-svn: 139102
2011-09-04 19:54:14 +00:00
Sebastian Redl e9c4e84f8e Add test case for defaulted copy and move structure validation.
Fix bug this uncovered.
Address minor comments from Doug.
Enable cxx_implicit_moves feature.

llvm-svn: 139101
2011-09-04 18:14:28 +00:00
Argyrios Kyrtzidis b914e3bc5c Handle a code-completion token being passed to the macro stringify operator.
Fixes http://llvm.org/PR10826.

llvm-svn: 139087
2011-09-04 03:32:19 +00:00
Argyrios Kyrtzidis 5cec2aea3f Support code-completion for C++ inline methods and ObjC buffering methods.
Previously we would cut off the source file buffer at the code-completion
point; this impeded code-completion inside C++ inline methods and,
recently, with buffering ObjC methods.

Have the code-completion inserted into the source buffer so that it can
be buffered along with a method body. When we actually hit the code-completion
point the cut-off lexing or parsing.

Fixes rdar://10056932&8319466

llvm-svn: 139086
2011-09-04 03:32:15 +00:00
Argyrios Kyrtzidis a3deaeeb52 Fix Lexer::ComputePreamble when MaxLines parameter is non-zero.
The function was only counting lines that included tokens and not empty lines,
but MaxLines (mainly initiated to the line where the code-completion point resides)
is a count of overall lines (even empty ones).

llvm-svn: 139085
2011-09-04 03:32:04 +00:00
Benjamin Kramer a66aaa93ee More unused variable removal.
llvm-svn: 139080
2011-09-03 08:46:20 +00:00
Benjamin Kramer 2667afa980 Make helpers static, remove unused variables.
llvm-svn: 139078
2011-09-03 03:30:59 +00:00
Chandler Carruth d551d4e1da Teach -Wdangling-field to warn about temporaries bound to references as
well.

Also, clean up the flow of the code a bit, and factor things more
nicely.

Finally, add the test case that was missing from my previous
commit (sorry), with new tests added to cover temporaries and other fun
cases.

llvm-svn: 139077
2011-09-03 02:21:57 +00:00
Chandler Carruth 599deef379 Add a simple new warning to catch blatantly dangling pointer and
reference members of classes. We've had several bugs reported because of
this, and there's no reason not to flag it right away in the compiler.

Comments especially welcome on the strategy for implementing this
warning (IE, what should trigger this?) and on the text of the warning
itself.

I'm going to extend this to cover obvious cases with temporaries and
beef up the test cases some in subsequent patches. I'll then run it over
a large codebase and make sure its not misbehaving before I add it to
-Wall or turn it on by default. I think this one might be a good
candidate for on by default.

llvm-svn: 139075
2011-09-03 01:14:15 +00:00
Richard Trieu 48277e5710 Fix some indenting issues in SemaExpr.cpp
llvm-svn: 139042
2011-09-02 21:44:27 +00:00
Fariborz Jahanian 2bb8270e6f blocks: Support capturing complex variable in block.
// rdar://10033896

llvm-svn: 139041
2011-09-02 21:33:44 +00:00
Richard Trieu 7aa58f1eea Refactor UsualArithmeticConversions() in SemaExpr.cpp into several functions.
llvm-svn: 139033
2011-09-02 20:58:51 +00:00
Fariborz Jahanian b74711df52 revert patch in r139020
llvm-svn: 139029
2011-09-02 20:03:16 +00:00
Ted Kremenek aed4677a1c -Wuninitialized: fix insidious bug resulting from interplay of blocks and dead code. Fixes <rdar://problem/10060250>.
llvm-svn: 139027
2011-09-02 19:39:26 +00:00
Fariborz Jahanian f30bc00103 blocks: Support capturing complex variable in block.
// rdar://10033896

llvm-svn: 139020
2011-09-02 18:39:40 +00:00
Eli Friedman 29538899ef Make StmtDumper::VisitCXXFunctionalCastExpr dump the attached cast kind. Fix the cast kind for a cast from floating-point to enum type. (The difference isn't actually visible, but that's just because IRGen is overly forgiving.) Per report by Enea Zaffanella on cfe-dev.
llvm-svn: 139011
2011-09-02 17:38:59 +00:00
Jordy Rose 087611ed81 [analyzer] Remove TransferFuncs.h, then deal with the fallout.
And with that, TransferFuncs is gone!

llvm-svn: 139003
2011-09-02 08:02:59 +00:00
Jordy Rose 75e680eae3 [analyzer] Move RetainReleaseChecker to the Checkers library and rename it to RetainCountChecker...and clean up the file while I'm at it.
llvm-svn: 139002
2011-09-02 06:44:22 +00:00
Chandler Carruth d3e83677b4 Hoist the emission of parseable fixits into a helper method, simplifying
and reducing indentation through the clever use of early exits. ;]

llvm-svn: 139001
2011-09-02 06:30:30 +00:00
Jordy Rose dd7a654b1a [analyzer] Remove lingering CFRefCount creation, which would have resulted in a leak. There's room for improvement here...
llvm-svn: 139000
2011-09-02 06:29:27 +00:00
Jordy Rose a87a2775fa [analyzer] Fix member initialization order. No functionality change.
llvm-svn: 138999
2011-09-02 06:21:26 +00:00
Jordy Rose c49ec53e29 [analyzer] Move the knowledge of whether or not GC is enabled for the current analysis from CFRefCount to ExprEngine.
Remove TransferFuncs from ExprEngine and AnalysisConsumer.

Demote RetainReleaseChecker to a regular checker, and give it the name osx.cocoa.RetainCount (class name change coming shortly). Update tests accordingly.

llvm-svn: 138998
2011-09-02 05:55:19 +00:00
Richard Trieu eea56f785e Move the warning for different enum comparisons and the warning for using NULL as a non-pointer in a binary operation into separate functions.
llvm-svn: 138995
2011-09-02 03:48:46 +00:00
Richard Trieu dd82a5c5d7 Reduce code duplication for pointer comparisons in CheckCompareOperands().
llvm-svn: 138994
2011-09-02 02:55:45 +00:00
Richard Trieu aba2280573 Pull out incomplete pointer type checking code, used from arithmetic checking functions, into its own function.
llvm-svn: 138993
2011-09-02 02:15:37 +00:00
Richard Trieu 27ae4cb7c4 Refactor CheckConditionalOperands() by moving chunks of code to helper functions making a slimmer function.
llvm-svn: 138992
2011-09-02 01:51:02 +00:00
Richard Trieu 3fd7bb8224 Refactor CheckAddressOfOperand() by pulling out redundant code and moving hard coding strings from SemaExpr.cpp to DiagnosticSemaKinds.td.
llvm-svn: 138987
2011-09-02 00:47:55 +00:00
Douglas Gregor 8835e03cee Always construct an ASTReader with a non-NULL ASTContext and
Preprocessor, eliminating the constructor that was used by ASTUnit
(which didn't provide an ASTContext or Prepreprocessor). Ensuring that
both objects are non-NULL will simplify module loading (but none of
that is done yet).

llvm-svn: 138986
2011-09-02 00:26:20 +00:00
Douglas Gregor e8bbc12152 Extend the ASTContext constructor to delay the initialization of
builtin types (When requested). This is another step toward making
ASTUnit build the ASTContext as needed when loading an AST file,
rather than doing so after the fact. No actual functionality change (yet).

llvm-svn: 138985
2011-09-02 00:18:52 +00:00
Douglas Gregor 83297dfc7e Allow the preprocessor to be constructed without performing target-
and language-specific initialization. Use this to allow ASTUnit to
create a preprocessor object *before* loading the AST file. No actual
functionality change.

llvm-svn: 138983
2011-09-01 23:39:15 +00:00
Richard Trieu b10c631f53 Refactor CheckAdditionOperands(), CheckSubtractionOperands(), and CheckIncrementDecrementOperand() in SemaExpr.cpp to move reused code to separate functions.
llvm-svn: 138975
2011-09-01 22:53:23 +00:00
Argyrios Kyrtzidis 43ea78b48d Don't try keeping a 'LeadingEmptyMacroLoc' in NullStmt. This fails
in the face of buffering C++/ObjC method bodies.

llvm-svn: 138972
2011-09-01 21:53:45 +00:00
Nick Lewycky 0112b11f5c Don't try to emit unsupported templated friend declarations. They're unsupported
and may very well be dependent-types, triggering an assertion in debug info
codegen.

llvm-svn: 138970
2011-09-01 21:49:51 +00:00
Richard Trieu a04ad1a1b9 Extend the self-reference warning to catch when a constructor references itself upon initialization, such as using itself within its own copy constructor.
struct S {};
S s(s);

llvm-svn: 138969
2011-09-01 21:44:13 +00:00
Argyrios Kyrtzidis cbbc0141f6 [arcmt] Fix test/ARCMT/remove-statements.m regression due to
Objective-C method buffering(rdar://10056942)

Turned out the same issue existed for C++ inline methods.

llvm-svn: 138960
2011-09-01 20:53:18 +00:00
Douglas Gregor 7018d5bcfb Teach ASTContext and Preprocessor to hold on to references to the same
LangOptions, rather than making distinct copies of
LangOptions. Granted, LangOptions doesn't actually get modified, but
this will eventually make it easier to construct ASTContext and
Preprocessor before we know all of the LangOptions.

llvm-svn: 138959
2011-09-01 20:23:19 +00:00
Fariborz Jahanian 415e47dd6e default property synthesis is off by default
for now.

llvm-svn: 138958
2011-09-01 20:23:17 +00:00
Fariborz Jahanian f7a3d4ad15 objective-c: Make auto synthesis of properties the default.
This concludes //rdar://8843851

llvm-svn: 138947
2011-09-01 17:50:05 +00:00
Douglas Gregor 4a69c2e6c5 Modules hide macro definitions by default, so that silly things like
include guards don't show up as macro definitions in every translation
unit that imports a module. Macro definitions can, however, be
exported with the intentionally-ugly #__export_macro__
directive. Implement this feature by not even bothering to serialize
non-exported macros to a module, because clients of that module need
not (should not) know that these macros even exist.

llvm-svn: 138943
2011-09-01 17:04:32 +00:00
Francois Pichet 0274487d97 Enable -fdelayed-template-parsing by default on Win32.
I had to force -fno-delayed-template-parsing on some Index tests because delayed template parsing will change the output of some tests.

llvm-svn: 138942
2011-09-01 16:38:08 +00:00
Rafael Espindola 5f344fff08 Fix PR10744 by adding the toolchain path to the regular program path
and doing a simple search. Before we would manually check for the linker
before the -B options were searched.

llvm-svn: 138941
2011-09-01 16:25:49 +00:00
Hans Wennborg ecc25a2812 Add 4.4.6 to GccVersions[] in lib/Driver/ToolChains.cpp.
llvm-svn: 138940
2011-09-01 14:41:39 +00:00
Zhongxing Xu bfb8e2fe6e If size was equal to 0, either NULL or a pointer suitable to be passed to
free() is returned by realloc(). Most code expect NULL.

And we only need to transfer one final ProgramState.

llvm-svn: 138937
2011-09-01 04:53:59 +00:00
Argyrios Kyrtzidis 019f3c2444 Fix "multi-line comment" compiler error.
llvm-svn: 138936
2011-09-01 03:07:11 +00:00
Douglas Gregor 528499bb44 When defining the implicit move assignment operator, don't perform
semantic analysis when taking the address of an xvalue. Instead, just
build the unary operator directly, since it's safe to do so (from the
IRgen and AST perspectives) for any glvalue. Fixes PR10822.

llvm-svn: 138935
2011-09-01 02:09:07 +00:00
Argyrios Kyrtzidis 7d847c9fd8 Support importing of ObjC categories from modules.
The initial incentive was to fix a crash when PCH chaining categories
to an interface, but the fix was done in the "modules way" that I hear
is popular with the kids these days.

Each module stores the local chain of categories and we combine them
when the interface is loaded. We also warn if non-dependent modules
introduce duplicate named categories.

llvm-svn: 138926
2011-09-01 00:58:55 +00:00
Chandler Carruth eef47ba664 Create a CaretDiagnostic class to hold the logic for emitting
(unsurprisingly) caret diagnostics. This is designed to bring some
organization to the monstrous EmitCaretDiagnostic function, and allow
factoring it more easily and with less mindless parameter passing.

Currently this just lifts the existing function into a method, and
splits off the obviously invariant arguments to be class members. No
functionality is changed, and there are still lots of warts to let
existing code continue functioning as-is. Definitely WIP, more cleanups
to follow.

llvm-svn: 138921
2011-08-31 23:59:23 +00:00
Chandler Carruth 153a7bb35e Sink all of the include stack printing logic into its member function.
llvm-svn: 138920
2011-08-31 23:59:19 +00:00
Fariborz Jahanian 97d744bea4 objective-c: this patch (re)introduces objective-c's default property
synthesis. This new feature is currently placed under 
-fobjc-default-synthesize-properties option
and is off by default pending further testing.
It will become the default feature soon. 
// rdar://8843851

llvm-svn: 138913
2011-08-31 22:24:06 +00:00
Douglas Gregor dd8a2fe0be Switch the "no module found" default-fatal warning to a default-fatal error.
llvm-svn: 138909
2011-08-31 21:52:21 +00:00
John McCall fa6f5d6ab8 Don't assert when diagnosing a missing cast of an unknown-anytype
message send to an unknown method.

rdar://problem/9416370, redux.

llvm-svn: 138893
2011-08-31 20:57:36 +00:00
Chad Rosier 64707fee22 [driver] If no -miphoneos-version-min is specified on the command line *and*
IPHONEOS_DEPLOYMENT_TARGET if undefined, set -miphoneos-version-min based on 
isysroot.

llvm-svn: 138892
2011-08-31 20:56:25 +00:00
Eli Friedman 874844123f Make sure to initialize field. Hopefully this will fix some test failures on Windows.
llvm-svn: 138880
2011-08-31 18:45:31 +00:00
Jordy Rose 973a8886f6 [analyzer] Fix varargs helper to only use POD types even for named arguments. Thanks, Joerg.
llvm-svn: 138875
2011-08-31 18:33:45 +00:00
Douglas Gregor ca97589f7d Switch __import__ over to __import_module__, so we don't conflict with
existing practice with Python extension modules. Not that Python
extension modules should be using a double-underscored identifier
anyway, but...

llvm-svn: 138870
2011-08-31 18:19:09 +00:00
Fariborz Jahanian bd0642fede objective-c - This patch buffers method implementations
and does the Sema on their body after the entire 
class/category @implementation is seen. This change allows messaging 
of forward private methods, as well as, access to 
synthesized ivars of properties with foward synthesize
declarations; among others. In effect, this patch removes
several restrictions placed on objective-c due to in-place
semantics processing of methods.
This is part of // rdar://8843851.

llvm-svn: 138865
2011-08-31 17:37:55 +00:00
Sebastian Redl b74486312b Serialize the new bits in CXXRecordDecl::DefinitionData.
llvm-svn: 138855
2011-08-31 13:59:56 +00:00
Chandler Carruth c841b6e598 Improve the diagnostic text for -Wmissing-noreturn to include the name
of the function in question when applicable (that is, not for blocks).
Patch by Joerg Sonnenberger with some stylistic tweaks by me.

When discussing this weth Joerg, streaming the decl directly into the
diagnostic didn't work because we have a pointer-to-const, and the
overload doesn't accept such. In order to make my style tweaks to the
patch, I first changed the overload to accept a pointer-to-const, and
then changed the diagnostic printing layer to also use
a pointer-to-const, cleaning up a gross line of code along the way.

llvm-svn: 138854
2011-08-31 09:01:53 +00:00
Eli Friedman 3781a36238 Change err_pp_file_not_found back to an Error; when it's a Warning, we suppress it in system headers. And it is not a good idea to suppress it in system headers. (This was originally changed in r134996 to implement -MG.)
Fixes <rdar://10041960>.  And also brings down the number of warnings without a flag by one :)

llvm-svn: 138842
2011-08-30 23:07:51 +00:00
Douglas Gregor 86325ad2b5 Allow C99 hexfloats in C++0x mode. This change resolves the standards
collision between C99 hexfloats and C++0x user-defined literals by
giving C99 hexfloats precedence. Also, warning about user-defined
literals that conflict with hexfloats and those that have names that
are reserved by the implementation. Fixes <rdar://problem/9940194>.

llvm-svn: 138839
2011-08-30 22:40:35 +00:00
Jeffrey Yasskin 924255875e Fix PR10694: Boolean conversions can be from pointers, and those conversions
aren't considered narrowing conversions.

llvm-svn: 138838
2011-08-30 22:25:41 +00:00
Douglas Gregor 05ef93158d When writing out the entries in a lookup table for a DeclContext, make
sure that all of the CXXConversionDecls go into the same
bucket. Otherwise, name lookup might not find them all. Fixes
<rdar://problem/10041960>.

llvm-svn: 138824
2011-08-30 20:49:19 +00:00
Sebastian Redl 22653bac1a Declare and define implicit move constructor and assignment operator.
This makes the code duplication of implicit special member handling even worse,
but the cleanup will have to come later. For now, this works.
Follow-up with tests for explicit defaulting and enabling the __has_feature
flag to come.

llvm-svn: 138821
2011-08-30 19:58:05 +00:00
Argyrios Kyrtzidis 3a5094b18c Remove a few mutating ObjCCategoryDecl methods.
Remove
  -setClassInterface
  -setNextClassCategory
  -insertNextClassCategory

and combine them in the Create function.

llvm-svn: 138817
2011-08-30 19:43:26 +00:00
Argyrios Kyrtzidis d3497db59b In ASTWriter::WriteDeclContextVisibleBlock, don't write empty lookups.
Empty lookups can occur in the DeclContext map when we are chaining PCHs, where
the empty lookup indicates that we already looked in ExternalASTSource.

llvm-svn: 138816
2011-08-30 19:43:23 +00:00
Argyrios Kyrtzidis 342e08fbf1 Remove a couple of unnecessary objc method lookups.
llvm-svn: 138815
2011-08-30 19:43:21 +00:00
Fariborz Jahanian 59b75285f6 objc - fixes a regression in declaring c decls nested in
objective-c containers due to recent changes to objc decl 
contexts. // rdar://10041908

llvm-svn: 138803
2011-08-30 17:10:52 +00:00
Jordy Rose b7abce9f8b Remove obsolete ObjCInferRelatedReturnType from LangOptions...the correct option is ObjCInferRelatedResultType.
llvm-svn: 138793
2011-08-30 01:51:13 +00:00
John McCall 3480ef24d1 The size of struct UnwindException varies by platform with no
apparent general rule.  Just special-case it as appropriate.
PR10789.

llvm-svn: 138792
2011-08-30 01:42:09 +00:00
John McCall 154a2fd3cb Be sure to emit lvalue-to-rvalue casts for loads from x-values.
Doing this happens to disrupt the pattern that ARC was looking for
for move optimizations, so we need to fix that simultaneously.

llvm-svn: 138789
2011-08-30 00:57:29 +00:00
Douglas Gregor 9f05ed53fd Fix a typo when determining whether to strip cv-qualifiers during template argument deduction
llvm-svn: 138787
2011-08-30 00:37:54 +00:00
John McCall 0562caaad6 Update the comment on the default-argument conversion fix; thanks to
Johannes Schaub for talking me around to sense.

llvm-svn: 138784
2011-08-29 23:55:37 +00:00
Nico Weber f926a45df5 Do not warn about [super finalize] in arc mode.
llvm-svn: 138776
2011-08-29 22:59:14 +00:00
Ivan Krasin 69a990badb Clang/PNaCl: Improve test coverage for PNaClTargetInfo (type aligns), fixes nits:
- wrong alignment for double (it was 4, but 8 is desired),
- added checks for _REENTRANT define,
- fixed the issue that defines were not tested (because the check for inside #ifdef).

llvm-svn: 138775
2011-08-29 22:39:12 +00:00
Caitlin Sadowski dd5fd87a6d Thread safety: added basic handling for pt_guarded_by/var and guarded_by/var annotations. We identify situations where we are accessing (reading or writing) guarded variables, and report an error if the appropriate locks are not held.
llvm-svn: 138774
2011-08-29 22:27:51 +00:00
Fariborz Jahanian abc11aa3bc Fix a rewriter bug caused by recent changes in objc's
group decls.

llvm-svn: 138772
2011-08-29 22:21:46 +00:00
Eli Friedman f8cb480528 Add missing function _mm_ucomige_sd to emmintrin.h. PR10803.
llvm-svn: 138769
2011-08-29 21:26:24 +00:00
Anna Zaks 50dd696339 [analyzer] MacOSKeychainAPIChecker: Simplify getSymbolForRegion by using existing API. Thanks Jordy.
llvm-svn: 138765
2011-08-29 21:10:00 +00:00
Anna Zaks 814adf7752 Fix: Bug 10798 - [analyzer] Crash when analyzing ICU. (A slight improvement on the previous commit.)
llvm-svn: 138762
2011-08-29 20:43:37 +00:00
Anna Zaks cda129eb1c Fix bug 10797: Crash: "cast<Ty>() argument of incompatible type!" assert when analyzing ICU.
Patch by Jean-Daniel Dupas. Thanks for spotting and fixing!

llvm-svn: 138757
2011-08-29 20:05:54 +00:00
Eli Friedman d62d51c84d Some minor updates to the Linux search path handling for Slackware. Patch by Will Dietz. PR10692.
llvm-svn: 138753
2011-08-29 18:56:43 +00:00
Fariborz Jahanian 4327b32654 Minor clean up of objc's decl context stuff.
No change in functionality.

llvm-svn: 138742
2011-08-29 17:33:12 +00:00
Douglas Gregor 26858b7e10 Add and document __has_feature values for the remaining C++0x
features, so clients can check for the availability of these features
even before we get around to implementing them.

llvm-svn: 138741
2011-08-29 17:28:38 +00:00
Caitlin Sadowski 293d24a5ba Thread safety: various minor bugfixes, with test cases
This patch is by DeLesley Hutchins.

llvm-svn: 138738
2011-08-29 17:12:27 +00:00
Jeffrey Yasskin 74231381a3 Print 'int' instead of 'const int' in the narrowing conversion error, since the
qualification of a type doesn't affect whether a conversion is a narrowing
conversion.
This doesn't work in template cases because SubstTemplateTypeParmType gets in
the way.

llvm-svn: 138735
2011-08-29 15:59:37 +00:00
Nico Weber 1fb82667dd Warn on missing [super finalize] calls.
This matches gcc's logic. Second half of PR10661.

llvm-svn: 138730
2011-08-28 22:35:17 +00:00
Jordy Rose 58a20d31b7 [analyzer] Introduce a new callback for checkers, printState, to be used for debug-printing the contents of a ProgramState.
Unlike the other callbacks, this one is a simple virtual method, since it is only to be used for debugging.

This new callback replaces the old ProgramState::Printer interface, and allows us to move the printing of refcount bindings from CFRefCount to RetainReleaseChecker.

llvm-svn: 138728
2011-08-28 19:11:56 +00:00
Jordy Rose e9ff97b850 [analyzer] Remove the ProgramState argument from ExprEngine::evalBind; we were ignoring it anyway. No functionality change.
llvm-svn: 138720
2011-08-28 06:02:28 +00:00
Jordy Rose d26e9e7f7c [analyzer] Eliminate almost all uses of TransferFuncs from ExprEngine.
llvm-svn: 138719
2011-08-28 05:54:23 +00:00
Jordy Rose d188d66e69 [analyzer] Migrate argument invalidation from CFRefCount to ExprEngine.
This is a common path for function and C++ method calls, Objective-C messages and property accesses, and C++ construct-exprs.

As support, add message receiver accessors to ObjCMessage and CallOrObjCMessage.

llvm-svn: 138718
2011-08-28 05:16:28 +00:00
Jordy Rose 1fad663126 [analyzer] Change the check::RegionChanges callback to include the regions explicitly requested for invalidation.
Also, allow CallOrObjCMessage to wrap a CXXConstructExpr as well.

Finally, this allows us to remove the clunky whitelisting system from CFRefCount/RetainReleaseChecker. Slight regression due to CXXNewExprs not yet being handled in post-statement callbacks (PR forthcoming).

llvm-svn: 138716
2011-08-27 22:51:26 +00:00
John McCall 4bb057d321 Disable the l-value to r-value conversion on C++ class types passed
to varargs functions in unevaluated contexts.  AFAICT, there is no
standards justification for this, but it matches what other compilers do
and therefore preserves compatibility with certain template metaprogramming
idioms.

Should fix self-host.

llvm-svn: 138715
2011-08-27 22:06:17 +00:00