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

23593 Коммитов

Автор SHA1 Сообщение Дата
Anna Zaks f196a90b26 [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);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149579 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-02 01:30:08 +00:00
Richard Smith f15fda02e9 constexpr:
* support the gcc __builtin_constant_p() ? ... : ... folding hack in C++11
  * check for unspecified values in pointer comparisons and pointer subtractions


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149578 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-02 01:16:57 +00:00
Douglas Gregor c69a181049 Introduce a -cc1 option "-dependency-graphviz" that determines header
dependencies and outputs them in GraphViz format.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149575 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-02 00:54:52 +00:00
Fariborz Jahanian c645ddf240 objc: don't crash if primary class is missing and continuation class
is declaring ivars. // rdar://10752081



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149573 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-02 00:49:12 +00:00
Eli Friedman 34ff062936 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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149572 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-02 00:40:20 +00:00
Dylan Noblesmith f2462be34a back out r149504
Too many weird build failures.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149571 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-02 00:40:14 +00:00
Ted Kremenek 34a2c42ba8 Per discussion on cfe-dev, remove '#error' and '#warning' from diagnostic text.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149566 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-02 00:16:13 +00:00
Fariborz Jahanian f83a615ad0 objc2: add __has_feature(objc_default_synthesize_properties).
// rdar://10770497


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149565 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-02 00:15:51 +00:00
Eric Christopher 271ce5454b 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149560 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 23:39:00 +00:00
Rafael Espindola 20039ae1d9 Reject mismatched "#pragma GCC visibility push" and "#pragma GCC visibility pop".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149559 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 23:24:59 +00:00
Fariborz Jahanian 52b6236427 Look for declaration of CFBridgingRetain/CFBridgingRetain before
changing the diagnostic. Also use correct spelling for both.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149554 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 22:56:20 +00:00
Eric Christopher ef81e0f8f1 Remove duplicated comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149544 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 21:48:10 +00:00
Eric Christopher af790885c7 Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149543 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 21:44:56 +00:00
Douglas Gregor ac32ff9812 Make sure that imported definitions get completed before we add
anything into the corresponding DeclContext. Co-hacked with Sean;
fixes <rdar://problem/10768928>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149535 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 21:00:38 +00:00
Argyrios Kyrtzidis 7f3a458cd4 [libclang] Make sure we don't ever leave a StoredDiagnostic associated with
a SourceManager that has already been deleted, rdar://10768346.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149532 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 19:54:02 +00:00
Douglas Gregor a28c1df2cc Add missing dependency to unbreak the CMake build
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149531 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 19:53:01 +00:00
David Chisnall dccaa239ec size() == 0 -> empty().
Spotted by rjmcall.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149526 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 19:16:56 +00:00
Anna Zaks 84aac9acc7 [analyzer] Fix a crash in CheckerContext::isCLibraryFunction for C++
declarations with special names.

A patch by Dmitri Gribenko.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149525 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 19:16:20 +00:00
Anna Zaks c36bedc90c 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149524 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 19:08:57 +00:00
Douglas Gregor b710dfe523 Diagnose the restriction on default arguments in C++11 [expr.prim.lambda]p5.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149517 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 17:18:19 +00:00
Douglas Gregor a1f2114d9e 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149516 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 17:04:21 +00:00
Dylan Noblesmith 69d3b4f7c9 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149504 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 14:25:28 +00:00
Richard Smith 15efc4d597 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149490 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 08:10:20 +00:00
Stepan Dyatkovskiy ab14ae2ab1 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149482 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 07:50:21 +00:00
Argyrios Kyrtzidis 5d3a4bb13d 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149477 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 06:36:49 +00:00
Argyrios Kyrtzidis c221411ad5 Remove redundant checks in CXXRecordDecl::isCLike(), as suggested by Sebastian.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149476 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 06:36:44 +00:00
Eric Christopher 0086a5b44a For pass-by-value record arguments to functions emit a forward decl
instead of the entire class definition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149474 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 06:07:23 +00:00
Richard Smith 7b48a29863 constexpr: overflow checking for integral and floating-point arithmetic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149473 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 05:53:12 +00:00
Douglas Gregor b223d8c426 When providing code completions for a switch over a scoped enumeration
type, be sure to add the qualifier for the enumeration type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149471 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 05:02:47 +00:00
Richard Smith 8398cbfc73 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149469 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 04:40:02 +00:00
Richard Smith b04035a7b1 constexpr: require 'this' to point to an object in a constexpr method call.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149467 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 02:39:43 +00:00
Richard Smith b02e4629f7 constexpr: add support for comparisons of pointer-to-members.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149463 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 01:42:44 +00:00
Douglas Gregor 93962e5360 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149462 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 01:18:43 +00:00
Nico Weber ee625afea7 Fix crash on invalid in microsoft anonymous struct extension.
Fixes PR11847. Patch from Jason Haslam!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149460 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 00:41:00 +00:00
Douglas Gregor fe9b559f81 Diagnose attempts to explicitly capture a __block variable in a lambda.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149458 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 00:09:55 +00:00
Bob Wilson 48b68a0dc3 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149455 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 23:52:58 +00:00
Bob Wilson 8f1e656178 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149454 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 23:52:54 +00:00
Kaelyn Uhrain 16e46dd0c2 Make the callback object to Sema::CorrectTypo mandatory.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149451 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 23:49:25 +00:00
Fariborz Jahanian 7eb82f0d09 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149449 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 23:42:37 +00:00
Richard Smith 3df61308dd 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149448 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 23:24:19 +00:00
Eli Friedman d29975fd08 Make sure we call MaybeCreateExprWithCleanups for the sub-expression of an indirect goto.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149441 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 22:47:07 +00:00
Eli Friedman c6c14e56e3 A couple minor fixes to template instantiation for for-range loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149440 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 22:45:40 +00:00
Bob Wilson 4c5ffb32e8 Use new Triple::getMacOSXVersion function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149439 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 22:43:59 +00:00
Fariborz Jahanian 9c7aed308a arc migrator: twik previous patch to exclude user provided
explicit type cast. // rdar://10521744


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149437 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 22:09:44 +00:00
Fariborz Jahanian 2908ffbc5f 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149435 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 21:58:23 +00:00
Douglas Gregor eb7b9eb18b 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149434 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 21:57:50 +00:00
Bob Wilson 1085377d9b 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149422 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 21:30:03 +00:00
Anna Zaks e00575f12c [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.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149407 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 19:33:39 +00:00
Anna Zaks 393b9793da [analyzer] Change the warning to suggest 'strlcat/strlcpy' as
replacements for 'starcat/strcpy' instead of 'strncat/strncpy'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149406 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 19:33:31 +00:00
Chad Rosier 588e83bf3e Fix 80-column violation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149405 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 19:31:12 +00:00