Commit Graph

45205 Commits

Author SHA1 Message Date
Ted Kremenek bedcd85645 Add test case for -Wdeprecated-objc-pointer-introspection, and
tweak warning to suggest that it is just a bad thing to do.

llvm-svn: 180175
2013-04-24 06:52:20 +00:00
Ted Kremenek 616986f859 Remove CXCursorSet and related APIs. There are no known clients.
llvm-svn: 180174
2013-04-24 06:52:14 +00:00
Daniel Jasper 770eb7c5f9 Fix comment alignment behavior.
In the following snippet, clang-format incorrectly aligned the
trailing comment, when only the last line was formatted:

  int aaaaaa; // comment
  int b;
  int c; // Formatting only this line moved this comment.

llvm-svn: 180173
2013-04-24 06:33:59 +00:00
Jakob Stoklund Olesen f759989bcd Add some more required SPARC v9 predefined macros.
Solaris/AuroraUX only need __arch64__, the BSDs need the other variants.

llvm-svn: 180172
2013-04-24 04:36:38 +00:00
Anna Zaks 7712f38978 [analyzer] IvarInvalidation: correctly handle cases where only partial invalidators exist
- If only partial invalidators exist and there are no full invalidators in @implementation, report every ivar that has
not been invalidated. (Previously, we reported the first Ivar in the list, which could actually have been invalidated
by a partial invalidator. The code assumed you cannot have only partial invalidators.)

- Do not report missing invalidation method declaration if a partial invalidation method declaration exists.

llvm-svn: 180170
2013-04-24 02:49:16 +00:00
Anna Zaks 404028798f [analyzer] Set the allocation site to be the uniqueing location for retain count checker leaks.
The uniqueing location is the location which is part of the hash used to determine if two reports are
the same. This is used by the CmpRuns.py script to compare two analyzer runs and determine which
warnings are new.

llvm-svn: 180166
2013-04-23 23:57:50 +00:00
Anna Zaks 4e16b29c13 [analyzer] Refactor BugReport::getLocation and PathDiagnosticLocation::createEndOfPath for greater code reuse
The 2 functions were computing the same location using different logic (each one had edge case bugs that the other
one did not). Refactor them to rely on the same logic.

The location of the warning reported in text/command line output format will now match that of the plist file.

There is one change in the plist output as well. When reporting an error on a BinaryOperator, we use the location of the
operator instead of the beginning of the BinaryOperator expression. This matches our output on command line and
looks better in most cases.

llvm-svn: 180165
2013-04-23 23:57:43 +00:00
Ted Kremenek 721ffed9bc Update checker build.
llvm-svn: 180164
2013-04-23 23:55:03 +00:00
Argyrios Kyrtzidis c2233beba4 [libclang] Introduce a CXCursor_ObjCSelfExpr cursor, which is the equivalent of CXCursor_CXXThisExpr for C++ code.
rdar://13717006

llvm-svn: 180127
2013-04-23 17:57:17 +00:00
Benjamin Kramer d408de6a2e Make compares unsigned. The expression can't become negative anyways.
Silences a sign compare warning on 32 bit archs.

llvm-svn: 180110
2013-04-23 14:42:47 +00:00
Daniel Jasper 4431aa99ab Fix formatting of complex #if expressions.
Before:
  #if !defined(AAAAAAAAAAAAAAAA) && (defined CCCCCCCC ||                         \
                                     defined DDDDDDDD) && defined(BBBBBBBB)

After:
  #if !defined(AAAAAAAAAAAAAAAA) && (defined CCCCCCCC || defined DDDDDDDD) &&    \
      defined(BBBBBBBB)

This fixes llvm.org/PR15828.

llvm-svn: 180105
2013-04-23 13:54:04 +00:00
Richard Trieu d0d87b5972 Warn that scoped enumerations are a C++11 extenstion when compiling in
C++98 mode.  This improves on the previous diagnostic message of:

error: expected identifier or '{'
llvm-svn: 180076
2013-04-23 02:47:36 +00:00
Jordan Rose 7467f06533 [analyzer] RetainCountChecker: Clean up path notes for autorelease.
No functionality change.

<rdar://problem/13710586>

llvm-svn: 180075
2013-04-23 01:42:25 +00:00
Ted Kremenek b44bc7d599 [scan-build] Whitelist all -mXXXX options.
llvm-svn: 180073
2013-04-23 00:10:55 +00:00
Argyrios Kyrtzidis 40bcfd71b6 When modifying an implicit instantiation with information from an explicit one, make sure to reset the "right brace" location.
Otherwise the source range of the explicit instantiation may become invalid (begin location will be after the end location).

rdar://13706991

llvm-svn: 180070
2013-04-22 23:23:42 +00:00
Jordan Rose 6e3cf2ba85 [analyzer] Model strsep(), particularly that it returns its input.
This handles the false positive leak warning in PR15374, and also serves
as a basic model for the strsep() function.

llvm-svn: 180069
2013-04-22 23:18:42 +00:00
Manman Ren 4a838160e4 Add triple to tbaa-struct.cpp to appease bots
llvm-svn: 180065
2013-04-22 22:50:27 +00:00
Ted Kremenek ebeabab9a9 Add a warning for Objective-C pointer introspection, which is solely the job of the Objective-C runtime.
llvm-svn: 180062
2013-04-22 22:46:52 +00:00
Ted Kremenek 760b5e360d Rename this test to make it more general for including more tests.
llvm-svn: 180056
2013-04-22 22:09:21 +00:00
Chad Rosier 7359d4793e [ms-inline asm] Set the OpDecl to the InlineAsmIdentifierInfo struct.
Part of rdar://13663589

llvm-svn: 180055
2013-04-22 22:05:00 +00:00
Jordan Rose b957113b3f [analyzer] Treat reinterpret_cast like a base cast in certain cases.
The analyzer represents all pointer-to-pointer bitcasts the same way, but
this can be problematic if an implicit base cast gets layered on top of a
manual base cast (performed with reinterpret_cast instead of static_cast).
Fix this (and avoid a valid assertion) by looking through cast regions.

Using reinterpret_cast this way is only valid if the base class is at the
same offset as the derived class; this is checked by -Wreinterpret-base-class.
In the interest of performance, the analyzer doesn't repeat this check
anywhere; it will just silently do the wrong thing (use the wrong offsets
for fields of the base class) if the user code is wrong.

PR15394

llvm-svn: 180052
2013-04-22 21:36:49 +00:00
Jordan Rose 3437669ca9 [analyzer] Type information from C++ new expressions is perfect.
This improves our handling of dynamic_cast and devirtualization for
objects allocated by 'new'.

llvm-svn: 180051
2013-04-22 21:36:44 +00:00
Simon Atanasyan af9ebc742d [Mips] Remove "REQUIRES: mips-registered-target" from some MIPS-related
driver tests. These tests check the driver only and do not require mips
target.

llvm-svn: 180042
2013-04-22 20:26:27 +00:00
Manman Ren 09a3912b5c TBAA: make sure zero-length bitfield works for tbaa.struct and path-aware tbaa
For ms structs, zero-length bitfields following non-bitfield members are
completely ignored, we should not increase the field index.
Before the fix, we will have an assertion failure.

llvm-svn: 180038
2013-04-22 19:50:07 +00:00
Chad Rosier b18a285525 [ms-inline asm] Refactor/clean up the SemaLookup interface. No functional
change indended.
Part of rdar://13663589

llvm-svn: 180027
2013-04-22 17:01:37 +00:00
Adrian Prantl 8cb1896b6e Move debug info tests for scoped enums into a separate file.
llvm-svn: 180026
2013-04-22 16:47:50 +00:00
Benjamin Kramer c272794899 Use the ugly PRIx64 macro to make format string portable.
This is debugging code so functionality isn't a concern, but mingw32 warns
because it doesn't understand the %llx format specifier.

llvm-svn: 180024
2013-04-22 16:10:38 +00:00
Richard Smith d9f663b510 C++1y constexpr extensions, round 1: Allow most forms of declaration and
statement in constexpr functions. Everything which doesn't require variable
mutation is also allowed as an extension in C++11. 'void' becomes a literal
type to support constexpr functions which return 'void'.

llvm-svn: 180022
2013-04-22 15:31:51 +00:00
Richard Smith da466db02a cmake: Only add -pedantic if LLVM didn't add it. Don't unconditionally add
-Wall -W, since it's already provided by LLVM's cmake config, and that
overrides fixes (such as -Wno-uninitialized) which LLVM's cmake setup may have
provided.

llvm-svn: 180018
2013-04-22 14:51:21 +00:00
Richard Smith 9543c5e371 Fix array constant expression evaluation bug: we can have different values for
different array elements, even if they're all constructed using the same
default constructor.

llvm-svn: 180017
2013-04-22 14:44:29 +00:00
Richard Smith 1847baa20e Don't emit _ZTW wrappers for TLS variables which don't use the C++ thread_local keyword.
llvm-svn: 180004
2013-04-22 08:06:17 +00:00
Arnaud A. de Grandmaison 7c6571bce1 Cleanup: test source file does not need to be executable
llvm-svn: 180002
2013-04-22 08:00:37 +00:00
Daniel Jasper cc960fa645 Fix bin-packing behavior of constructor initialziers.
In Google style, constructor initializers need to be all on one line or
one initializer per line if that does not fit. Without this patch, this
non-bin-packing-behavior incorrectly extends to the parameters of the
initializers.

