Commit Graph

44609 Commits

Author SHA1 Message Date
Eric Christopher 06cbed4121 Fix order of initialization warning.
llvm-svn: 178255
2013-03-28 18:22:58 +00:00
Anton Yartsev 0578959981 [analyzer] These implements unix.MismatchedDeallocatorChecker checker.
+ Improved display names for allocators and deallocators

The checker checks if a deallocation function matches allocation one. ('free' for 'malloc', 'delete' for 'new' etc.)

llvm-svn: 178250
2013-03-28 17:05:19 +00:00
Rafael Espindola cfbbecd86c These are all simple pointer wrappers. Pass them by value.
llvm-svn: 178247
2013-03-28 16:26:16 +00:00
Anton Yartsev 8b662704dc [analyzer] For now assume all standard global 'operator new' functions allocate memory in heap.
+ Improved test coverage for cplusplus.NewDelete checker.

llvm-svn: 178244
2013-03-28 16:10:38 +00:00
Hal Finkel 1fe8b3dd4b Add support for gcc-compatible -mpopcntd -mno-popcntd PPC options
gcc provides -mpopcntd and -mno-popcntd for controlling the popcntd target
feature; support these options as well.

llvm-svn: 178235
2013-03-28 13:51:36 +00:00
Edwin Vane 584da4043e Updating LibASTMatchersReference
The generator for LibASTMatchersReference.html didn't get run last time
ASTMatchers changes were made. Here are up-to-date docs.

llvm-svn: 178234
2013-03-28 13:50:22 +00:00
Simon Atanasyan 66ceaa439a [Mips] Handle pseudo-target flags '-EL' and '-EB' and properly adjust
toolchain flags for MIPS targets.

llvm-svn: 178232
2013-03-28 11:36:22 +00:00
Hal Finkel 279ca4d608 Add support for gcc-compatible -mmfcrf -mno-mfcrf PPC options
gcc provides -mmfcrf and -mno-mfcrf for controlling what we call
the mfocrf target feature. Also, PPC is now making use of the
static function AddTargetFeature used by the Mips Driver code.

llvm-svn: 178227
2013-03-28 08:38:53 +00:00
Evgeniy Stepanov c3c725aae3 Define __SIZE_MAX__ preprocessor macro.
llvm-svn: 178226
2013-03-28 08:36:54 +00:00
Richard Smith 8ea9720b90 For -Wignored-qualifiers, don't warn on qualifiers which we acquire via a
typedef. Also don't warn on the _Atomic type specifier, just on the _Atomic
type qualifier.

llvm-svn: 178218
2013-03-28 03:27:52 +00:00
Richard Smith 8bff9616ef Teach -Wigored-qualifiers about exotic flavors of declarator and the _Atomic type qualifier.
llvm-svn: 178217
2013-03-28 02:51:21 +00:00
David Blaikie 8663941068 Revert "Update debug info test for schema change made to LLVM."
This reverts commit 5035c483b7fcbf0fa2a7afba24fa35a10995d195.

This schema change wasn't necessary after all. I'm going ith a different
solution that will hopefully use space more conservatively.

llvm-svn: 178213
2013-03-28 02:44:15 +00:00
Richard Smith 1e8c3b8c02 Remove outdated FIXME.
llvm-svn: 178211
2013-03-28 01:56:34 +00:00
Richard Smith 8e1ac33ec7 Support C11 _Atomic type qualifier. This is more-or-less just syntactic sugar for the _Atomic type specifier.
llvm-svn: 178210
2013-03-28 01:55:44 +00:00
Richard Smith 89b466c603 Fold together the two implementations of 6.7.3p2 in SemaType. Fix two bugs, each of which was only present in one version:
* Give the right diagnostic for 'restrict' applied to a non-pointer, non-reference type.
 * Don't reject 'restrict' applied indirectly to an Objective-C object pointer type (eg, through template instantiation).

llvm-svn: 178200
2013-03-28 00:03:10 +00:00
Argyrios Kyrtzidis c36633c47a [Parser] Don't code-complete twice.
When we are consuming the current token just to enter a new token stream, we push
the current token in the back of the stream so that we get it again.

Unfortunately this had the effect where if the current token is a code-completion one,
we would code-complete once during consuming it and another time after the stream ended.

Fix this by making sure that, in this case, ConsumeAnyToken() will consume a code-completion
token without invoking code-completion.

rdar://12842503

llvm-svn: 178199
2013-03-27 23:58:17 +00:00
Richard Smith deec07403c Don't reject __restrict applied to a dependent type; it might instantiate to a pointer or reference type.
llvm-svn: 178198
2013-03-27 23:36:39 +00:00
Bill Wendling 55ab0c5438 Simplify test to use a count for the number of notes expected.
llvm-svn: 178196
2013-03-27 23:26:09 +00:00
Richard Smith 2b01d5089b UBSan: Don't diagnose inf/nan conversions between floating-point types. It's far from clear whether these have undefined behavior, and these checks are helping no-one. Keep the double->float overflow warnings, though, since those are useful in practice, even though it's unclear whether such operations have defined behavior.
llvm-svn: 178194
2013-03-27 23:20:25 +00:00
Chad Rosier 459d3ee1dd Remove unnecessary attributes from test case.
llvm-svn: 178188
2013-03-27 21:54:09 +00:00
Chad Rosier a0ef404973 Add a front-end test case for r178186.
llvm-svn: 178187
2013-03-27 21:50:39 +00:00
Fariborz Jahanian 7e1eae004c Fixes a typo in my last patch.
llvm-svn: 178184
2013-03-27 21:33:52 +00:00
Argyrios Kyrtzidis 95aa0b77f2 Revert "[lib/Headers] Define NULL as __DARWIN_NULL when on __APPLE__."
Per feedback by Doug, we should avoid platform-specific implementations
in lib/Headers as much as possible.

This reverts commit r178110.

llvm-svn: 178181
2013-03-27 21:22:45 +00:00
Fariborz Jahanian 84510744d9 Objective-C: Issue more precise warning when user
is accessing 'isa' as an object pointer.
// rdar://13503456. FixIt to follow in another patch.

llvm-svn: 178179
2013-03-27 21:19:25 +00:00
Rafael Espindola fe3107892b Cleanup clang's specializations of simplify_type.
Now that the basic implementation in llvm has been fixed, simplify the
specializations in clang.

llvm-svn: 178173
2013-03-27 19:38:14 +00:00
Chad Rosier 05c71aa745 Update the error handing static functions for r178161.
Part of rdar://13296693

llvm-svn: 178162
2013-03-27 18:28:23 +00:00
Jordan Rose 3503cb3572 [analyzer] Use evalBind for C++ new of scalar types.
These types will not have a CXXConstructExpr to do the initialization for
them. Previously we just used a simple call to ProgramState::bindLoc, but
that doesn't trigger proper checker callbacks (like pointer escape).

Found by Anton Yartsev.

