Let ASTReader optionally delete its ASTDeserializationListener.

Use this to fix the leak of DeserializedDeclsDumper and DeserializedDeclsChecker
in FrontendAction (found by LSan), PR19560.

The "delete this" bool is necessary because both PCHGenerator and ASTUnit
return the same object from both getDeserializationListener() and
getASTMutationListener(), so ASTReader can't just have a unique_ptr.

It's also not possible to just let FrontendAction (or CompilerInstance) own
these listeners due to lifetime issues (see comments on PR19560).

Finally, ASTDeserializationListener can't easily be refcounted, since several of
the current listeners are allocated on the stack.

Having this bool isn't ideal, but it's a pattern that's used in other places in
the codebase too, and it seems better than leaking.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208277 91177308-0d34-0410-b5e6-96231b3b80d8
[OPENMP] Fix codegen test for msvc build


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208278 91177308-0d34-0410-b5e6-96231b3b80d8
[OPENMP] Another one fix in test for msvc


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208279 91177308-0d34-0410-b5e6-96231b3b80d8
[C++11] Use 'nullptr'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208280 91177308-0d34-0410-b5e6-96231b3b80d8
clang-format: [JS] Initial support for regex literals.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208281 91177308-0d34-0410-b5e6-96231b3b80d8
clang-format: [JS] Support regex literals after 'return'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208285 91177308-0d34-0410-b5e6-96231b3b80d8
clang-format: Fix binary operator detection before lambdas.

Before:
  bool foo = true&& [] { return false; }();

After:
  bool foo = true && [] { return false; }();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208288 91177308-0d34-0410-b5e6-96231b3b80d8
clang-format: [JS] support closures in container literals.

Before:
  return {body: {setAttribute: function(key, val) {this[key] = val;
  }
  , getAttribute : function(key) { return this[key]; }
  , style : {
  direction:
    ''
  }
  }
  }
  ;

After:
  return {
    body: {
      setAttribute: function(key, val) { this[key] = val; },
      getAttribute: function(key) { return this[key]; },
      style: {direction: ''}
    }
  };

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208292 91177308-0d34-0410-b5e6-96231b3b80d8
Suggest fix-it ':' when '=' used in for-range-declaration

Fix for PR19176. Clang will suggest a fix-it hint for cases like:
  int arr[] = {1, 2, 3, 4};
  for (auto i = arr)
              ^
              :


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208299 91177308-0d34-0410-b5e6-96231b3b80d8
Explicitly keep track of temporaries during the consumed analysis.

This makes the consumed analysis less dependent on the CFG layout and fixes
a bug where we wouldn't warn on an unconsumed value.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208300 91177308-0d34-0410-b5e6-96231b3b80d8
clang-format: Initial support for try-catch.

Most of this patch was created by Alexander Rojas in
http://reviews.llvm.org/D2555
Thank you!

Synced and addressed review comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208302 91177308-0d34-0410-b5e6-96231b3b80d8
clang-format: Cleanup redundant calculation of ParenLevel.

No functional changes intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208304 91177308-0d34-0410-b5e6-96231b3b80d8
Enable standalone-debug by default on FreeBSD

It was set by default on Darwin in r198655.  The same usability issues
with DTrace and LLDB apply to FreeBSD, so set it by default there too.

rdar://problem/15758808
http://llvm.org/pr19676

Differential Revision: http://reviews.llvm.org/D3448


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208310 91177308-0d34-0410-b5e6-96231b3b80d8
Use predicate function to simplify a bit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208312 91177308-0d34-0410-b5e6-96231b3b80d8
Fix PR19169 [Crash on invalid attempting to specialize a template method as a template variable].
A template declaration of a template name can be null in case we have a dependent name or a set of function templates.
Hence use dyn_cast_or_null instead of dyn_cast. Also improve the diagnostic emitted in this case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208313 91177308-0d34-0410-b5e6-96231b3b80d8
Fix segmentation fault when mixing -Rpass with #line.

Summary:
When using #line directives, FileManager::getFile() will return a nil
entry. This triggers an assert in translateFileLineCol().

This patch handles nil FileEntry instances by emitting a note that the
location could not be translated back to a SourceLocation. I don't
really like this solution, but we are translating presumed locations,
so some information has already been lost.

Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D3625

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208315 91177308-0d34-0410-b5e6-96231b3b80d8
Small simplification: Reduce the use of cast<>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208320 91177308-0d34-0410-b5e6-96231b3b80d8
Use more specific type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208321 91177308-0d34-0410-b5e6-96231b3b80d8
Replace virtual with override.

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

Use more specific type, update comments and name style.

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