Fix bug when formatting overloaded operators.

Before, the actual operator of an overloaded operator declaration was
handled as a binary operator an thus, clang-format could not find valid
formattings for many examples, e.g.:

template <typename AAAAAAA, typename BBBBBBB>
AAAAAAA operator/(const AAAAAAA &a, BBBBBBB &b);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181585 91177308-0d34-0410-b5e6-96231b3b80d8
Add support for __wchar_t in -fms-extensions mode.

MSVC provides __wchar_t. This is the same as the built-in wchar_t type
from C++, but it is also available with -fno-wchar and in C.

The commit changes ASTContext to have two different types for this:

  - WCharTy is the built-in type used for wchar_t in C++ and __wchar_t.

  - WideCharTy is the type of a wide character literal. In C++ this is
    the same as WCharTy, and in C  it is an integer type compatible with
    the type in <stddef.h>.

This fixes PR15815.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181587 91177308-0d34-0410-b5e6-96231b3b80d8
Add caseStmt(), defaultStmt(), eachCase() and hasCaseConstant() matchers.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181588 91177308-0d34-0410-b5e6-96231b3b80d8
Config file support for clang-format, part 2.

Summary:
Adds actual config file reading to the clang-format utility.
Configuration file name is .clang-format. It is looked up for each input file
in its parent directories starting from immediate one. First found .clang-format
file is used. When using standard input, .clang-format is searched starting from
the current directory.
Added -dump-config option to easily create configuration files.

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits, jordan_rose, kimgr

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181589 91177308-0d34-0410-b5e6-96231b3b80d8
Always format entire macro definitions.

Thereby, the macro is consistently formatted (including the trailing
escaped newlines) even if clang-format is invoked only on single lines
of the macro.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181590 91177308-0d34-0410-b5e6-96231b3b80d8
Minor clarifications in help messages and a comment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181591 91177308-0d34-0410-b5e6-96231b3b80d8
ArrayRef'ize GenericSelectionExpr


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181592 91177308-0d34-0410-b5e6-96231b3b80d8
Updated clang-format help messages for -offset and -length

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181593 91177308-0d34-0410-b5e6-96231b3b80d8
ArrayRef'ize Sema::FindAllocationFunctions

Patch by Robert Wilhelm.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181594 91177308-0d34-0410-b5e6-96231b3b80d8
When breaking at function calls, indent from function name.

Otherwise (when indenting from the wrapped -> or .), this looks
like a confusing indent.

Before:
aaaaaaa        //
    .aaaaaaa( //
        aaaaaaa);
After:
aaaaaaa        //
    .aaaaaaa( //
         aaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181595 91177308-0d34-0410-b5e6-96231b3b80d8
Codegen tests for captured statements with templates

Differential-revision: llvm-reviews.chandlerc.com/D778



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181598 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Indirect invalidation counts as an escape for leak checkers.

Consider this example:

  char *p = malloc(sizeof(char));
  systemFunction(&p);
  free(p);

In this case, when we call systemFunction, we know (because it's a system
function) that it won't free 'p'. However, we /don't/ know whether or not
it will /change/ 'p', so the analyzer is forced to invalidate 'p', wiping
out any bindings it contains. But now the malloc'd region looks like a
leak, since there are no more bindings pointing to it, and we'll get a
spurious leak warning.

The fix for this is to notice when something is becoming inaccessible due
to invalidation (i.e. an imperfect model, as opposed to being explicitly
overwritten) and stop tracking it at that point. Currently, the best way
to determine this for a call is the "indirect escape" pointer-escape kind.

In practice, all the patch does is take the "system functions don't free
memory" special case and limit it to direct parameters, i.e. just the
arguments to a call and not other regions accessible to them. This is a
conservative change that should only cause us to escape regions more
eagerly, which means fewer leak warnings.

This isn't perfect for several reasons, the main one being that this
example is treated the same as the one above:

  char **p = malloc(sizeof(char *));
  systemFunction(p + 1);
  // leak

Currently, "addresses accessible by offsets of the starting region" and
"addresses accessible through bindings of the starting region" are both
considered "indirect" regions, hence this uniform treatment.

Another issue is our longstanding problem of not distinguishing const and
non-const bindings; if in the first example systemFunction's parameter were
a char * const *, we should know that the function will not overwrite 'p',
and thus we can safely report the leak.

<rdar://problem/13758386>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181607 91177308-0d34-0410-b5e6-96231b3b80d8
Allocate memory for the new number of subexpressions.  Fixup for r181572


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181611 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Do not check if sys/queue.h file is a system header.

In most cases it is, by just looking at the name. Also, this check prevents the heuristic from working in strange user settings.
radar://13839692

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181615 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Assume [NSNull null] does not return nil.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181616 91177308-0d34-0410-b5e6-96231b3b80d8
Reformat clang-format help strings, filter out irrelevant options.

Summary: +updated ClangFormat.rst

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181617 91177308-0d34-0410-b5e6-96231b3b80d8
PR15966: don't get confused by a complex integer -> complex integer conversion
and misclassify it as a complex-real conversion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181626 91177308-0d34-0410-b5e6-96231b3b80d8
Avoid patching storage class for block scope thread_local variables.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181627 91177308-0d34-0410-b5e6-96231b3b80d8
ObjC debug info: Substitute the class type for methods that return
a related type (e.g., if they use the instancetype keyword).

rdar://problem/13359718

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181629 91177308-0d34-0410-b5e6-96231b3b80d8
PR14992: Debug Info: Support more non-type template parameters

* Provide DW_TAG_template_value_parameter for pointers, function
  pointers, member pointers, and member function pointers (still missing
  support for template template parameters which GCC encodes as a
  DW_TAG_GNU_template_template_param)
* Provide values for all but the (member & non-member) function pointer case.
  Simple constant integer values for member pointers (offset within the
  object) and address for the value pointer case. GCC doesn't provide a
  value for the member function pointer case so I'm not sure how, if at
  all, GDB supports encoding that. & non-member function pointers should
  follow shortly in a subsequent patch.
* Null pointer value encodings of all of these types, including
  correctly encoding null data member pointers as -1.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181634 91177308-0d34-0410-b5e6-96231b3b80d8