Added comprehensive macro arg usage logic to Use-Nullptr Transform

If a NullTo(Member)Pointer cast results from a macro arg expansion, all uses of
the arg must result in such casts or else the macro arg cannot be replaced with
'nullptr' safely. This revision adds logic and tests to ensure the safety of
replacing macro args in the Use-Nullptr Transform.

Fixes: PR15816


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@181221 91177308-0d34-0410-b5e6-96231b3b80d8
Stop LoopConvert removing DeclStmts from selection/iteration condition clauses

If the LoopConvert Transform detects an alias for the loop variable, it
attempts to use that name in the resulting range-based for loop while removing
the original DeclStmt for the variable. That removal produced bad code when the
declaration was in the condition of an if, switch, while, or for stmt. This
revision fixes the problem by simply replacing the declaration with a use of
the alias variable.



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@181242 91177308-0d34-0410-b5e6-96231b3b80d8
Use 'auto const&' for iterators whose deref operator return a const var

This patch fixes PR15601.
- Added check for whether the loop variable and the initializer have the same
type.
- Added tests.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@181528 91177308-0d34-0410-b5e6-96231b3b80d8
Transform for loops over pseudo-arrays only if begin/end members exist

For loops using pseudo-arrays, classes that can be used like arrays from
the Loop Convert Transform's point of view, should only get transformed
if the pseudo-array class has begin()/end() members for the
range-based for-loop to call.

Free versions of begin()/end() should also be allowed but this is an
enhancement for another revision.



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@181539 91177308-0d34-0410-b5e6-96231b3b80d8
cpp11-migrate: Fix crash in AddOverride due to template instantiations

This patch fixes different issues:
- override is not added in template 'contexts' (this will be further improved
  to handle safe situations, a test for this has been written already)
- the main file is now checked before the modifications are applied
- override is not applied now when dealing with pure methods since it was
  misplaced (ignoring it isn't the perfect solution but it seems difficult to
  find the location just before the pure-specifier)

Fixes PR15827

Author: Guillaume Papin <guillaume.papin@epitech.eu>



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@181596 91177308-0d34-0410-b5e6-96231b3b80d8
cpp11-migrate: Add override specifier before comments on inline methods

This commit fixes a "FIXME" in the add-override transform. ' override' was
misplaced when a comment was between the function body and the end of the
'prototype'.

It also remove duplicated check for the main file from the last commit (and
fixes the typo in the comment above).

Author: Guillaume Papin <guillaume.papin@epitech.eu>


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@181806 91177308-0d34-0410-b5e6-96231b3b80d8
cpp11-migrate: Refactor NullptrActions

Several free functions related to macro arg testing are being moved into
CastSequenceVisitor to facilitate upcoming fix.



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@182013 91177308-0d34-0410-b5e6-96231b3b80d8
cpp11-migrate: Check for valid NULL macros from macro arg expansions

The recent improvement to the Use Nullptr Transform for macro arg
expansions wasn't testing that only allowed NULL macros used in macro
args can be transformed. This revision replaces a TODO to that effect.

Fixes PR15955.



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@182014 91177308-0d34-0410-b5e6-96231b3b80d8
Fix UseAuto replacing variable declaration lists containing non-initialized
variables.

UseAuto used to match initialized variable declarations independently of
whether they were defined in a declaration list or as a single declaration.
Now it matches declaration statements where every variable declaration is
initialized.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@182114 91177308-0d34-0410-b5e6-96231b3b80d8
Unbreak the build.

UseAutoActions.cpp:48:17: error: redefinition of 'E' with a different type.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@182119 91177308-0d34-0410-b5e6-96231b3b80d8