Before:
Constructor()
    : aaaaa(aaaaaaaaaaaaaaaaaaaaaa,
            aaaaaaaaaaaaaaaaaaaaaa,
            aaaaaaaaaaaaaaaaaaaaaa) {}

After:
Constructor()
    : aaaaa(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa,
            aaaaaaaaaaaaaaaaaaaaaa) {}

llvm-svn: 180001
2013-04-22 07:59:53 +00:00
David Blaikie 9f88fe865c Revert "Revert "PR14606: Debug info for using directives/DW_TAG_imported_module""
This reverts commit 179839 now that the corresponding LLVM patch has been fixed.

llvm-svn: 179997
2013-04-22 06:13:21 +00:00
David Blaikie 8ddc2b50e8 Add a triple to make a test resilient to non-TLS hosts (eg: darwin10)
Making the test introduced in r179962 resilient to being run on darwin10 hosts.

llvm-svn: 179992
2013-04-22 04:18:25 +00:00
Dmitri Gribenko 2dbe8f94a9 Fix return type of isBitfield in the binding definition
Patch by Loïc Jaquemet.

llvm-svn: 179984
2013-04-21 18:35:51 +00:00
Simon Atanasyan 4938ddb1ab [Mips] Convert a GNU style Mips ABI name to the name accepted by LLVM
Mips backend.

llvm-svn: 179981
2013-04-21 13:30:10 +00:00
Simon Atanasyan 9035898c21 [Mips] Do not add unnecessary Mips toolchain path to the list
of system include directories with extern "C" semantics.

llvm-svn: 179979
2013-04-21 12:55:59 +00:00
Richard Smith 034185c2f9 The 'constexpr implies const' rule for non-static member functions is gone in
C++1y, so stop adding the 'const' there. Provide a compatibility warning for
code relying on this in C++11, with a fix-it hint. Update our lazily-written
tests to add the const, except for those ones which were testing our
implementation of this rule.

llvm-svn: 179969
2013-04-21 01:08:50 +00:00
Richard Smith 74d0c1eeef Disable VLA diagnostic in C++1y mode, and add some tests.
Still to do here:
  - we have a collection of syntactic accepts-invalids to diagnose
  - support non-PODs in VLAs, including dynamic initialization /
    destruction
  - runtime checks (and throw std::bad_array_length) for bad bound
  - support VLA capture by reference in lambdas
  - properly support VLAs in range-based for (don't recompute bound)

llvm-svn: 179962
2013-04-20 23:28:26 +00:00
Richard Smith 51fe3a48aa Add another test I forgot to svn add.
llvm-svn: 179959
2013-04-20 22:23:29 +00:00
Richard Smith 852c9db72b C++1y: Allow aggregates to have default initializers.
Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in
CXXCtorInitializers and in InitListExprs to represent a default initializer.

There's an additional complication here: because the default initializer can
refer to the initialized object via its 'this' pointer, we need to make sure
that 'this' points to the right thing within the evaluation.

llvm-svn: 179958
2013-04-20 22:23:05 +00:00
Richard Smith f30c842a38 Update some stuff on the open projects page to reflect things we've already done.
llvm-svn: 179953
2013-04-20 16:20:44 +00:00
Richard Smith 95997207e0 Switch C++11 open project to C++1y :)
llvm-svn: 179951
2013-04-20 15:57:27 +00:00
Richard Smith 4cf9a1ee0b Add note that some of these links are dead for now.
llvm-svn: 179950
2013-04-20 13:22:50 +00:00
Richard Smith 33089cbdae VLAs in C++14!
llvm-svn: 179949
2013-04-20 13:20:33 +00:00
Richard Smith 7898d7ba96 Variable templates and generic lambdas are approved for C++14.
llvm-svn: 179947
2013-04-20 12:58:57 +00:00
Richard Smith d3a7386452 Clarifying memory allocation: approved for C++14. Move from N/A to no, since we currently relax 'operator new' calls which didn't come from new-expressions.
llvm-svn: 179946
2013-04-20 12:57:49 +00:00
Richard Smith 74c61eaca2 No digit separators for C++14.
llvm-svn: 179945
2013-04-20 12:56:37 +00:00
Richard Smith 7feda2f990 Generalized constexpr is approved for C++14.
llvm-svn: 179944
2013-04-20 12:49:36 +00:00
Richard Smith 5db8b286e2 More approved C++14 features.
llvm-svn: 179943
2013-04-20 12:47:36 +00:00
Richard Smith 0fa4fceaae Binary literals are approved for C++14.
llvm-svn: 179942
2013-04-20 12:44:32 +00:00
Richard Smith 0feaf0c7e3 Implement core issue 1608: class members can be found via operator lookup in a trailing return type in that class's body.
llvm-svn: 179941
2013-04-20 12:41:22 +00:00
Simon Atanasyan 08450bd55c Supports Sourcery CodeBench Mips toolchain directories tree.
Sourcery CodeBench and modern FSF Mips toolchains require a bit more
complicated algorithm to calculate headers, libraries and sysroot paths
than implemented by Clang driver now. The main problem is that all these
paths depend on a set of command line arguments additionally to a target
triple value. For example, let $TC is a toolchain installation directory.
If we compile big-endian 32-bit mips code, crtbegin.o is in the
$TC/lib/gcc/mips-linux-gnu/4.7.2 folder and the toolchain's linker requires
--sysroot=$TC/mips-linux-gnu/libc argument. If we compile little-endian
32-bit soft-float mips code, crtbegin.o is in the
$TC/lib/gcc/mips-linux-gnu/4.7.2/soft-float/el folder and the toolchain's
linker requires --sysroot=$TC/mips-linux-gnu/libc/soft-float/el argument.

1. Calculate MultiarchSuffix using all necessary command line options and
   use this MultiarchSuffix to detect crtbegin.o location in the
   GCCInstallationDetector::ScanLibDirForGCCTriple() routine.
2. If a user does not provide --sysroot argument to the driver explicitly,
   calculate new sysroot value based on command line options. Then use this
   calculated sysroot path:
   a. To populate a file search paths list in the Linux::Linux() constructor.
   b. To find Mips toolchain specific include headers directories
      in the Linux::AddClangSystemIncludeArgs() routine.
   c. To provide -–sysroot argument for a linker.

Note:
- The FSF's tree slightly differs (folder names) and is not supported
  yet.
- New addExternCSystemIncludeIfExits() routine is a temporary solution.
  I plan to move path existence check to the addExternCSystemInclude()
  routine by a separate commit.

The patch reviewed by Rafael Espindola.
http://llvm-reviews.chandlerc.com/D644

llvm-svn: 179934
2013-04-20 08:15:03 +00:00
Anna Zaks 6c0c47ede5 [analyzer] Ensure BugReporterTracking works on regions with pointer arithmetic
Introduce a new helper function, which computes the first symbolic region in
the base region chain. The corresponding symbol has been used for assuming that
a pointer is null. Now, it will also be used for checking if it is null.

This ensures that we are tracking a null pointer correctly in the BugReporter.

llvm-svn: 179916
2013-04-20 01:15:42 +00:00
Anna Zaks 390fb10a9b [analyzer] Flip printPretty and printPrettyAsExpr as per suggestion from Jordan (r179572)
llvm-svn: 179915
2013-04-20 01:15:36 +00:00
Anna Zaks 4e88300256 [analyzer] Correct the comment
llvm-svn: 179914
2013-04-20 01:15:32 +00:00
Argyrios Kyrtzidis 0903f8dac5 [libclang] Make sure the preable does not truncate comments.
rdar://13647445

llvm-svn: 179907
2013-04-19 23:24:25 +00:00
Jordan Rose 2a481fa63b [analyzer] Website: update lists of potential and actual checkers.
- memory.MismatchedDelete, memory.MultipleDelete, and memory.DeallocateNonPtr
  are complete (unix.MismatchedDeallocator and cplusplus.NewDelete)
- Per discussion on the mailing list, different.UnaryPlusWithUnsigned has
  dubious value; remove it.
- Add potential checker ctordtor.PlacementSelfCopy per an internal bug report.
- core.AttributeNonNull is now core.NonNullParamChecker, though no one should
  be depending on this name anyway.

llvm-svn: 179900
2013-04-19 22:19:14 +00:00
Adrian Prantl 8ac6170341 Remove an empty line so the line numbers match up again after the recent documentation change.
llvm-svn: 179898
2013-04-19 21:59:40 +00:00
Adrian Prantl c0dd7a4f25 still not relaxed enough.
llvm-svn: 179897
2013-04-19 21:52:06 +00:00
Adrian Prantl b37427fd82 cleanup and relax test cases
llvm-svn: 179896
2013-04-19 21:48:07 +00:00
Richard Smith c5c27f2a1f Note that we support (and in fact have supported since the dawn of time itself)
C++1y binary literals.