llvm-svn: 178160
2013-03-27 18:10:35 +00:00
Anna Zaks 54417f6d68 [analyzer] Cleanup: only get the PostStmt when we need the underlying Stmt + comment
llvm-svn: 178153
2013-03-27 17:36:01 +00:00
Anna Zaks 22fa6ecc14 [analyzer] Ensure that the node NilReceiverBRVisitor is looking for is not reclaimed
The visitor should look for the PreStmt node as the receiver is nil in the PreStmt and this is the node. Also, tag the nil
receiver nodes with a special tag for consistency.

llvm-svn: 178152
2013-03-27 17:35:58 +00:00
Argyrios Kyrtzidis 0f06b98387 [modules] Make sure enabled diagnostic pragmas inside the module don't affect the translation unit that
imports the module.

Getting diagnostic sections from modules properly working is a fixme.

rdar://13516663

llvm-svn: 178151
2013-03-27 17:17:23 +00:00
Alexander Kornienko fd433365e0 Insert extra new line before access specifiers.
Summary: Insert extra new line before access specifiers.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

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

llvm-svn: 178149
2013-03-27 17:08:02 +00:00
Douglas Gregor bf7fc9c542 <rdar://problem/13509689> Introduce -module-file-info option that provides information about a particular module file.
This option can be useful for end users who want to know why they
ended up with a ton of different variants of the "std" module in their
module cache. This problem should go away over time, as we reduce the
need for module variants, but it will never go away entirely.

llvm-svn: 178148
2013-03-27 16:47:18 +00:00
Rafael Espindola 210de57694 Add const in preparation for a simplify_type change in llvm.
llvm-svn: 178146
2013-03-27 15:37:54 +00:00
Tim Northover c1ec2dbbd2 Add another expected note. Two errors => two notes.
llvm-svn: 178143
2013-03-27 13:50:57 +00:00
Evgeniy Stepanov 8d7d1b5377 Disable ASan/MSan symbolization of reports in tests.
It was using an instrumented symbolizer binary, which is a potential fork bomb.

llvm-svn: 178140
2013-03-27 13:11:46 +00:00
Evgeniy Stepanov dff0255270 Mark comment-to-html-xml-conversion test as XFAIL:msan, in addition to valgrind.
llvm-svn: 178138
2013-03-27 13:05:40 +00:00
Douglas Gregor b0d0aa5cdc <rdar://problem/13317030> Consider using directives when performing unqualified name lookup into declarations contexts represented by the qualified-id but not in the actual scope hierarchy.
llvm-svn: 178136
2013-03-27 12:51:49 +00:00
Alexander Kornienko ffd6d04a43 Split line comments
Summary:
Split line comments that exceed column limit + fixed leading whitespace
handling when splitting block comments.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

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

llvm-svn: 178133
2013-03-27 11:52:18 +00:00
Bill Wendling 953c701b8b Fix testcase to add expected note.
llvm-svn: 178122
2013-03-27 06:45:37 +00:00
Bill Wendling b68b7571a9 Pass the diagnostic in for better error messages.
llvm-svn: 178120
2013-03-27 06:06:26 +00:00
Argyrios Kyrtzidis fff55a028b [lib/Headers] Break the module import cycle between _Builtin_intrinsics.sse and _Builtin_intrinsics.sse2
Module "sse" implicitly exports module "sse2".
This is bad because we also have module "sse2" export module "sse" (as intended) so we end up with a cycle
in the module import graph:
1. sse2 -> (also imports) sse
2. sse -> (also imports) sse2

To eliminate the cycle remove 2.; importing module "sse2" will also import module "sse", but just importing
module "sse" will not also import module "sse2".

rdar://13240552

llvm-svn: 178117
2013-03-27 05:12:34 +00:00
Joao Matos c9523d4f44 Implement compiler intrinsics needed for compatibility with MSVC 2012 <type_traits>.
Patch by me and Ryan Molden.

llvm-svn: 178111
2013-03-27 01:34:16 +00:00
Argyrios Kyrtzidis 0909d3c5ed [lib/Headers] Define NULL as __DARWIN_NULL when on __APPLE__.
This makes it identical with the system definition.

llvm-svn: 178110
2013-03-27 01:25:37 +00:00
Argyrios Kyrtzidis 3a9c42c423 [modules] Before marking the module imported macros as ambiguous, check if this is a case where
the system macro uses a not identical definition compared to a macro from the clang headers.

For example (these come from different modules):
   \#define LONG_MAX __LONG_MAX__ (clang's limits.h)
   \#define LONG_MAX 0x7fffffffffffffffL (system's limits.h)
in which case don't mark them ambiguous to avoid the "ambiguous macro expansion" warning.

llvm-svn: 178109
2013-03-27 01:25:34 +00:00
Argyrios Kyrtzidis 2e2ff1373e Remove IdentifierInfo::setHadMacroDefinition()
It's not used anymore.

llvm-svn: 178108
2013-03-27 01:25:31 +00:00
Argyrios Kyrtzidis 14c61d1421 [PCH/modules] Remove HiddenName::MacroUndef
llvm-svn: 178107
2013-03-27 01:25:28 +00:00
Argyrios Kyrtzidis 6c811411cf [Preprocessor] Remove PPMutationListener.
It's not used anymore.

llvm-svn: 178106
2013-03-27 01:25:24 +00:00
Argyrios Kyrtzidis 09796b9a23 [modules] Re-enable the "ambiguous expansion of macro" warning.
Also update "test/Modules/macros.c" to test modified semantics:
-When there is an ambiguous macro, expand using the latest introduced version, not the first one.
-#undefs in submodules cause the macro to not be exported by that submodule, it doesn't cause
 undefining of macros in the translation unit that imported that submodule.
 This reduces macro namespace interference across modules.

llvm-svn: 178105
2013-03-27 01:25:19 +00:00
Richard Smith 3901dfe431 PR15597: Fix a confusion between the implicit exception specification and the
uninstantiated exception specification when a special member within a class
template is both defaulted and given an exception specification on its first
declaration.

llvm-svn: 178103
2013-03-27 00:22:47 +00:00
Chad Rosier ecafbe6038 If we're unable to create the TargetMachine, then just quit producing the
backend output; there's no need to report a fatal error.  This reverts r178042.
Part of rdar://13295753 and rdar://13401547

llvm-svn: 178102
2013-03-27 00:14:35 +00:00
David Blaikie 2398f30115 Update debug info test for schema change made to LLVM.
This accounts for the addition of another field to DIScopes that will be used
to store a list of DIImportedModules in the future.

llvm-svn: 178100
2013-03-27 00:08:24 +00:00
John McCall f2abe19dbb Make the -Wreinterpret-base-class logic safe against invalid
declarations at any point. Patch by Alexander Zinenko, and
report by Richard Smith.

llvm-svn: 178098
2013-03-27 00:03:48 +00:00
Ted Kremenek 65d635775d Split "incomplete implementation" warnings for ObjC into separate warnings.
Previously all unimplemented methods for a class were grouped under
a single warning, with all the unimplemented methods mentioned
as notes.  Based on feedback from users, most users would like
a separate warning for each method, with a note pointing back to
the original method declaration.

Implements <rdar://problem/13350414>

