Commit Graph

23593 Commits

Author SHA1 Message Date
Anna Zaks 699f55b98c [analyzer] Fix a false positive in the CFArrayCreate check that surfaces
the the code like this (due to x and &x being the same value but
different size):

void* x[] = { ptr1, ptr2, ptr3 };
CFArrayCreate(NULL, (const void **) &x, count, NULL);

llvm-svn: 149579
2012-02-02 01:30:08 +00:00
Richard Smith 84f6dcf2b5 constexpr:
* support the gcc __builtin_constant_p() ? ... : ... folding hack in C++11
  * check for unspecified values in pointer comparisons and pointer subtractions

llvm-svn: 149578
2012-02-02 01:16:57 +00:00
Douglas Gregor 83d46be31e Introduce a -cc1 option "-dependency-graphviz" that determines header
dependencies and outputs them in GraphViz format.

llvm-svn: 149575
2012-02-02 00:54:52 +00:00
Fariborz Jahanian 17612b1dbf objc: don't crash if primary class is missing and continuation class
is declaring ivars. // rdar://10752081

llvm-svn: 149573
2012-02-02 00:49:12 +00:00
Eli Friedman e1ffd49165 Change the check for constant-conversion with width-1 bitfields so it doesn't suppress quite as many cases. Based off a testcase in the gcc testsuite.
llvm-svn: 149572
2012-02-02 00:40:20 +00:00
Dylan Noblesmith 4f4e745725 back out r149504
Too many weird build failures.

llvm-svn: 149571
2012-02-02 00:40:14 +00:00
Ted Kremenek 7f4bd16b53 Per discussion on cfe-dev, remove '#error' and '#warning' from diagnostic text.
llvm-svn: 149566
2012-02-02 00:16:13 +00:00
Fariborz Jahanian ccded6e447 objc2: add __has_feature(objc_default_synthesize_properties).
// rdar://10770497

llvm-svn: 149565
2012-02-02 00:15:51 +00:00
Eric Christopher c9e6924fb2 r149474 went a bit too far when combined with type caching. If we want
a full type go ahead and emit it if we currently only have a forward
declaration.

Fixes gdb bots for gdb1090.exp and call-ar-st.exp.

llvm-svn: 149560
2012-02-01 23:39:00 +00:00
Rafael Espindola 6d65d7b63d Reject mismatched "#pragma GCC visibility push" and "#pragma GCC visibility pop".
llvm-svn: 149559
2012-02-01 23:24:59 +00:00
Fariborz Jahanian 30febeb224 Look for declaration of CFBridgingRetain/CFBridgingRetain before
changing the diagnostic. Also use correct spelling for both.

llvm-svn: 149554
2012-02-01 22:56:20 +00:00
Eric Christopher 25a11e6dbd Remove duplicated comment.
llvm-svn: 149544
2012-02-01 21:48:10 +00:00
Eric Christopher 034ba7e487 Fix comment.
llvm-svn: 149543
2012-02-01 21:44:56 +00:00
Douglas Gregor 2e15c844a5 Make sure that imported definitions get completed before we add
anything into the corresponding DeclContext. Co-hacked with Sean;
fixes <rdar://problem/10768928>.

llvm-svn: 149535
2012-02-01 21:00:38 +00:00
Argyrios Kyrtzidis 38bacf3429 [libclang] Make sure we don't ever leave a StoredDiagnostic associated with
a SourceManager that has already been deleted, rdar://10768346.

llvm-svn: 149532
2012-02-01 19:54:02 +00:00
Douglas Gregor c48190c10a Add missing dependency to unbreak the CMake build
llvm-svn: 149531
2012-02-01 19:53:01 +00:00
David Chisnall af066bbb1f size() == 0 -> empty().
Spotted by rjmcall.

llvm-svn: 149526
2012-02-01 19:16:56 +00:00
Anna Zaks 7aba6368fa [analyzer] Fix a crash in CheckerContext::isCLibraryFunction for C++
declarations with special names.

A patch by Dmitri Gribenko.

llvm-svn: 149525
2012-02-01 19:16:20 +00:00
Anna Zaks 314cd09b5c Add a new compiler warning, which flags anti-patterns used as the size
argument in strncat.

The warning is ignored by default since it needs more qualification. 

TODO: The warning message and the note are messy when
strncat is a builtin due to the macro expansion.

llvm-svn: 149524
2012-02-01 19:08:57 +00:00
Douglas Gregor 6b8ef34f84 Diagnose the restriction on default arguments in C++11 [expr.prim.lambda]p5.
llvm-svn: 149517
2012-02-01 17:18:19 +00:00
Douglas Gregor cdd11d4e7e Introduce the lambda scope before determining explicit captures, which
cleans up and improves a few things:
  - We get rid of the ugly dance of computing all of the captures in
  data structures that clone those of CapturingScopeInfo, centralizing
  the logic for accessing/updating these data structures
  - We re-use the existing capture logic for 'this', which actually
  works now.

