Recommit 213307: unique_ptr-ify ownership of ASTConsumers (reverted in r213325)

After post-commit review and community discussion, this seems like a
reasonable direction to continue, making ownership semantics explicit in
the source using the type system.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215323 91177308-0d34-0410-b5e6-96231b3b80d8
Out-of-line CompilerInstance::takeSema to avoid a header dependence from CompilerInstance.h on Sema.h

Hopefully this fixes the libstdc++ build on some of the buildbots after
r215321.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215325 91177308-0d34-0410-b5e6-96231b3b80d8
Follow up to r215323 - avoid llvm::make_unique in this particular case that's causing GCC on some buildbots some confusion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215327 91177308-0d34-0410-b5e6-96231b3b80d8
unique_ptrify CompilerInstance::OutputFile(s) and remove a unique_ptr around a non-owning raw_ostream in CodeGenAction::CreateASTConsumer

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215331 91177308-0d34-0410-b5e6-96231b3b80d8
Revert r215331, "unique_ptrify CompilerInstance::OutputFile(s) and remove a unique_ptr around a non-owning raw_ostream in CodeGenAction::CreateASTConsumer"

It cannot be compiled on Visual Studio 2012.

  clang\include\clang/Frontend/CompilerInstance.h(153):
error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>'
            with
            [
                _Ty=llvm::raw_ostream
            ]
            D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\memory(1447) : see declaration of 'std::unique_ptr<_Ty>::unique_ptr'
            with
            [
                _Ty=llvm::raw_ostream
            ]
            This diagnostic occurred in the compiler generated function 'clang::CompilerInstance::OutputFile::OutputFile(const clang::CompilerInstance::OutputFile &)'

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215346 91177308-0d34-0410-b5e6-96231b3b80d8
Sema: Handle declspecs without declarators in records properly in C mode

We had two bugs:
- We wouldn't properly warn when a struct/union/enum was mentioned
  inside of a record definition if no declarator was provided.  We
  should have mentioned that this declaration declares nothing.
- We didn't properly support Microsoft's extension where certain
  declspecs without declarators would act as anonymous structs/unions.
  * We completely ignored the case where such a declspec could be a
    union.
  * We didn't properly handle the case where a record was defined inside
    another record:
      struct X {
        int a;
        struct Y {
          int b;
        };
      };

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215347 91177308-0d34-0410-b5e6-96231b3b80d8
Properly #include ASTConsumer.h instead of forward declaration.

Otherwise, this can lead to compile failures if a user/subclass of
FrontendAction doesn't #include this file, even if CreateASTConsumer
isn't used directly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215353 91177308-0d34-0410-b5e6-96231b3b80d8
Fixes bug 20587 - Add K&R break before braces style

Summary:
http://llvm.org/bugs/show_bug.cgi?id=20587

Added K&R style. It could be enabled by the following option:

```
BreakBeforeBraces: KernighanRitchie
```

This style is like `Attach`, but break *only* before function
declarations.

As I can see, no additional logic required to support this style, any
style different from other styles automagically satisfies K&R.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215354 91177308-0d34-0410-b5e6-96231b3b80d8
Work around default parameter problem in the static analyzer.

In cases like:
  struct C { ~C(); }
  void f(C c = C());
  void t() {
    f();
  }

We currently do not add the CXXBindTemporaryExpr for the temporary (the
code mentions that as the default parameter expressions are owned by
the declaration, we'd otherwise add the same expression multiple times),
but we add the temporary destructor pointing to the CXXBindTemporaryExpr.
We need to fix that before we can re-enable the assertion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215357 91177308-0d34-0410-b5e6-96231b3b80d8
Increase SmallVector<> size in DiagnosticsEngine::setSeverityForGroup

In a Clang bootstrap, this vector always held 129 elements.

Also switch to a range-based for loop.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215360 91177308-0d34-0410-b5e6-96231b3b80d8
Increase the size of ToolChain::FilePaths

In a Clang bootstrap build, the size was always at least 9.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215362 91177308-0d34-0410-b5e6-96231b3b80d8
Coverage mapping: emit mapping for cxx constructors that use microsoft's ABI

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215365 91177308-0d34-0410-b5e6-96231b3b80d8
GCC compatibility: Ignore -fexec-charset=UTF-8 argument. It is the default in Clang. Reject other values. 

Summary:
Just like with -finput-charset=UTF-8 in review http://reviews.llvm.org/D4347, I think we should just ignore it when UTF-8 is provided.


Reviewers: rnk, rafael

Reviewed By: rafael

Subscribers: rafael, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215368 91177308-0d34-0410-b5e6-96231b3b80d8
Increase the size of two SmallVectors in Generic_GCC::GCCInstallationDetector::init

In a bootstrap build of Clang, the size was always greater than 12.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215369 91177308-0d34-0410-b5e6-96231b3b80d8
ToolChains.cpp: Increase size of Lines vector in DetectDistro

In a Clang bootstrap, the size of this vector was always 11.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215370 91177308-0d34-0410-b5e6-96231b3b80d8
Revert r215365 - Coverage mapping: emit mapping for cxx constructors that use microsoft's ABI

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215371 91177308-0d34-0410-b5e6-96231b3b80d8
Sema: Properly perform lookup when acting on fields for desig inits

Clang used a custom implementation of lookup when handling designated
initializers.  The custom code was not particularly optimized and relied
on standard lookup for typo-correction anyway.

This custom code has to go, it doesn't properly support MSVC-style
anonymous structs embedded inside other records; replace it with the
typo-correction path.

This has the side effect of speeding up semantic handling of the fields
for a designated initializer while simplifying the code at the same
time.

This fixes PR20573.

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

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215375 91177308-0d34-0410-b5e6-96231b3b80d8
unique_ptr-ify the MemoryBuffer parameter of GlobalModuleIndex

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215376 91177308-0d34-0410-b5e6-96231b3b80d8
unique_ptr-ify FileSystemStatCache::setNextStatCache

And in the process, discover that FileManager::removeStatCache had a
double-delete when removing an element from the middle of the list (at
the beginning or the end of the list, there was no problem) and add a
unit test to exercise the code path (which successfully crashed when run
(with modifications to match the old API) without this patch applied)

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