llvm-svn: 178097
2013-03-27 00:02:21 +00:00
Douglas Gregor 6fa6ab0675 <rdar://problem/13278115> Improve diagnostic when failing to bind an rvalue reference to an lvalue of compatible type.
llvm-svn: 178095
2013-03-26 23:59:23 +00:00
Anna Zaks fb0a6329bd [analyzer] Better test for r178063.
Jordan pointed out that my previously committed test was bogus.

llvm-svn: 178094
2013-03-26 23:58:52 +00:00
Anna Zaks bd8f60d6d1 [analyzer] Make sure IDC works for ‘NSContainer value/key is nil’ checks.
Register the nil tracking visitors with the region and refactor trackNullOrUndefValue a bit.

Also adds the cast and paren stripping before checking if the value is an OpaqueValueExpr
or ExprWithCleanups.

llvm-svn: 178093
2013-03-26 23:58:49 +00:00
David Blaikie 49ae6a7cf8 Remove magic number usage from CGDebugInfo with new DICompositeType::setContainingType
llvm-svn: 178092
2013-03-26 23:47:35 +00:00
Chad Rosier d14757751f [driver] Do not generate crash diagnostics if the compilation command failed
to execute as the crash will surely reoccur while generating the diagnostics.
rdar://13362359

llvm-svn: 178089
2013-03-26 23:41:30 +00:00
Douglas Gregor 45bb4834e9 <rdar://problem/13267210> Ensure that Sema::CompareReferenceRelationship returns consistent results with invalid types.
When Sema::RequireCompleteType() is given a class template
specialization type that then fails to instantiate, it returns
'true'. On subsequent invocations, it can return false. Make sure that
this difference doesn't change the result of
Sema::CompareReferenceRelationship, which is expected to remain stable
while we're checking an initialization sequence.

llvm-svn: 178088
2013-03-26 23:36:30 +00:00
Chad Rosier ab003df656 Remove a FIXME that's not planned to be fixed. We only generated crash
diagnostics for the first failing command.

llvm-svn: 178086
2013-03-26 23:25:41 +00:00
Douglas Gregor 89c0a914ec <rdar://problem/13473493> Handle 'this->' insertion recovery within trailing return types.
llvm-svn: 178081
2013-03-26 22:43:55 +00:00
David Blaikie 2ebf08ecbd Debug Info: remove use of magic numbers to tweak specific debug info metadata fields
llvm-svn: 178079
2013-03-26 22:09:53 +00:00
Anna Zaks b13d21b6e1 [analyzer] Change inlining policy to inline small functions when reanalyzing ObjC methods as top level.
This allows us to better reason about(inline) small wrapper functions.

llvm-svn: 178063
2013-03-26 18:57:58 +00:00
Anna Zaks ea47959c2f [analyzer] micro optimization as per Jordan’s feedback on r177905.
llvm-svn: 178062
2013-03-26 18:57:51 +00:00
NAKAMURA Takumi 719f8584f2 clang/test/CodeGenCXX/debug-info-namespace.cpp: Disable it on non-bash lit for now.
With dosish filename, it misgenerates an improper extra entry.

!1 = metadata !{metadata !"E:\5Cllvm\5Cllvm-project\5Cclang\5Ctest\5CCodeGenCXX/debug-info-namespace.cpp", metadata !"E:\5Cllvm\5Cbuild\5Cninja-win32-vs11\5Ctools\5Cclang\5Ctest\5CCodeGenCXX"}

!8 = metadata !{metadata !"E:\5Cllvm\5Cllvm-project\5Cclang\5Ctest\5CCodeGenCXX\5Cdebug-info-namespace.cpp", metadata !"E:\5Cllvm\5Cbuild\5Cninja-win32-vs11\5Ctools\5Cclang\5Ctest\5CCodeGenCXX"}

!8 is unexpected.

llvm-svn: 178061
2013-03-26 18:57:40 +00:00
Rafael Espindola 609f5d98d4 Remove useGlobalsForAutomaticVariables.
It is unused since pic support went away.

llvm-svn: 178055
2013-03-26 18:41:47 +00:00
Reid Kleckner 6a476082a6 [ms-cxxabi] Give the MS inheritance attributes a base class
Required making a handful of changes to the table generator.  Also adds
an unspecified inheritance attribute.  This opens the path for us to
apply these attributes to C++ records implicitly.

llvm-svn: 178054
2013-03-26 18:30:28 +00:00
Manman Ren a8540819df Fix uninitialized read of CalleeWithThisReturn.
Initialize CalleeWithThisReturn to 0 in the constructor.
Also revert r170815 since checking CalleeWithThisReturn is faster.

PR15598

llvm-svn: 178053
2013-03-26 18:29:15 +00:00
Chad Rosier a96b3ae724 Fix a crasher by reporting a fatal error if we're unable to create the target
machine and one is required.
Part of rdar://13295753

llvm-svn: 178042
2013-03-26 18:01:48 +00:00
Michael Liao 74f4eaf4dc Add PRFCHW intrinsic support
- Add head 'prfchwintrin.h' to define '_m_prefetchw' which is mapped to
  LLVM/clang prefetch builtin
- Add option '-mprfchw' to enable PRFCHW feature and pre-define '__PRFCHW__'
  macro

llvm-svn: 178041
2013-03-26 17:52:08 +00:00
Argyrios Kyrtzidis b6210dff97 [Preprocessor/Modules] Separate the macro directives kinds into their own MacroDirective's subclasses.
For each macro directive (define, undefine, visibility) have a separate object that gets chained
to the macro directive history. This has several benefits:

-No need to mutate a MacroDirective when there is a undefine/visibility directive. Stuff like
 PPMutationListener become unnecessary.
-No need to keep extra source locations for the undef/visibility locations for the define directive object
 (which is the majority of the directives)
-Much easier to hide/unhide a section in the macro directive history.
-Easier to track the effects of the directives across different submodules.

llvm-svn: 178037
2013-03-26 17:17:01 +00:00
Reid Kleckner e7e64d8a7b [ms-cxxabi] Mangle vector types
Summary:
The only vector types a user can pass from MSVC code to clang code are
the ones from *mmintrin.h, so we only have to match the MSVC mangling
for these types.  MSVC mangles the __m128 family of types as tag types,
which we match.  For other vector types, we emit a unique tag type
mangling that won't match anything produced by MSVC.

Reviewers: rjmccall

CC: chandlerc, timurrrr, cfe-commits

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

llvm-svn: 178036
2013-03-26 16:56:59 +00:00
Evgeniy Stepanov 2e7d6cd0ec Fix uninitialized read of CalleeWithThisReturn.
CalleeWithThisReturn can be left initialized if HasThisReturn() is false.
This change reverses the order of checks in EmitFunctionEpilog such that
CalleeWithThisReturn is only examined when it has a meaningful value.

Found with MemorySanitizer.

llvm-svn: 178015
2013-03-26 13:44:29 +00:00
Alexey Samsonov 9d8043b4cc Actually mark ASan-unfriendly test as XFAIL
llvm-svn: 177997
2013-03-26 08:45:29 +00:00
Alexey Samsonov 55b688f062 Add asan/msan to the list of available features in LIT test runner. Mark ASan-unfriendly test as XFAIL.
llvm-svn: 177995
2013-03-26 08:28:18 +00:00
Chandler Carruth 456ab006a4 Manually specify the link dependencies. Turns out that all the work on
LLVMBuild stuff didn't actually provide a single place for dependencies,
it just added a third place.

