Commit Graph

21200 Commits

Author SHA1 Message Date
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
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
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
Caitlin Sadowski eecd273951 Thread safety: small formatting change
llvm-svn: 139548
2011-09-12 22:28:41 +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
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
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
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 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
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 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
Richard Trieu 7fde916498 Fix a broken assert in AST/DeclCXX.cpp.
llvm-svn: 139461
2011-09-10 02:16:48 +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 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