llvm-svn: 179883
2013-04-19 20:47:20 +00:00
Chad Rosier 7f2ab89774 [ms-inline asm] The parsing of C++ identifiers is a task of the front-end parser,
not the asm parser.  As such, begin moving the parsing logic in that direction.
This patch is just a temporary hack until the real frontend parser can be hooked
up.  Part of rdar://13663589

llvm-svn: 179882
2013-04-19 20:37:49 +00:00
Adrian Prantl c60dc718c0 Emit the underlying type in the debug info for all kinds of fixed enums
instead of only C++11-scoped-with-class-tag enums.

rdar://problem/13463793

llvm-svn: 179879
2013-04-19 19:56:39 +00:00
Adrian Prantl 6847fe3686 s/C++0x/C++11/
llvm-svn: 179878
2013-04-19 19:56:35 +00:00
Richard Smith 9172520f57 Initial work on status page for C++14.
llvm-svn: 179864
2013-04-19 17:27:48 +00:00
Andy Gibbs aa0b94a2d8 Keep the parentheses in #pragma message (partial revert of r179771).
llvm-svn: 179862
2013-04-19 17:13:17 +00:00
Richard Smith 25b555a6bf C++11 support is now feature-complete.
llvm-svn: 179861
2013-04-19 17:00:31 +00:00
Reid Kleckner 7ab75b3f68 Avoid names like __in that conflict with SAL in builtin headers
Microsoft's Source Annotation Language (SAL) defines a bunch of keywords
for annotating the inputs and outputs of functions.  Empty definitions
for the keywords are provided by <stdlib.h> -> <crtdefs.h> -> <sal.h>.
This makes it basically impossible to include MSVC's stdlib.h and
Clang's *mmintrin.h headers at the same time if they have variables
named __in.  As a workaround, I've renamed those variables.

This fixes the Modules/compiler_builtins.m test which was XFAILed,
presumably due to this conflict.

llvm-svn: 179860
2013-04-19 17:00:14 +00:00
Richard Smith 2fd1d7aee3 Implement CodeGen for C++11 thread_local, following the Itanium ABI specification as discussed on cxx-abi-dev.
llvm-svn: 179858
2013-04-19 16:42:07 +00:00
Anton Yartsev 3976656e08 [analyzer] Call proper callback for const regions escaped other then on call.
llvm-svn: 179846
2013-04-19 09:39:51 +00:00
Eric Christopher 3669c3c603 Revert "PR14606: Debug info for using directives/DW_TAG_imported_module"
This reverts commit r179837 as it seems to be causing test failures.

llvm-svn: 179839
2013-04-19 07:46:36 +00:00
David Blaikie cf5e5bade1 PR14606: Debug info for using directives/DW_TAG_imported_module
More changes later for using declarations/DW_TAG_imported_declaration.

llvm-svn: 179837
2013-04-19 07:04:02 +00:00
David Blaikie bfa5274df5 Give CGDebugInfo::getContextDescriptor a more specific return type
Not that the DI* hierarchy is terribly type safe, but this makes the contract a
little clearer I think.

llvm-svn: 179835
2013-04-19 06:56:38 +00:00
Argyrios Kyrtzidis 982934e7d4 [libclang] Fix copy-paste error in comment.
llvm-svn: 179823
2013-04-19 00:51:52 +00:00
Argyrios Kyrtzidis 23814e4f49 [libclang] Introduce clang_Cursor_isVariadic, which returns non-zero if the given cursor is a variadic function or method.
rdar://13667150

llvm-svn: 179819
2013-04-18 23:53:05 +00:00
Fariborz Jahanian d5d6f3d5a2 Objective-C++: Enable passing of modern C++11 style
initialized temporaries to objc++ methods. 
// rdar://12788429

llvm-svn: 179818
2013-04-18 23:43:21 +00:00
Argyrios Kyrtzidis 9d9bc01e42 [libclang] Introduce clang_Cursor_getObjCDeclQualifiers, to query for 'ObjC Qualifiers' written next to the return and
parameter types in an ObjC method declarations.

rdar://13676977

llvm-svn: 179816
2013-04-18 23:29:12 +00:00
Chad Rosier 274800025a Fix typo.
llvm-svn: 179811
2013-04-18 23:12:05 +00:00
Benjamin Kramer 1e4a886c28 Add comment to describe cleverness.
llvm-svn: 179806
2013-04-18 22:49:48 +00:00
Argyrios Kyrtzidis 9adfd8aabb [libclang] Introduce clang_Cursor_getObjCPropertyAttributes to query the written attributes in a property declaration.
rdar://13684512

llvm-svn: 179803
2013-04-18 22:15:49 +00:00
Dmitri Gribenko c2c804d145 Comment parsing: simplify code. As a side effect, this also silences GCC's
-Wunitnitialized warning.

Patch by Rui Ueyama.

llvm-svn: 179794
2013-04-18 20:50:35 +00:00
Fariborz Jahanian 507a5f8cb3 Objective-C parsing [qoi]: Provide good recovery when
Objective-C dictionary literals has bad syntax for the
separator. // rdar://10679157

llvm-svn: 179784
2013-04-18 19:37:43 +00:00
Argyrios Kyrtzidis 08dff958e9 [CMake] Create the directory before creating the link to the clang headers.
llvm-svn: 179782
2013-04-18 18:54:03 +00:00
Argyrios Kyrtzidis b86ea8a29f some more tests for r179743.
llvm-svn: 179781
2013-04-18 18:32:48 +00:00
Argyrios Kyrtzidis f790c74b60 Add IRGen test case for r179743.
llvm-svn: 179777
2013-04-18 17:52:10 +00:00
Ted Kremenek d51ad8c125 [analyzer] Refine 'nil receiver' diagnostics to mention the name of the method not called.
llvm-svn: 179776
2013-04-18 17:44:15 +00:00
Andy Gibbs 96d93907eb Dropped the parentheses for #pragma message and its kin in the -E output generator.
This was a suggestion by Jordan Rose since the documented format for these pragmas is without the parentheses.  At the same time, I've increased test coverage too for the preprocessed output.

llvm-svn: 179771
2013-04-18 16:49:37 +00:00
Fariborz Jahanian 65ff01bccb Adds a new doxygen tag needed. // rdar://12379053
llvm-svn: 179770
2013-04-18 16:45:57 +00:00
Argyrios Kyrtzidis 5af4f2b7ea [libclang] Report parameter array types as written in source, not decayed to pointer types.
Patch by Doug.
rdar://13684618

llvm-svn: 179769
2013-04-18 16:41:15 +00:00
Jordan Rose 3720e2f006 [analyzer] "Force" LazyCompoundVals on bind when they are simple enough.
The analyzer uses LazyCompoundVals to represent rvalues of aggregate types,
most importantly structs and arrays. This allows us to efficiently copy
around an entire struct, rather than doing a memberwise load every time a
struct rvalue is encountered. This can also keep memory usage down by
allowing several structs to "share" the same snapshotted bindings.

However, /lookup/ through LazyCompoundVals can be expensive, especially
since they can end up chaining back to the original value. While we try
to reuse LazyCompoundVals whenever it's safe, and cache information about
this transitivity, the fact is it's sometimes just not a good idea to
perpetuate LazyCompoundVals -- the tradeoffs just aren't worth it.

This commit changes RegionStore so that binding a LazyCompoundVal to struct
will do a memberwise copy if the struct is simple enough. Today's definition
of "simple enough" is "up to N scalar members" (see below), but that could
easily be changed in the future. This is enough to bring the test case in
PR15697 back down to a manageable analysis time (within 20% of its original
time, in an unfair test where the new analyzer is not compiled with LTO).

The actual value of "N" is controlled by a new -analyzer-config option,
'region-store-small-struct-limit'. It defaults to "2", meaning structs with
zero, one, or two scalar members will be considered "simple enough" for
this code path.

It's worth noting that a more straightforward implementation would do this
on load, not on bind, and make use of the structure we already have for this:
CompoundVal. A long time ago, this was actually how RegionStore modeled
aggregate-to-aggregate copies, but today it's only used for compound literals.
Unfortunately, it seems that we've special-cased LazyCompoundVal in certain
places (such as liveness checks) but failed to similarly special-case
CompoundVal in all of them. Until we're confident that CompoundVal is
handled properly everywhere, this solution is safer, since the entire
optimization is just an implementation detail of RegionStore.

<rdar://problem/13599304>

llvm-svn: 179767
2013-04-18 16:33:46 +00:00
Jordan Rose cdb44bdb3d [analyzer] Don't crash if we cache out after making a temporary region.
A C++ overloaded operator may be implemented as an instance method, and
that instance method may be called on an rvalue object, which has no
associated region. The analyzer handles this by creating a temporary region
just for the evaluation of this call; however, it is possible that /by
creating the region/, the analyzer ends up in a previously-explored state.
In this case we don't need to continue along this path.

This doesn't actually show any behavioral change now, but it starts being
used with the next commit and prevents an assertion failure there.