llvm-svn: 177989
2013-03-26 03:45:48 +00:00
Richard Trieu 8fbd91d445 Handle CXXOperatorCallExpr when checking self referrnce during initialization of
class types.

llvm-svn: 177987
2013-03-26 03:41:40 +00:00
Chandler Carruth b45836a231 The IRReader header is now part of its own library. Update the include
line and the library dependencies to reflect this.

llvm-svn: 177972
2013-03-26 02:25:54 +00:00
Richard Smith b2bfad2355 Remove FIXMEs: these are covered by a core issue which we don't yet implement
(but we happen to get this part right).

llvm-svn: 177958
2013-03-26 01:17:18 +00:00
Richard Smith 7447af48b1 Implement special-case name lookup for inheriting constructors: member
using-declarations with names which look constructor-like are interpreted as
constructor names.

llvm-svn: 177957
2013-03-26 01:15:19 +00:00
Richard Smith 74bb2d2285 Remove some no-op static_casts.
llvm-svn: 177954
2013-03-26 00:54:11 +00:00
Fariborz Jahanian 36b1e5ce82 Objective-C: Property declaration overiding one in
its super class or protocols inherit their 
availability/deprecated attribute. // rdar://13467644

llvm-svn: 177948
2013-03-25 23:59:42 +00:00
NAKAMURA Takumi f759061908 clang/test/Index/crash-recovery-code-complete.c: Mark it as XFAIL:win32 for now.
I know MemoryBuffer might affect this. Still investigating.

llvm-svn: 177946
2013-03-25 23:49:11 +00:00
Douglas Gregor a3890528d6 <rdar://problem/13395022> Strip references when extracting an initializer_list's element type during application of an initialization sequence.
llvm-svn: 177944
2013-03-25 23:47:01 +00:00
Douglas Gregor ea306a14f4 <rdar://problem/13185264> Don't crash when attempting to redundantly initialize a member of an anonymous union.
llvm-svn: 177941
2013-03-25 23:28:23 +00:00
Matt Beaumont-Gay 677ce95a08 Fix layering violation harder.
llvm-svn: 177940
2013-03-25 23:19:32 +00:00
Douglas Gregor c060b4cfa2 <rdar://problem/13358795> Teach CMake to check Subversion version information at build time, not configure time.
llvm-svn: 177939
2013-03-25 23:16:38 +00:00
Ted Kremenek 30b77bf737 Fix testcase.
llvm-svn: 177934
2013-03-25 23:05:40 +00:00
Ted Kremenek cd3d440b82 For printf checking, handle nested typedefs for darwin-specific checking.
Fixes <rdar://problem/13491605>.

llvm-svn: 177931
2013-03-25 22:28:37 +00:00
Douglas Gregor 780420ea4e <rdar://problem/13459871> Allow forward declaration of enums with a fixed underlying type in Objective-C (as well as C++11).
llvm-svn: 177930
2013-03-25 22:22:35 +00:00
Douglas Gregor 5168e70c0c Remove local path from test.
llvm-svn: 177925
2013-03-25 21:52:42 +00:00
Douglas Gregor 37da327c6a Use <time.h> rather than <sys/time.h>
llvm-svn: 177924
2013-03-25 21:51:16 +00:00
Douglas Gregor b0c9201eb9 Use xargs rather than
llvm-svn: 177923
2013-03-25 21:49:54 +00:00
Matt Beaumont-Gay 07544fa55f Fix a layering violation introduced in r177705.
llvm-svn: 177922
2013-03-25 21:32:02 +00:00
Douglas Gregor 1f37dddd57 Use 'touch -t', which both BSD and Linux support.
llvm-svn: 177921
2013-03-25 21:27:57 +00:00
Nick Lewycky 966b19951f Try harder to be signal-safe inside our signal handler. The most prominent behavioural
difference is that we no longer clean the token before emitting it. This fixes a bug where
clang hangs in the middle of crashing because the crash handler calls malloc from inside
a crash that happened inside of free.

llvm-svn: 177919
2013-03-25 21:24:30 +00:00
Douglas Gregor 527b1c95df <rdar://problem/13434605> Periodically prune the module cache so that it does not grow forever.
llvm-svn: 177918
2013-03-25 21:19:16 +00:00
Nick Lewycky 1d9a5d27ba Correct indentation. No functionality change.
llvm-svn: 177916
2013-03-25 21:10:14 +00:00
Bill Wendling c4fc3a2ba5 Emit an error message instead of crashing when dereferencing an incomplete pointer type.
If the ASM statement is dereferencing an incomplete pointer type, issue an error
instead of crashing.
<rdar://problem/12700799>

llvm-svn: 177915
2013-03-25 21:09:49 +00:00
Chad Rosier 651c1839ee IR-gen should not generate an MMX types unless the code is explicitly using MMX
intrinsics.
rdar://13213542

llvm-svn: 177911
2013-03-25 21:00:27 +00:00
Anna Zaks f60f2fb142 [analyzer] Set concrete offset bindings to UnknownVal when processing symbolic offset binding, even if no bindings are present.
This addresses an undefined value false positive from concreteOffsetBindingIsInvalidatedBySymbolicOffsetAssignment.

Fixes PR14877; radar://12991168.

llvm-svn: 177905
2013-03-25 20:43:24 +00:00
Fariborz Jahanian b0d81f8626 Added PR number for failing win64 tests.
llvm-svn: 177886
2013-03-25 18:56:45 +00:00
Daniel Jasper b7fb5e6f4b Re-add clang-format tests to clang/test.
Also now use -strict-whitespace as the tests are confusing otherwise.

llvm-svn: 177853
2013-03-25 09:14:25 +00:00
Anton Yartsev 13df03624b [analyzer] Adds cplusplus.NewDelete checker that check for memory leaks, double free, and use-after-free problems of memory managed by new/delete.
llvm-svn: 177849
2013-03-25 01:35:45 +00:00
Jordan Rose d1d8929370 [analyzer] Teach ConstraintManager to ignore NonLoc <> NonLoc comparisons.
These aren't generated by default, but they are needed when either side of
the comparison is tainted.

Should fix our internal buildbot.

llvm-svn: 177846
2013-03-24 20:25:22 +00:00
Benjamin Kramer ef89ae016d Simplify code. No functionality change.
llvm-svn: 177842
2013-03-24 16:04:55 +00:00
Rafael Espindola 7976446c2c Reject -no-integrated-as on windows.
llvm-svn: 177840
2013-03-24 15:06:53 +00:00
Guy Benyei fb36ede52e Generate metadata to implement the -cl-kernel-arg-info option.
OpenCL 1.2 spec. 5.7.3.

llvm-svn: 177839
2013-03-24 13:58:12 +00:00
Benjamin Kramer 2c923accd6 Don't actually invoke codegen in driver test.
llvm-svn: 177838
2013-03-24 11:30:15 +00:00
Nadav Rotem 1da30944a6 Make clang to mark static stack allocations with lifetime markers to enable a more aggressive stack coloring.
Patch by John McCall with help by Shuxin Yang.
rdar://13115369