Cleaned up some diagnostic wording in minor ways as well.

llvm-svn: 149516
2012-02-01 17:04:21 +00:00
Dylan Noblesmith 86780e906b include clang's config.h unconditionally
And remove HAVE_CLANG_CONFIG_H, now that the header is generated
in the autoconf build, too. (clang r149497 / llvm r149498)

Also include the config.h header after all other headers, per
the LLVM coding standards.

It also turns out WindowsToolChain.cpp wasn't using the config
header at all, so that include's just deleted now.

llvm-svn: 149504
2012-02-01 14:25:28 +00:00
Richard Smith 1b470417e4 constexpr: check for overflow in pointer subtraction.
This is a mess. According to the C++11 standard, pointer subtraction only has
undefined behavior if the difference of the array indices does not fit into a
ptrdiff_t.

However, common implementations effectively perform a char* subtraction first,
and then divide the result by the element size, which can cause overflows in
some cases. Those cases are not considered to be undefined behavior by this
change; perhaps they should be.

llvm-svn: 149490
2012-02-01 08:10:20 +00:00
Stepan Dyatkovskiy 5fecf54460 Compatability fix for SwitchInst refactoring.
The purpose of refactoring is to hide operand roles from SwitchInst user (programmer). If you want to play with operands directly, probably you will need lower level methods than SwitchInst ones (TerminatorInst or may be User). After this patch we can reorganize SwitchInst operands and successors as we want.

What was done:

1. Changed semantics of index inside the getCaseValue method:
getCaseValue(0) means "get first case", not a condition. Use getCondition() if you want to resolve the condition. I propose don't mix SwitchInst case indexing with low level indexing (TI successors indexing, User's operands indexing), since it may be dangerous.
2. By the same reason findCaseValue(ConstantInt*) returns actual number of case value. 0 means first case, not default. If there is no case with given value, ErrorIndex will returned.
3. Added getCaseSuccessor method. I propose to avoid usage of TerminatorInst::getSuccessor if you want to resolve case successor BB. Use getCaseSuccessor instead, since internal SwitchInst organization of operands/successors is hidden and may be changed in any moment.
4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of these methods is to see how case successors are really mapped in TerminatorInst.
4.1 "resolveSuccessorIndex" was created if you need to level down from SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for given case successor.
4.2 "resolveCaseIndex" converts low level successors index to case index that curresponds to the given successor.

Note: There are also related compatability fix patches for dragonegg, klee, llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang.
llvm-svn: 149482
2012-02-01 07:50:21 +00:00
Argyrios Kyrtzidis a11b35a9b0 Revert r149363 which was part a series of commits that were reverted in llvm
commit 149470. This fixes test/CodeGen/PR3589-freestanding-libcalls.c.

Original log:

    ConstantArray::get() (for strings) is going away, use
    ConstantDataArray::getString instead.

    Many instances of ConstantArray::get() could be moved to
    use more efficient ConstantDataArray methods that avoid a ton
    of intermediate Constant*'s for each element (e.g.
    GetConstantArrayFromStringLiteral).  I don't plan on doing this
    in the short-term though.

llvm-svn: 149477
2012-02-01 06:36:49 +00:00
Argyrios Kyrtzidis c3c9ee5623 Remove redundant checks in CXXRecordDecl::isCLike(), as suggested by Sebastian.
llvm-svn: 149476
2012-02-01 06:36:44 +00:00
Eric Christopher ee4ab93906 For pass-by-value record arguments to functions emit a forward decl
instead of the entire class definition.

llvm-svn: 149474
2012-02-01 06:07:23 +00:00
Richard Smith c8042323e1 constexpr: overflow checking for integral and floating-point arithmetic.
llvm-svn: 149473
2012-02-01 05:53:12 +00:00
Douglas Gregor d3cebdba41 When providing code completions for a switch over a scoped enumeration
type, be sure to add the qualifier for the enumeration type.

llvm-svn: 149471
2012-02-01 05:02:47 +00:00
Richard Smith 0287910521 constexpr: Unlike other incomplete types, 'void' cannot possibly be completed as
a literal type. Disallow it as the return type of a constexpr function
declaration.

llvm-svn: 149469
2012-02-01 04:40:02 +00:00
Richard Smith 47b349328b constexpr: require 'this' to point to an object in a constexpr method call.
llvm-svn: 149467
2012-02-01 02:39:43 +00:00
Richard Smith 7bb0067c06 constexpr: add support for comparisons of pointer-to-members.
llvm-svn: 149463
2012-02-01 01:42:44 +00:00
Douglas Gregor 53a9bdf17e Improve checking of explicit captures in a C++11 lambda expression:
- Actually building the var -> capture mapping properly (there was an off-by-one error)
  - Keeping track of the source location of each capture
  - Minor QoI improvements, e.g, highlighing the prior capture if
  there are multiple captures, pointing at the variable declaration we
  found if we reject it.

