Commit Graph

32665 Commits

Author SHA1 Message Date
Kaelyn Uhrain 858fb61d22 Split the two invalid uses of the unqualified Foobar at line 3 to two lines
so that it is clearer which use triggered which error.

llvm-svn: 139653
2011-09-13 22:31:32 +00:00
Eli Friedman 84d2812111 Re-commit r139643.
Make clang use Acquire loads and Release stores where necessary.

llvm-svn: 139650
2011-09-13 22:21:56 +00:00
Eli Friedman acca089617 Revert r139643 while I look into it; it's breaking selfhost.
llvm-svn: 139648
2011-09-13 22:08:16 +00:00
Argyrios Kyrtzidis 91672b3c03 [libclang] Introduce clang_getPresumedLocation which works like clang_getExpansionLocation
but takes into account #line directives coming from preprocessed files.

Patch by Vinay Sajip!

llvm-svn: 139647
2011-09-13 21:49:08 +00:00
Argyrios Kyrtzidis a98e861939 [PCH] Fix a regression that r139441 introduced (decls were getting passed
to the consumer without being fully deserialized).

The regression was on compiling boost.python and it was too difficult to get a reduced
test case unfortunately.

Also modify the logic of how objc methods are getting passed to the consumer;
codegen depended on receiving objc methods before the implementation decl.
Since the interesting objc methods are ones with a body and such methods only
exist inside an ObjCImplDecl, deserialize and pass to consumer all the methods
of ObCImplDecl when we see one.

Fixes http://llvm.org/PR10922 & rdar://10117105.

llvm-svn: 139644
2011-09-13 21:35:00 +00:00
Eli Friedman f92b2e0714 Make clang use Acquire loads and Release stores where necessary.
llvm-svn: 139643
2011-09-13 21:31:32 +00:00
Eli Friedman 5be3e6ae9d Turn off the generation of unaligned atomic load/store; I'm going to explicitly error out on such cases in the backend, at least for the moment.
llvm-svn: 139640
2011-09-13 20:48:30 +00:00
Douglas Gregor f1312a828a When building a module on-demand, clear out the "non-modular" language
and preprocessor options (such as macro definitions) first.

llvm-svn: 139638
2011-09-13 20:44:41 +00:00
Argyrios Kyrtzidis 4c2131a775 [libclang] Correct annotation and taking of cursor for objc class references
inside the IBOutletCollection attribute.

llvm-svn: 139621
2011-09-13 18:49:56 +00:00
Argyrios Kyrtzidis c179111536 Rename InterFace -> Interface, no functionality change.
llvm-svn: 139620
2011-09-13 18:49:52 +00:00
John McCall 94312285b7 A strong property of block type has "copy" setter semantics, not "retain".
This is consistent with the behavior of assigning into a __strong l-value,
and it's also necessary for ensuring that the ivar doesn't end up a dangling
reference.  We decided not to change the behavior of "retain" properties, but
just to make them warnings/errors when of block type.

llvm-svn: 139619
2011-09-13 18:49:24 +00:00
Argyrios Kyrtzidis 8db67df663 Add the location of the interface reference to IBOutletCollectionAttr.
Depends on a llvm tablegen commit.

llvm-svn: 139618
2011-09-13 18:41:59 +00:00
John McCall 4319286337 Refactoring, mostly to give ObjCPropertyDecls stronger invariants for
their semantic attributes and then to take advantage of that.

llvm-svn: 139615
2011-09-13 18:31:23 +00:00
Douglas Gregor c2ae880070 Switch the serialization of LangOptions over to use the .def file. We
should no longer have the serialization of LangOptions out of sync
with the structure itself (yay).

llvm-svn: 139613
2011-09-13 18:26:39 +00:00
Caitlin Sadowski 427f42e04a Thread safety: Initializing var before exhaustive switch statement to deal with extraneous warning produced by gcc but not clang
llvm-svn: 139611
2011-09-13 18:01:58 +00:00
Argyrios Kyrtzidis 2cb4e3c554 [libclang]
-Allow cursor visitation of an attribute using its source range
-Add C++ 'final' and 'override' attributes as cursor kinds
-Simplify the logic that marks 'final' and 'override' attributes as tokens.

llvm-svn: 139609
2011-09-13 17:39:31 +00:00
Douglas Gregor 79a91418bd Switch LangOptions over to a .def file that describes header of the
language options. Use that .def file to declare the LangOptions class
and initialize all of its members, eliminating a source of annoying
initialization bugs.

AST serialization changes are next up.

llvm-svn: 139605
2011-09-13 17:21:33 +00:00
Chad Rosier dc2b8269d6 [driver] Add follow up comment for r139551 to ensure the unused option is not
removed in the future.
rdar://10110352 and PR10908