llvm-svn: 177819
2013-03-23 06:43:35 +00:00
Bob Wilson a20a1dad7f Revert svn r176894 and r177658.
Changing -ccc-install-dir to affect cc1's resource-dir setting broke our
internal LNT tests. After discussing the situation with Jim, we've decided to
pursue an alternate approach. We really want the resource-dir to be located
relative to clang, even when using -ccc-install-dir, but we're going to
add a fallback setting for the libc++ headers if they don't exist alongside
the compiler.

llvm-svn: 177815
2013-03-23 05:17:59 +00:00
John McCall eff1884274 Under ARC, when we're passing the address of a strong variable
to an out-parameter using the indirect-writeback conversion,
and we copied the current value of the variable to the temporary,
make sure that we register an intrinsic use of that value with
the optimizer so that the value won't get released until we have
a chance to retain it.

rdar://13195034

llvm-svn: 177813
2013-03-23 02:35:54 +00:00
Richard Trieu 3cee413b4a Strip off local qualifiers when converting from RecordType to
TemplateSpecializationType during template type diffing.  This allows the
correct printing of diffing qualifiers on templates.

llvm-svn: 177809
2013-03-23 01:38:36 +00:00
Jordan Rose 8828d356fb [analyzer] Teach constraint managers about unsigned comparisons.
In C, comparisons between signed and unsigned numbers are always done in
unsigned-space. Thus, we should know that "i >= 0U" is always true, even
if 'i' is signed. Similarly, "u >= 0" is also always true, even though '0'
is signed.

Part of <rdar://problem/13239003> (false positives related to std::vector)

llvm-svn: 177806
2013-03-23 01:21:33 +00:00
Jordan Rose 8eca04b24e [analyzer] Loc-Loc operations (subtraction or comparison) produce a NonLoc.
For two concrete locations, we were producing another concrete location and
then casting it to an integer. We should just create a nonloc::ConcreteInt
to begin with.

No functionality change.

llvm-svn: 177805
2013-03-23 01:21:29 +00:00
Jordan Rose b042cc7822 [analyzer] CmpRuns.py: Accept single files as input.
This allows us to compare two direct invocations of the analyzer on a
single source file without having to wrap the output plists in their
own directories.

llvm-svn: 177804
2013-03-23 01:21:26 +00:00
Jordan Rose 59d179e9d2 [analyzer] Also transform "a < b" to "(b - a) > 0" in the constraint manager.
We can support the full range of comparison operations between two locations
by canonicalizing them as subtraction, as in the previous commit.

This won't work (well) if either location includes an offset, or (again)
if the comparisons are not consistent about which region comes first.

<rdar://problem/13239003>

llvm-svn: 177803
2013-03-23 01:21:23 +00:00
Jordan Rose 604d0bbba5 Add reverseComparisonOp and negateComparisonOp to BinaryOperator.
...and adopt them in the analyzer.

llvm-svn: 177802
2013-03-23 01:21:20 +00:00
Jordan Rose 8e6b6c0c2f [analyzer] Translate "a != b" to "(b - a) != 0" in the constraint manager.
Canonicalizing these two forms allows us to better model containers like
std::vector, which use "m_start != m_finish" to implement empty() but
"m_finish - m_start" to implement size(). The analyzer should have a
consistent interpretation of these two symbolic expressions, even though
it's not properly reasoning about either one yet.