llvm-svn: 179766
2013-04-18 16:33:40 +00:00
Chad Rosier 384823dc32 Specify that we're parsing ms-style inline assembly.
llvm-svn: 179762
2013-04-18 15:45:31 +00:00
Manuel Klimek f5a0ae82e9 Multiple improvements to the AST matcher tutorial.
Patch by Jochen Eisinger.

llvm-svn: 179758
2013-04-18 14:30:45 +00:00
Benjamin Kramer 7ee3b9c0e4 Reject asm output constraints that consist of modifiers only.
Fixes PR15759.

llvm-svn: 179756
2013-04-18 13:23:23 +00:00
Benjamin Kramer 06022fc91a Add llvm_unreachable at end of fully covered switch to pacify GCC.
llvm-svn: 179753
2013-04-18 10:44:27 +00:00
Argyrios Kyrtzidis 71c12fb4a3 [Parser] Handle #pragma pack/align inside C structs.
Fixes PR13580. Patch by Serge Pavlov!

llvm-svn: 179743
2013-04-18 01:42:35 +00:00
Richard Trieu e089497121 Switch the note order for -Woverloaded-shift-op-parentheses so that the note
with the silence fix-it comes first.  This is more consistent with the rest
of the warnings in -Wparentheses.

llvm-svn: 179742
2013-04-18 01:04:37 +00:00
Richard Trieu cf2a4c0653 Update the -Wparentheses tests to check that fix-its are in the correct place.
llvm-svn: 179740
2013-04-18 00:56:23 +00:00
Anna Zaks 05139fff42 [analyzer] Tweak getDerefExpr more to track DeclRefExprs to references.
In the committed example, we now see a note that tells us when the pointer
was assumed to be null.

This is the only case in which getDerefExpr returned null (failed to get
the dereferenced expr) throughout our regression tests. (There were multiple
occurrences of this one.)

llvm-svn: 179736
2013-04-18 00:15:15 +00:00
Anna Zaks 1baf545fa6 [analyzer] Improve dereferenced expression tracking for MemberExpr with a dot and non-reference base
llvm-svn: 179734
2013-04-17 23:17:43 +00:00
Bob Wilson fd4f39e893 Add description of -Ofast optimization option to the man page. <rdar://13660458>
llvm-svn: 179733
2013-04-17 22:32:43 +00:00
Anna Zaks 4f59835182 [analyzer] Gain more precision retrieving the right SVal by specifying the type of the expression.
Thanks to Jordan for suggesting the fix.

llvm-svn: 179732
2013-04-17 22:29:51 +00:00
Anna Zaks 54f4d01bd3 [analyzer] Allow TrackConstraintBRVisitor to work when the value it’s tracking is not live in the last node of the path
We always register the visitor on a node in which the value we are tracking is live and constrained. However,
the visitation can restart at a node, later on the path, in which the value is under constrained because
it is no longer live. Previously, we just silently stopped tracking in that case.

llvm-svn: 179731
2013-04-17 22:29:47 +00:00
Argyrios Kyrtzidis 9aca3c61c0 [Modules] Use global index to improve typo correction performance
Typo correction for an unqualified name needs to walk through all of the identifier tables of all modules.
When we have a global index, just walk its identifier table only.

rdar://13425732

llvm-svn: 179730
2013-04-17 22:10:55 +00:00
Nico Weber 7e2da79efa Add support for gcc's spelling of -fcolor-diagnostics.
See http://gcc.gnu.org/onlinedocs/gcc/Language-Independent-Options.html

llvm-svn: 179728
2013-04-17 21:52:44 +00:00
Daniel Dunbar 893f3d54d9 [tests] Only include stdint.h if we are in freestanding mode.
- We shouldn't even try to include stdint.h in hosted mode, as the dependency
   on even parsing a platforms stdint.h might fail for some targets.

llvm-svn: 179723
2013-04-17 21:11:07 +00:00
Fariborz Jahanian 799a4036da [document parsing]: When tag declaration (but not definition!)
is part of the decl-specifier-seq of some other declaration, 
it doesn't get comment. // rdar://12390371

llvm-svn: 179722
2013-04-17 21:05:20 +00:00
Chad Rosier efd87c8f4b Test cases for r179719.
llvm-svn: 179720
2013-04-17 21:02:39 +00:00
Jordan Rose 111c4a6b69 Fix off-by-one error in #pragma clang system_header.
The system_header pragma (from GCC) is implemented using line notes in the
source manager. However, a line note's line number specifies the number
not for the current line, but for the next line. This was making all
line numbers appear off by one after the pragma.

Reported by Andy Gibbs, uncovered during r179677.

llvm-svn: 179709
2013-04-17 19:09:18 +00:00
Richard Smith 3c626edda2 PR15755: don't drop parameter packs when dropping parameters with default
arguments in the formation of a candidate set of inheriting constructors.

llvm-svn: 179708
2013-04-17 19:00:52 +00:00
Benjamin Kramer 892cb486a4 Sema: Remove unused variable.
llvm-svn: 179701
2013-04-17 18:05:23 +00:00
Jordan Rose add14263ea [analyzer] Don't warn for returning void expressions in void blocks.
This was slightly tricky because BlockDecls don't currently store an
inferred return type. However, we can rely on the fact that blocks with
inferred return types will have return statements that match the inferred
type.

<rdar://problem/13665798>

llvm-svn: 179699
2013-04-17 18:03:48 +00:00
Alexander Kornienko 9e90b62e01 Unified token breaking logic: support for line comments.
Summary:
Added BreakableLineComment, moved common code from
BreakableBlockComment to newly added BreakableComment. As a side-effect of the
rewrite, found another problem with escaped newlines and had to change
code which removes trailing whitespace from line comments not to break after
this patch.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D682

llvm-svn: 179693
2013-04-17 17:34:05 +00:00
Eric Christopher 01c5f028ff Revert r179671 and just pass a triple to the test for a platform with known
TLS support.

llvm-svn: 179692
2013-04-17 17:27:51 +00:00
Richard Smith 3cb4c63073 DR974: Lambdas can have default arguments.
llvm-svn: 179688
2013-04-17 16:25:20 +00:00
Andy Gibbs 9c2ccd622f Implemented #pragma GCC warning/error in the same mould as #pragma message.
llvm-svn: 179687
2013-04-17 16:16:16 +00:00
Manuel Klimek 21ae2519bb This corrects problems in the LibASTMatchers tutorial.
Patch by Jochen Eisinger.

llvm-svn: 179683
2013-04-17 15:02:12 +00:00
Timur Iskhodzhanov 8fe501dc0f Set SRet flags properly in '-cxx-abi microsoft'.
Also,
- abstract out the indirect/in memory/in registers decisions into the CGCXXABI
- fix handling of empty struct arguments for '-cxx-abi microsoft'
- add/fix tests

llvm-svn: 179681
2013-04-17 12:54:10 +00:00
Douglas Gregor 19a41f161b Fix PR15291: noreturn adjustment in overload resolution for function templates, from Alexander Zinenko!
llvm-svn: 179680
2013-04-17 08:45:07 +00:00
Andy Gibbs fcc699aee8 Extended VerifyDiagnosticConsumer to also verify source file for diagnostic.
VerifyDiagnosticConsumer previously would not check that the diagnostic and
its matching directive referenced the same source file.  Common practice was
to create directives that referenced other files but only by line number,
and this led to problems such as when the file containing the directive
didn't have enough lines to match the location of the diagnostic in the
other file, leading to bizarre file formatting and other oddities.

This patch causes VerifyDiagnosticConsumer to match source files as well as
line numbers.  Therefore, a new syntax is made available for directives, for
example:

// expected-error@file:line {{diagnostic message}}

This extends the @line feature where "file" is the file where the diagnostic
is generated.  The @line syntax is still available and uses the current file
for the diagnostic.  "file" can be specified either as a relative or absolute
path - although the latter has less usefulness, I think!  The #include search
paths will be used to locate the file and if it is not found an error will be
generated.

The new check is not optional: if the directive is in a different file to the
diagnostic, the file must be specified.  Therefore, a number of test-cases
have been updated with regard to this.

This closes out PR15613.

llvm-svn: 179677
2013-04-17 08:06:46 +00:00
Daniel Jasper dd77743af8 Small improvements to clang-format documentation and integration
scripts.

llvm-svn: 179676
2013-04-17 07:55:02 +00:00
Eric Christopher 6ddf14db89 Add a bit of a hack to deal with a failing testcase on darwin10 bots.
We currently emit an error message when you try to use thread local
storage on targets that don't support it and testing C++11 thread
locals will trip this. We don't want to xfail the test for all darwin
hosts so add a quick hack to check for darwin10 and disable the
test based on that. Only checking darwin10 because anything earlier
is really old and I don't have a list of what other hosts don't
support tls handy.

Alternate suggestions welcome!

llvm-svn: 179671
2013-04-17 07:19:56 +00:00
Eric Christopher ddc6923a12 Remove dead option.
llvm-svn: 179670
2013-04-17 07:19:52 +00:00
Richard Trieu fe042e6aab Add warning group -Woverloaded-shift-op-parentheses to -Wparentheses. This
will fire on code such as:

  cout << x == 0;