llvm-svn: 139602
2011-09-13 16:46:01 +00:00
Argyrios Kyrtzidis 309b4c49e4 Keep the source range of attributes. Depends on a llvm tablegen commit.
llvm-svn: 139600
2011-09-13 16:05:58 +00:00
Argyrios Kyrtzidis 635a9b4dcf Record the full source range of an attribute.
llvm-svn: 139599
2011-09-13 16:05:53 +00:00
Douglas Gregor a057a58048 Add a struct-size check for modules when dealing with module-private fields
llvm-svn: 139597
2011-09-13 15:37:05 +00:00
Francois Pichet 051f5e5cba In Microsoft mode, downgrade "goto into protected scope" from error to warning if we are jumping over a variable initialization via a goto.
This fixes a few errors when parsing MFC code with clang.

llvm-svn: 139595
2011-09-13 10:26:51 +00:00
Chandler Carruth 03faf78953 Switch -Wreturn-type to completely rely on the CFG model of no-return.
This deletes a bunch of crufty code, and allows more logic sharing
between the analyzer and the warnings.

llvm-svn: 139594
2011-09-13 09:53:58 +00:00
Chandler Carruth 75d78232fd Add a bit to the CFGBlock to track when it contains a no-return
CFGElement. This will allow greatly simplifying the logic in
-Wreturn-type.

llvm-svn: 139593
2011-09-13 09:53:55 +00:00
Chandler Carruth a70991bb3f Consolidate the logic for building a no-return CFG block into a single
location with a single comment rather than scattering it in three
places.

llvm-svn: 139592
2011-09-13 09:13:49 +00:00
John McCall 0bef0badf6 Don't use native atomics on ivars whose size is not a power of two,
even on architectures that support unaligned access (which is the
only way this is otherwise legal, given that ivars apparently do
not honor alignment attributes).

llvm-svn: 139590
2011-09-13 07:33:34 +00:00
John McCall 69cdcec11f This test seems pretty low-value.
llvm-svn: 139589
2011-09-13 07:24:27 +00:00
Chandler Carruth ad74725ab5 Enhance the CFG construction to detect no-return destructors for
temporary objects and local variables. When detected, these split the
block, marking the new one as having only the exit block as a successor.
This prevents a large number of false positives in warnings sensitive to
no-return constructs such as -Wreturn-type, and fixes the remainder of
PR10063 along with several variations of this bug that had not been
reported. The test cases are extended across the board to cover these
patterns.

This also checks in a stress test for these types of CFGs. The stress
test declares some 32k variables, a mixture of no-return and normal
destructors. Previously, this resulted in roughly 2500 CFG blocks, but
didn't model any of the no-return destructors. With this patch, it
results in over 33k blocks, many of them now unreachable.

The nice thing about how the analyzer is set up? This causes *no*
regression in performance of building the CFG. It actually in some cases
makes it faster, as best I can benchmark. The analysis for -Wreturn-type
(and any other that cares about no-return code paths) is technically
slower now as it has to look at many more candidate blocks, but it
computes the correct answer. I have more test cases to follow, I think
they all work now. Also I have further work that should dramatically
simplify analyses in the presence of no-return.

llvm-svn: 139586
2011-09-13 06:09:01 +00:00
John McCall bdd8185e22 Handle reference properties correctly in the trivial-getter check.
llvm-svn: 139585
2011-09-13 06:00:03 +00:00
John McCall 0e5c086de4 Always emit bitfield properties using expression behavior, even if they're
atomic.  This is probably something we should warn about.

llvm-svn: 139584
2011-09-13 05:36:29 +00:00
John McCall f4528ae063 Unify the decision of how to emit property getters and setters into a
single code path.  Use atomic loads and stores where necessary.  Load and
store anything of the appropriate size and alignment with primitive
operations instead of going through the call.

llvm-svn: 139580
2011-09-13 03:34:09 +00:00
Douglas Gregor 2b9b464290 When compiling a module on-demand, re-use the diagnostics client
already provided. This required a little bit of clean-up in the way
that VerifyDiagnosticsClient managed ownership of its underlying
"primary" client, because now it will no longer always take ownership.

llvm-svn: 139570
2011-09-13 01:26:44 +00:00
Douglas Gregor faeb1d4658 When an import statement fails to find a module in the module cache,
but there is a corresponding umbrella header in a framework, build the
module on-the-fly so it can be immediately loaded at the import
statement. This is very much proof-of-concept code, with details to be
fleshed out over time.

llvm-svn: 139558
2011-09-12 23:31:24 +00:00
John McCall b923ece770 Privatize the setter/getter call generation methods, plus some minor
modernization.  No functionality change.