The other unfortunate thing is that while the size() expression will only
ever be written "m_finish - m_start", the comparison may be written
"m_finish == m_start" or "m_start == m_finish". Right now the analyzer does
not attempt to canonicalize those two expressions, since it doesn't know
which length expression to pick. Doing this correctly will probably require
implementing unary minus as a new SymExpr kind (<rdar://problem/12351075>).

For now, the analyzer inverts the order of arguments in the comparison to
build the subtraction, on the assumption that "begin() != end()" is
written more often than "end() != begin()". This is purely speculation.

<rdar://problem/13239003>

llvm-svn: 177801
2013-03-23 01:21:16 +00:00
Jordan Rose 3b4c3ea2fb [analyzer] Use SymExprs to represent '<loc> - <loc>' and '<loc> == <loc>'.
We just treat this as opaque symbols, but even that allows us to handle
simple cases where the same condition is tested twice. This is very common
in the STL, which means that any project using the STL gets spurious errors.

Part of <rdar://problem/13239003>.

llvm-svn: 177800
2013-03-23 01:21:05 +00:00
Fariborz Jahanian be8bc67b66 documentation parsing: when providing code completion comment
for a getter used in property-dot syntax, if geter has its own
comment use it. // rdar://12791315

llvm-svn: 177797
2013-03-23 01:10:45 +00:00
Anna Zaks 130df4b0a4 [analyzer] Warn when a nil key or value are passed to NSMutableDictionary and ensure it works with subscripting.
llvm-svn: 177789
2013-03-23 00:39:21 +00:00
Anna Zaks 911a7c9e03 [analyzer] Correct the stale comment.
llvm-svn: 177788
2013-03-23 00:39:17 +00:00
Richard Smith f3e624ca73 If a .syms file is available alongside a sanitizer runtime, pass it to the
linker via --dynamic-list instead of using --export-dynamic. This reduces the
size of the dynamic symbol table, and thus of the binary (in some cases by up
to ~30%).

llvm-svn: 177783
2013-03-23 00:30:08 +00:00
Bill Wendling b3b4a37138 Use RequireCompleteType() instead of isIncompleteType().
isIncompleteType() returns true or false for template types depending on whether
the type is instantiated yet. In this context, that's arbitrary. The better way
to check for a complete type is RequireCompleteType().

Thanks to Eli Friedman for noticing this!

<rdar://problem/12700799>

llvm-svn: 177768
2013-03-22 21:33:46 +00:00
Ted Kremenek 21c29e5713 Add test case for PR 12921.
llvm-svn: 177767
2013-03-22 21:30:22 +00:00
Douglas Gregor 11ef0b7778 <rdar://problem/13479539> Only rebuild the global module cache when we're allowed to.
This eliminates excessive rebuilds of the global module cache.

llvm-svn: 177766
2013-03-22 21:26:48 +00:00
Jordan Rose 25fac2f6dc Revert "[analyzer] Break cycles (optionally) when trimming an ExplodedGraph."
The algorithm used here was ridiculously slow when a potential back-edge
pointed to a node that already had a lot of successors. The previous commit
makes this feature unnecessary anyway.

This reverts r177468 / f4cf6b10f863b9bc716a09b2b2a8c497dcc6aa9b.

Conflicts:

	lib/StaticAnalyzer/Core/BugReporter.cpp

llvm-svn: 177765
2013-03-22 21:15:33 +00:00
Jordan Rose f342adef47 [analyzer] Use a forward BFS instead of a reverse BFS to find shortest paths.
For a given bug equivalence class, we'd like to emit the report with the
shortest path. So far to do this we've been trimming the ExplodedGraph to
only contain relevant nodes, then doing a reverse BFS (starting at all the
error nodes) to find the shortest paths from the root. However, this is
fairly expensive when we are suppressing many bug reports in the same
equivalence class.

r177468-9 tried to solve this problem by breaking cycles during graph
trimming, then updating the BFS priorities after each suppressed report
instead of recomputing the whole thing. However, breaking cycles is not
a cheap operation because an analysis graph minus cycles is still a DAG,
not a tree.

This fix changes the algorithm to do a single forward BFS (starting from the
root) and to use that to choose the report with the shortest path by looking
at the error nodes with the lowest BFS priorities. This was Anna's idea, and
has the added advantage of requiring no update step: we can just pick the
error node with the next lowest priority to produce the next bug report.

<rdar://problem/13474689>

llvm-svn: 177764
2013-03-22 21:15:28 +00:00
Jordan Rose 08821c84da [analyzer] Fix test to actually test what was intended.
llvm-svn: 177763
2013-03-22 21:15:26 +00:00
Jordan Rose 73aa6f2178 [analyzer] Fix ExprEngine::ViewGraph to handle C++ initializers.
Debugging aid only, no functionality change.

llvm-svn: 177762
2013-03-22 21:15:16 +00:00
Argyrios Kyrtzidis eb663daeff [PCH/Modules] De/Serialize MacroInfos separately than MacroDirectives.
-Serialize the macro directives history into its own section
-Get rid of the macro updates section
-When de/serializing an identifier from a module, associate only one macro per
 submodule that defined+exported it.

llvm-svn: 177761
2013-03-22 21:12:57 +00:00
Argyrios Kyrtzidis 4f32da1ef5 [modules] When a MacroInfo object is deserialized, allocate and store its submodule ID.
llvm-svn: 177760
2013-03-22 21:12:51 +00:00
Reid Kleckner 407e8b642b [ms-cxxabi] Implement member data pointers for non-dynamic classes
Summary:
For non-dynamic classes (no virtual bases), member data pointers are
simple offsets from the base of the record.  Dynamic classes use an
aggregate for member data pointers and are therefore currently
unsupported.

Unlike Itanium, the ms ABI uses 0 to represent null for polymorphic
classes.  Non-polymorphic classes use -1 like Itanium, since 0 is a
valid field offset.

Reviewers: rjmccall

CC: timurrrr, cfe-commits

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

llvm-svn: 177753
2013-03-22 19:02:54 +00:00
Douglas Gregor 603cd869f7 <rdar://problem/13479539> Simplify ModuleManager/GlobalModuleIndex interaction to eliminate a pile of extraneous stats().
The refactoring in r177367 introduced a serious performance bug where
the "lazy" resolution of module file names in the global module index
to actual module file entries in the module manager would perform
repeated negative stats(). The new interaction requires the module
manager to inform the global module index when a module file has been
loaded, eliminating the extraneous stat()s and a bunch of bookkeeping
on both sides.

llvm-svn: 177750
2013-03-22 18:50:14 +00:00
Fariborz Jahanian 1fcf4921af documentation parsing. Provide code completion comment
for self.GetterName where GetterName is the getter method 
for a property with name different from the property name 
(declared via a property getter attribute) // rdar://12791315

llvm-svn: 177744
2013-03-22 17:55:27 +00:00
Fariborz Jahanian c56ae1b677 These tests fail on our Window64 machine.
Feel free to revert them (or let me know and I will revert)
if they shouldn't be.

llvm-svn: 177743
2013-03-22 17:42:39 +00:00
Daniel Jasper dd9276e464 Better fix for r177725.
It turns out that

-foo;

can be an objective C method declaration. So instead of the previous
solution, recognize objective C methods only if we are in a declaration
scope.

llvm-svn: 177740
2013-03-22 16:55:40 +00:00
Daniel Jasper bc0fa39d69 Align comments to surrounding unformatted comments.
Before:
int a; // not formatted
// formatting this line only

After:
int a; // not formatted
       // formatting this line only

This makes clang-format stable independent of whether the whole
file or single lines are formatted in most cases.

llvm-svn: 177739
2013-03-22 16:25:51 +00:00
Reid Kleckner 9cffbc1873 [cxxabi] Get ptrdiff_t from the CodeGenModule instead of caching it
As the comment says, it's a little silly to cache it in the ABI code.

llvm-svn: 177738
2013-03-22 16:13:10 +00:00
Daniel Jasper 4172375713 Update docs after moving clang-format from clang-tools-extra to cfe.
llvm-svn: 177729
2013-03-22 12:44:20 +00:00
Daniel Jasper be0d173099 Add clang-format to the corresponding Makefile.
llvm-svn: 177727
2013-03-22 11:43:51 +00:00
Daniel Jasper 399d1ee5a0 More precisely recognize ObjC method declarations.
Otherwise, +/- and the beginning of constants can be recognized
incorrectly.

Before:  #define A - 1
After:   #define A -1
llvm-svn: 177725
2013-03-22 10:44:43 +00:00
Dmitri Gribenko 22ee0c17a6 Documentation: fix a typo and formatting
llvm-svn: 177722
2013-03-22 10:25:15 +00:00
Daniel Jasper 689ae01244 Fix DeclRefExpr::getFoundDecl() for usages by reference.
llvm-svn: 177721
2013-03-22 10:01:35 +00:00
Daniel Jasper 5521365248 Make clang-format understand more line comments.
Apparently one needs to set LangOptions.LineComment.

Before "//* */" got reformatted to "/ /* */" as the lexer was returning
the token sequence (slash, comment). This could also lead to weird other
stuff, e.g. for people that like to using comments like:
//****************

llvm-svn: 177720
2013-03-22 10:01:29 +00:00
Douglas Gregor aeb2a3c3a2 Add future directions for modules
llvm-svn: 177707
2013-03-22 07:08:56 +00:00
Douglas Gregor 485996c696 More modules documentation, including the straw-man import declaration syntax and "how to modularize a platform".
llvm-svn: 177706
2013-03-22 07:05:07 +00:00
Alexey Bataev a769e07232 OpenMP threadprivate directive parsing and semantic analysis
llvm-svn: 177705
2013-03-22 06:34:35 +00:00
Douglas Gregor de0beaa8f8 More documentation on the module map language.
llvm-svn: 177704
2013-03-22 06:21:35 +00:00
Alexey Bataev 353fba6cdd test commit
llvm-svn: 177701
2013-03-22 05:24:29 +00:00
John McCall cda8083309 Warn about attempts to reinterpret_cast between two types that are
hierarchy-related at a possibly nonzero offset.

Patch by Alexander Zinenko!

llvm-svn: 177698
2013-03-22 02:58:14 +00:00
John McCall eaef89b197 Fix a crash-on-valid where a block capture copy expression was
picking up cleanups from earlier in the statement.  Also fix a
crash-on-invalid where a reference to an invalid decl from an
enclosing scope was causing an expression to fail to build, but
only *after* a cleanup was registered from that statement,
causing an assertion downstream.

The crash-on-valid is rdar://13459289.

llvm-svn: 177692
2013-03-22 02:10:40 +00:00
Richard Smith 48366f7af9 ubsan: Pass floating-point arguments to the runtime by value if they fit the
value argument. If not, be sure we don't accidentally use a dynamic alloca.

llvm-svn: 177690
2013-03-22 00:47:07 +00:00
Douglas Gregor 96efb4a442 <rdar://problem/13479214> Make Clang's <stddef.h> robust against system headers defining size_t/ptrdiff_t/wchar_t.
Clang's <stddef.h> provides definitions for the C standard library
types size_t, ptrdiff_t, and wchar_t. However, the system's C standard
library headers tend to provide the same typedefs, and the two
generally avoid each other using the macros
_SIZE_T/_PTRDIFF_T/_WCHAR_T. With modules, however, we need to see
*all* of the places where these types are defined, so provide the
typedefs (ignoring the macros) when modules are enabled.

llvm-svn: 177686
2013-03-22 00:10:49 +00:00
Jordan Rose 83662f75ad [analyzer] scan-build: emit errors on stderr, and exit(1) instead of exit(0).
PR14963

llvm-svn: 177678
2013-03-21 23:14:26 +00:00
David Blaikie af802be01b Update debug info test case for more incoming DIBuilder changes
Switching the DIFile field in DISubprogram to refer to the raw
filename/directory pair instead of a DIFile.

llvm-svn: 177676
2013-03-21 23:07:47 +00:00
David Blaikie c89bfbec19 Update debug info test case for an incoming change to DIBuilder in LLVM
(this will produce some transient test failure/skew)

llvm-svn: 177673
2013-03-21 22:28:46 +00:00
Douglas Gregor 23c7d67de2 <rdar://problem/13477190> Give the Clang module cache directory some structure, so it's easier to find.
We now put the Clang module cache in
<system-temp-directory>/org.llvm.clang/ModuleCache. Perhaps some day
there will be other caches under <system-temp-directory>/org.llvm.clang>.

llvm-svn: 177671
2013-03-21 21:48:48 +00:00
David Blaikie 9db060485c Fix indentation
llvm-svn: 177665
2013-03-21 21:35:15 +00:00
Fariborz Jahanian 1446b34629 Objective-C: Tighten the rules when warning
is issused for on overriding 'readwrite'
property which is not auto-synthesized.
Buttom line is that if hueristics determine
that there will be a user implemented setter,
no warning will be issued. // rdar://13388503

llvm-svn: 177662
2013-03-21 20:50:53 +00:00
David Blaikie 8ad22a37af Generalize debug info tests to be forward compatible with future DISubprogram changes
llvm-svn: 177659
2013-03-21 20:20:15 +00:00
Aaron Ballman 63352de02e This ugly regex is required because on Windows, the paths come out as \\ delimited instead of / delimited. Fixes a test breakage since r176894.
llvm-svn: 177658
2013-03-21 20:12:19 +00:00
Benjamin Kramer 3d0235e16e Remove unused variable.
llvm-svn: 177657
2013-03-21 19:47:38 +00:00
Benjamin Kramer 5fbe2629ff Avoid warnings from compilers that think you can drop off the end of a fully covered switch.
llvm-svn: 177656
2013-03-21 19:45:46 +00:00
Aaron Ballman 3fd576f7d6 Delayed template parsing is not supported by the AST serialization system yet, so turning it off. This fixes a test breakage caused by r177336.
llvm-svn: 177655
2013-03-21 19:38:59 +00:00
Jordan Rose e4bdb1016e [analyzer] Print return values from debug.DumpCalls checker.
Debug utility only, no functionality change.

llvm-svn: 177649
2013-03-21 18:16:59 +00:00
Alexander Kornienko 547a9f5264 Better block comment formatting.
Summary:
1. When splitting one-line block comment, use indentation and *s.
2. Remove trailing whitespace from all lines of a comment, not only the ones being splitted.
3. Add backslashes for all lines if a comment is used insed a preprocessor directive.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

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

llvm-svn: 177635
2013-03-21 12:28:10 +00:00
Alexander Potapenko 5700f40d80 [ASan] Let the users to invoke `clang -fsanitize=address` to link binaries targeting the iOS simulator.
llvm-svn: 177633
2013-03-21 10:49:06 +00:00
Bob Wilson c962f9a624 Fix a typo.
llvm-svn: 177626
2013-03-21 06:09:09 +00:00
Douglas Gregor 0339a64a40 <rdar://problem/13037793> Allow the names of modules to differ from the name of their subdirectory in the include path.
llvm-svn: 177621
2013-03-21 01:08:50 +00:00
John McCall 433c2e64f8 Further weaken block conversion rules to permit blocks with
enum return type to be converted to blocks with any integer type
of the same size.

rdar://13463504

llvm-svn: 177613
2013-03-21 00:10:07 +00:00
Manman Ren 8aa84081e9 Add more testing cases for tbaa.struct
Testing cases for structs of structs and unions of structs.

llvm-svn: 177612
2013-03-21 00:09:50 +00:00
David Blaikie d54bb5c192 Debug info - generalize namespace test to not depend on a DW_TAG_file_type entry
This isn't necessary & with the next change to LLVM the DW_TAG_file_type entry
won't be emitted at all - only the raw filename/directory pair, so match on
that directly instead.

llvm-svn: 177609
2013-03-20 23:57:15 +00:00
Richard Smith cff3cde28b Split ubsan runtime into three pieces (clang part):
* libclang_rt-san-* is sanitizer_common, and is linked in only if no other
   sanitizer runtime is present.
 * libclang_rt-ubsan-* is the piece of the runtime which doesn't depend on
   a C++ ABI library, and is always linked in.
 * libclang_rt-ubsan_cxx-* is the piece of the runtime which depends on a
   C++ ABI library, and is only linked in when linking a C++ binary.

This change also switches us to using -whole-archive for the ubsan runtime
(which is made possible by the above split), and switches us to only linking
the sanitizer runtime into the main binary and not into DSOs (which is made
possible by using -whole-archive).

The motivation for this is to only link a single copy of sanitizer_common
into any binary. This is becoming important now because we want to share
more state between multiple sanitizers in the same process (for instance,
we want a single shared output mutex).

The Darwin ubsan runtime is unchanged; because we use a DSO there, we don't
need this complexity.

llvm-svn: 177605
2013-03-20 23:49:07 +00:00
Reid Kleckner 831b71e0b5 [ms-cxxabi] Mangle function pointer template arguments correctly
Reviewers: rjmccall

CC: timurrrr, llvm-commits

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

llvm-svn: 177589
2013-03-20 22:29:42 +00:00
Jordan Rose 3b6af191d8 [analyzer] Appease buildbots: include template arguments in base class ref.
llvm-svn: 177583
2013-03-20 21:44:17 +00:00
James Dennett 83942a9bf8 Documentation cleanup for MacroInfo.
* Clarify what MacroInfo::isBuiltinMacro means, as it really means something
  more like "isMagicalMacro" or "requiresProcessingBeforeExpansion" -- the
  macros defined in "<built-in>" are not considered built-in by this function;
* Escape __LINE__ as \__LINE__ in Doxygen comments so that the underscores
  don't get replaced by *bold* output;
* Turn comments in MacroInfo.cpp into non-Doxygen comments, so that they
  don't result in duplicated/badly formatted Doxygen output;
* Clean up a bunch of \brief formatting, and add a \file comment for
  MacroInfo.h.

llvm-svn: 177581
2013-03-20 21:30:03 +00:00
Douglas Gregor fb9126578e <rdar://problem/12368093> Extend module maps with a 'conflict' declaration, and warn when a newly-imported module conflicts with an already-imported module.
llvm-svn: 177577
2013-03-20 21:10:35 +00:00
Jordan Rose 28c68a2d07 [analyzer] Don't invalidate globals when there's no call involved.
This fixes some mistaken condition logic in RegionStore that caused
global variables to be invalidated when /any/ region was invalidated,
rather than only as part of opaque function calls. This was only
being used by CStringChecker, and so users will now see that strcpy()
and friends do not invalidate global variables.

Also, add a test case we don't handle properly: explicitly-assigned
global variables aren't being invalidated by opaque calls. This is
being tracked by <rdar://problem/13464044>.

llvm-svn: 177572
2013-03-20 20:36:01 +00:00
Jordan Rose 5d22fcb257 [analyzer] Track malloc'd memory into struct fields.
Due to improper modelling of copy constructors (specifically, their
const reference arguments), we were producing spurious leak warnings
for allocated memory stored in structs. In order to silence this, we
decided to consider storing into a struct to be the same as escaping.
However, the previous commit has fixed this issue and we can now properly
distinguish leaked memory that happens to be in a struct from a buffer
that escapes within a struct wrapper.

Originally applied in r161511, reverted in r174468.
<rdar://problem/12945937>

llvm-svn: 177571
2013-03-20 20:35:57 +00:00
Jordan Rose 5413aaa791 [analyzer] Invalidate regions indirectly accessible through const pointers.
In this case, the value of 'x' may be changed after the call to indirectAccess:

  struct Wrapper {
    int *ptr;
  };

  void indirectAccess(const Wrapper &w);

  void test() {
    int x = 42;
    Wrapper w = { x };

    clang_analyzer_eval(x == 42); // TRUE
    indirectAccess(w);
    clang_analyzer_eval(x == 42); // UNKNOWN
  }

This is important for modelling return-by-value objects in C++, to show
that the contents of the struct are escaping in the return copy-constructor.

<rdar://problem/13239826>

llvm-svn: 177570
2013-03-20 20:35:53 +00:00
Jordan Rose 153c81b7c4 [analyzer] Remove strip of ElementRegion in CallEvent::invalidateRegions.
This is a bit of old code trying to deal with the fact that functions that
take pointers often use them to access an entire array via pointer
arithmetic. However, RegionStore already conservatively assumes you can use
pointer arithmetic to access any part of a region.

Some day we may want to go back to handling this specifically for calls,
but we can do that in the future.

No functionality change.

llvm-svn: 177569
2013-03-20 20:35:48 +00:00
David Blaikie 431153cf2a refactoring file/directory for namespace debug info
(this is a paired commit with an LLVM change to DIBuilder - expect some
buildbot skew/fallout)

llvm-svn: 177565
2013-03-20 19:38:29 +00:00
David Blaikie 9e38bde14d Enhance debug info namespace test to check for context/scope reference
The #line directive is mostly for backend testing (keeping these files matching
should simplify maintenance somewhat) though the corresponding backend test
improvement/update doesn't verify the file information directly just yet.
Coming in a later iteration.