which the compiler will intrepret as

  (cout << x) == 0;

This warning comes with two fixits attached to notes, one for parentheses to
silence the warning, and another to evaluate the comparison first.

llvm-svn: 179662
2013-04-17 02:12:45 +00:00
Argyrios Kyrtzidis a077279184 Correct the range returned by ParmVarDecl::getSourceRange(), for parameters in ObjC methods with postfix types.
For a parameter in a method like this:

-(int)methodWithFn:(void (*)(int *p))fn;

we would return the source range of the type and not include the parameter name.

Fixes rdar://13668626.

llvm-svn: 179660
2013-04-17 01:56:48 +00:00
Jordan Rose 406503a0f9 [analyzer] Merge C++ status page into Open Projects.
Also, add a few random extra open projects.

Most of C++ support is done; we don't need the status page anymore. We're
hoping that the C++-related open projects are the only major pieces of
functionality we don't model at this point.

llvm-svn: 179659
2013-04-17 00:57:39 +00:00
Jordan Rose 4e225c0646 [analyzer] Open Projects: grammar, phrasing, formatting
llvm-svn: 179658
2013-04-17 00:57:24 +00:00
Chad Rosier eb294538c3 Test cases for r179655.
llvm-svn: 179656
2013-04-17 00:12:09 +00:00
Argyrios Kyrtzidis c2091d5d71 Use the extra info in global method pool to speed up looking for ObjC overridden methods.
When we are in a implementation, we check the global method pool whether there were category
methods with the same selector. If there were none (common case) we don't need to do lookups for
overridden methods again.

