Commit Graph

38 Commits

Author SHA1 Message Date
Alexander Kornienko ab9db51042 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
llvm-svn: 240353
2015-06-22 23:07:51 +00:00
Alexander Kornienko 3d9d929e42 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

  $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
      -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
      work/llvm/tools/clang

To reduce churn, not touching namespaces spanning less than 10 lines.

llvm-svn: 240270
2015-06-22 09:47:44 +00:00
Yaron Keren 92e1b62d45 Remove many superfluous SmallString::str() calls.
Now that SmallString is a first-class citizen, most SmallString::str()
calls are not required. This patch removes a whole bunch of them, yet
there are lots more.

There are two use cases where str() is really needed:
1) To use one of StringRef member functions which is not available in
SmallString.
2) To convert to std::string, as StringRef implicitly converts while 
SmallString do not. We may wish to change this, but it may introduce
ambiguity.

llvm-svn: 232622
2015-03-18 10:17:07 +00:00
Craig Topper 0dbb783c7b [C++11] Use 'nullptr'. StaticAnalyzer edition.
llvm-svn: 209642
2014-05-27 02:45:47 +00:00
Aaron Ballman 0f6e64d505 [C++11] Replacing ObjCProtocolDecl iterators protocol_begin() and protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203863
2014-03-13 22:58:06 +00:00
Aaron Ballman f53d8dd37d [C++11] Replacing ObjCInterfaceDecl iterators visible_extensions_begin() and visible_extensions_end() with iterator_range visible_extensions(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203855
2014-03-13 21:47:07 +00:00
Aaron Ballman a49c5064a1 [C++11] Replacing ObjCInterfaceDecl iterators protocol_begin() and protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops.
Drive-by fixing some incorrect types where a for loop would be improperly using ObjCInterfaceDecl::protocol_iterator. No functional changes in these cases.

llvm-svn: 203842
2014-03-13 20:29:09 +00:00
Aaron Ballman aff18c0446 [C++11] Replacing ObjCContainerDecl iterators meth_begin() and meth_end() with iterator_range methods(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203832
2014-03-13 19:03:34 +00:00
Aaron Ballman be22bcb180 [C++11] Replacing DeclBase iterators specific_attr_begin() and specific_attr_end() with iterator_range specific_attrs(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203474
2014-03-10 17:08:28 +00:00
Alexander Kornienko 4aca9b1cd8 Expose the name of the checker producing each diagnostic message.
Summary:
In clang-tidy we'd like to know the name of the checker producing each
diagnostic message. PathDiagnostic has BugType and Category fields, which are
both arbitrary human-readable strings, but we need to know the exact name of the
checker in the form that can be used in the CheckersControlList option to
enable/disable the specific checker.

This patch adds the CheckName field to the CheckerBase class, and sets it in
the CheckerManager::registerChecker() method, which gets them from the
CheckerRegistry.

Checkers that implement multiple checks have to store the names of each check
in the respective registerXXXChecker method.

Reviewers: jordan_rose, krememek

Reviewed By: jordan_rose

CC: cfe-commits

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

llvm-svn: 201186
2014-02-11 21:49:21 +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
Fariborz Jahanian aedaaa4f35 objective-C: synthesize properties in order of their
declarations to synthesize their ivars in similar
determinstic order so they are laid out in
a determinstic order. // rdar://13192366

llvm-svn: 175214
2013-02-14 22:33:34 +00:00
Anna Zaks 7811c3efd5 [analyzer] Invalidation checker: move the "missing implementation" check
The missing definition check should be in the same category as the
missing ivar validation - in this case, the intent is to invalidate in
the given class, as described in the declaration, but the implementation
does not perform the invalidation. Whereas the MissingInvalidationMethod
checker checks the cases where the method intention is not to
invalidate. The second checker has potential to have a much higher false
positive rate.

llvm-svn: 174787
2013-02-09 01:09:27 +00:00
Anna Zaks 0d8779cb79 [analyzer] Move DefaultBool so that all checkers can share it.
llvm-svn: 174782
2013-02-08 23:55:50 +00:00
Anna Zaks 91a5fdf83a [analyzer] Split IvarInvalidation into two checkers
Separate the checking for the missing invalidation methods into a
separate checker so that it can be turned on/off independently.

llvm-svn: 174781
2013-02-08 23:55:47 +00:00
Anna Zaks 470543bb2b [analyzer] IvarInvalidation: refactor, pull out the diagnostic printing
llvm-svn: 174780
2013-02-08 23:55:45 +00:00
Anna Zaks a5096f6f51 [analyzer] IvarInvalidation: add annotation for partial invalidation
The new annotation allows having methods that only partially invalidate
IVars and might not be called from the invalidation methods directly
(instead, are guaranteed to be called before the invalidation occurs).
The checker is going to trust the programmer to call the partial
invalidation method before the invalidator.This is common in cases when
partial object tear down happens before the death of the object.

llvm-svn: 174779
2013-02-08 23:55:43 +00:00
Douglas Gregor 048fbfa302 Rework the traversal of Objective-C categories and extensions to
consider (sub)module visibility.

The bulk of this change replaces myriad hand-rolled loops over the
linked list of Objective-C categories/extensions attached to an
interface declaration with loops using one of the four new category
iterator kinds:

  visible_categories_iterator: Iterates over all visible categories
  and extensions, hiding any that have their "hidden" bit set. This is
  by far the most commonly used iterator.

  known_categories_iterator: Iterates over all categories and
  extensions, ignoring the "hidden" bit. This tends to be used for
  redeclaration-like traversals.

  visible_extensions_iterator: Iterates over all visible extensions,
  hiding any that have their "hidden" bit set.

  known_extensions_iterator: Iterates over all extensions, whether
  they are visible to normal name lookup or not.

The effect of this change is that any uses of the visible_ iterators
will respect module-import visibility. See the new tests for examples.

Note that the old accessors for categories and extensions are gone;
there are *Raw() forms for some of them, for those (few) areas of the
compiler that have to manipulate the linked list of categories
directly. This is generally discouraged.

Part two of <rdar://problem/10634711>.
 

llvm-svn: 172665
2013-01-16 23:00:23 +00:00
Anna Zaks 8a023580c7 [analyzer] Fix warning typo.
llvm-svn: 172596
2013-01-16 01:35:57 +00:00
Anna Zaks 39a7692091 [analyzer] Rename the warning: state the issue before the hint of how it
can be fixed

llvm-svn: 172170
2013-01-11 03:52:44 +00:00
Anna Zaks ca49e535ae [analyzer]Recognize ivar invalidation protocol even if it was redeclared
This will get rid of some false positives as well as false negatives.

llvm-svn: 172169
2013-01-11 03:52:40 +00:00
Anna Zaks 2975cf27e4 [analyzer] Ivar invalidation: track ivars declared in categories.
llvm-svn: 172168
2013-01-11 03:52:37 +00:00
Anna Zaks a96a9ef716 [analyzer] Allow IvarInvalidation checker to suppress warnings via
assertions.

To ensure that custom assertions/conditional would also be supported,
just check if the ivar that needs to be invalidated or set to nil is
compared against 0.

Unfortunately, this will not work for code containing 'assert(IvarName)'

llvm-svn: 172147
2013-01-10 23:34:16 +00:00
Anna Zaks 640123de5e [analyzer] Fix non-determinizm introduced in r172104.
In some cases, we just pick any ivar that needs invalidation and attach
the warning to it. Picking the first from DenseMap of pointer keys was
triggering non-deterministic output.

llvm-svn: 172134
2013-01-10 22:44:16 +00:00
Anna Zaks 0aeb60d79d [analyzer] Add more checks to the ObjC Ivar Invalidation checker.
Restructured the checker so that it could easily find two new classes of
issues:
 - when a class contains an invalidatable ivar, but no declaration of an
invalidation method
 - when a class contains an invalidatable ivar, but no definition of an
invalidation method in the @implementation.

The second case might trigger some false positives, for example, when
the method is defined in a category.

llvm-svn: 172104
2013-01-10 20:59:51 +00:00
Anna Zaks 5f37643de1 [analyzer] Fix a false positive in the ivar invalidation checker.
When a property is "inherited" through both a parent class and directly
through a protocol, we should not require the child to invalidate it
since the backing ivar belongs to the parent class.
(Fixes radar://12913734)

llvm-svn: 171769
2013-01-07 19:12:56 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Benjamin Kramer ea70eb30a0 Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't pull in all the generated Attr code.
Required to pull some functions out of line, but this shouldn't have a perf impact.
No functionality change.

llvm-svn: 169092
2012-12-01 15:09:41 +00:00
Anna Zaks 92898a79eb [analyzer] Ivar invalidation: identify properties declared in protocols.
llvm-svn: 166211
2012-10-18 19:17:57 +00:00
Anna Zaks b642fc5db4 [analyzer] Ivar Invalidation: track ivars in continuations and
@implementation.

llvm-svn: 166047
2012-10-16 19:36:37 +00:00
Anna Zaks 09ffeba552 [analyzer] Enhance the error message.
llvm-svn: 165993
2012-10-15 22:48:17 +00:00
Anna Zaks 97c7ce3368 Move isObjCSelf into Expr.
llvm-svn: 164966
2012-10-01 20:34:04 +00:00
Anna Zaks bfacf17b8b [analyzer] Address Jordan's review for r164868.
llvm-svn: 164965
2012-10-01 20:33:58 +00:00
Anna Zaks 0353aad5a9 [analyzer] Re-implement IvarInvalidationChecker so that it verifies that
the validation occurred.

The original implementation was pessimistic - we assumed that ivars
which escape are invalidated. This version is optimistic, it assumes
that the ivars will always be explicitly invalidated: either set to nil
or sent an invalidation message.

llvm-svn: 164868
2012-09-29 00:20:38 +00:00
Anna Zaks a0c8331663 [analyzer] IvarInvalidation: track synthesized ivars and allow escape
through property getters.

llvm-svn: 164802
2012-09-27 21:57:14 +00:00
Anna Zaks 8c0dd36ede [analyzer] Address Jordan's code review comments for r164716.
llvm-svn: 164788
2012-09-27 19:45:08 +00:00
NAKAMURA Takumi 453807fffe IvarInvalidationChecker.cpp: Remove an unused member, InterfD. [-Wunused-private-field]
llvm-svn: 164745
2012-09-27 01:52:00 +00:00
Anna Zaks 9802f9fb2a [analyzer] Add experimental ObjC invalidation method checker.
This checker is annotation driven. It checks that the annotated
invalidation method accesses all ivars of the enclosing objects that are
objects of type, which in turn contains an invalidation method.

This is driven by
__attribute((annotation("objc_instance_variable_invalidator")).

llvm-svn: 164716
2012-09-26 18:55:16 +00:00