llvm-svn: 177559
2013-03-20 19:10:57 +00:00
Fariborz Jahanian 0b171939dc Do the error recovery for @end only.
I am not sure how much we can improve for
when a randon ObjC keyword is thrown into the
ivar decl. block. // rdar://6854840

llvm-svn: 177553
2013-03-20 18:45:49 +00:00
Sean Silva 99c9d9810b [docs] Point inquisitive users to existing module.map files.
llvm-svn: 177552
2013-03-20 18:37:47 +00:00
Sean Silva 28e0def9f3 [docs] Prominently note that modules are expemental.
And ask for people to try it out and send us bug reports!

llvm-svn: 177551
2013-03-20 18:37:42 +00:00
Fariborz Jahanian 089f39ec06 Objective-C [qoi] more gracefull recovery when
'}' is missing for the ivar declarations.
// rdar://6854840

llvm-svn: 177549
2013-03-20 18:09:33 +00:00
David Blaikie 5e026f55e9 PR7256: Provide a fixit for incorrect destructor declarations
Fix by Ismail Pazarbasi (ismail.pazarbasi@gmail.com), review by Dmitri Gribenko.

llvm-svn: 177546
2013-03-20 17:42:13 +00:00
Douglas Gregor bb1c7e358c Fix typo and grammaro in modules documentation
llvm-svn: 177544
2013-03-20 17:11:13 +00:00
Douglas Gregor 2bb719f3a9 Only introduce the SDKSettings.plist dependency in modules/PCH files that don't depend on any other modules or PCH files.
llvm-svn: 177542
2013-03-20 16:59:53 +00:00
Manman Ren 0175461296 Exploit this-return of a callsite in a this-return function.
For constructors/desctructors that return 'this', if there exists a callsite
that returns 'this' and is immediately before the return instruction, make
sure we are using the return value from the callsite.