Note that for an interface method (if we don't encounter its implementation), it is considered that
it overrides methods that were declared before it, not for category methods introduced after it.

This is tradeoff in favor of performance, since it is expensive to do lookups in case there was a
category, and moving the global method pool to ASTContext (so we can check it) would increase complexity.

rdar://13508196

llvm-svn: 179654
2013-04-17 00:09:08 +00:00
Argyrios Kyrtzidis c8e700848c In ASTContext::getOverriddenMethods, call overridden_methods_begin/overridden_methods_end directly.
This avoids unnecessary Decl::getASTContext() invocations.

llvm-svn: 179653
2013-04-17 00:09:03 +00:00
Argyrios Kyrtzidis d3da6e01e8 Enhance the ObjC global method pool to record whether there were 0, 1, or >= 2 methods (with a particular selector) inside categories.
This is done by extending ObjCMethodList (which is only used by the global method pool) to have 2 extra bits of information.
We will later take advantage of this info in global method pool for the overridden methods calculation.

llvm-svn: 179652
2013-04-17 00:08:58 +00:00
Michael Gottesman 6cd3e560fd [6/6] ARM Neon Intrinsic Tablegen Test Generator.
Added GenerateChecksForIntrinsic method to generate FileCheck patterns
for generated arm neon tests.

Reviewed by Bob Wilson.

llvm-svn: 179644
2013-04-16 23:00:26 +00:00
Michael Gottesman 1d712fe52d [5/6] ARM Neon Intrinsic Tablegen Test Generator.
Changed the test generation target cpu type from cortex-a9 to swift.

Reviewed by Bob Wilson.

llvm-svn: 179642
2013-04-16 22:55:01 +00:00
Michael Gottesman d44c8f7d20 [4/6] ARM Neon Intrinsic Tablegen Test Generator.
Added code to NeonEmitter::runTests so that GenTest gets all of the needed
arguments to invoke the neon test generation methods.

Reviewed by Bob Wilson.

llvm-svn: 179640
2013-04-16 22:48:52 +00:00
John McCall 568d4100e7 Don't propagate around TargetOptions in IR-gen; we don't use it.
Patch by Stephen Lin!

llvm-svn: 179639
2013-04-16 22:48:20 +00:00
John McCall c8e0170578 Standardize accesses to the TargetInfo in IR-gen.
Patch by Stephen Lin!

llvm-svn: 179638
2013-04-16 22:48:15 +00:00
John McCall 0d9dd73847 Don't put too much thought into whether or not to capture a
type-dependent intermediate result in a postfix ++ pseudo-
object operation.

Test case by Tong Shen.

llvm-svn: 179637
2013-04-16 22:32:04 +00:00
Michael Gottesman 095c58f1c4 [3/6] ARM Neon Intrinsic Tablegen Test Generator.
Refactored out the method InstructionTypeCode from MangleName for use in
further patches which perform neon tablegen test generation.

Reviewed by Bob Wilson.

llvm-svn: 179636
2013-04-16 22:07:30 +00:00
Ted Kremenek 20871cd6b9 Make test portable.
llvm-svn: 179635
2013-04-16 21:59:21 +00:00
Ted Kremenek 8671acba95 [analyzer] Add experimental option "leak-diagnostics-reference-allocation".
This is an opt-in tweak for leak diagnostics to reference the allocation
site if the diagnostic consumer only wants a pithy amount of information,
and not the entire path.

This is a strawman enhancement that I expect to see some experimentation
with over the next week, and can go away if we don't want it.

Currently it is only used by RetainCountChecker, but could be used
by MallocChecker if and when we decide this should stay in.

llvm-svn: 179634
2013-04-16 21:44:22 +00:00
Anna Zaks 4082c43d06 [analyzer] Add Open Projects page to the analyzer website
llvm-svn: 179631
2013-04-16 21:37:04 +00:00
John McCall b7ff6db3b1 objc_autoreleasePoolPop() can throw if a -dealloc does.
Model it as throwing so that the exception can be caught.

This is generally not expected to have significant code-size
impact because the contents of the @autoreleasepool block
are very likely to contain a call, very likely at the same
cleanup level as the @autoreleasepool itself.

rdar://13660038

llvm-svn: 179630
2013-04-16 21:29:40 +00:00
Fariborz Jahanian d17c3dc60f Trying fixing test to make buildbot happy again.
llvm-svn: 179629
2013-04-16 21:19:17 +00:00
Michael Gottesman fc89cc2a91 [2/6] ARM Neon Intrinsic Tablegen Test Generator.
This patch causes OpInst records to be silently identified with their Non-Op
inst counterparts so that the same test generation infrastructure can be used to
generate tests.

Reviewed by Bob Wilson.

llvm-svn: 179628
2013-04-16 21:18:42 +00:00
Ted Kremenek eb5f089ce1 Properly sort list.
llvm-svn: 179627
2013-04-16 21:10:09 +00:00
Ted Kremenek 8a28295895 Factor CheckerManager to be able to pass AnalyzerOptions to checkers
during checker registration.  There are no immediate clients of this,
but this provides a way for checkers to query the options table
at startup instead.

llvm-svn: 179626
2013-04-16 21:10:05 +00:00
Ted Kremenek 3296ff13db Remove unused "getConfig()" method. A new way is to have high-level
APIs that access the configuration table without clients reasoning
about the string table.  The string table is an implementation
detail.

llvm-svn: 179625
2013-04-16 21:10:02 +00:00
Michael Gottesman 43844b5459 [1/6] ARM Neon Intrinsic Tablegen Test Generator.
Changes necessary to arm_neon.td for the generation of Neon tests.

This is the first of six patches to add to the arm neon tablegen
generator the capability of generating tests to verify that the various
ARM intrinsics are implemented properly.

The changes include such items as:
  1. Adding attributes to the Inst record so that additional metadata that is only
     needed for the tests can be specified in TableGen.
  2. Adding wrapper classes for operator (i.e. ``Op'') intrinsics which before
     were simply notates as Inst. This allows us to classify what sort of test
     to generate for said intrinsic and further since the classes do not effect
     the behavior of the Inst base class, allow for normal functioning.

Reviewed by Bob Wilson.

llvm-svn: 179624
2013-04-16 21:08:04 +00:00
Tareq A. Siraj 6dfa25a19f Sema for Captured Statements
Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic
analysis. Currently captures all variables by reference.

TODO: templates

Author: Ben Langmuir <ben.langmuir@intel.com>

Differential Revision: http://llvm-reviews.chandlerc.com/D433

llvm-svn: 179618
2013-04-16 19:37:38 +00:00
Benjamin Kramer b10e615c44 rewrite-includes: Rewrite __has_include(_next) to get rid of a host dependency.
This broke e.g. compiling a crash report from a glibc system on Darwin. Sadly,
the implementation had to game the lexer a lot as we're not using a real
preprocessor here. It also doesn't handle special cases like arbitrary macros in
__has_include, but since this macro isn't common outside of clang's headers we
can get away with that.

Fixes PR14422.

Differential Revision: http://llvm-reviews.chandlerc.com/D594

llvm-svn: 179616
2013-04-16 19:08:41 +00:00
Tareq A. Siraj 24110cc733 Implement CapturedStmt AST
CapturedStmt can be used to implement generic function outlining as described in
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-January/027540.html.

CapturedStmt is not exposed to the C api.

Serialization and template support are pending.

Author: Wei Pan <wei.pan@intel.com>

Differential Revision: http://llvm-reviews.chandlerc.com/D370

llvm-svn: 179615
2013-04-16 18:53:08 +00:00
Tareq A. Siraj 0de0dd4923 Parser support for #pragma clang __debug captured
This patch implements parsing ‘#pragma clang __debug’ as a first step for
implementing captured statements. Captured statements are a mechanism for
doing outlining in the AST.
see http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-January/027540.html.

Currently returns StmtEmpty

Author: Andy Zhang <andy.zhang@intel.com>

Differential Revision: http://llvm-reviews.chandlerc.com/D369

llvm-svn: 179614
2013-04-16 18:41:26 +00:00
Daniel Dunbar e246fbe40b [Modules] Convert module specific -fno-modules-autolink into -fno-autolink.
- There is no reason to have a modules specific flag for disabling
   autolinking. Instead, convert the existing flag into -fno-autolink (which
   should cover other autolinking code generation paths like #pragmas if and
   when we support them).

llvm-svn: 179612
2013-04-16 18:21:19 +00:00
Fariborz Jahanian f177c035b7 modify test to try to make buildbot happy.
llvm-svn: 179606
2013-04-16 17:18:37 +00:00
Jyotsna Verma e90fe76abd Remove setjmp.h header file from Sema/return.c test and include necessary
declarations explicitly in the test.

llvm-svn: 179604
2013-04-16 16:10:38 +00:00
Douglas Gregor 012efe22bc Fix PR4296: Add parser detection/error recovery for nested functions, from Serve Pavlov!
llvm-svn: 179603
2013-04-16 16:01:32 +00:00
Jyotsna Verma abd62140c0 Use -emit-llvm for the following tests to stop them from failing for Hexagon:
CodeGenCXX/vtable-debug-info.cpp
Driver/objc++-cpp-output.mm
Driver/objc-cpp-output.m

llvm-svn: 179602
2013-04-16 15:55:41 +00:00
Douglas Gregor 8997dac30a Fix handling of atomic shift operations, from Serge Pavlov.
llvm-svn: 179600
2013-04-16 15:41:08 +00:00
Fariborz Jahanian d1b6778e69 Objective-C IRGen. Use llvm::WeakVH
for caching couple of global symbols used
for generation of CF/NS string meta-data
so they are not released prematuely in certain
corner cases. // rdar:// 13598026.
Reviewed by John M.

llvm-svn: 179599
2013-04-16 15:25:39 +00:00
Rafael Espindola 3c4a251ce8 Suppress unused warning on static inline function template specializations.
Patch by Halfdan Ingvarsson!

llvm-svn: 179598
2013-04-16 15:21:30 +00:00
Jakob Stoklund Olesen 4dda152d14 Add support for sparcv9 targets.
The SPARC v8 and SPARC v8 architectures are very similar, so use a base
class to share most information between them.

Include operating systems with known SPARC v9 ports.

Also fix two issues with the SPARC v8 data layout string: SPARC v8 is a
big endian target with a 64-bit aligned stack.

llvm-svn: 179596
2013-04-16 15:17:49 +00:00
John McCall 5e77d76c95 Basic support for Microsoft property declarations and
references thereto.

Patch by Tong Shen!

llvm-svn: 179585
2013-04-16 07:28:30 +00:00
Rafael Espindola 9dd86de771 Correctly propagate the storage class to function template instantiations.
This fixes pr15753. This is another case of the fuzzy definition of the
"as written" storage class of an instantiation.

llvm-svn: 179581
2013-04-16 02:29:15 +00:00
Anna Zaks e4cfcd4e41 [analyzer] Improve the malloc checker stack hint message
llvm-svn: 179580
2013-04-16 00:22:55 +00:00
Anna Zaks 8591aa78db [analyzer] Do not crash when processing binary "?:" in C++
When computing the value of ?: expression, we rely on the last expression in
the previous basic block to be the resulting value of the expression. This is
not the case for binary "?:" operator (GNU extension) in C++. As the last
basic block has the expression for the condition subexpression, which is an
R-value, whereas the true subexpression is the L-value.

Note the operator evaluation just happens to work in C since the true
subexpression is an R-value (like the condition subexpression). CFG is the
same in C and C++ case, but the AST nodes are different, which the LValue to
Rvalue conversion happening after the BinaryConditionalOperator evaluation.

Changed the logic to only use the last expression from the predecessor only
if it matches either true or false subexpression. Note, the logic needed
fortification anyway: L and R were passed but not even used by the function.

Also, change the conjureSymbolVal to correctly compute the type, when the
expression is an LG-value.

llvm-svn: 179574
2013-04-15 22:38:07 +00:00
Anna Zaks 7460deb15d [analyzer] Add pretty printing to CXXBaseObjectRegion.
llvm-svn: 179573
2013-04-15 22:38:04 +00:00
Anna Zaks e2e8ea62df [analyzer] Address code review for r179395
Mostly refactoring + handle the nested fields by printing the innermost field only.

llvm-svn: 179572
2013-04-15 22:37:59 +00:00
Anna Zaks 0881b8882e [analyzer] Add more specialized error messages for corner cases as per Jordan's code review for r179396
llvm-svn: 179571
2013-04-15 22:37:53 +00:00
Daniel Jasper 1b8e76f14e Break after multiline parameters.
We do this in general, but missed a few cases.

Before:
void aaaaaaaaaaaaaaaaaaaaaaa(
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbb bbbb);

After:
void aaaaaaaaaaaaaaaaaaaaaaa(
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
    bbbb bbbb);

llvm-svn: 179570
2013-04-15 22:36:37 +00:00
Jordan Rose 27ae8a2800 [analyzer] Don't assert on a temporary of pointer-to-member type.
While we don't do anything intelligent with pointers-to-members today,
it's perfectly legal to need a temporary of pointer-to-member type to, say,
pass by const reference. Tweak an assertion to allow this.

PR15742 and PR15747

llvm-svn: 179563
2013-04-15 22:03:38 +00:00
Joey Gouly 75e81e645d Remove some dead code that has not been used since 2010.
llvm-svn: 179558
2013-04-15 21:13:33 +00:00
Jordan Rose 2820e3dfca [analyzer] Be lazy about struct/array global invalidation too.
Structs and arrays can take advantage of the single top-level global
symbol optimization (described in the previous commit) just as well
as scalars.

No intended behavioral change.

llvm-svn: 179555
2013-04-15 20:39:48 +00:00
Jordan Rose fa80736bca [analyzer] Re-enable using global regions as a symbolic base.
Now that we're invalidating global regions properly, we want to continue
taking advantage of a particular optimization: if all global regions are
invalidated together, we can represent the bindings of each region with
a "derived region value" symbol. Essentially, this lazily links each
global region with a single symbol created at invalidation time, rather
than binding each region with a new symbolic value.

We used to do this, but haven't been for a while; the previous commit
re-enabled this code path, and this handles the fallout.

<rdar://problem/13464044>

llvm-svn: 179554
2013-04-15 20:39:45 +00:00
Jordan Rose 577749a337 [analyzer] Properly invalidate global regions on opaque function calls.
This fixes a regression where a call to a function we can't reason about
would not actually invalidate global regions that had explicit bindings.

  void test_that_now_works() {
    globalInt = 42;
    clang_analyzer_eval(globalInt == 42); // expected-warning{{TRUE}}

    invalidateGlobals();
    clang_analyzer_eval(globalInt == 42); // expected-warning{{UNKNOWN}}
  }

This has probably been around since the initial "cluster" refactoring of
RegionStore, if not longer.

<rdar://problem/13464044>

llvm-svn: 179553
2013-04-15 20:39:41 +00:00
Jordan Rose d02adbf03c [analyzer] Tests: move system functions into system header simulator files.
Some checkers ascribe different behavior to functions declared in system
headers, so when working with standard library functions it's probably best
to always have them in a standard location.

Test change only (no functionality change), but necessary for the next commit.

llvm-svn: 179552
2013-04-15 20:39:37 +00:00
Argyrios Kyrtzidis fe7a59d9c2 Revert "Speed-up ObjCMethodDecl::getOverriddenMethods()."
This reverts commit r179436.

Due to caching, it was possible that we could miss overridden methods that
were introduced by categories later on.

Along with reverting the commit I also included a test case that would have caught this.

llvm-svn: 179547
2013-04-15 18:47:22 +00:00
Rafael Espindola 05976798dc Remove XFAIL now that the test is standalone.
llvm-svn: 179538
2013-04-15 17:06:15 +00:00
Argyrios Kyrtzidis 7134bb4531 [PCH/test] Make test/PCH/cxx-typeid.cpp self-contained by including the relevant standard library declarations
instead of depending on a system header inclusion.

llvm-svn: 179537
2013-04-15 16:52:57 +00:00
Alexander Kornienko c3c8affc06 Fix unused variable warning with assertions disabled.
llvm-svn: 179531
2013-04-15 15:47:34 +00:00
Rafael Espindola 3f532c5c38 Use llvm::sys::IsBigEndianHost.
llvm-svn: 179529
2013-04-15 15:10:35 +00:00
Alexander Kornienko cb45bc1861 Unified token breaking logic for strings and block comments.
Summary:
Both strings and block comments are broken into lines in
breakProtrudingToken. Logic specific for strings or block comments is abstracted
in implementations of the BreakToken interface. Among other goodness, this
change fixes placement of backslashes after a block comment inside a
preprocessor directive (see removed FIXMEs in unit tests).

The code is far from being polished, and some parts of it will be changed for
line comments support.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D665

llvm-svn: 179526
2013-04-15 14:28:00 +00:00
Timur Iskhodzhanov 088b603989 Add a missing space
llvm-svn: 179525
2013-04-15 14:16:31 +00:00
Rafael Espindola 5bddd6a92a Remove hasExternalLinkageUncached.
It was being used correctly, but it is a very dangerous API to have around.
Instead, move the logic from the filtering to when we are deciding if we should
link two decls.

llvm-svn: 179523
2013-04-15 12:49:13 +00:00
Rafael Espindola 29cda59a9d Fix the storage class of method instantiations.
We keep the "as written" storage class, but that is a fuzzy concept for
instantiations. With this patch instantiations of methods of class templates
now get a storage class that is based on the semantics of isStatic(). With this
can simplify isStatic() itself.

llvm-svn: 179521
2013-04-15 12:38:20 +00:00
Tim Northover 737889ded7 Remove reference to MSVC only building X86 backend.
This is no longer true.

llvm-svn: 179519
2013-04-15 11:55:27 +00:00
Richard Smith 5990db62f6 Local thread_local variables are implicitly 'static'. (This doesn't apply to _Thread_local nor __thread.)
llvm-svn: 179517
2013-04-15 08:33:22 +00:00
Richard Smith 774672e943 Properly check for a constant initializer for a thread-local variable.
llvm-svn: 179516
2013-04-15 08:07:34 +00:00
Richard Smith a8f52c8d88 Add triple to another test.
llvm-svn: 179515
2013-04-15 08:02:05 +00:00
Richard Smith 643a2869b3 Add triples to these tests since they're now using TLS, which isn't available on all targets.
llvm-svn: 179514
2013-04-15 08:00:15 +00:00
Nadav Rotem 6a0dd6b78c Add a new flag -vectorize-slp-aggressive to enable Hals BB vectorizer.
llvm-svn: 179507
2013-04-15 05:38:41 +00:00
Nadav Rotem 0a2604daab Rename the slp-vectorizer clang/llvm flags. No functionality change.
llvm-svn: 179506
2013-04-15 04:57:18 +00:00
Dmitri Gribenko 6e06e04ec1 Comment command table: use inheritance instead of duplicating code
llvm-svn: 179501
2013-04-15 02:31:50 +00:00
Richard Smith dbf74baee5 CodeGen support for function-local static thread_local variables with
non-constant constructors or non-trivial destructors. Plus bugfixes for
thread_local references bound to temporaries (the temporaries themselves are
lifetime-extended to become thread_local), and the corresponding case for
std::initializer_list.

llvm-svn: 179496
2013-04-14 23:01:42 +00:00
Rafael Espindola e45f58d8a9 Removed #if 0 code that doesn't compiled if uncommented.
llvm-svn: 179495
2013-04-14 22:08:07 +00:00
Richard Smith 6ea1a4d1dc Diagnose if a __thread or _Thread_local variable has a non-constant initializer
or non-trivial destructor.

llvm-svn: 179491
2013-04-14 20:11:31 +00:00
Anna Zaks 1ebded0a11 [analyzer] Add a link to the Building a Checker in 24 Hours talk to the developer manual
llvm-svn: 179490
2013-04-14 18:36:51 +00:00
Simon Atanasyan 607776140b [Mips] Support -mmicromips / -mno-micromips command line options.
llvm-svn: 179489
2013-04-14 14:07:51 +00:00
Simon Atanasyan f00872479c [Mips] Fix indentation.
llvm-svn: 179488
2013-04-14 14:07:41 +00:00
Simon Atanasyan 82eec3aeba [Mips] Follow-up to r179481. Reduce code duplication. Use
AddTargetFeature() routine to handle -msingle-float / -mdouble-float
options.

llvm-svn: 179487
2013-04-14 14:07:36 +00:00
Simon Atanasyan 1607191e66 [Mips] Follow-up to r179481. Consider "single-float" as a separate
independent of float ABI feature in the MipsTargetInfoBase class.

llvm-svn: 179486
2013-04-14 14:07:30 +00:00
Rafael Espindola 50ba983d25 Add driver support for fedora 18 on ARM.
llvm-svn: 179484
2013-04-14 10:14:21 +00:00
John McCall ad327cd214 Handle incompatible redeclarations of library builtins better.
Invalid redeclarations of valid explicit declarations shouldn't
take the same path as redeclarations of implicit declarations,
and invalid local extern declarations shouldn't foul things up
for everybody else.

llvm-svn: 179482
2013-04-14 08:50:55 +00:00
Simon Atanasyan 512dc38f81 [Mips] Remove "single" from the list of valid MIPS float ABI names. Add
two new options –msingle-float and –mdouble-float. These options can be
used simultaneously with float ABI selection options (-mfloat-abi,
-mhard-float, -msoft-float). They mark whether a floating-point
coprocessor supports double-precision operations.

llvm-svn: 179481
2013-04-14 08:37:15 +00:00
Rafael Espindola 4f16ebfb30 Simplify test so that it is more portable.
I have checked that the test still fails when the "|| !P.isRegularFile()" from
the original patch is removed.

llvm-svn: 179464
2013-04-13 22:26:02 +00:00
Simon Atanasyan e64a2b37a3 Remove duplicated comment.
llvm-svn: 179454
2013-04-13 06:43:15 +00:00
Richard Smith fd3834f7a1 Annotate flavor of TLS variable (statically or dynamically initialized) onto the AST.
llvm-svn: 179447
2013-04-13 02:43:54 +00:00
Richard Smith f21c9617f8 Use MapVector rather than simulating it.
llvm-svn: 179438
2013-04-13 01:28:18 +00:00
Argyrios Kyrtzidis 53a6558771 Speed-up ObjCMethodDecl::getOverriddenMethods().
Use an newly introduce ASTContext::getBaseObjCCategoriesAfterInterface() which caches its
results instead of re-calculating the categories multiple times.

llvm-svn: 179436
2013-04-13 01:04:01 +00:00
Argyrios Kyrtzidis 37613a9c6f Introduce SourceManager::getDecomposedIncludedLoc, that returns the "included/expanded in" decomposed location of the given FileID.
The main benefit is to speed-up SourceManager::isBeforeInTranslationUnit which is common to query
the included/expanded location of the same FileID multiple times.

llvm-svn: 179435
2013-04-13 01:03:57 +00:00
Richard Smith 6da24a2e8b Give this test a triple so that its use of thread_local doesn't make it fail on the MSVC bot.
llvm-svn: 179432
2013-04-13 00:34:48 +00:00
John McCall a4da323ee0 Don't replace an existing decl in the scope chains with its
local-extern redeclaration;  type refinements, default arguments,
etc. must all be locally scoped.

rdar://13535367

llvm-svn: 179430
2013-04-13 00:20:21 +00:00
Daniel Dunbar 50b8b5507b Headers: Don't try to use RSIZE_MAX unless we are freestanding.
- We don't want to depend on the platforms stdint.h.

llvm-svn: 179429
2013-04-12 23:41:08 +00:00
Anton Yartsev 7af0aa86dd [analyzer] Enable NewDelete checker if NewDeleteLeaks checker is enabled.
llvm-svn: 179428
2013-04-12 23:25:40 +00:00
Daniel Dunbar 95f1de3de5 Headers: Add support for ISO9899:2011 rsize_t.
llvm-svn: 179427
2013-04-12 23:24:56 +00:00
Anton Yartsev b0e284824f NewDeleteLeaks is a subchecker of NewDelete checker; it is tested in NewDelete-checker-test.cpp
llvm-svn: 179426
2013-04-12 23:18:46 +00:00
Richard Smith b4a9e86877 Parsing support for thread_local and _Thread_local. We give them the same
semantics as __thread for now.

llvm-svn: 179424
2013-04-12 22:46:28 +00:00
Richard Smith 2362829734 tl;dr: Teach Clang to work around g++ changing its workaround to glibc's
implementation of C99's attempt to control the C++ standard. *sigh*


The C99 standard says that certain macros in <stdint.h>, such as SIZE_MAX,
should not be defined when the header is included in C++ mode, unless
__STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are defined. The C++11 standard
says "Thanks, but no thanks" and C11 removed this rule, but various C library
implementations (such as glibc) follow C99 anyway.

g++ prior to 4.8 worked around the C99 / glibc behavior by defining
__STDC_*_MACROS in <cstdint>, which was incorrect, because <stdint.h> is
supposed to provide these macros too. g++ 4.8 works around it by defining
__STDC_*_MACROS in its builtin <stdint.h> header.

This change makes Clang act like g++ 4.8 in this regard: our <stdint.h> now
countermands any attempt by the C library to implement the undesired C99 rules,
by defining the __STDC_*_MACROS first. Unlike g++, we do this even in C++98
mode, since that was the intent of the C++ committee, matches the behavior
required in C11, and matches our built-in implementation of <stdint.h>.

llvm-svn: 179419
2013-04-12 22:11:07 +00:00
Douglas Gregor 0b202052b3 <rdar://problem/13643854> Only emit ambiguous-expansion warnings when at least one of the macro definitions comes from a non-system header.
This slightly weakens the heuristic introduced in r178109.

llvm-svn: 179411
2013-04-12 21:00:54 +00:00
Anton Yartsev c92f2c5899 [analyzer] Makes NewDeleteLeaks checker work independently from NewDelete.
llvm-svn: 179410
2013-04-12 20:48:49 +00:00
Bob Wilson 2b59395d0e Define Neon intrinsics as "static inline" to avoid warning. rdar://13108414
We had been defining Neon intrinsics as "static" with always_inline attributes.
If you use them from an extern inline function, you get a warning, e.g.:

static function 'vadd_u8' is used in an inline function with external linkage

This change simply adds the inline keyword to avoid that warning.

llvm-svn: 179406
2013-04-12 20:17:20 +00:00
Chad Rosier 7181ed3346 Add test case for r179403.
llvm-svn: 179404
2013-04-12 19:52:07 +00:00
Chad Rosier 4a3b160d4f Add test case for r179399.
llvm-svn: 179400
2013-04-12 18:54:40 +00:00
Anna Zaks 685e913d71 [analyzer] Print a diagnostic note even if the region cannot be printed.
There are few cases where we can track the region, but cannot print the note,
which makes the testing limited. (Though, I’ve tested this manually by making
all regions non-printable.) Even though the applicability is limited now, the enhancement
will be more relevant as we start tracking more regions.

llvm-svn: 179396
2013-04-12 18:40:27 +00:00
Anna Zaks 6cea7d9e5e [analyzer]Print field region even when the base region is not printable
llvm-svn: 179395
2013-04-12 18:40:21 +00:00
Chad Rosier f8bcfbdd5f Add test case for r179383 and r179393.
llvm-svn: 179394
2013-04-12 18:22:08 +00:00
Jyotsna Verma 2249e9cfa8 Disable following tests for Hexagon:
1) Driver/output-file-is-dir.c - Checks for object file which can't
be created for Hexagon since assembler is unavailable.
2) PCH/cxx-typeid.cpp - 'typeinfo' include file is unavailable for Hexagon.

