Implemented support for "pragma clang optimize on/off", based on attribute 'optnone'.

This patch implements support for selectively disabling optimizations on a
range of function definitions through a pragma. The implementation is that
all function definitions in the range are decorated with attribute
'optnone'.

    #pragma clang optimize off
    // All function definitions in here are decorated with 'optnone'.
    #pragma clang optimize on
    // Compilation resumes as normal.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209510 91177308-0d34-0410-b5e6-96231b3b80d8
PR19352 - getLocation() points to the wrong position for FriendDecls

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209511 91177308-0d34-0410-b5e6-96231b3b80d8
[test] Force a triple in the pragma optimize test due to expected mangled names.

No functional change to the compiler.
This should just make the test pass on all buildbots.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209515 91177308-0d34-0410-b5e6-96231b3b80d8
[MS-ABI] Implements MS-compatible RTTI
Enables the emission of MS-compatible RTTI data structures for use with 
typeid, dynamic_cast and exceptions.  Does not implement dynamic_cast 
or exceptions.  As an artiface, typeid works in some cases but proper 
support an testing will coming in a subsequent patch.

majnemer has fuzzed the results.  Test cases included.

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




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209523 91177308-0d34-0410-b5e6-96231b3b80d8
Replace system() by native perl calls

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209524 91177308-0d34-0410-b5e6-96231b3b80d8
[MS-ABI] Silence warning from r209523
no functional change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209525 91177308-0d34-0410-b5e6-96231b3b80d8
List the function/method name in the index page of scan-build 

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209526 91177308-0d34-0410-b5e6-96231b3b80d8
revert "r209526 List the function/method name in the index page of scan-build "
Depends on http://reviews.llvm.org/D3762



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209527 91177308-0d34-0410-b5e6-96231b3b80d8
Make the ParentVector default to size 2.

As Jordan noted, it makes more sense when we store it in the ParentMap,
and doesn't really make a difference when we return it from getParents.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209530 91177308-0d34-0410-b5e6-96231b3b80d8
Make dead return statement detection more robust against changes in the CFG.

This change is a precondition to the proposed change to handle temporary
dtors correctly.

The idea is to explicitly search for the next return that doesn't have other
paths into it (that is, if the current block is dead, the block containing the
return must be dead, too). Thus, introducing non-control-flow block
transitions will not break the logic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209531 91177308-0d34-0410-b5e6-96231b3b80d8
Test case for r209489.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209532 91177308-0d34-0410-b5e6-96231b3b80d8
Add the hasRangeInit() matcher for range-based for loop.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209533 91177308-0d34-0410-b5e6-96231b3b80d8
Stopgap fix for finding module for a file mapped in the VFS

If we lookup a path using its 'real' path first, we need to ensure that
when we run header search we still use the VFS-mapped path or we will
not be able to find the corresponding module for the header.

The real problem is that we tie the name of a file to its underlying
FileEntry, which is uniqued by inode, so we only ever get the first name
it is looked up by. This doesn't work with modules, which rely on a
specific file system structure.  I'm hoping to have time to write up a
proposal for fixing this more permanently soon, but as a stopgap this
patch updates the name of the file's directory if it comes from a VFS
mapping.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209540 91177308-0d34-0410-b5e6-96231b3b80d8
Fix broken FileCheck prefix

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209541 91177308-0d34-0410-b5e6-96231b3b80d8
Sema: Add more tests for dll attributes on inline functions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209542 91177308-0d34-0410-b5e6-96231b3b80d8
Don't suppress warning about dllimport on typedefs etc. in MicrosoftExt mode

It's true the MSVC doesn't warn about dllimport when applied to e.g. a typedef,
but that applies to dllexport too. I'd like us to be consistent, and I think
the right thing to do is to warn.

The original test that came with implementing the old behaviour doesn't provide
a good motivation, and it said it was checking that we're not repoting an *error*,
which is still true since this is just a warning.

There are plenty of tests e.g. in Sema/dllimport.c to check that we do warn
about dllimport on non functions or variables.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209546 91177308-0d34-0410-b5e6-96231b3b80d8
Emit used/dllexport inline method definitions in nested classes (PR19743, PR11170)

The previous code that was supposed to handle this didn't work
since parsing of inline method definitions is delayed to the end
of the outer class definition. Thus, when HandleTagDeclDefinition()
got called for the inner class, the inline functions in that class
had not been parsed yet.

Richard suggested that the way to do this is by handling inline
method definitions through a new ASTConsumer callback.

I really wanted to call ASTContext::DeclMustBeEmitted() instead of
checking for attributes, but doing that causes us to compute linkage,
and then we fail with "error: unsupported: typedef changes linkage
of anonymous type, but linkage was already computed" on tests like
this: (from SemaCXX/undefined-internal.cpp) :-/

  namespace test7 {
    typedef struct {
      void bar();
      void foo() { bar(); }
    } A;
  }

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209549 91177308-0d34-0410-b5e6-96231b3b80d8
[modules] If a referenced-but-not-instantiated class template specialization
gets explicitly specialized, don't reuse the previous class template
specialization declaration as a new declaration. The benefit here is fairly
marginal, it harms source fidelity, and this is horrible to model if the
specialization was imported from another module (without this change, it
asserts or worse).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209552 91177308-0d34-0410-b5e6-96231b3b80d8
Use comdats to avoid double initialization of weak data

Initializers of global data that can appear multiple TUs (static data
members of class templates or __declspec(selectany) data) are now in a
comdat group keyed on the global variable being initialized.  On
non-Windows platforms, this is a code size and startup time
optimization.  On Windows, this is necessary for ABI compatibility with
MSVC.

Fixes PR16959.

Reviewers: rsmith

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

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