llvm-svn: 139555
2011-09-12 23:06:44 +00:00
Chad Rosier c0f3e383c9 [driver] Ignore the '--' option, rather then fail. Do so to match gcc's
behavior.
rdar://10110352 and PR10908

llvm-svn: 139551
2011-09-12 22:43:01 +00:00
Anna Zaks ea8f5725c5 [analyzer] CmpRuns can now optionally delete empty reports.
llvm-svn: 139550
2011-09-12 22:40:36 +00:00
Caitlin Sadowski eecd273951 Thread safety: small formatting change
llvm-svn: 139548
2011-09-12 22:28:41 +00:00
Argyrios Kyrtzidis 01e3c590ae [libclang] For getDeclFromExpr in CIndex.cpp, associate the decl of
a DeclRefExpr, MemberExpr, etc. with a CastExpr if it is ImplicitCast,
since the implicit cast is the one that is invisible in source code.

llvm-svn: 139547
2011-09-12 22:17:26 +00:00
Anna Zaks b80d836137 [analyzer] CmpRuns.cmpScanBuildResults() should be easy to call from other modules.
llvm-svn: 139543
2011-09-12 21:32:41 +00:00
Anna Zaks 03f3598ff1 Rename CmpRuns into CmpRuns.py so that it could be used as a module.
llvm-svn: 139540
2011-09-12 21:07:18 +00:00
Douglas Gregor 1e44e02292 Introduce a cc1-level option to provide the path to the module cache,
where the compiler will look for module files. Eliminates the
egregious hack where we looked into the header search paths for
modules.

llvm-svn: 139538
2011-09-12 20:41:59 +00:00
Douglas Gregor 7bfedd69c5 Kill off an irrelevant FIXME
llvm-svn: 139523
2011-09-12 18:58:37 +00:00
Devang Patel b0fa5b57ac By popular demand, enumerate all builtin types!
llvm-svn: 139521
2011-09-12 18:50:21 +00:00
Richard Trieu b420bcaeb0 Refactor CheckAdditionOperands() to use early return for pointer addition.
llvm-svn: 139520
2011-09-12 18:37:54 +00:00
Douglas Gregor 41866816ce Diagnose attempt to mark function-local declarations as __module_private__.
llvm-svn: 139519
2011-09-12 18:37:38 +00:00
Anna Zaks 05dda473e6 [analyzer] Simplify the test, use generic/more descriptive names.
llvm-svn: 139516
2011-09-12 18:28:35 +00:00
Devang Patel 33e097b699 Add an assert so that new builtins do not sneak without proper debug info.
llvm-svn: 139514
2011-09-12 18:24:46 +00:00
Devang Patel ba15240e83 Update test to fix windows buildbot.
llvm-svn: 139513
2011-09-12 18:11:52 +00:00
Argyrios Kyrtzidis 14c32e8894 [libclang] In ASTUnit::Parse copy the CompilerInvocation object instead of
modifying directly for the preamble.

This avoids an awful, hard to find, bug where "PreprocessorOpts.DisablePCHValidation = true"
would be persistent for subsequent reparses of the translation unit which would result
in defines, present in command-line but not in the PCH, being ignored.

Fixes rdar://9615399.

llvm-svn: 139512
2011-09-12 18:09:38 +00:00
Argyrios Kyrtzidis 3405baa3f0 [libclang] Make c-index-test check CINDEXTEST_REMAP_AFTER_TRIAL environment variable,
which when set it determines the trial number after which the remapping of files should
take effect.