We don't need to keep 'this' alive through the callsite. It also enables
optimizations in the backend, such as tail call optimization.

Updated from r177211.
rdar://12818789

llvm-svn: 177541
2013-03-20 16:59:38 +00:00
Alexander Kornienko 674be0a3da Support for pointers-to-members usage via .*
Summary: Added support for pointers-to-members usage via .* and a few tests.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

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

llvm-svn: 177537
2013-03-20 16:41:56 +00:00
Daniel Jasper 291f936351 Remove assertion that can be triggered on bad input.
clang-format can't do anything useful, so it should leave the remainder
of the line unchanged, but it should not assert/segfault.

llvm-svn: 177530
2013-03-20 15:58:10 +00:00
Daniel Jasper 1a32a61ad4 Fix infinite-loop in unwrapped line parser.
Discovered when accidentally formatting a python file :-).

llvm-svn: 177527
2013-03-20 15:12:38 +00:00
Daniel Jasper 66dc2ec30b Do not consider comments when adjusting to local indent style.
Before (when only reformatting "int b"):
int a; // comment
       // comment
       int b;

After:
int a; // comment
       // comment
int b;

This also fixes llvm.org/PR15433.

llvm-svn: 177524
2013-03-20 14:31:47 +00:00
Daniel Jasper aab220f307 Reduce penalty for breaks after "(" for functions with parameters.
Before:
  aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
  aaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 177521
2013-03-20 13:53:11 +00:00
Daniel Jasper d1ae3588c6 Add extra indentation for multiline comparisons.
This seems to be generally more desired.

Before:
if (aaaaaaaa &&
    bbbbbbbb >
    cccccccc) {}
After:
if (aaaaaaaa &&
    bbbbbbbb >
        cccccccc) {}

Also: Some formatting cleanup on clang-format's files.
llvm-svn: 177514
2013-03-20 12:37:50 +00:00
Daniel Jasper a127512cb4 Don't remove all indentation when in #defines.
Otherwise, this can become hard to read.

Before: #define A \
        case 1:
After:  #define A \
           case 1:
llvm-svn: 177509
2013-03-20 10:23:53 +00:00