As part of this, add standard citations for the various semantic
checks we perform, and note where we're not performing those checks as
we should.

llvm-svn: 149462
2012-02-01 01:18:43 +00:00
Nico Weber f8bb3de488 Fix crash on invalid in microsoft anonymous struct extension.
Fixes PR11847. Patch from Jason Haslam!

llvm-svn: 149460
2012-02-01 00:41:00 +00:00
Douglas Gregor 0e8ff39dc7 Diagnose attempts to explicitly capture a __block variable in a lambda.
llvm-svn: 149458
2012-02-01 00:09:55 +00:00
Bob Wilson 8e5acc5cc1 Use the new Triple::getMacOSXVersion function in another place.
I removed support for "*-darwin*-iphoneos" triples, since we now have
iOS listed as a separate OS in the triples.

llvm-svn: 149455
2012-01-31 23:52:58 +00:00
Bob Wilson c333749312 Fix an assertion failure in isMacOSXVersionLT for IOS targets.
Check if the triple OS is IOS instead of checking for arm/thumb architectures
and check that before calling isMacOSXVersionLT.

llvm-svn: 149454
2012-01-31 23:52:54 +00:00
Kaelyn Uhrain 4e8942c139 Make the callback object to Sema::CorrectTypo mandatory.
llvm-svn: 149451
2012-01-31 23:49:25 +00:00
Fariborz Jahanian bcdc282d85 objc-arc: In various diagnostics mention
CFBridgingRetain/CFBridgingRelease calls instead
of __bridge_retained/__bridge_transfer casts as preferred
way of moving cf objects to arc land. // rdar://10207950

llvm-svn: 149449
2012-01-31 23:42:37 +00:00
Richard Smith 000e9aa7ed constexpr: Treat INT_MIN % -1 as undefined behavior in C++11. Technically, it
isn't, but this is just a (reported) defect in the wording.

llvm-svn: 149448
2012-01-31 23:24:19 +00:00
Eli Friedman 9ccdb1d01b Make sure we call MaybeCreateExprWithCleanups for the sub-expression of an indirect goto.
llvm-svn: 149441
2012-01-31 22:47:07 +00:00
Eli Friedman 87d3280985 A couple minor fixes to template instantiation for for-range loops.
llvm-svn: 149440
2012-01-31 22:45:40 +00:00
Bob Wilson a223401498 Use new Triple::getMacOSXVersion function.
llvm-svn: 149439
2012-01-31 22:43:59 +00:00
Fariborz Jahanian a1c1b152f0 arc migrator: twik previous patch to exclude user provided
explicit type cast. // rdar://10521744

llvm-svn: 149437
2012-01-31 22:09:44 +00:00
Fariborz Jahanian eb00284f22 arc migrator: Do not attempt to migrate to bridge casts which
cancel out each other. Leave it alone so users can take a look
(unmigrated code forces error diagnostic). // rdar://10521744

llvm-svn: 149435
2012-01-31 21:58:23 +00:00
Douglas Gregor 232e3431e2 Split compiler builtin module into "stdlib" builtins and "intrinsic"
builds, and bring mm_alloc.h into the fold. Start playing some tricks
with these builtin modules to mirror the include_next tricks that the
headers already perform.

llvm-svn: 149434
2012-01-31 21:57:50 +00:00
Bob Wilson 9d3f7af8c3 Fix more fallout from the introduction of "macosx" and "ios" triples.
The Darwin toolchain constructor was assuming that all Darwin triples would
have an OS string starting with "darwin".  Triples starting with "macosx"
would misinterpret the version number, and "ios" triples would completely
miss the version number (or worse) because the OS name is not 6 characters
long.  We lose some sanity checking of triple strings here, since the
Triple.getOSVersion function doesn't do all the checking that the previous
code did, but this still seems like a step in the right direction.

llvm-svn: 149422
2012-01-31 21:30:03 +00:00
Anna Zaks 87b6ff09f9 [analyzer] Add checks for common anti-patterns in strncat.
(Since this is syntax only, might be a good candidate for turning into a
compiler warning.)

llvm-svn: 149407
2012-01-31 19:33:39 +00:00
Anna Zaks ee5e8ae845 [analyzer] Change the warning to suggest 'strlcat/strlcpy' as
replacements for 'starcat/strcpy' instead of 'strncat/strncpy'.

llvm-svn: 149406
2012-01-31 19:33:31 +00:00
Chad Rosier ebaefe7527 Fix 80-column violation.
llvm-svn: 149405
2012-01-31 19:31:12 +00:00