llvm-svn: 139511
2011-09-12 18:09:31 +00:00
Richard Trieu 993f3ab07b Fix two comments from warn to emit error to match the actual diagnostic used.
llvm-svn: 139510
2011-09-12 18:08:02 +00:00
Anna Zaks 79301b16f3 [analyzer] Fix a failure encountered while analyzing bind (radar://10105448).
llvm-svn: 139509
2011-09-12 18:07:30 +00:00
Anna Zaks 6e05e32e12 Doxygen comments.
llvm-svn: 139508
2011-09-12 17:57:20 +00:00
Anna Zaks 295208d744 [analyzer] Fix a new failure encountered while building Adium exposed as a result of r138196(radar://10087620). ObjectiveC property of type int has a value of type ObjCPropRef, which is a Loc.
llvm-svn: 139507
2011-09-12 17:56:08 +00:00
Anna Zaks 964c186ffe [analyzer] Test for -analyze-function on ObjectiveC to accompany r139439.
llvm-svn: 139506
2011-09-12 17:48:08 +00:00
Devang Patel 98ca8aeca6 Fix debug info encodings for char16_t and char32_t.
llvm-svn: 139502
2011-09-12 17:11:58 +00:00
Douglas Gregor 3baa6702ab Allow __module_private__ on fields
llvm-svn: 139499
2011-09-12 16:11:24 +00:00
Douglas Gregor fc33bcfc4a Remove the restriction on module-private friends. Since the friend
declaration may be the first declaration, we want the ability to that
declaration to be marked module-private.

llvm-svn: 139497
2011-09-12 15:48:15 +00:00
Douglas Gregor b63ab9477c Only predefine the __EXCEPTIONS macro if C++ exceptions are turned on.
Only predefine the OBJC_ZEROCOST_EXCEPTIONS macro if Objective-C
exceptions are turned on. Fixes PR10910.

llvm-svn: 139496
2011-09-12 15:17:19 +00:00
Hans Wennborg be207b3c74 Silence ?: precendence warning when parenthesis are present.
Fixes PR10898. The warning should be silent when there are parenthesis
around the condition expression.

llvm-svn: 139492
2011-09-12 12:07:30 +00:00
Benjamin Kramer 8a8051f2cd Silence "end of non-void function" warnings with llvm_unreachable and add an assert.
llvm-svn: 139474
2011-09-10 21:52:04 +00:00
Fariborz Jahanian 9f0bc5757c objc rewriter - more fixes to support compiling the rewritten
test case having instancetype. Fix in rewriter is unrelated to
using of instancetype. Test case uses other feature not yet
supported in the rewriter. There is more work to do, but this
is an ongoing task and not urgent at this time.

llvm-svn: 139473
2011-09-10 17:01:56 +00:00
Chris Lattner d2cd41c5bf remove pedantic ;
llvm-svn: 139472
2011-09-10 16:13:42 +00:00
John McCall 6acaef9fe8 Modernize and comment; no functionality change.
llvm-svn: 139470
2011-09-10 09:30:49 +00:00
John McCall 7f16c42b9e Simplify the generation of Objective-C setters, at least a little.
Use a more portable heuristic for deciding when to emit a single
atomic store;  it's possible that I've lost information here, but
I'm not sure how much of the logic before was intentionally arch-specific
and how much was just not quite consistent.

llvm-svn: 139468
2011-09-10 09:17:20 +00:00
John McCall 2d637d2e79 Rename the ARC cast kinds to start with "ARC".
llvm-svn: 139466
2011-09-10 06:18:15 +00:00
David Blaikie f1e2924b6b Correctly referring to the null pointer as 'null' not the macro 'NULL' in the boolean conversion diagnostic message.
llvm-svn: 139465
2011-09-10 05:47:59 +00:00
Julien Lerouge d25ed06c63 Make this test portable on Win32.
llvm-svn: 139464
2011-09-10 05:46:15 +00:00
David Blaikie e5f9a9e603 Show either a location or a fixit note, not both, for uninitialized variable warnings.
llvm-svn: 139463
2011-09-10 05:35:08 +00:00
John McCall 5dc5c1ea47 Missed a %local use; hopefully this clears this test up.
llvm-svn: 139462
2011-09-10 05:31:57 +00:00
Richard Trieu 7fde916498 Fix a broken assert in AST/DeclCXX.cpp.
llvm-svn: 139461
2011-09-10 02:16:48 +00:00
Eli Friedman 5c917278fd clang part of r139458; un-XFAIL testcase.
llvm-svn: 139460
2011-09-10 02:03:28 +00:00
Richard Trieu c41773ab6a Revision 139454 fixed a broken assert in LLVM, which causes
a test failure in CodeGen/palignr.c, which has been marked
XFAIL for the time being.  A bug has been filed at PR10901
for this issue.

llvm-svn: 139457
2011-09-10 01:56:32 +00:00
John McCall e5e7e6bc84 Make this test not depend on unnecessary details and IR variable names.
llvm-svn: 139455
2011-09-10 01:37:23 +00:00
John McCall cd78e805e9 When converting a block pointer to an Objective-C pointer type, extend
the lifetime of the block by copying it to the heap, or else we'll get
a dangling reference because the code working with the non-block-typed
object will not know it needs to copy.

There is some danger here, e.g. with assigning a block literal to an
unsafe variable, but, well, it's an unsafe variable.

llvm-svn: 139451
2011-09-10 01:16:55 +00:00
Douglas Gregor 97e3590a6e Fix a diagnostics crasher with -Wmissing-noreturn in Objective-C
methods, and improve the diagnostic slightly along the way. Fixes
<rdar://problem/10098695>.

llvm-svn: 139446
2011-09-10 00:56:20 +00:00
Chandler Carruth 73fddfe1b0 Fix a -Wreturn-type warning due to this field not explicitly having the
enumeration type.

llvm-svn: 139445
2011-09-10 00:51:24 +00:00
Devang Patel 964d758d17 Emit debug info for wchar_t.
llvm-svn: 139443
2011-09-10 00:44:49 +00:00
Douglas Gregor abc5fbe9d6 Don't crash when we fail to load a module. It's unbecoming of a
well-bred compiler like Clang.

llvm-svn: 139442
2011-09-10 00:30:18 +00:00
Douglas Gregor 87d8124b0e Clean up our handling of Objective-C definitions in AST files. Rather
than having CodeGen check whether a declaration comes from an AST file
(which it shouldn't know or care about), make sure that the AST writer and
reader pass along "interesting" declarations that CodeGen needs to
know about.

llvm-svn: 139441
2011-09-10 00:22:34 +00:00
Anna Zaks dfbea6b244 [analyzer] -analyze-function for ObjectiveC should check if any of the methods match the name (not only the first one).
llvm-svn: 139439
2011-09-10 00:12:23 +00:00
Douglas Gregor 98c05b286c Kill of the Decl::PCHLevel field entirely. We now only need to know
whether a Decl was deserialized from an AST file (any AST file).

llvm-svn: 139438
2011-09-10 00:09:20 +00:00
Chandler Carruth a626d645d5 Extend the Stmt AST to make it easier to look through label, default,
and case statements. Use this to make the logic in the CFG builder more
robust at finding the actual statements within a compound statement,
even when there are many layers of labels obscuring it.

Also extend the test cases for a large chunk of PR10063. Still more work
to do here though.

llvm-svn: 139437
2011-09-10 00:02:34 +00:00
Douglas Gregor 1bbf030b8e The translation unit is never deserialized
llvm-svn: 139436
2011-09-09 23:34:14 +00:00
Douglas Gregor dd57400c06 Eliminate all but one caller of Decl::getPCHLevel()
llvm-svn: 139430
2011-09-09 23:07:59 +00:00
Douglas Gregor b3722e2223 Introduce a new predicate Decl::isFromASTFile() to determine whether a
declaration was deserialized from an AST file. Use this instead of
Decl::getPCHLevel() wherever possible. This is a simple step toward
killing off Decl::getPCHLevel().

llvm-svn: 139427
2011-09-09 23:01:35 +00:00
Caitlin Sadowski 82e2de512e Thread safety: removing unnecessary import and reordering import list
llvm-svn: 139426
2011-09-09 23:00:59 +00:00
Caitlin Sadowski 0bef2279fb Thread safety: removing unnecessary import
llvm-svn: 139425
2011-09-09 22:49:12 +00:00
Julien Lerouge e0d5fad37b Remove trailing } in comment.
llvm-svn: 139424
2011-09-09 22:46:39 +00:00
Julien Lerouge 5a6b6987dc Bring llvm.annotation* intrinsics support back to where it was in llvm-gcc: can
annotate global, local variables, struct fields, or arbitrary statements (using
the __builtin_annotation), rdar://8037476.

llvm-svn: 139423
2011-09-09 22:41:49 +00:00
Douglas Gregor 51825b49f3 In the ASTReader, replace the never-NULL Preprocessor pointer with a
Preprocessor reference. Simplify some code along the way, so there is
no separate "initialize the preprocessor" step.

llvm-svn: 139418
2011-09-09 22:02:16 +00:00
Kaelyn Uhrain 45e9370a24 Add smarter sorting of overload candidates that failed template deduction.
llvm-svn: 139417
2011-09-09 21:58:49 +00:00
Eric Christopher 65c5c9132f Carry the debug information from single exit unified return block
along with the new insert point.

Fixes PR10829

llvm-svn: 139416
2011-09-09 21:53:04 +00:00
Douglas Gregor 4163aca7db In ASTReader, replace the never-NULL ASTContext pointer with an
ASTContext reference. Remove all of the extra checking and logic that
was used to cope with a NULL ASTContext. No effective functionality
change.

llvm-svn: 139413
2011-09-09 21:34:22 +00:00
Douglas Gregor 6422642a1d Friends cannot be declared module-private
llvm-svn: 139411
2011-09-09 21:14:29 +00:00
Douglas Gregor 32ed0d204d Mark the translation unit as having lexical/visible storage only when we actually have data for that lexical or visible storage
llvm-svn: 139409
2011-09-09 21:09:37 +00:00
Douglas Gregor faf2adb6e4 Back out r139358 "[PCH] When loading the decls linked to an
identifier, also make them visible in the translation unit," which
isn't needed now that John's eliminated the AST dependency in blocks
CodeGen.

llvm-svn: 139408
2011-09-09 21:05:56 +00:00
Douglas Gregor 3c7cd6a0c4 Specializations cannot be module-hidden. Diagnose attempts to do so.
llvm-svn: 139406
2011-09-09 20:53:38 +00:00
John McCall 7959fee258 Treat the weak export of block runtime symbols as a deployment-target
feature akin to the ARC runtime checks.  Removes a terrible hack where
IR gen needed to find the declarations of those symbols in the translation
unit.

llvm-svn: 139404
2011-09-09 20:41:01 +00:00
Fariborz Jahanian e1378a4313 objc rewriter - Add rewriter test for new instancetype
along with minor rewriter fix to handle that. This
test is still incomplete due to rewriter issues
unrelated to instancetype.

llvm-svn: 139403
2011-09-09 20:35:22 +00:00
Douglas Gregor 64910ca9d5 Don't produce 'instancetype' as the type of a message send expression. Map it down to 'id'.
llvm-svn: 139394
2011-09-09 20:05:21 +00:00
Douglas Gregor 2820e6923a __module_private__ is inherited by redeclarations of an entity, and
must also be present of the first declaration of that entity.

llvm-svn: 139384
2011-09-09 19:05:14 +00:00
Anna Zaks 45ce1bf091 [analyzer] When running scan-build with -plist on ./configure, delete the plist files.
(scan-build does not set the $HtmlDir when running against configure. Previously, this implied that the plist files would appear in the current directory, with this patch they will get deleted.)

llvm-svn: 139382
2011-09-09 18:43:53 +00:00
Douglas Gregor ef15bdbe1a Propagate __module_private__ from previous declarations to later
declarations.

llvm-svn: 139380
2011-09-09 18:32:39 +00:00
Douglas Gregor 6b3bcf29f5 When type-checking a call to an overloaded, builtin atomic operation,
construct a new DeclRefExpr rather than re-using the existing
DeclRefExpr. Patch by Likai Liu, fixes PR8345.

llvm-svn: 139373
2011-09-09 16:51:10 +00:00
Caitlin Sadowski ff2f3f8105 Thread safety: This patch deals with previously unhandled cases when building lock expressions. We now resolve this expressions, avoid crashing when encountering cast expressions, and have a diagnostic for unresolved lock expressions
llvm-svn: 139370
2011-09-09 16:21:55 +00:00
Caitlin Sadowski 33208340bd Thread Safety: Moving the analysis to a new file
llvm-svn: 139369
2011-09-09 16:11:56 +00:00
Caitlin Sadowski a2fd6e0473 Thread safety: refactoring test cases
llvm-svn: 139368
2011-09-09 16:07:55 +00:00
Caitlin Sadowski 0b3501c5e2 Thread safety: refactoring to use an error handler
llvm-svn: 139367
2011-09-09 16:04:02 +00:00
Francois Pichet 2731b7ded3 Update comment because JumpDiagnostics.cpp is not just about VLA scope.
llvm-svn: 139364
2011-09-09 11:02:57 +00:00
John McCall b46f287e48 Clean up the sentinel-attribute checking code a lot. Document
what 'nullPos' is supposed to mean, at least at this one site.
Use closed forms for the arithmetic.  Rip out some clever but
ultimately pointless code that was trying to use 0 or 0L depending
the size of a pointer vs. the size of int;  first, it didn't work
on LLP64 systems, and second, the sentinel checking code requires
a pointer-typed value anyway, so this fixit would not have actually
removed the warning.

llvm-svn: 139361
2011-09-09 07:56:05 +00:00
Argyrios Kyrtzidis 2169a75a0a Do a lookup for the blocks runtime globals to see if they were declared,
instead of codegen waiting to consume such a declaration, which won't
happen if that decls are coming from a PCH.

Fixes rdar://10028656.

llvm-svn: 139359
2011-09-09 06:44:21 +00:00
Argyrios Kyrtzidis e74bc0ef4c [PCH] When loading the decls linked to an identifier, also make them visible
in the translation unit.

llvm-svn: 139358
2011-09-09 06:44:17 +00:00
Argyrios Kyrtzidis 94d3f9dcd0 Use ArrayRef in ExternalASTSource::SetExternalVisibleDeclsForName.
llvm-svn: 139357
2011-09-09 06:44:14 +00:00
John McCall 9c3467e26c Code formatting; no functionality change.
llvm-svn: 139355
2011-09-09 06:12:06 +00:00
John McCall fec112d50e Contextually converting to 'id' is not a useful operation. Contextually
converting to an arbitrary Objective-C pointer type is.  Without
significantly re-implementing anything, change the API to reflect this,
and as a minor optimization, strip the pointer conversion off before
potentially building it.

Mostly, this removes a really bizarre-looking bit of code from
BuildInstanceMessage.

llvm-svn: 139354
2011-09-09 06:11:02 +00:00
John McCall 9320b87cff Give conversions of block pointers to ObjC pointers a different cast kind
than conversions of C pointers to ObjC pointers.  In order to ensure that
we've caught every case, add asserts to CastExpr that strictly determine
which cast kind is used for which kind of bit cast.

llvm-svn: 139352
2011-09-09 05:25:32 +00:00
Richard Trieu 10162ab7ed Clean up the RebuildUnknownAnyExpr visitor in SemaExpr.cpp. Mainly swapped around variable names so that this visitor be more like other visitors in clang.
llvm-svn: 139351
2011-09-09 03:59:41 +00:00
Richard Trieu 9becef691d Changed references of BaseTy, MemInitTy, CXXScopeTy, TemplateParamsTy to CXXBaseSpecifier, CXXCtorInitializer, NestedNameSpecifier, TemplateParameterList and removed their typedefs.
llvm-svn: 139350
2011-09-09 03:18:59 +00:00
Richard Trieu 3481fcd869 Change references to StmtTy to Stmt and removed typedefs of StmtTy. Also removed typedef of AttrTy since it is not used.
llvm-svn: 139349
2011-09-09 02:16:15 +00:00
Douglas Gregor 26701a4371 Modules: introduce the __module_private__ declaration specifier, which
indicates that a declaration is only visible within the module it is
declared in.

llvm-svn: 139348
2011-09-09 02:06:17 +00:00
Richard Trieu 2bd0401b04 Change all references of type ExprTy to Expr and get rid of the typedefs.
llvm-svn: 139347
2011-09-09 02:00:50 +00:00
Richard Trieu ba63ce6b7b Capitialize paramater names in SemaExpr.cpp and resolve any parameter name conflicts between declarations and definitions from this and previous refactorings.
llvm-svn: 139346
2011-09-09 01:45:06 +00:00
Douglas Gregor 3168dcf134 The integer type of an enumeration type isn't always canonical
llvm-svn: 139334
2011-09-08 23:29:05 +00:00
Eric Christopher 22164ed943 Rearrange comment slightly for Bill.
llvm-svn: 139333
2011-09-08 23:28:19 +00:00
Eric Christopher bd202c0496 Remove WCHAR_MIN and WCHAR_MAX from limits.h. According to posix and c99
these should be in stdint.h - and they already are.

Fixes rdar://10097036.

llvm-svn: 139332
2011-09-08 23:25:25 +00:00
Caitlin Sadowski b4d24a9054 Thread safety: small edit to unused variation on warning left in by accident from earlier commit
llvm-svn: 139331
2011-09-08 23:17:03 +00:00
Douglas Gregor 8d9c56bb59 Add some delay between PCH creation and modifying one of the headers it depends on, which will---hopefully make this test predictably pass on Windows
llvm-svn: 139327
2011-09-08 22:32:33 +00:00
Matt Beaumont-Gay 042ce8e9d8 Extend -Wliteral-conversion to catch "int i = -1.234"
llvm-svn: 139326
2011-09-08 22:30:47 +00:00
Caitlin Sadowski ee5db8b5c4 Thread Safety: In C++0x Mutexes are the objects that control access to shared variables, while Locks are the objects that acquire and release Mutexes. We switch to this new terminology.
llvm-svn: 139321
2011-09-08 21:52:50 +00:00
Jakob Stoklund Olesen ed2a360fd1 The frexp, modf, and remquo builtins are not 'const'.
These functions return a second value by writing to a pointer argument,
so they cannot be marked 'readnone' which implies that they don't access
memory.

<rdar://problem/10070234>

llvm-svn: 139319
2011-09-08 21:18:03 +00:00
Caitlin Sadowski 2d3f70ac1c Thread Safety: adding basic no thread safety analysis option
llvm-svn: 139310
2011-09-08 18:35:21 +00:00
Caitlin Sadowski 69b367af17 Thread safety: Adding basic support for locks required and excluded attributes
llvm-svn: 139308
2011-09-08 18:27:31 +00:00
Caitlin Sadowski 46b057681a Thread safety: shared vs. exclusive locks
llvm-svn: 139307
2011-09-08 18:19:38 +00:00
Caitlin Sadowski bc1f11162a Thread safety: small formatting change in test comments
llvm-svn: 139306
2011-09-08 18:07:26 +00:00
Douglas Gregor 6a40b088e9 Look through SubstNonTypeTemplateParmExpr nodes in the various
Expr::Ignore* methods that also look through implicit casts.

llvm-svn: 139303
2011-09-08 17:56:33 +00:00
Caitlin Sadowski 990d571226 Thread safety: added support for function scopes in attribute arguments.
This patch was written by DeLesley Hutchins.

llvm-svn: 139302
2011-09-08 17:42:31 +00:00
Caitlin Sadowski 9385dd7415 Thread Safety: Patch to implement delayed parsing of attributes within a
class scope.

This patch was also written by DeLesley Hutchins.

llvm-svn: 139301
2011-09-08 17:42:22 +00:00
Douglas Gregor dc28ba12e1 Document __has_feature(objc_instancetype).
llvm-svn: 139299
2011-09-08 17:19:31 +00:00
Argyrios Kyrtzidis 80f78b961a [libclang] Fix annotation and getting a "macro expansion" cursor
for a builtin macro expansion.

llvm-svn: 139298
2011-09-08 17:18:41 +00:00
Douglas Gregor 8b7d403684 Allow C++0x enumerations with a fixed underlying type in
Objective-C. The @encode'ing of such an enumeration type is the same
as its underlying type. <rdar://problem/5276348>.

llvm-svn: 139297
2011-09-08 17:18:35 +00:00
Eric Christopher d98e424716 Formatting.
llvm-svn: 139296
2011-09-08 17:15:04 +00:00
Eric Christopher d0e4955b14 Add a block comment explaining how the different source locations work
including some source examples.

llvm-svn: 139295
2011-09-08 17:15:01 +00:00
Abramo Bagnara 41bfb66e76 Added missing initialization.
llvm-svn: 139291
2011-09-08 14:20:25 +00:00
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
Argyrios Kyrtzidis 37ad0091c3 [arcmt] Try fixing the windows buildbot.
llvm-svn: 139262
2011-09-07 21:50:18 +00:00
Argyrios Kyrtzidis 933725c59e Revert r139222, operator->() in PreprocessingRecord::iterator. It is useful
to meet the requirements of the InputIterator concept.

llvm-svn: 139261
2011-09-07 21:50:10 +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
James Molloy 98f3e18f25 Fix up MCInstPrinter creation to take the new SubtargetInfo parameter (see LLVM r139237)
llvm-svn: 139238
2011-09-07 17:25:30 +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
Argyrios Kyrtzidis 9d4fac0f9f [arcmt] Remove xfail on test for windows, Takumi reported that it passes mingw and msvc.
llvm-svn: 139223
2011-09-07 03:43:41 +00:00
Argyrios Kyrtzidis 7d500b3457 operator->() in PreprocessingRecord::iterator is useless since we
are returning a pointer to pointer.

llvm-svn: 139222
2011-09-07 03:43:39 +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
Ted Kremenek 99c0966fc4 Place 'equality comparison with extraneous parentheses...' into a subgroup of -Wparentheses called -Wparentheses-equality.
llvm-svn: 139180
2011-09-06 20:58:32 +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
Richard Smith 3ab15558d7 PR10867: Work around a bug in lit. Multiple RUN: lines are joined with &&, so:
RUN: foo
  RUN: bar || true

is equivalent to:

  RUN: foo && bar || true

which is equivalent to:

  RUN: (foo && bar) || true

This resulted in several of the fixit tests not really testing anything.

llvm-svn: 139132
2011-09-06 03:01:15 +00:00
Peter Collingbourne 2e8201422d Add missing dependency
Spotted by Ninja.

llvm-svn: 139129
2011-09-06 02:08:40 +00:00
Peter Collingbourne 15a26dacbc Fix typo
llvm-svn: 139128
2011-09-06 02:08:36 +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
Benjamin Kramer e007e80fc0 Stop cluttering the test directory with temporary files.
llvm-svn: 139114
2011-09-05 07:19:32 +00:00
Chandler Carruth 58b3749d6c Enable -Wdangling-fields by default in Clang. I've run this warning over
a very large chunk of code and found zero false positives. I've only
found a few bugs, but that likely is because bugs of this nature
actually do manifest. We've also identified several bugs that were
caught by Valgrind, but would have been caught faster and more easily
with this warning.

If anyone has concerns, or this causes fallout on any build bots, lemme
know. I'm happy to just put it under -Wmost.

llvm-svn: 139112
2011-09-05 05:47: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
Richard Smith 3f9211d322 PR10506: Extend test for temporary cleanups in range-based for loop to cover the dependent case.
llvm-svn: 139109
2011-09-04 23:52:03 +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
Fariborz Jahanian 4efb6b35f6 Revise test and see if it passes with a release-built clang.
llvm-svn: 139043
2011-09-02 21:47:51 +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
Argyrios Kyrtzidis 48d7798de1 [arcmt] Clear out temporary dirs in the tests or we may get failures because of leftovers.
llvm-svn: 138971
2011-09-01 21:53:39 +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