llvm-svn: 179385
2013-04-12 17:25:02 +00:00
Argyrios Kyrtzidis 25f7af1aeb [libclang] Introduce clang_Location_isInSystemHeader to check if a location resides in a system header.
This is a modified patch provided from Mikołaj Siedlarek!

llvm-svn: 179384
2013-04-12 17:06:51 +00:00
Benjamin Kramer 1b4342dbda Sema: Give a typically small DenseMap some inline capacity.
Also reflow code a bit, no change in functionality.

llvm-svn: 179382
2013-04-12 15:22:25 +00:00
Manuel Klimek 1a18c40468 Revamps structural error detection / handling.
Previously we'd only detect structural errors on the very first level.
This leads to incorrectly balanced braces not being discovered, and thus
incorrect indentation.

This change fixes the problem by:
- changing the parser to use an error state that can be detected
  anywhere inside the productions, for example if we get an eof on
  SOME_MACRO({ some block <eof>
- previously we'd never break lines when we discovered a structural
  error; now we break even in the case of a structural error if there
  are two unwrapped lines within the same line; thus,
  void f() { while (true) { g(); y(); } }
  will still be re-formatted, even if there's missing braces somewhere
  in the file
- still exclude macro definitions from generating structural error;
  macro definitions are inbalanced snippets

llvm-svn: 179379
2013-04-12 14:13:36 +00:00
Daniel Jasper 31f916ac51 Fix clang-format-diff.py script.
llvm-svn: 179377
2013-04-12 13:42:36 +00:00
Daniel Jasper 92a3130509 Provide better emacs integration.
The new emacs integration is simpler, does not save the current file
before reformatting and ensures that emacs does not scroll as a result
of formatting.

Also explicitly set the style in clang-format tests to make them more
robust.

llvm-svn: 179372
2013-04-12 10:12:01 +00:00
Jordan Rose 73b75e01bf [analyzer] Fix grammar in comment.
By Adam Schnitzer!

llvm-svn: 179352
2013-04-12 00:44:24 +00:00
Jordan Rose 526d93c55d [analyzer] Show "Returning from ..." note at caller's depth, not callee's.
Before:
  1. Calling 'foo'
    2. Doing something interesting
    3. Returning from 'foo'
  4. Some kind of error here

After:
  1. Calling 'foo'
    2. Doing something interesting
  3. Returning from 'foo'
  4. Some kind of error here

The location of the note is already in the caller, not the callee, so this
just brings the "depth" attribute in line with that.

This only affects plist diagnostic consumers (i.e. Xcode). It's necessary
for Xcode to associate the control flow arrows with the right stack frame.

<rdar://problem/13634363>

llvm-svn: 179351
2013-04-12 00:44:17 +00:00
Jordan Rose ce781ae6ae [analyzer] Don't emit extra context arrow after returning from an inlined call.
In this code

  int getZero() {
    return 0;
  }

  void test() {
    int problem = 1 / getZero(); // expected-warning {{Division by zero}}
  }

we generate these arrows:

    +-----------------+
    |                 v
    int problem = 1 / getZero();
                  ^   |
                  +---+

where the top one represents the control flow up to the first call, and the
bottom one represents the flow to the division.* It turns out, however, that
we were generating the top arrow twice, as if attempting to "set up context"
after we had already returned from the call. This resulted in poor
highlighting in Xcode.

* Arguably the best location for the division is the '/', but that's a
  different problem.

<rdar://problem/13326040>

llvm-svn: 179350
2013-04-12 00:44:01 +00:00
Rafael Espindola 59d29e9b55 Remove REQUIRES now that r179237 fixed the real problem.
llvm-svn: 179349
2013-04-12 00:32:20 +00:00
Douglas Gregor bc2c1e0e1c Make sure we have the include paths we need
llvm-svn: 179347
2013-04-12 00:23:25 +00:00
Douglas Gregor c9be4734d6 <rdar://problem/13615607> Include SDK version information in the module hash.
This is a Darwin-SDK-specific hash criteria used to identify a
particular SDK without having to hash the contents of all of its
headers. If other platforms have such versioned files, we should add
those checks here.

llvm-svn: 179346
2013-04-12 00:18:53 +00:00
Chad Rosier 766d0dea11 Add test case for r179343.
llvm-svn: 179344
2013-04-11 23:57:29 +00:00
Chad Rosier da0ab491b6 Test case for r179339.
llvm-svn: 179340
2013-04-11 23:37:53 +00:00
John McCall 67517f0bc9 Flail at trying to appease various linuxy buildbots.
llvm-svn: 179338
2013-04-11 23:25:27 +00:00
Manman Ren e1ad74e6fd Struct-path aware TBAA: uniformize scalar tag and path tag.
For struct-path aware TBAA, we used to use scalar type node as the scalar tag,
which has an incompatible format with the struct path tag. We now use the same
format: base type, access type and offset.

We also uniformize the scalar type node and the struct type node: name, a list
of pairs (offset + pointer to MDNode). For scalar type, we have a single pair.
These are to make implementaiton of aliasing rules easier.

llvm-svn: 179335
2013-04-11 23:02:56 +00:00
John McCall 65b8da0623 Fix the driver logic for recent versions of DragonFly.
Patch by John Marino.

llvm-svn: 179334
2013-04-11 22:55:55 +00:00
Chad Rosier 76154684e9 Update test case for r179323.
llvm-svn: 179324
2013-04-11 21:49:48 +00:00
Reid Kleckner dac9342a52 Widen the checks in the ms abi memptr test to work under NDEBUG
llvm-svn: 179311
2013-04-11 19:01:17 +00:00
Jyotsna Verma 2147a3d039 Exclude test30 of Sema/return.c for Hexagon since setjmp.h include file
is unavailable for Hexagon.

llvm-svn: 179310
2013-04-11 18:56:34 +00:00
Bob Wilson 9c8af45a0c Add a new -mimplicit-float option for symmetry with -mno-implicit-float.
This new option is the default, but it is useful to have a flag to override
-mno-implicit-float by putting -mimplicit-float later on the command line.

llvm-svn: 179309
2013-04-11 18:53:25 +00:00
Reid Kleckner 96cf7adce2 Follow Jordan's advice and use {{^}} and {{$}} for this test
This is a better way of ensuring that we match the output of the
rewriter and not the CHECK line.

llvm-svn: 179308
2013-04-11 18:39:10 +00:00
Reid Kleckner 2341ae3856 [ms-cxxabi] Implement member pointer emission and dereferencing
Summary:
Handles all inheritance models for both data and function member
pointers.

Also implements isZeroInitializable() and refactors some of the null
member pointer code.

MSVC supports converting member pointers through virtual bases, which
clang does not (yet?) support.  Implementing that extension is covered
by http://llvm.org/15713

Reviewers: rjmccall

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D613

llvm-svn: 179305
2013-04-11 18:13:19 +00:00