[llvm-branch-commits] [cfe-branch] r159496 - in /cfe/branches/tooling: ./ bindings/python/clang/ bindings/python/tests/cindex/ bindings/python/tests/cindex/INPUTS/ docs/ docs/tools/ include/clang-c/ include/clang/AST/ include/clang/Basic/ include/clang/Driver/ include/clang/Frontend/ include/clang/StaticAnalyzer/Core/PathSensitive/ lib/AST/ lib/Analysis/ lib/Basic/ lib/CodeGen/ lib/Driver/ lib/Edit/ lib/Frontend/ lib/Headers/ lib/Lex/ lib/Parse/ lib/Rewrite/ lib/Sema/ lib/StaticAnalyzer/Checkers/ lib/StaticAnalyzer/Core/ test...

Manuel Klimek klimek at google.com
Sat Jun 30 14:45:29 PDT 2012


Author: klimek
Date: Sat Jun 30 16:45:28 2012
New Revision: 159496

URL: http://llvm.org/viewvc/llvm-project?rev=159496&view=rev
Log:
Merging mainline.

Added:
    cfe/branches/tooling/bindings/python/tests/cindex/INPUTS/compile_commands.json
      - copied unchanged from r159493, cfe/trunk/bindings/python/tests/cindex/INPUTS/compile_commands.json
    cfe/branches/tooling/bindings/python/tests/cindex/test_cdb.py
      - copied unchanged from r159493, cfe/trunk/bindings/python/tests/cindex/test_cdb.py
    cfe/branches/tooling/include/clang-c/CXCompilationDatabase.h
      - copied unchanged from r159493, cfe/trunk/include/clang-c/CXCompilationDatabase.h
    cfe/branches/tooling/include/clang-c/CXString.h
      - copied unchanged from r159493, cfe/trunk/include/clang-c/CXString.h
    cfe/branches/tooling/include/clang-c/Platform.h
      - copied unchanged from r159493, cfe/trunk/include/clang-c/Platform.h
    cfe/branches/tooling/include/clang/AST/CommentBriefParser.h
      - copied unchanged from r159493, cfe/trunk/include/clang/AST/CommentBriefParser.h
    cfe/branches/tooling/include/clang/AST/CommentLexer.h
      - copied unchanged from r159493, cfe/trunk/include/clang/AST/CommentLexer.h
    cfe/branches/tooling/include/clang/Basic/BuiltinsMips.def
      - copied unchanged from r159493, cfe/trunk/include/clang/Basic/BuiltinsMips.def
    cfe/branches/tooling/lib/AST/CommentBriefParser.cpp
      - copied unchanged from r159493, cfe/trunk/lib/AST/CommentBriefParser.cpp
    cfe/branches/tooling/lib/AST/CommentLexer.cpp
      - copied unchanged from r159493, cfe/trunk/lib/AST/CommentLexer.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp
      - copied unchanged from r159493, cfe/trunk/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp
    cfe/branches/tooling/test/Analysis/traversal-algorithm.mm
      - copied unchanged from r159493, cfe/trunk/test/Analysis/traversal-algorithm.mm
    cfe/branches/tooling/test/CodeGen/branch-target-layout.c
      - copied unchanged from r159493, cfe/trunk/test/CodeGen/branch-target-layout.c
    cfe/branches/tooling/test/CodeGen/builtins-mips.c
      - copied unchanged from r159493, cfe/trunk/test/CodeGen/builtins-mips.c
    cfe/branches/tooling/test/CodeGen/tls-model.c
      - copied unchanged from r159493, cfe/trunk/test/CodeGen/tls-model.c
    cfe/branches/tooling/test/CodeGenCXX/global-block-literal-helpers.cpp
      - copied unchanged from r159493, cfe/trunk/test/CodeGenCXX/global-block-literal-helpers.cpp
    cfe/branches/tooling/test/CodeGenObjC/encode-test-6.m
      - copied unchanged from r159493, cfe/trunk/test/CodeGenObjC/encode-test-6.m
    cfe/branches/tooling/test/Driver/crash-report.c
      - copied unchanged from r159493, cfe/trunk/test/Driver/crash-report.c
    cfe/branches/tooling/test/Index/annotate-comments-unterminated.c
      - copied unchanged from r159493, cfe/trunk/test/Index/annotate-comments-unterminated.c
    cfe/branches/tooling/test/Index/compile_commands.json
      - copied unchanged from r159493, cfe/trunk/test/Index/compile_commands.json
    cfe/branches/tooling/test/Misc/diag-template-diffing-color.cpp
      - copied unchanged from r159493, cfe/trunk/test/Misc/diag-template-diffing-color.cpp
    cfe/branches/tooling/test/Misc/diag-template-diffing.cpp
      - copied unchanged from r159493, cfe/trunk/test/Misc/diag-template-diffing.cpp
    cfe/branches/tooling/test/PCH/pch__VA_ARGS__.c
      - copied unchanged from r159493, cfe/trunk/test/PCH/pch__VA_ARGS__.c
    cfe/branches/tooling/test/PCH/pch__VA_ARGS__.h
      - copied unchanged from r159493, cfe/trunk/test/PCH/pch__VA_ARGS__.h
    cfe/branches/tooling/test/Rewriter/objc-modern-StretAPI.mm
      - copied unchanged from r159493, cfe/trunk/test/Rewriter/objc-modern-StretAPI.mm
    cfe/branches/tooling/test/Sema/warn-self-assign-memvar.mm
      - copied unchanged from r159493, cfe/trunk/test/Sema/warn-self-assign-memvar.mm
    cfe/branches/tooling/test/SemaCXX/warn-static-function-inheader.cpp
      - copied unchanged from r159493, cfe/trunk/test/SemaCXX/warn-static-function-inheader.cpp
    cfe/branches/tooling/test/SemaCXX/warn-static-function-inheader.h
      - copied unchanged from r159493, cfe/trunk/test/SemaCXX/warn-static-function-inheader.h
    cfe/branches/tooling/test/SemaObjC/warn-retain-block-property.m
      - copied unchanged from r159493, cfe/trunk/test/SemaObjC/warn-retain-block-property.m
    cfe/branches/tooling/tools/libclang/CXCompilationDatabase.cpp
      - copied unchanged from r159493, cfe/trunk/tools/libclang/CXCompilationDatabase.cpp
    cfe/branches/tooling/unittests/AST/
      - copied from r159493, cfe/trunk/unittests/AST/
    cfe/branches/tooling/unittests/AST/CMakeLists.txt
      - copied unchanged from r159493, cfe/trunk/unittests/AST/CMakeLists.txt
    cfe/branches/tooling/unittests/AST/CommentLexer.cpp
      - copied unchanged from r159493, cfe/trunk/unittests/AST/CommentLexer.cpp
    cfe/branches/tooling/unittests/AST/Makefile
      - copied unchanged from r159493, cfe/trunk/unittests/AST/Makefile
Removed:
    cfe/branches/tooling/test/SemaObjC/arc-retain-block-property.m
Modified:
    cfe/branches/tooling/   (props changed)
    cfe/branches/tooling/bindings/python/clang/cindex.py
    cfe/branches/tooling/docs/InternalsManual.html
    cfe/branches/tooling/docs/ReleaseNotes.html
    cfe/branches/tooling/docs/UsersManual.html
    cfe/branches/tooling/docs/tools/clang.pod
    cfe/branches/tooling/include/clang-c/Index.h
    cfe/branches/tooling/include/clang/AST/ASTContext.h
    cfe/branches/tooling/include/clang/AST/DeclCXX.h
    cfe/branches/tooling/include/clang/AST/Expr.h
    cfe/branches/tooling/include/clang/AST/Mangle.h
    cfe/branches/tooling/include/clang/AST/RawCommentList.h
    cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h
    cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def
    cfe/branches/tooling/include/clang/Basic/Diagnostic.h
    cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/branches/tooling/include/clang/Basic/FileManager.h
    cfe/branches/tooling/include/clang/Basic/TargetBuiltins.h
    cfe/branches/tooling/include/clang/Basic/TokenKinds.def
    cfe/branches/tooling/include/clang/Driver/Compilation.h
    cfe/branches/tooling/include/clang/Driver/Options.td
    cfe/branches/tooling/include/clang/Driver/Types.def
    cfe/branches/tooling/include/clang/Frontend/CodeGenOptions.h
    cfe/branches/tooling/include/clang/Frontend/DiagnosticOptions.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
    cfe/branches/tooling/lib/AST/ASTContext.cpp
    cfe/branches/tooling/lib/AST/ASTDiagnostic.cpp
    cfe/branches/tooling/lib/AST/CMakeLists.txt
    cfe/branches/tooling/lib/AST/DeclCXX.cpp
    cfe/branches/tooling/lib/AST/Expr.cpp
    cfe/branches/tooling/lib/AST/ExprConstant.cpp
    cfe/branches/tooling/lib/AST/Mangle.cpp
    cfe/branches/tooling/lib/AST/MicrosoftMangle.cpp
    cfe/branches/tooling/lib/AST/RawCommentList.cpp
    cfe/branches/tooling/lib/AST/TypePrinter.cpp
    cfe/branches/tooling/lib/Analysis/ThreadSafety.cpp
    cfe/branches/tooling/lib/Basic/Diagnostic.cpp
    cfe/branches/tooling/lib/Basic/FileManager.cpp
    cfe/branches/tooling/lib/Basic/Targets.cpp
    cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp
    cfe/branches/tooling/lib/CodeGen/CGBuilder.h
    cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp
    cfe/branches/tooling/lib/CodeGen/CGCXXABI.cpp
    cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
    cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h
    cfe/branches/tooling/lib/CodeGen/CGDecl.cpp
    cfe/branches/tooling/lib/CodeGen/CGDeclCXX.cpp
    cfe/branches/tooling/lib/CodeGen/CGExpr.cpp
    cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp
    cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.cpp
    cfe/branches/tooling/lib/CodeGen/CGRecordLayout.h
    cfe/branches/tooling/lib/CodeGen/CGRecordLayoutBuilder.cpp
    cfe/branches/tooling/lib/CodeGen/CGValue.h
    cfe/branches/tooling/lib/CodeGen/CodeGenFunction.cpp
    cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h
    cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
    cfe/branches/tooling/lib/CodeGen/CodeGenModule.h
    cfe/branches/tooling/lib/Driver/Driver.cpp
    cfe/branches/tooling/lib/Driver/Tools.cpp
    cfe/branches/tooling/lib/Edit/Commit.cpp
    cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
    cfe/branches/tooling/lib/Frontend/TextDiagnostic.cpp
    cfe/branches/tooling/lib/Frontend/Warnings.cpp
    cfe/branches/tooling/lib/Headers/avx2intrin.h
    cfe/branches/tooling/lib/Headers/stddef.h
    cfe/branches/tooling/lib/Lex/Lexer.cpp
    cfe/branches/tooling/lib/Lex/PPDirectives.cpp
    cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp
    cfe/branches/tooling/lib/Lex/Pragma.cpp
    cfe/branches/tooling/lib/Lex/Preprocessor.cpp
    cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp
    cfe/branches/tooling/lib/Parse/ParseDecl.cpp
    cfe/branches/tooling/lib/Parse/Parser.cpp
    cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp
    cfe/branches/tooling/lib/Rewrite/RewriteObjC.cpp
    cfe/branches/tooling/lib/Sema/Sema.cpp
    cfe/branches/tooling/lib/Sema/SemaChecking.cpp
    cfe/branches/tooling/lib/Sema/SemaDecl.cpp
    cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp
    cfe/branches/tooling/lib/Sema/SemaExpr.cpp
    cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp
    cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp
    cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp
    cfe/branches/tooling/lib/Sema/SemaType.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/CoreEngine.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp
    cfe/branches/tooling/test/CMakeLists.txt
    cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
    cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
    cfe/branches/tooling/test/CodeGen/2010-02-10-PointerName.c
    cfe/branches/tooling/test/CodeGen/address-safety-attr.cpp
    cfe/branches/tooling/test/CodeGen/avx2-builtins.c
    cfe/branches/tooling/test/CodeGen/block-3.c
    cfe/branches/tooling/test/CodeGen/blocks.c
    cfe/branches/tooling/test/CodeGen/blocksignature.c
    cfe/branches/tooling/test/CodeGen/blockwithlocalstatic.c
    cfe/branches/tooling/test/CodeGen/capture-complex-expr-in-block.c
    cfe/branches/tooling/test/CodeGen/func-in-block.c
    cfe/branches/tooling/test/CodeGen/packed-nest-unpacked.c
    cfe/branches/tooling/test/CodeGen/varargs.c
    cfe/branches/tooling/test/CodeGenCXX/block-in-ctor-dtor.cpp
    cfe/branches/tooling/test/CodeGenCXX/blocks.cpp
    cfe/branches/tooling/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
    cfe/branches/tooling/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
    cfe/branches/tooling/test/CodeGenCXX/mangle-ms-back-references.cpp
    cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp
    cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m
    cfe/branches/tooling/test/CodeGenObjC/blocks-2.m
    cfe/branches/tooling/test/CodeGenObjC/blocks.m
    cfe/branches/tooling/test/CodeGenObjCXX/lambda-expressions.mm
    cfe/branches/tooling/test/CodeGenObjCXX/mangle-blocks.mm
    cfe/branches/tooling/test/CodeGenObjCXX/nrvo.mm
    cfe/branches/tooling/test/Driver/apple-kext-i386.cpp
    cfe/branches/tooling/test/Index/annotate-comments.cpp
    cfe/branches/tooling/test/Misc/diag-aka-types.cpp
    cfe/branches/tooling/test/Misc/warning-flags-enabled.c
    cfe/branches/tooling/test/Misc/warning-flags.c
    cfe/branches/tooling/test/Parser/DelayedTemplateParsing.cpp
    cfe/branches/tooling/test/Preprocessor/line-directive.c
    cfe/branches/tooling/test/Rewriter/objc-modern-container-subscript.mm
    cfe/branches/tooling/test/SemaCXX/deleted-function.cpp
    cfe/branches/tooling/test/SemaCXX/neon-vector-types.cpp
    cfe/branches/tooling/test/SemaCXX/typo-correction.cpp
    cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp
    cfe/branches/tooling/test/SemaCXX/warn-unique-enum.cpp
    cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp   (props changed)
    cfe/branches/tooling/test/SemaCXX/warn-unused-member.cpp
    cfe/branches/tooling/test/SemaObjC/provisional-ivar-lookup.m
    cfe/branches/tooling/test/SemaObjC/weak-receiver-warn.m
    cfe/branches/tooling/test/SemaObjCXX/arc-type-traits.mm
    cfe/branches/tooling/tools/c-index-test/c-index-test.c
    cfe/branches/tooling/tools/libclang/CIndex.cpp
    cfe/branches/tooling/tools/libclang/CMakeLists.txt
    cfe/branches/tooling/tools/libclang/Indexing.cpp
    cfe/branches/tooling/tools/libclang/Makefile
    cfe/branches/tooling/tools/libclang/libclang.exports
    cfe/branches/tooling/unittests/Makefile
    cfe/branches/tooling/www/content.css
    cfe/branches/tooling/www/diagnostics.html

Propchange: cfe/branches/tooling/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jun 30 16:45:28 2012
@@ -1,3 +1,3 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:146581-159190
+/cfe/trunk:146581-159493
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/tooling/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/bindings/python/clang/cindex.py?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/bindings/python/clang/cindex.py (original)
+++ cfe/branches/tooling/bindings/python/clang/cindex.py Sat Jun 30 16:45:28 2012
@@ -2096,6 +2096,120 @@
         """True if the included file is the input file."""
         return self.depth == 0
 
+class CompilationDatabaseError(Exception):
+    """Represents an error that occurred when working with a CompilationDatabase
+
+    Each error is associated to an enumerated value, accessible under
+    e.cdb_error. Consumers can compare the value with one of the ERROR_
+    constants in this class.
+    """
+
+    # An unknown error occured
+    ERROR_UNKNOWN = 0
+
+    # The database could not be loaded
+    ERROR_CANNOTLOADDATABASE = 1
+
+    def __init__(self, enumeration, message):
+        assert isinstance(enumeration, int)
+
+        if enumeration > 1:
+            raise Exception("Encountered undefined CompilationDatabase error "
+                            "constant: %d. Please file a bug to have this "
+                            "value supported." % enumeration)
+
+        self.cdb_error = enumeration
+        Exception.__init__(self, 'Error %d: %s' % (enumeration, message))
+
+class CompileCommand(object):
+    """Represents the compile command used to build a file"""
+    def __init__(self, cmd, ccmds):
+        self.cmd = cmd
+        # Keep a reference to the originating CompileCommands
+        # to prevent garbage collection
+        self.ccmds = ccmds
+
+    @property
+    def directory(self):
+        """Get the working directory for this CompileCommand"""
+        return CompileCommand_getDirectory(self.cmd).spelling
+
+    @property
+    def arguments(self):
+        """
+        Get an iterable object providing each argument in the
+        command line for the compiler invocation as a _CXString.
+
+        Invariants :
+          - the first argument is the compiler executable
+          - the last argument is the file being compiled
+        """
+        length = CompileCommand_getNumArgs(self.cmd)
+        for i in xrange(length):
+          yield CompileCommand_getArg(self.cmd, i)
+
+class CompileCommands(object):
+    """
+    CompileCommands is an iterable object containing all CompileCommand
+    that can be used for building a specific file.
+    """
+    def __init__(self, ccmds):
+        self.ccmds = ccmds
+
+    def __del__(self):
+        CompileCommands_dispose(self.ccmds)
+
+    def __len__(self):
+        return int(CompileCommands_getSize(self.ccmds))
+
+    def __getitem__(self, i):
+        cc = CompileCommands_getCommand(self.ccmds, i)
+        if cc is None:
+            raise IndexError
+        return CompileCommand(cc, self)
+
+    @staticmethod
+    def from_result(res, fn, args):
+        if not res:
+            return None
+        return CompileCommands(res)
+
+class CompilationDatabase(ClangObject):
+    """
+    The CompilationDatabase is a wrapper class around
+    clang::tooling::CompilationDatabase
+
+    It enables querying how a specific source file can be built.
+    """
+
+    def __del__(self):
+        CompilationDatabase_dispose(self)
+
+    @staticmethod
+    def from_result(res, fn, args):
+        if not res:
+            raise CompilationDatabaseError(0,
+                                           "CompilationDatabase loading failed")
+        return CompilationDatabase(res)
+
+    @staticmethod
+    def fromDirectory(buildDir):
+        """Builds a CompilationDatabase from the database found in buildDir"""
+        errorCode = c_uint()
+        try:
+          cdb = CompilationDatabase_fromDirectory(buildDir, byref(errorCode))
+        except CompilationDatabaseError as e:
+          raise CompilationDatabaseError(int(errorCode.value),
+                                         "CompilationDatabase loading failed")
+        return cdb
+
+    def getCompileCommands(self, filename):
+        """
+        Get an iterable object providing all the CompileCommands available to
+        build filename. Returns None if filename is not found in the database.
+        """
+        return CompilationDatabase_getCompileCommands(self, filename)
+
 # Additional Functions and Types
 
 # String Functions
@@ -2463,9 +2577,48 @@
 _clang_getCompletionPriority.argtypes = [c_void_p]
 _clang_getCompletionPriority.restype = c_int
 
+# Compilation Database
+CompilationDatabase_fromDirectory = lib.clang_tooling_CompilationDatabase_fromDirectory
+CompilationDatabase_fromDirectory.argtypes = [c_char_p, POINTER(c_uint)]
+CompilationDatabase_fromDirectory.restype = c_object_p
+CompilationDatabase_fromDirectory.errcheck = CompilationDatabase.from_result
+
+CompilationDatabase_dispose = lib.clang_tooling_CompilationDatabase_dispose
+CompilationDatabase_dispose.argtypes = [c_object_p]
+
+CompilationDatabase_getCompileCommands = lib.clang_tooling_CompilationDatabase_getCompileCommands
+CompilationDatabase_getCompileCommands.argtypes = [c_object_p, c_char_p]
+CompilationDatabase_getCompileCommands.restype = c_object_p
+CompilationDatabase_getCompileCommands.errcheck = CompileCommands.from_result
+
+CompileCommands_dispose = lib.clang_tooling_CompileCommands_dispose
+CompileCommands_dispose.argtypes = [c_object_p]
+
+CompileCommands_getSize = lib.clang_tooling_CompileCommands_getSize
+CompileCommands_getSize.argtypes = [c_object_p]
+CompileCommands_getSize.restype = c_uint
+
+CompileCommands_getCommand = lib.clang_tooling_CompileCommands_getCommand
+CompileCommands_getCommand.argtypes = [c_object_p, c_uint]
+CompileCommands_getCommand.restype = c_object_p
+
+CompileCommand_getDirectory = lib.clang_tooling_CompileCommand_getDirectory
+CompileCommand_getDirectory.argtypes = [c_object_p]
+CompileCommand_getDirectory.restype = _CXString
+
+CompileCommand_getNumArgs = lib.clang_tooling_CompileCommand_getNumArgs
+CompileCommand_getNumArgs.argtypes = [c_object_p]
+CompileCommand_getNumArgs.restype = c_uint
+
+CompileCommand_getArg = lib.clang_tooling_CompileCommand_getArg
+CompileCommand_getArg.argtypes = [c_object_p, c_uint]
+CompileCommand_getArg.restype = _CXString
 
 __all__ = [
     'CodeCompletionResults',
+    'CompilationDatabase',
+    'CompileCommands',
+    'CompileCommand',
     'CursorKind',
     'Cursor',
     'Diagnostic',

Modified: cfe/branches/tooling/docs/InternalsManual.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/InternalsManual.html?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/docs/InternalsManual.html (original)
+++ cfe/branches/tooling/docs/InternalsManual.html Sat Jun 30 16:45:28 2012
@@ -357,6 +357,12 @@
 <tr><td>Example:</td><td><tt>"candidate found by name lookup is %q0"</tt></td></tr>
 <tr><td>Class:</td><td>NamedDecl*</td></tr>
 <tr><td>Description</td><td><p>This formatter indicates that the fully-qualified name of the declaration should be printed, e.g., "std::vector" rather than "vector".</p></td></tr>
+
+<tr><td colspan="2"><b>"diff" format</b></td></tr>
+<tr><td>Example:</td><td><tt>"no known conversion %diff{from | to | }1,2"</tt></td></tr>
+<tr><td>Class:</td><td>QualType</td></tr>
+<tr><td>Description</td><td><p>This formatter takes two QualTypes and attempts to print a template difference between the two.  If tree printing is off, the text inside the the braces before the pipe is printed, with the formatted text replacing the $.  If tree printing is on, the text after the pipe is printed and a type tree is printed after the diagnostic message.
+</p></td></tr>
     
 </table>
 

Modified: cfe/branches/tooling/docs/ReleaseNotes.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/ReleaseNotes.html?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/docs/ReleaseNotes.html (original)
+++ cfe/branches/tooling/docs/ReleaseNotes.html Sat Jun 30 16:45:28 2012
@@ -121,6 +121,55 @@
   This functionality can be enabled or disabled separately from
   <tt>-Wuninitialized</tt> with the <tt>-Wsometimes-uninitialized</tt> warning
   flag.</li>
+
+  <li>Template type diffing improves the display of diagnostics with templated
+  types in them.
+
+<pre>
+int f(vector<map<int, double>>);
+int x = f(vector<map<int, float>>());
+</pre>
+  The error message is the same, but the note is different based on the options selected.
+<pre>
+<b>template-diff.cpp:5:9: <span class="error">error:</span> no matching function for call to 'f'</b>
+int x = f(vector<map<int, float>>());
+        <span class="caret">^</span>
+</pre>
+  Templated type diffing with type elision (default):
+<pre>
+<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion from 'vector<map<[...], <span class="template-highlight">float</span>>>' to 'vector<map<[...], <span class="template-highlight">double</span>>>' for 1st argument;
+int f(vector<map<int, double>>);
+    <span class="caret">^</span>
+</pre>
+  Templated type diffing without type elision (-fno-elide-type):
+<pre>
+<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion from 'vector<map<int, <span class="template-highlight">float</span>>>' to 'vector<map<int, <span class="template-highlight">double</span>>>' for 1st argument;
+int f(vector<map<int, double>>);
+    <span class="caret">^</span>
+</pre>
+  Templated tree printing with type elision (-fdiagnostics-show-template-tree):
+<pre>
+<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion for 1st argument;
+  vector<
+    map<
+      [...],
+      [<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]>>
+int f(vector<map<int, double>>);
+    <span class="caret">^</span>
+</pre>
+  Templated tree printing without type elision (-fdiagnostics-show-template-tree -fno-elide-type):
+<pre>
+<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion for 1st argument;
+  vector<
+    map<
+      int,
+      [<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]>>
+int f(vector<map<int, double>>);
+    <span class="caret">^</span>
+</pre>
+
+  </li>
+
 </ul>
 
 <h4 id="tlsmodel">Support for <code>tls_model</code> attribute</h4>

Modified: cfe/branches/tooling/docs/UsersManual.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/UsersManual.html?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/docs/UsersManual.html (original)
+++ cfe/branches/tooling/docs/UsersManual.html Sat Jun 30 16:45:28 2012
@@ -417,6 +417,48 @@
 "\xxx").</p>
 </dd>
 
+<dt id="opt_fno-elide-type">
+<b>-fno-elide-type</b>:
+Turns off elision in template type printing.</td>
+<dd><p>The default for template type printing is to elide as many template
+arguments as possible, removing those which are the same in both template types,
+leaving only the differences.  Adding this flag will print all the template
+arguments.  If supported by the terminal, highlighting will still appear on
+differing arguments.</p>
+
+Default:
+<pre>
+t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion from 'vector<map<[...], map<<span class="template-highlight">float</span>, [...]>>>' to 'vector<map<[...], map<<span class="template-highlight">double</span>, [...]>>>' for 1st argument;
+</pre>
+-fno-elide-type:
+<pre>
+t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion from 'vector<map<int, map<<span class="template-highlight">float</span>, int>>>' to 'vector<map<int, map<<span class="template-highlight">double</span>, int>>>' for 1st argument;
+</pre>
+</dd>
+
+<dt id="opt_fdiagnostics-show-template-tree">
+<b>-fdiagnostics-show-template-tree</b>:
+Template type diffing prints a text tree.</td>
+<dd><p>For diffing large templated types, this option will cause Clang to
+display the templates as an indented text tree, one argument per line, with
+differences marked inline.  This is compatible with -fno-elide-type.</p>
+
+Default:
+<pre>
+t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion from 'vector<map<[...], map<<span class="template-highlight">float</span>, [...]>>>' to 'vector<map<[...], map<<span class="template-highlight">double</span>, [...]>>>' for 1st argument;
+</pre>
+-fdiagnostics-show-template-tree
+<pre>
+t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion for 1st argument;
+  vector<
+    map<
+      [...],
+      map<
+        [<span class="template-highlight">float</span> != <span class="template-highlight">float</span>],
+        [...]>>>
+</pre>
+</dd>
+
 </dl>
 
 

Modified: cfe/branches/tooling/docs/tools/clang.pod
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/tools/clang.pod?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/docs/tools/clang.pod (original)
+++ cfe/branches/tooling/docs/tools/clang.pod Sat Jun 30 16:45:28 2012
@@ -303,6 +303,14 @@
 This flag specifies that variables without initializers get common linkage.  It
 can be disabled with B<-fno-common>.
 
+=item B<-ftls-model>
+
+Set the default thread-local storage (TLS) model to use for thread-local
+variables. Valid values are: "global-dynamic", "local-dynamic", "initial-exec"
+and "local-exec". The default is "global-dynamic". The default model can be
+overridden with the tls_model attribute. The compiler will try to choose a more
+efficient model if possible.
+
 =item B<-flto> B<-emit-llvm>
 
 Generate output files in LLVM formats, suitable for link time optimization. When

Modified: cfe/branches/tooling/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang-c/Index.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang-c/Index.h (original)
+++ cfe/branches/tooling/include/clang-c/Index.h Sat Jun 30 16:45:28 2012
@@ -20,31 +20,13 @@
 #include <time.h>
 #include <stdio.h>
 
+#include "clang-c/Platform.h"
+#include "clang-c/CXString.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/* MSVC DLL import/export. */
-#ifdef _MSC_VER
-  #ifdef _CINDEX_LIB_
-    #define CINDEX_LINKAGE __declspec(dllexport)
-  #else
-    #define CINDEX_LINKAGE __declspec(dllimport)
-  #endif
-#else
-  #define CINDEX_LINKAGE
-#endif
-
-#ifdef __GNUC__
-  #define CINDEX_DEPRECATED __attribute__((deprecated))
-#else
-  #ifdef _MSC_VER
-    #define CINDEX_DEPRECATED __declspec(deprecated)
-  #else
-    #define CINDEX_DEPRECATED
-  #endif
-#endif
-
 /** \defgroup CINDEX libclang: C Interface to Clang
  *
  * The C Interface to Clang provides a relatively small API that exposes
@@ -157,39 +139,6 @@
 } CXVersion;
   
 /**
- * \defgroup CINDEX_STRING String manipulation routines
- *
- * @{
- */
-
-/**
- * \brief A character string.
- *
- * The \c CXString type is used to return strings from the interface when
- * the ownership of that string might different from one call to the next.
- * Use \c clang_getCString() to retrieve the string data and, once finished
- * with the string data, call \c clang_disposeString() to free the string.
- */
-typedef struct {
-  void *data;
-  unsigned private_flags;
-} CXString;
-
-/**
- * \brief Retrieve the character data associated with the given string.
- */
-CINDEX_LINKAGE const char *clang_getCString(CXString string);
-
-/**
- * \brief Free the given string,
- */
-CINDEX_LINKAGE void clang_disposeString(CXString string);
-
-/**
- * @}
- */
-
-/**
  * \brief Provides a shared context for creating translation units.
  *
  * It provides two options:
@@ -3201,6 +3150,12 @@
 CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
 
 /**
+ * \brief Given a cursor that represents a declaration, return the associated
+ * \\brief paragraph; otherwise return the first paragraph.
+ */
+CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
+
+/**
  * @}
  */
 

Modified: cfe/branches/tooling/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ASTContext.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ASTContext.h (original)
+++ cfe/branches/tooling/include/clang/AST/ASTContext.h Sat Jun 30 16:45:28 2012
@@ -429,7 +429,7 @@
   /// with a given declaration.
   mutable llvm::DenseMap<const Decl *, const RawComment *> DeclComments;
 
-  /// \brief Return the Doxygen-style comment attached to a given declaration,
+  /// \brief Return the documentation comment attached to a given declaration,
   /// without looking into cache.
   const RawComment *getRawCommentForDeclNoCache(const Decl *D) const;
 
@@ -438,7 +438,7 @@
     Comments.addComment(RC);
   }
 
-  /// \brief Return the Doxygen-style comment attached to a given declaration.
+  /// \brief Return the documentation comment attached to a given declaration.
   /// Returns NULL if no comment is attached.
   const RawComment *getRawCommentForDecl(const Decl *D) const;
 

Modified: cfe/branches/tooling/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/DeclCXX.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclCXX.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclCXX.h Sat Jun 30 16:45:28 2012
@@ -1630,7 +1630,20 @@
   /// supplied by IR generation to either forward to the function call operator
   /// or clone the function call operator.
   bool isLambdaStaticInvoker() const;
-  
+
+  /// \brief Find the method in RD that corresponds to this one.
+  ///
+  /// Find if RD or one of the classes it inherits from override this method.
+  /// If so, return it. RD is assumed to be a base class of the class defining
+  /// this method (or be the class itself).
+  CXXMethodDecl *
+  getCorrespondingMethodInClass(const CXXRecordDecl *RD);
+
+  const CXXMethodDecl *
+  getCorrespondingMethodInClass(const CXXRecordDecl *RD) const {
+    return const_cast<CXXMethodDecl*>(this)->getCorrespondingMethodInClass(RD);
+  }
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classof(const CXXMethodDecl *D) { return true; }

Modified: cfe/branches/tooling/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Expr.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Expr.h (original)
+++ cfe/branches/tooling/include/clang/AST/Expr.h Sat Jun 30 16:45:28 2012
@@ -634,6 +634,13 @@
   /// ParenExpr or CastExprs, returning their operand.
   Expr *IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY;
 
+  /// Ignore parentheses and derived-to-base casts.
+  Expr *ignoreParenBaseCasts() LLVM_READONLY;
+
+  const Expr *ignoreParenBaseCasts() const LLVM_READONLY {
+    return const_cast<Expr*>(this)->ignoreParenBaseCasts();
+  }
+
   /// \brief Determine whether this expression is a default function argument.
   ///
   /// Default arguments are implicitly generated in the abstract syntax tree
@@ -665,6 +672,15 @@
 
   static bool hasAnyTypeDependentArguments(llvm::ArrayRef<Expr *> Exprs);
 
+  /// \brief For an expression of class type or pointer to class type,
+  /// return the most derived class decl the expression is known to refer to.
+  ///
+  /// If this expression is a cast, this method looks through it to find the
+  /// most derived decl that can be inferred from the expression.
+  /// This is valid because derived-to-base conversions have undefined
+  /// behavior if the object isn't dynamically of the derived type.
+  const CXXRecordDecl *getBestDynamicClassType() const;
+
   static bool classof(const Stmt *T) {
     return T->getStmtClass() >= firstExprConstant &&
            T->getStmtClass() <= lastExprConstant;

Modified: cfe/branches/tooling/include/clang/AST/Mangle.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Mangle.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Mangle.h (original)
+++ cfe/branches/tooling/include/clang/AST/Mangle.h Sat Jun 30 16:45:28 2012
@@ -121,6 +121,7 @@
                              raw_ostream &) = 0;
 
   void mangleGlobalBlock(const BlockDecl *BD,
+                         const NamedDecl *ID,
                          raw_ostream &Out);
   void mangleCtorBlock(const CXXConstructorDecl *CD, CXXCtorType CT,
                        const BlockDecl *BD, raw_ostream &Out);
@@ -129,7 +130,8 @@
   void mangleBlock(const DeclContext *DC, const BlockDecl *BD,
                    raw_ostream &Out);
   // Do the right thing.
-  void mangleBlock(const BlockDecl *BD, raw_ostream &Out);
+  void mangleBlock(const BlockDecl *BD, raw_ostream &Out,
+                   const NamedDecl *ID=0);
 
   void mangleObjCMethodName(const ObjCMethodDecl *MD,
                             raw_ostream &);

Modified: cfe/branches/tooling/include/clang/AST/RawCommentList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/RawCommentList.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/RawCommentList.h (original)
+++ cfe/branches/tooling/include/clang/AST/RawCommentList.h Sat Jun 30 16:45:28 2012
@@ -15,6 +15,7 @@
 
 namespace clang {
 
+class ASTContext;
 class ASTReader;
 
 class RawComment {
@@ -27,7 +28,7 @@
     CK_BCPLExcl,     ///< \code //! stuff \endcode
     CK_JavaDoc,      ///< \code /** stuff */ \endcode
     CK_Qt,           ///< \code /*! stuff */ \endcode, also used by HeaderDoc
-    CK_Merged        ///< Two or more Doxygen comments merged together
+    CK_Merged        ///< Two or more documentation comments merged together
   };
 
   RawComment() : Kind(CK_Invalid), IsAlmostTrailingComment(false) { }
@@ -53,7 +54,7 @@
   /// \code /**< stuff */ \endcode
   /// \code /*!< stuff */ \endcode
   bool isTrailingComment() const LLVM_READONLY {
-    assert(isDoxygen());
+    assert(isDocumentation());
     return IsTrailingComment;
   }
 
@@ -64,13 +65,13 @@
     return IsAlmostTrailingComment;
   }
 
-  /// Returns true if this comment is not a Doxygen comment.
+  /// Returns true if this comment is not a documentation comment.
   bool isOrdinary() const LLVM_READONLY {
     return (Kind == CK_OrdinaryBCPL) || (Kind == CK_OrdinaryC);
   }
 
-  /// Returns true if this comment any kind of a Doxygen comment.
-  bool isDoxygen() const LLVM_READONLY {
+  /// Returns true if this comment any kind of a documentation comment.
+  bool isDocumentation() const LLVM_READONLY {
     return !isInvalid() && !isOrdinary();
   }
 
@@ -91,11 +92,21 @@
   unsigned getBeginLine(const SourceManager &SM) const;
   unsigned getEndLine(const SourceManager &SM) const;
 
+  StringRef getBriefText(const ASTContext &Context) const {
+    if (BriefTextValid)
+      return BriefText;
+
+    return extractBriefText(Context);
+  }
+
 private:
   SourceRange Range;
 
   mutable StringRef RawText;
-  mutable bool RawTextValid : 1; ///< True if RawText is valid
+  mutable StringRef BriefText;
+
+  mutable bool RawTextValid : 1;   ///< True if RawText is valid
+  mutable bool BriefTextValid : 1; ///< True if BriefText is valid
 
   unsigned Kind : 3;
 
@@ -110,7 +121,7 @@
   /// \brief Constructor for AST deserialization.
   RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,
              bool IsAlmostTrailingComment) :
-    Range(SR), RawTextValid(false), Kind(K),
+    Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),
     IsTrailingComment(IsTrailingComment),
     IsAlmostTrailingComment(IsAlmostTrailingComment),
     BeginLineValid(false), EndLineValid(false)
@@ -118,6 +129,8 @@
 
   StringRef getRawTextSlow(const SourceManager &SourceMgr) const;
 
+  StringRef extractBriefText(const ASTContext &Context) const;
+
   friend class ASTReader;
 };
 

Modified: cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h Sat Jun 30 16:45:28 2012
@@ -1762,7 +1762,7 @@
   TRY_TO(TraverseDeclaratorHelper(D));
   // Default params are taken care of when we traverse the ParmVarDecl.
   if (!isa<ParmVarDecl>(D) &&
-      (!D->isCXXForRangeDecl() || shouldVisitImplicitCode()))
+      (!D->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
     TRY_TO(TraverseStmt(D->getInit()));
   return true;
 }
@@ -1881,7 +1881,7 @@
 DEF_TRAVERSE_STMT(ObjCForCollectionStmt, { })
 DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, { })
 DEF_TRAVERSE_STMT(CXXForRangeStmt, {
-  if (!shouldVisitImplicitCode()) {
+  if (!getDerived().shouldVisitImplicitCode()) {
     TRY_TO(TraverseStmt(S->getLoopVarStmt()));
     TRY_TO(TraverseStmt(S->getRangeInit()));
     TRY_TO(TraverseStmt(S->getBody()));

Modified: cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def Sat Jun 30 16:45:28 2012
@@ -595,6 +595,25 @@
 BUILTIN(__builtin_ia32_psrlv4di, "V4LLiV4LLiV4LLi", "")
 BUILTIN(__builtin_ia32_psrlv2di, "V2LLiV2LLiV2LLi", "")
 
+// GATHER
+BUILTIN(__builtin_ia32_gatherd_pd, "V2dV2dV2dC*V4iV2dIc", "")
+BUILTIN(__builtin_ia32_gatherd_pd256, "V4dV4dV4dC*V4iV4dIc", "")
+BUILTIN(__builtin_ia32_gatherq_pd, "V2dV2dV2dC*V2LLiV2dIc", "")
+BUILTIN(__builtin_ia32_gatherq_pd256, "V4dV4dV4dC*V4LLiV4dIc", "")
+BUILTIN(__builtin_ia32_gatherd_ps, "V4fV4fV4fC*V4iV4fIc", "")
+BUILTIN(__builtin_ia32_gatherd_ps256, "V8fV8fV8fC*V8iV8fIc", "")
+BUILTIN(__builtin_ia32_gatherq_ps, "V4fV4fV4fC*V2LLiV4fIc", "")
+BUILTIN(__builtin_ia32_gatherq_ps256, "V4fV4fV4fC*V4LLiV4fIc", "")
+
+BUILTIN(__builtin_ia32_gatherd_q, "V2LLiV2LLiV2LLiC*V4iV2LLiIc", "")
+BUILTIN(__builtin_ia32_gatherd_q256, "V4LLiV4LLiV4LLiC*V4iV4LLiIc", "")
+BUILTIN(__builtin_ia32_gatherq_q, "V2LLiV2LLiV2LLiC*V2LLiV2LLiIc", "")
+BUILTIN(__builtin_ia32_gatherq_q256, "V4LLiV4LLiV4LLiC*V4LLiV4LLiIc", "")
+BUILTIN(__builtin_ia32_gatherd_d, "V4iV4iV4iC*V4iV4iIc", "")
+BUILTIN(__builtin_ia32_gatherd_d256, "V8iV8iV8iC*V8iV8iIc", "")
+BUILTIN(__builtin_ia32_gatherq_d, "V4iV4iV4iC*V2LLiV4iIc", "")
+BUILTIN(__builtin_ia32_gatherq_d256, "V4iV4iV4iC*V4LLiV4iIc", "")
+
 // BMI
 BUILTIN(__builtin_ia32_bextr_u32, "UiUiUi", "")
 BUILTIN(__builtin_ia32_bextr_u64, "ULLiULLiULLi", "")

Modified: cfe/branches/tooling/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/Diagnostic.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/Diagnostic.h (original)
+++ cfe/branches/tooling/include/clang/Basic/Diagnostic.h Sat Jun 30 16:45:28 2012
@@ -153,7 +153,8 @@
     ak_declarationname, // DeclarationName
     ak_nameddecl,       // NamedDecl *
     ak_nestednamespec,  // NestedNameSpecifier *
-    ak_declcontext      // DeclContext *
+    ak_declcontext,     // DeclContext *
+    ak_qualtype_pair    // pair<QualType, QualType>
   };
 
   /// Specifies which overload candidates to display when overload resolution
@@ -175,6 +176,9 @@
   bool ErrorsAsFatal;            // Treat errors like fatal errors.
   bool SuppressSystemWarnings;   // Suppress warnings in system headers.
   bool SuppressAllDiagnostics;   // Suppress all diagnostics.
+  bool ElideType;                // Elide common types of templates.
+  bool PrintTemplateTree;        // Print a tree when comparing templates.
+  bool ShowColors;               // Color printing is enabled.
   OverloadsShown ShowOverloads;  // Which overload candidates to show.
   unsigned ErrorLimit;           // Cap of # errors emitted, 0 -> no limit.
   unsigned TemplateBacktraceLimit; // Cap on depth of template backtrace stack,
@@ -438,7 +442,22 @@
     SuppressAllDiagnostics = Val; 
   }
   bool getSuppressAllDiagnostics() const { return SuppressAllDiagnostics; }
-  
+
+  /// \brief Set type eliding, to skip outputting same types occurring in
+  /// template types.
+  void setElideType(bool Val = true) { ElideType = Val; }
+  bool getElideType() { return ElideType; }
+ 
+  /// \brief Set tree printing, to outputting the template difference in a
+  /// tree format.
+  void setPrintTemplateTree(bool Val = false) { PrintTemplateTree = Val; }
+  bool getPrintTemplateTree() { return PrintTemplateTree; }
+ 
+  /// \brief Set color printing, so the type diffing will inject color markers
+  /// into the output.
+  void setShowColors(bool Val = false) { ShowColors = Val; }
+  bool getShowColors() { return ShowColors; }
+
   /// \brief Specify which overload candidates to show when overload resolution
   /// fails.  By default, we show all candidates.
   void setShowOverloads(OverloadsShown Val) {
@@ -1058,7 +1077,6 @@
     return DiagObj->DiagArgumentsVal[Idx];
   }
 
-
   /// getNumRanges - Return the number of source ranges associated with this
   /// diagnostic.
   unsigned getNumRanges() const {
@@ -1223,6 +1241,20 @@
   }
 };
 
+// Struct used for sending info about how a type should be printed.
+struct TemplateDiffTypes {
+  intptr_t FromType;
+  intptr_t ToType;
+  unsigned PrintTree : 1;
+  unsigned PrintFromType : 1;
+  unsigned ElideType : 1;
+  unsigned ShowColors : 1;
+};
+
+/// Special character that the diagnostic printer will use to toggle the bold
+/// attribute.  The character itself will be not be printed.
+const char ToggleHighlight = 127;
+
 }  // end namespace clang
 
 #endif

Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td Sat Jun 30 16:45:28 2012
@@ -145,6 +145,9 @@
 def : DiagGroup<"old-style-definition">;
 def OutOfLineDeclaration : DiagGroup<"out-of-line-declaration">;
 def : DiagGroup<"overflow">;
+def ForwardClassReceiver : DiagGroup<"receiver-forward-class">;
+def MethodAccess : DiagGroup<"objc-method-access">;
+def ObjCReceiver : DiagGroup<"receiver-expr">;
 def OverlengthStrings : DiagGroup<"overlength-strings">;
 def OverloadedVirtual : DiagGroup<"overloaded-virtual">;
 def ObjCPropertyImpl : DiagGroup<"objc-property-implementation">;
@@ -166,7 +169,8 @@
 def ReturnType : DiagGroup<"return-type", [ReturnTypeCLinkage]>;
 def BindToTemporaryCopy : DiagGroup<"bind-to-temporary-copy",
                                     [CXX98CompatBindToTemporaryCopy]>;
-def SelfAssignment : DiagGroup<"self-assign">;
+def SelfAssignmentMemvar : DiagGroup<"self-assign-memvar">;
+def SelfAssignment : DiagGroup<"self-assign", [SelfAssignmentMemvar]>;
 def SemiBeforeMethodBody : DiagGroup<"semicolon-before-method-body">;
 def Sentinel : DiagGroup<"sentinel">;
 def MissingMethodReturnType : DiagGroup<"missing-method-return-type">;
@@ -214,6 +218,7 @@
   DiagGroup<"implicit-fallthrough-per-function">;
 def ImplicitFallthrough  : DiagGroup<"implicit-fallthrough",
                                      [ImplicitFallthroughPerFunction]>;
+def InvalidPPToken : DiagGroup<"invalid-pp-token">;
 def Trigraphs      : DiagGroup<"trigraphs">;
 
 def : DiagGroup<"type-limits">;

Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td Sat Jun 30 16:45:28 2012
@@ -64,9 +64,12 @@
 def warn_cxx11_keyword : Warning<"'%0' is a keyword in C++11">,
   InGroup<CXX11Compat>, DefaultIgnore;
 
-def warn_unterminated_string : ExtWarn<"missing terminating '\"' character">;
-def warn_unterminated_char : ExtWarn<"missing terminating ' character">;
-def err_empty_character : Error<"empty character constant">;
+def ext_unterminated_string : ExtWarn<"missing terminating '\"' character">,
+  InGroup<InvalidPPToken>;
+def ext_unterminated_char : ExtWarn<"missing terminating ' character">,
+  InGroup<InvalidPPToken>;
+def ext_empty_character : ExtWarn<"empty character constant">,
+  InGroup<InvalidPPToken>;
 def err_unterminated_block_comment : Error<"unterminated /* comment">;
 def err_invalid_character_to_charify : Error<
   "invalid argument to convert to character">;
@@ -415,6 +418,9 @@
   "floating point literal in preprocessor expression">;
 def err_pp_line_requires_integer : Error<
   "#line directive requires a positive integer argument">;
+def ext_pp_line_zero : Extension<
+  "#line directive with zero argument is a GNU extension">, 
+  InGroup<GNU>;
 def err_pp_line_invalid_filename : Error<
   "invalid filename for #line directive">;
 def warn_pp_line_decimal : Warning<

Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td Sat Jun 30 16:45:28 2012
@@ -23,6 +23,9 @@
 def warn_identical_enum_values : Warning<
   "all elements of %0 are initialized with literals to value %1">,
   InGroup<DiagGroup<"unique-enum">>;
+def note_identical_enum_values : Note<
+  "initialize the last element with the previous element to silence "
+  "this warning">;
 
 // Constant expressions
 def err_expr_not_ice : Error<
@@ -170,6 +173,10 @@
 def warn_unneeded_internal_decl : Warning<
   "%select{function|variable}0 %1 is not needed and will not be emitted">,
   InGroup<UnneededInternalDecl>, DefaultIgnore;
+def warn_unneeded_static_internal_decl : Warning<
+  "'static' function %0 declared in header file "
+  "should be declared 'static inline'">,
+  InGroup<UnneededInternalDecl>, DefaultIgnore;
 def warn_unneeded_member_function : Warning<
   "member function %0 is not needed and will not be emitted">,
   InGroup<UnneededMemberFunction>, DefaultIgnore;
@@ -631,8 +638,8 @@
   " declared in a protocol">,
   InGroup<DiagGroup<"objc-protocol-property-synthesis">>;
 def warn_autosynthesis_property_ivar_match :Warning<
-  "autosynthesized property '%0' will use %select{|synthesized}1 instance variable "
-  "'%2', not existing instance variable '%3'">,
+  "autosynthesized property %0 will use %select{|synthesized}1 instance variable "
+  "%2, not existing instance variable %3">,
   InGroup<DiagGroup<"objc-autosynthesis-property-ivar-name-match">>;
 def warn_missing_explicit_synthesis : Warning <
   "auto property synthesis is synthesizing property not explicitly synthesized">,
@@ -1143,22 +1150,23 @@
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
   "volatile and restrict|const, volatile, and restrict}6)}4">;
 
-def err_lvalue_to_rvalue_ref : Error<"rvalue reference to type %0 cannot bind "
-  "to lvalue of type %1">;
+def err_lvalue_to_rvalue_ref : Error<"rvalue reference %diff{to type $ cannot "
+  "bind to lvalue of type $|cannot bind to incompatible lvalue}0,1">;
 def err_lvalue_reference_bind_to_initlist : Error<
   "%select{non-const|volatile}0 lvalue reference to type %1 cannot bind to an "
   "initializer list temporary">;
 def err_lvalue_reference_bind_to_temporary : Error<
-  "%select{non-const|volatile}0 lvalue reference to type %1 cannot bind to a "
-  "temporary of type %2">;
+  "%select{non-const|volatile}0 lvalue reference %diff{to type $ cannot bind "
+  "to a temporary of type $|cannot bind to incompatible temporary}1,2">;
 def err_lvalue_reference_bind_to_unrelated : Error<
-  "%select{non-const|volatile}0 lvalue reference to type %1 cannot bind to a "
-  "value of unrelated type %2">;
+  "%select{non-const|volatile}0 lvalue reference %diff{to type $ cannot bind "
+  "to a value of unrelated type $|cannot bind to a value of unrelated type}1,2">;
 def err_reference_bind_drops_quals : Error<
-  "binding of reference to type %0 to a value of type %1 drops qualifiers">;
+  "binding of reference %diff{to type $ to a value of type $ drops "
+  "qualifiers|drops qualifiers}0,1">;
 def err_reference_bind_failed : Error<
-  "reference to type %0 could not bind to an %select{rvalue|lvalue}1 of type "
-  "%2">;
+  "reference %diff{to type $ could not bind to an %select{rvalue|lvalue}1 of "
+  "type $|could not bind to %select{rvalue|lvalue}1 of incompatible type}0,2">;
 def err_reference_bind_init_list : Error<
   "reference to type %0 cannot bind to an initializer list">;
 def warn_temporary_array_to_pointer_decay : Warning<
@@ -2162,12 +2170,13 @@
     "function (the implicit copy assignment operator)|"
     "function (the implicit move assignment operator)|"
     "constructor (inherited)}0%1"
-    " not viable: no known conversion from %2 to %3 for "
-    "%select{%ordinal5 argument|object argument}4; "
-    "%select{|dereference the argument with *|"
-    "take the address of the argument with &|"
-    "remove *|"
-    "remove &}6">;
+    " not viable: no known conversion "
+    "%diff{from $ to $|from argument type to parameter type}2,3 for "
+    "%select{%ordinal5 argument|object argument}4"
+    "%select{|; dereference the argument with *|"
+    "; take the address of the argument with &|"
+    "; remove *|"
+    "; remove &}6">;
 def note_ovl_candidate_bad_arc_conv : Note<"candidate "
     "%select{function|function|constructor|"
     "function |function |constructor |"
@@ -3517,7 +3526,7 @@
   "receiver type %0 for instance message is a forward declaration">;
 def warn_receiver_forward_instance : Warning<
   "receiver type %0 for instance message is a forward declaration">,
-  InGroup<DiagGroup<"receiver-forward-class">>, DefaultIgnore;
+  InGroup<ForwardClassReceiver>, DefaultIgnore;
 def err_arc_collection_forward : Error<
   "collection expression type %0 is a forward declaration">;
 def err_arc_multiple_method_decl : Error< 
@@ -4077,13 +4086,17 @@
 
 // Obj-c expressions
 def warn_root_inst_method_not_found : Warning<
-  "instance method %0 is being used on 'Class' which is not in the root class">;
+  "instance method %0 is being used on 'Class' which is not in the root class">,
+  InGroup<MethodAccess>;
 def warn_class_method_not_found : Warning<
-  "class method %objcclass0 not found (return type defaults to 'id')">;
+  "class method %objcclass0 not found (return type defaults to 'id')">,
+  InGroup<MethodAccess>;
 def warn_instance_method_on_class_found : Warning<
-  "instance method %0 found instead of class method %1">;
+  "instance method %0 found instead of class method %1">,
+  InGroup<MethodAccess>;
 def warn_inst_method_not_found : Warning<
-  "instance method %objcinstance0 not found (return type defaults to 'id')">;
+  "instance method %objcinstance0 not found (return type defaults to 'id')">,
+  InGroup<MethodAccess>;
 def error_no_super_class_message : Error<
   "no @interface declaration found in class messaging of %0">;
 def error_root_class_cannot_use_super : Error<
@@ -4098,7 +4111,7 @@
   "missing '[' at start of message send expression">;
 def warn_bad_receiver_type : Warning<
   "receiver type %0 is not 'id' or interface pointer, consider "
-  "casting it to 'id'">;
+  "casting it to 'id'">,InGroup<ObjCReceiver>;
 def err_bad_receiver_type : Error<"bad receiver type %0">;
 def err_unknown_receiver_suggest : Error<
   "unknown receiver %0; did you mean %1?">;
@@ -5266,6 +5279,10 @@
   "unspecified (use strncmp instead)">,
   InGroup<DiagGroup<"string-compare">>;
 
+def warn_identity_memvar_assign : Warning<
+  "assigning %select{member variable|instance variable}0 to itself">,
+  InGroup<SelfAssignmentMemvar>;
+
 // Generic selections.
 def err_assoc_type_incomplete : Error<
   "type %0 in generic association incomplete">;
@@ -5503,7 +5520,8 @@
 // Type
 def ext_invalid_sign_spec : Extension<"'%0' cannot be signed or unsigned">;
 def warn_receiver_forward_class : Warning<
-    "receiver %0 is a forward class and corresponding @interface may not exist">;
+    "receiver %0 is a forward class and corresponding @interface may not exist">,
+    InGroup<ForwardClassReceiver>;
 def note_method_sent_forward_class : Note<"method %0 is used for the forward class">;
 def ext_missing_declspec : ExtWarn<
   "declaration specifier missing, defaulting to 'int'">;

Modified: cfe/branches/tooling/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/FileManager.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/FileManager.h (original)
+++ cfe/branches/tooling/include/clang/Basic/FileManager.h Sat Jun 30 16:45:28 2012
@@ -222,6 +222,9 @@
   /// FileManager's FileSystemOptions.
   bool getNoncachedStatValue(StringRef Path, struct stat &StatBuf);
 
+  /// \brief Remove the real file Entry from the cache.
+  void InvalidateCache(const FileEntry* Entry);
+
   /// \brief If path is not absolute and FileSystemOptions set the working
   /// directory, the path is modified to be relative to the given
   /// working directory.

Modified: cfe/branches/tooling/include/clang/Basic/TargetBuiltins.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/TargetBuiltins.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/TargetBuiltins.h (original)
+++ cfe/branches/tooling/include/clang/Basic/TargetBuiltins.h Sat Jun 30 16:45:28 2012
@@ -105,6 +105,16 @@
         LastTSBuiltin
     };
   }
+
+  /// Mips builtins
+  namespace Mips {
+    enum {
+        LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/BuiltinsMips.def"
+        LastTSBuiltin
+    };
+  }
 } // end namespace clang.
 
 #endif

Modified: cfe/branches/tooling/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/TokenKinds.def?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/TokenKinds.def (original)
+++ cfe/branches/tooling/include/clang/Basic/TokenKinds.def Sat Jun 30 16:45:28 2012
@@ -592,6 +592,11 @@
 // handles them.
 ANNOTATION(pragma_pack)
 
+// Annotation for #pragma clang __debug parser_crash...
+// The lexer produces these so that they only take effect when the parser
+// handles them.
+ANNOTATION(pragma_parser_crash)
+
 #undef ANNOTATION
 #undef TESTING_KEYWORD
 #undef OBJC2_AT_KEYWORD

Modified: cfe/branches/tooling/include/clang/Driver/Compilation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/Compilation.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/Compilation.h (original)
+++ cfe/branches/tooling/include/clang/Driver/Compilation.h Sat Jun 30 16:45:28 2012
@@ -76,6 +76,8 @@
 
   const DerivedArgList &getArgs() const { return *TranslatedArgs; }
 
+  DerivedArgList &getArgs() { return *TranslatedArgs; }
+
   ActionList &getActions() { return Actions; }
   const ActionList &getActions() const { return Actions; }
 

Modified: cfe/branches/tooling/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/Options.td?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/Options.td Sat Jun 30 16:45:28 2012
@@ -358,6 +358,9 @@
     Group<f_Group>,  Flags<[CC1Option]>, HelpText<"Display include stacks for diagnostic notes">;
 def fdiagnostics_format_EQ : Joined<"-fdiagnostics-format=">, Group<f_clang_Group>;
 def fdiagnostics_show_category_EQ : Joined<"-fdiagnostics-show-category=">, Group<f_clang_Group>;
+def fdiagnostics_show_template_tree : Flag<"-fdiagnostics-show-template-tree">,
+    Group<f_Group>, Flags<[CC1Option]>,
+    HelpText<"Print a template comparison tree for differing templates">;
 def fdollars_in_identifiers : Flag<"-fdollars-in-identifiers">, Group<f_Group>,
   HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
 def fdwarf2_cfi_asm : Flag<"-fdwarf2-cfi-asm">, Group<f_Group>;
@@ -365,6 +368,9 @@
 def fdwarf_directory_asm : Flag<"-fdwarf-directory-asm">, Group<f_Group>;
 def fno_dwarf_directory_asm : Flag<"-fno-dwarf-directory-asm">, Group<f_Group>, Flags<[CC1Option]>;
 def felide_constructors : Flag<"-felide-constructors">, Group<f_Group>;
+def fno_elide_type : Flag<"-fno-elide-type">, Group<f_Group>,
+    Flags<[CC1Option]>,
+    HelpText<"Do not elide types when printing diagnostics">;
 def feliminate_unused_debug_symbols : Flag<"-feliminate-unused-debug-symbols">, Group<f_Group>;
 def femit_all_decls : Flag<"-femit-all-decls">, Group<f_Group>, Flags<[CC1Option]>,
   HelpText<"Emit all declarations, even if unused">;
@@ -642,6 +648,7 @@
 def fterminated_vtables : Flag<"-fterminated-vtables">, Alias<fapple_kext>;
 def fthreadsafe_statics : Flag<"-fthreadsafe-statics">, Group<f_Group>;
 def ftime_report : Flag<"-ftime-report">, Group<f_Group>, Flags<[CC1Option]>;
+def ftlsmodel_EQ : Joined<"-ftls-model=">, Group<f_Group>, Flags<[CC1Option]>;
 def ftrapv : Flag<"-ftrapv">, Group<f_Group>, Flags<[CC1Option]>,
   HelpText<"Trap on integer overflow">;
 def ftrapv_handler_EQ : Joined<"-ftrapv-handler=">, Group<f_Group>,
@@ -1123,6 +1130,7 @@
 def _write_user_dependencies : Flag<"--write-user-dependencies">, Alias<MMD>;
 def _ : Joined<"--">, Flags<[Unsupported]>;
 def mieee_rnd_near : Flag<"-mieee-rnd-near">, Group<m_hexagon_Features_Group>;
+def serialize_diags : Separate<"-serialize-diagnostics">, Alias<_serialize_diags>;
 
 // Special internal option to handle -Xlinker --no-demangle.
 def Z_Xlinker__no_demangle : Flag<"-Z-Xlinker-no-demangle">,

Modified: cfe/branches/tooling/include/clang/Driver/Types.def
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/Types.def?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/Types.def (original)
+++ cfe/branches/tooling/include/clang/Driver/Types.def Sat Jun 30 16:45:28 2012
@@ -40,17 +40,17 @@
 
 // C family source language (with and without preprocessing).
 TYPE("cpp-output",               PP_C,         INVALID,         "i",     "u")
-TYPE("c",                        C,            PP_C,            0,       "u")
-TYPE("cl",                       CL,           PP_C,            0,       "u")
-TYPE("cuda",                     CUDA,         PP_CXX,          0,       "u")
+TYPE("c",                        C,            PP_C,            "c",     "u")
+TYPE("cl",                       CL,           PP_C,            "cl",    "u")
+TYPE("cuda",                     CUDA,         PP_CXX,          "cpp",   "u")
 TYPE("objective-c-cpp-output",   PP_ObjC,      INVALID,         "mi",    "u")
 TYPE("objc-cpp-output",          PP_ObjC_Alias, INVALID,        "mi",    "u")
-TYPE("objective-c",              ObjC,         PP_ObjC,         0,       "u")
+TYPE("objective-c",              ObjC,         PP_ObjC,         "m",     "u")
 TYPE("c++-cpp-output",           PP_CXX,       INVALID,         "ii",    "u")
-TYPE("c++",                      CXX,          PP_CXX,          0,       "u")
+TYPE("c++",                      CXX,          PP_CXX,          "cpp",   "u")
 TYPE("objective-c++-cpp-output", PP_ObjCXX,    INVALID,         "mii",   "u")
 TYPE("objc++-cpp-output",        PP_ObjCXX_Alias, INVALID,      "mii",   "u")
-TYPE("objective-c++",            ObjCXX,       PP_ObjCXX,       0,       "u")
+TYPE("objective-c++",            ObjCXX,       PP_ObjCXX,       "mm",    "u")
 
 // C family input files to precompile.
 TYPE("c-header-cpp-output",      PP_CHeader,   INVALID,         "i",     "p")

Modified: cfe/branches/tooling/include/clang/Frontend/CodeGenOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/CodeGenOptions.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/CodeGenOptions.h Sat Jun 30 16:45:28 2012
@@ -44,6 +44,13 @@
     FullDebugInfo         // Generate complete debug info.
   };
 
+  enum TLSModel {
+    GeneralDynamicTLSModel,
+    LocalDynamicTLSModel,
+    InitialExecTLSModel,
+    LocalExecTLSModel
+  };
+
   unsigned AsmVerbose        : 1; ///< -dA, -fverbose-asm.
   unsigned ObjCAutoRefCountExceptions : 1; ///< Whether ARC should be EH-safe.
   unsigned CUDAIsDevice      : 1; ///< Set when compiling for CUDA device.
@@ -175,6 +182,9 @@
   /// The run-time penalty for bounds checking, or 0 to disable.
   unsigned char BoundsChecking;
 
+  /// The default TLS model to use.
+  TLSModel DefaultTLSModel;
+
 public:
   CodeGenOptions() {
     AsmVerbose = 0;
@@ -231,6 +241,7 @@
     DebugInfo = NoDebugInfo;
     Inlining = NoInlining;
     RelocationModel = "pic";
+    DefaultTLSModel = GeneralDynamicTLSModel;
   }
 
   ObjCDispatchMethodKind getObjCDispatchMethod() const {

Modified: cfe/branches/tooling/include/clang/Frontend/DiagnosticOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/DiagnosticOptions.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/DiagnosticOptions.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/DiagnosticOptions.h Sat Jun 30 16:45:28 2012
@@ -47,6 +47,9 @@
                                  /// diagnostics, indicated by markers in the
                                  /// input source file.
 
+  unsigned ElideType: 1;         /// Elide identical types in template diffing
+  unsigned ShowTemplateTree: 1;  /// Print a template tree when diffing
+
   unsigned ErrorLimit;           /// Limit # errors emitted.
   unsigned MacroBacktraceLimit;  /// Limit depth of macro expansion backtrace.
   unsigned TemplateBacktraceLimit; /// Limit depth of instantiation backtrace.

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h Sat Jun 30 16:45:28 2012
@@ -65,7 +65,7 @@
   /// WList - A set of queued nodes that need to be processed by the
   ///  worklist algorithm.  It is up to the implementation of WList to decide
   ///  the order that nodes are processed.
-  WorkList* WList;
+  OwningPtr<WorkList> WList;
 
   /// BCounterFactory - A factory object for created BlockCounter objects.
   ///   These are used to record for key nodes in the ExplodedGraph the
@@ -107,20 +107,15 @@
   ExplodedNode *generateCallExitBeginNode(ExplodedNode *N);
 
 public:
-  /// Construct a CoreEngine object to analyze the provided CFG using
-  ///  a DFS exploration of the exploded graph.
+  /// Construct a CoreEngine object to analyze the provided CFG.
   CoreEngine(SubEngine& subengine, SetOfConstDecls *VisitedCallees,
              FunctionSummariesTy *FS)
     : SubEng(subengine), G(new ExplodedGraph()),
-      WList(WorkList::makeBFS()),
+      WList(WorkList::makeDFS()),
       BCounterFactory(G->getAllocator()),
       AnalyzedCallees(VisitedCallees),
       FunctionSummaries(FS){}
 
-  ~CoreEngine() {
-    delete WList;
-  }
-
   /// getGraph - Returns the exploded graph.
   ExplodedGraph& getGraph() { return *G.get(); }
 
@@ -156,7 +151,7 @@
     blocksAborted.push_back(std::make_pair(block, node));
   }
   
-  WorkList *getWorkList() const { return WList; }
+  WorkList *getWorkList() const { return WList.get(); }
 
   BlocksExhausted::const_iterator blocks_exhausted_begin() const {
     return blocksExhausted.begin();

Modified: cfe/branches/tooling/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTContext.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTContext.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTContext.cpp Sat Jun 30 16:45:28 2012
@@ -61,6 +61,10 @@
 
   assert(D);
 
+  // User can not attach documentation to implicit declarations.
+  if (D->isImplicit())
+    return NULL;
+
   // TODO: handle comments for function parameters properly.
   if (isa<ParmVarDecl>(D))
     return NULL;
@@ -90,7 +94,7 @@
 
   // First check whether we have a trailing comment.
   if (Comment != RawComments.end() &&
-      Comment->isDoxygen() && Comment->isTrailingComment() &&
+      Comment->isDocumentation() && Comment->isTrailingComment() &&
       !isa<TagDecl>(D) && !isa<NamespaceDecl>(D)) {
     std::pair<FileID, unsigned> CommentBeginDecomp
       = SourceMgr.getDecomposedLoc(Comment->getSourceRange().getBegin());
@@ -111,7 +115,7 @@
   --Comment;
 
   // Check that we actually have a non-member Doxygen comment.
-  if (!Comment->isDoxygen() || Comment->isTrailingComment())
+  if (!Comment->isDocumentation() || Comment->isTrailingComment())
     return NULL;
 
   // Decompose the end of the comment.
@@ -134,8 +138,9 @@
   StringRef Text(Buffer + CommentEndDecomp.second,
                  DeclLocDecomp.second - CommentEndDecomp.second);
 
-  // There should be no other declarations between comment and declaration.
-  if (Text.find_first_of(",;{}") != StringRef::npos)
+  // There should be no other declarations or preprocessor directives between
+  // comment and declaration.
+  if (Text.find_first_of(",;{}#") != StringRef::npos)
     return NULL;
 
   return &*Comment;
@@ -150,6 +155,8 @@
       return Pos->second;
 
   const RawComment *RC = getRawCommentForDeclNoCache(D);
+  // If we found a comment, it should be a documentation comment.
+  assert(!RC || RC->isDocumentation());
   DeclComments[D] = RC;
   return RC;
 }
@@ -4142,6 +4149,8 @@
        E = Decl->param_end(); PI != E; ++PI) {
     QualType PType = (*PI)->getType();
     CharUnits sz = getObjCEncodingTypeSize(PType);
+    if (sz.isZero())
+      continue;
     assert (sz.isPositive() && "BlockExpr - Incomplete param type");
     ParmOffset += sz;
   }
@@ -4183,8 +4192,8 @@
     QualType PType = (*PI)->getType();
     CharUnits sz = getObjCEncodingTypeSize(PType);
     if (sz.isZero())
-      return true;
-    
+      continue;
+ 
     assert (sz.isPositive() && 
         "getObjCEncodingForFunctionDecl - Incomplete param type");
     ParmOffset += sz;
@@ -4252,8 +4261,8 @@
     QualType PType = (*PI)->getType();
     CharUnits sz = getObjCEncodingTypeSize(PType);
     if (sz.isZero())
-      return true;
-    
+      continue;
+ 
     assert (sz.isPositive() && 
         "getObjCEncodingForMethodDecl - Incomplete param type");
     ParmOffset += sz;

Modified: cfe/branches/tooling/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTDiagnostic.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTDiagnostic.cpp Sat Jun 30 16:45:28 2012
@@ -14,7 +14,11 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/TemplateBase.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Type.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -225,6 +229,11 @@
   return S;
 }
 
+static bool FormatTemplateTypeDiff(ASTContext &Context, QualType FromType,
+                                   QualType ToType, bool PrintTree,
+                                   bool PrintFromType, bool ElideType,
+                                   bool ShowColors, std::string &S);
+
 void clang::FormatASTNodeDiagnosticArgument(
     DiagnosticsEngine::ArgumentKind Kind,
     intptr_t Val,
@@ -244,6 +253,32 @@
   
   switch (Kind) {
     default: llvm_unreachable("unknown ArgumentKind");
+    case DiagnosticsEngine::ak_qualtype_pair: {
+      const TemplateDiffTypes &TDT = *reinterpret_cast<TemplateDiffTypes*>(Val);
+      QualType FromType =
+          QualType::getFromOpaquePtr(reinterpret_cast<void*>(TDT.FromType));
+      QualType ToType =
+          QualType::getFromOpaquePtr(reinterpret_cast<void*>(TDT.ToType));
+
+      if (FormatTemplateTypeDiff(Context, FromType, ToType, TDT.PrintTree,
+                                 TDT.PrintFromType, TDT.ElideType,
+                                 TDT.ShowColors, S)) {
+        NeedQuotes = !TDT.PrintTree;
+        break;
+      }
+
+      // Don't fall-back during tree printing.  The caller will handle
+      // this case.
+      if (TDT.PrintTree)
+        return;
+
+      // Attempting to do a templete diff on non-templates.  Set the variables
+      // and continue with regular type printing of the appropriate type.
+      Val = TDT.PrintFromType ? TDT.FromType : TDT.ToType;
+      ModLen = 0;
+      ArgLen = 0;
+      // Fall through
+    }
     case DiagnosticsEngine::ak_qualtype: {
       assert(ModLen == 0 && ArgLen == 0 &&
              "Invalid modifier for QualType argument");
@@ -329,3 +364,901 @@
   if (NeedQuotes)
     Output.push_back('\'');
 }
+
+/// TemplateDiff - A class that constructs a pretty string for a pair of
+/// QualTypes.  For the pair of types, a diff tree will be created containing
+/// all the information about the templates and template arguments.  Afterwards,
+/// the tree is transformed to a string according to the options passed in.
+namespace {
+class TemplateDiff {
+  /// Context - The ASTContext which is used for comparing template arguments.
+  ASTContext &Context;
+
+  /// Policy - Used during expression printing.
+  PrintingPolicy Policy;
+
+  /// ElideType - Option to elide identical types.
+  bool ElideType;
+
+  /// PrintTree - Format output string as a tree.
+  bool PrintTree;
+
+  /// ShowColor - Diagnostics support color, so bolding will be used.
+  bool ShowColor;
+
+  /// FromType - When single type printing is selected, this is the type to be
+  /// be printed.  When tree printing is selected, this type will show up first
+  /// in the tree.
+  QualType FromType;
+
+  /// ToType - The type that FromType is compared to.  Only in tree printing
+  /// will this type be outputed.
+  QualType ToType;
+
+  /// Str - Storage for the output stream.
+  llvm::SmallString<128> Str;
+
+  /// OS - The stream used to construct the output strings.
+  llvm::raw_svector_ostream OS;
+
+  /// IsBold - Keeps track of the bold formatting for the output string.
+  bool IsBold;
+
+  /// DiffTree - A tree representation the differences between two types.
+  class DiffTree {
+    /// DiffNode - The root node stores the original type.  Each child node
+    /// stores template arguments of their parents.  For templated types, the
+    /// template decl is also stored.
+    struct DiffNode {
+      /// NextNode - The index of the next sibling node or 0.
+      unsigned NextNode;
+
+      /// ChildNode - The index of the first child node or 0.
+      unsigned ChildNode;
+
+      /// ParentNode - The index of the parent node.
+      unsigned ParentNode;
+
+      /// FromType, ToType - The type arguments.
+      QualType FromType, ToType;
+
+      /// FromExpr, ToExpr - The expression arguments.
+      Expr *FromExpr, *ToExpr;
+
+      /// FromTD, ToTD - The template decl for template template
+      /// arguments or the type arguments that are templates.
+      TemplateDecl *FromTD, *ToTD;
+
+      /// FromDefault, ToDefault - Whether the argument is a default argument.
+      bool FromDefault, ToDefault;
+
+      /// Same - Whether the two arguments evaluate to the same value.
+      bool Same;
+
+      DiffNode(unsigned ParentNode = 0)
+        : NextNode(0), ChildNode(0), ParentNode(ParentNode),
+          FromType(), ToType(), FromExpr(0), ToExpr(0), FromTD(0), ToTD(0),
+          FromDefault(false), ToDefault(false), Same(false) { }
+    };
+
+    /// FlatTree - A flattened tree used to store the DiffNodes.
+    llvm::SmallVector<DiffNode, 16> FlatTree;
+
+    /// CurrentNode - The index of the current node being used.
+    unsigned CurrentNode;
+
+    /// NextFreeNode - The index of the next unused node.  Used when creating
+    /// child nodes.
+    unsigned NextFreeNode;
+
+    /// ReadNode - The index of the current node being read.
+    unsigned ReadNode;
+  
+  public:
+    DiffTree() :
+        CurrentNode(0), NextFreeNode(1) {
+      FlatTree.push_back(DiffNode());
+    }
+
+    // Node writing functions.
+    /// SetNode - Sets FromTD and ToTD of the current node.
+    void SetNode(TemplateDecl *FromTD, TemplateDecl *ToTD) {
+      FlatTree[CurrentNode].FromTD = FromTD;
+      FlatTree[CurrentNode].ToTD = ToTD;
+    }
+
+    /// SetNode - Sets FromType and ToType of the current node.
+    void SetNode(QualType FromType, QualType ToType) {
+      FlatTree[CurrentNode].FromType = FromType;
+      FlatTree[CurrentNode].ToType = ToType;
+    }
+
+    /// SetNode - Set FromExpr and ToExpr of the current node.
+    void SetNode(Expr *FromExpr, Expr *ToExpr) {
+      FlatTree[CurrentNode].FromExpr = FromExpr;
+      FlatTree[CurrentNode].ToExpr = ToExpr;
+    }
+
+    /// SetSame - Sets the same flag of the current node.
+    void SetSame(bool Same) {
+      FlatTree[CurrentNode].Same = Same;
+    }
+
+    /// SetDefault - Sets FromDefault and ToDefault flags of the current node.
+    void SetDefault(bool FromDefault, bool ToDefault) {
+      FlatTree[CurrentNode].FromDefault = FromDefault;
+      FlatTree[CurrentNode].ToDefault = ToDefault;
+    }
+
+    /// Up - Changes the node to the parent of the current node.
+    void Up() {
+      CurrentNode = FlatTree[CurrentNode].ParentNode;
+    }
+
+    /// AddNode - Adds a child node to the current node, then sets that node
+    /// node as the current node.
+    void AddNode() {
+      FlatTree.push_back(DiffNode(CurrentNode));
+      DiffNode &Node = FlatTree[CurrentNode];
+      if (Node.ChildNode == 0) {
+        // If a child node doesn't exist, add one.
+        Node.ChildNode = NextFreeNode;
+      } else {
+        // If a child node exists, find the last child node and add a
+        // next node to it.
+        unsigned i;
+        for (i = Node.ChildNode; FlatTree[i].NextNode != 0;
+             i = FlatTree[i].NextNode) {
+        }
+        FlatTree[i].NextNode = NextFreeNode;
+      }
+      CurrentNode = NextFreeNode;
+      ++NextFreeNode;
+    }
+
+    // Node reading functions.
+    /// StartTraverse - Prepares the tree for recursive traversal.
+    void StartTraverse() {
+      ReadNode = 0;
+      CurrentNode = NextFreeNode;
+      NextFreeNode = 0;
+    }
+
+    /// Parent - Move the current read node to its parent.
+    void Parent() {
+      ReadNode = FlatTree[ReadNode].ParentNode;
+    }
+
+    /// NodeIsTemplate - Returns true if a template decl is set, and types are
+    /// set.
+    bool NodeIsTemplate() {
+      return (FlatTree[ReadNode].FromTD &&
+              !FlatTree[ReadNode].ToType.isNull()) ||
+             (FlatTree[ReadNode].ToTD && !FlatTree[ReadNode].ToType.isNull());
+    }
+
+    /// NodeIsQualType - Returns true if a Qualtype is set.
+    bool NodeIsQualType() {
+      return !FlatTree[ReadNode].FromType.isNull() ||
+             !FlatTree[ReadNode].ToType.isNull();
+    }
+
+    /// NodeIsExpr - Returns true if an expr is set.
+    bool NodeIsExpr() {
+      return FlatTree[ReadNode].FromExpr || FlatTree[ReadNode].ToExpr;
+    }
+
+    /// NodeIsTemplateTemplate - Returns true if the argument is a template
+    /// template type.
+    bool NodeIsTemplateTemplate() {
+      return FlatTree[ReadNode].FromType.isNull() &&
+             FlatTree[ReadNode].ToType.isNull() &&
+             (FlatTree[ReadNode].FromTD || FlatTree[ReadNode].ToTD);
+    }
+
+    /// GetNode - Gets the FromType and ToType.
+    void GetNode(QualType &FromType, QualType &ToType) {
+      FromType = FlatTree[ReadNode].FromType;
+      ToType = FlatTree[ReadNode].ToType;
+    }
+
+    /// GetNode - Gets the FromExpr and ToExpr.
+    void GetNode(Expr *&FromExpr, Expr *&ToExpr) {
+      FromExpr = FlatTree[ReadNode].FromExpr;
+      ToExpr = FlatTree[ReadNode].ToExpr;
+    }
+
+    /// GetNode - Gets the FromTD and ToTD.
+    void GetNode(TemplateDecl *&FromTD, TemplateDecl *&ToTD) {
+      FromTD = FlatTree[ReadNode].FromTD;
+      ToTD = FlatTree[ReadNode].ToTD;
+    }
+
+    /// NodeIsSame - Returns true the arguments are the same.
+    bool NodeIsSame() {
+      return FlatTree[ReadNode].Same;
+    }
+
+    /// HasChildrend - Returns true if the node has children.
+    bool HasChildren() {
+      return FlatTree[ReadNode].ChildNode != 0;
+    }
+
+    /// MoveToChild - Moves from the current node to its child.
+    void MoveToChild() {
+      ReadNode = FlatTree[ReadNode].ChildNode;
+    }
+
+    /// AdvanceSibling - If there is a next sibling, advance to it and return
+    /// true.  Otherwise, return false.
+    bool AdvanceSibling() {
+      if (FlatTree[ReadNode].NextNode == 0)
+        return false;
+
+      ReadNode = FlatTree[ReadNode].NextNode;
+      return true;
+    }
+
+    /// HasNextSibling - Return true if the node has a next sibling.
+    bool HasNextSibling() {
+      return FlatTree[ReadNode].NextNode != 0;
+    }
+
+    /// FromDefault - Return true if the from argument is the default.
+    bool FromDefault() {
+      return FlatTree[ReadNode].FromDefault;
+    }
+
+    /// ToDefault - Return true if the to argument is the default.
+    bool ToDefault() {
+      return FlatTree[ReadNode].ToDefault;
+    }
+
+    /// Empty - Returns true if the tree has no information.
+    bool Empty() {
+      return !FlatTree[0].FromTD && !FlatTree[0].ToTD &&
+             !FlatTree[0].FromExpr && !FlatTree[0].ToExpr &&
+             FlatTree[0].FromType.isNull() && FlatTree[0].ToType.isNull();
+    }
+  };
+
+  DiffTree Tree;
+
+  /// TSTiterator - an iterator that is used to enter a
+  /// TemplateSpecializationType and read TemplateArguments inside template
+  /// parameter packs in order with the rest of the TemplateArguments.
+  struct TSTiterator {
+    typedef const TemplateArgument& reference;
+    typedef const TemplateArgument* pointer;
+
+    /// TST - the template specialization whose arguments this iterator
+    /// traverse over.
+    const TemplateSpecializationType *TST;
+
+    /// Index - the index of the template argument in TST.
+    unsigned Index;
+
+    /// CurrentTA - if CurrentTA is not the same as EndTA, then CurrentTA
+    /// points to a TemplateArgument within a parameter pack.
+    TemplateArgument::pack_iterator CurrentTA;
+
+    /// EndTA - the end iterator of a parameter pack
+    TemplateArgument::pack_iterator EndTA;
+
+    /// TSTiterator - Constructs an iterator and sets it to the first template
+    /// argument.
+    TSTiterator(const TemplateSpecializationType *TST)
+        : TST(TST), Index(0), CurrentTA(0), EndTA(0) {
+      if (isEnd()) return;
+
+      // Set to first template argument.  If not a parameter pack, done.
+      TemplateArgument TA = TST->getArg(0);
+      if (TA.getKind() != TemplateArgument::Pack) return;
+
+      // Start looking into the parameter pack.
+      CurrentTA = TA.pack_begin();
+      EndTA = TA.pack_end();
+
+      // Found a valid template argument.
+      if (CurrentTA != EndTA) return;
+
+      // Parameter pack is empty, use the increment to get to a valid
+      // template argument.
+      ++(*this);
+    }
+
+    /// isEnd - Returns true if the iterator is one past the end.
+    bool isEnd() const {
+      return Index == TST->getNumArgs();
+    }
+
+    /// &operator++ - Increment the iterator to the next template argument.
+    TSTiterator &operator++() {
+      assert(!isEnd() && "Iterator incremented past end of arguments.");
+
+      // If in a parameter pack, advance in the parameter pack.
+      if (CurrentTA != EndTA) {
+        ++CurrentTA;
+        if (CurrentTA != EndTA)
+          return *this;
+      }
+
+      // Loop until a template argument is found, or the end is reached.
+      while (true) {
+        // Advance to the next template argument.  Break if reached the end.
+        if (++Index == TST->getNumArgs()) break;
+
+        // If the TemplateArgument is not a parameter pack, done.
+        TemplateArgument TA = TST->getArg(Index);
+        if (TA.getKind() != TemplateArgument::Pack) break;
+
+        // Handle parameter packs.
+        CurrentTA = TA.pack_begin();
+        EndTA = TA.pack_end();
+
+        // If the parameter pack is empty, try to advance again.
+        if (CurrentTA != EndTA) break;
+      }
+      return *this;
+    }
+
+    /// operator* - Returns the appropriate TemplateArgument.
+    reference operator*() const {
+      assert(!isEnd() && "Index exceeds number of arguments.");
+      if (CurrentTA == EndTA)
+        return TST->getArg(Index);
+      else
+        return *CurrentTA;
+    }
+
+    /// operator-> - Allow access to the underlying TemplateArgument.
+    pointer operator->() const {
+      return &operator*();
+    }
+  };
+
+  // These functions build up the template diff tree, including functions to
+  // retrieve and compare template arguments. 
+
+  static const TemplateSpecializationType * GetTemplateSpecializationType(
+      ASTContext &Context, QualType Ty) {
+    if (const TemplateSpecializationType *TST =
+            Ty->getAs<TemplateSpecializationType>())
+      return TST;
+
+    const RecordType *RT = Ty->getAs<RecordType>();
+
+    if (!RT)
+      return 0;
+
+    const ClassTemplateSpecializationDecl *CTSD =
+        dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl());
+
+    if (!CTSD)
+      return 0;
+
+    Ty = Context.getTemplateSpecializationType(
+             TemplateName(CTSD->getSpecializedTemplate()),
+             CTSD->getTemplateArgs().data(),
+             CTSD->getTemplateArgs().size(),
+             Ty.getCanonicalType());
+
+    return Ty->getAs<TemplateSpecializationType>();
+  }
+
+  /// DiffTemplate - recursively visits template arguments and stores the
+  /// argument info into a tree.
+  void DiffTemplate(const TemplateSpecializationType *FromTST,
+                    const TemplateSpecializationType *ToTST) {
+    // Begin descent into diffing template tree.
+    TemplateParameterList *Params =
+        FromTST->getTemplateName().getAsTemplateDecl()->getTemplateParameters();
+    unsigned TotalArgs = 0;
+    for (TSTiterator FromIter(FromTST), ToIter(ToTST);
+         !FromIter.isEnd() || !ToIter.isEnd(); ++TotalArgs) {
+      Tree.AddNode();
+
+      // Get the parameter at index TotalArgs.  If index is larger
+      // than the total number of parameters, then there is an
+      // argument pack, so re-use the last parameter.
+      NamedDecl *ParamND = Params->getParam(
+          (TotalArgs < Params->size()) ? TotalArgs
+                                       : Params->size() - 1);
+      // Handle Types
+      if (TemplateTypeParmDecl *DefaultTTPD =
+              dyn_cast<TemplateTypeParmDecl>(ParamND)) {
+        QualType FromType, ToType;
+        GetType(FromIter, DefaultTTPD, FromType);
+        GetType(ToIter, DefaultTTPD, ToType);
+        Tree.SetNode(FromType, ToType);
+        Tree.SetDefault(FromIter.isEnd() && !FromType.isNull(),
+                        ToIter.isEnd() && !ToType.isNull());
+        if (!FromType.isNull() && !ToType.isNull()) {
+          if (Context.hasSameType(FromType, ToType)) {
+            Tree.SetSame(true);
+          } else {
+            const TemplateSpecializationType *FromArgTST =
+                GetTemplateSpecializationType(Context, FromType);
+            const TemplateSpecializationType *ToArgTST =
+                GetTemplateSpecializationType(Context, ToType);
+
+            if (FromArgTST && ToArgTST) {
+              bool SameTemplate = hasSameTemplate(FromArgTST, ToArgTST);
+              if (SameTemplate) {
+                Tree.SetNode(FromArgTST->getTemplateName().getAsTemplateDecl(),
+                             ToArgTST->getTemplateName().getAsTemplateDecl());
+                DiffTemplate(FromArgTST, ToArgTST);
+              }
+            }
+          }
+        }
+      }
+
+      // Handle Expressions
+      if (NonTypeTemplateParmDecl *DefaultNTTPD =
+              dyn_cast<NonTypeTemplateParmDecl>(ParamND)) {
+        Expr *FromExpr, *ToExpr;
+        GetExpr(FromIter, DefaultNTTPD, FromExpr);
+        GetExpr(ToIter, DefaultNTTPD, ToExpr);
+        Tree.SetNode(FromExpr, ToExpr);
+        Tree.SetSame(IsEqualExpr(Context, FromExpr, ToExpr));
+        Tree.SetDefault(FromIter.isEnd() && FromExpr,
+                        ToIter.isEnd() && ToExpr);
+      }
+
+      // Handle Templates
+      if (TemplateTemplateParmDecl *DefaultTTPD =
+              dyn_cast<TemplateTemplateParmDecl>(ParamND)) {
+        TemplateDecl *FromDecl, *ToDecl;
+        GetTemplateDecl(FromIter, DefaultTTPD, FromDecl);
+        GetTemplateDecl(ToIter, DefaultTTPD, ToDecl);
+        Tree.SetNode(FromDecl, ToDecl);
+        Tree.SetSame(FromDecl && ToDecl &&
+                     FromDecl->getIdentifier() == ToDecl->getIdentifier());
+      }
+
+      if (!FromIter.isEnd()) ++FromIter;
+      if (!ToIter.isEnd()) ++ToIter;
+      Tree.Up();
+    }
+  }
+
+  /// hasSameTemplate - Returns true if both types are specialized from the
+  /// same template declaration.  If they come from different template aliases,
+  /// do a parallel ascension search to determine the highest template alias in
+  /// common and set the arguments to them.
+  static bool hasSameTemplate(const TemplateSpecializationType *&FromTST,
+                              const TemplateSpecializationType *&ToTST) {
+    // Check the top templates if they are the same.
+    if (FromTST->getTemplateName().getAsTemplateDecl()->getIdentifier() ==
+        ToTST->getTemplateName().getAsTemplateDecl()->getIdentifier())
+      return true;
+
+    // Create vectors of template aliases.
+    SmallVector<const TemplateSpecializationType*, 1> FromTemplateList,
+                                                      ToTemplateList;
+
+    const TemplateSpecializationType *TempToTST = ToTST, *TempFromTST = FromTST;
+    FromTemplateList.push_back(FromTST);
+    ToTemplateList.push_back(ToTST);
+
+    // Dump every template alias into the vectors.
+    while (TempFromTST->isTypeAlias()) {
+      TempFromTST =
+          TempFromTST->getAliasedType()->getAs<TemplateSpecializationType>();
+      if (!TempFromTST)
+        break;
+      FromTemplateList.push_back(TempFromTST);
+    }
+    while (TempToTST->isTypeAlias()) {
+      TempToTST =
+          TempToTST->getAliasedType()->getAs<TemplateSpecializationType>();
+      if (!TempToTST)
+        break;
+      ToTemplateList.push_back(TempToTST);
+    }
+
+    SmallVector<const TemplateSpecializationType*, 1>::reverse_iterator
+        FromIter = FromTemplateList.rbegin(), FromEnd = FromTemplateList.rend(),
+        ToIter = ToTemplateList.rbegin(), ToEnd = ToTemplateList.rend();
+
+    // Check if the lowest template types are the same.  If not, return.
+    if ((*FromIter)->getTemplateName().getAsTemplateDecl()->getIdentifier() !=
+        (*ToIter)->getTemplateName().getAsTemplateDecl()->getIdentifier())
+      return false;
+
+    // Begin searching up the template aliases.  The bottom most template
+    // matches so move up until one pair does not match.  Use the template
+    // right before that one.
+    for (; FromIter != FromEnd && ToIter != ToEnd; ++FromIter, ++ToIter) {
+      if ((*FromIter)->getTemplateName().getAsTemplateDecl()->getIdentifier() !=
+          (*ToIter)->getTemplateName().getAsTemplateDecl()->getIdentifier())
+        break;
+    }
+
+    FromTST = FromIter[-1];
+    ToTST = ToIter[-1];
+
+    return true;
+  }
+
+  /// GetType - Retrieves the template type arguments, including default
+  /// arguments.
+  void GetType(const TSTiterator &Iter, TemplateTypeParmDecl *DefaultTTPD,
+               QualType &ArgType) {
+    ArgType = QualType();
+    bool isVariadic = DefaultTTPD->isParameterPack();
+
+    if (!Iter.isEnd())
+      ArgType = Iter->getAsType();
+    else if (!isVariadic)
+      ArgType = DefaultTTPD->getDefaultArgument();
+  }
+
+  /// GetExpr - Retrieves the template expression argument, including default
+  /// arguments.
+  void GetExpr(const TSTiterator &Iter, NonTypeTemplateParmDecl *DefaultNTTPD,
+               Expr *&ArgExpr) {
+    ArgExpr = 0;
+    bool isVariadic = DefaultNTTPD->isParameterPack();
+
+    if (!Iter.isEnd())
+      ArgExpr = Iter->getAsExpr();
+    else if (!isVariadic)
+      ArgExpr = DefaultNTTPD->getDefaultArgument();
+
+    if (ArgExpr)
+      while (SubstNonTypeTemplateParmExpr *SNTTPE =
+                 dyn_cast<SubstNonTypeTemplateParmExpr>(ArgExpr))
+        ArgExpr = SNTTPE->getReplacement();
+  }
+
+  /// GetTemplateDecl - Retrieves the template template arguments, including
+  /// default arguments.
+  void GetTemplateDecl(const TSTiterator &Iter,
+                       TemplateTemplateParmDecl *DefaultTTPD,
+                       TemplateDecl *&ArgDecl) {
+    ArgDecl = 0;
+    bool isVariadic = DefaultTTPD->isParameterPack();
+
+    TemplateArgument TA = DefaultTTPD->getDefaultArgument().getArgument();
+    TemplateDecl *DefaultTD = TA.getAsTemplate().getAsTemplateDecl();
+
+    if (!Iter.isEnd())
+      ArgDecl = Iter->getAsTemplate().getAsTemplateDecl();
+    else if (!isVariadic)
+      ArgDecl = DefaultTD;
+  }
+
+  /// IsEqualExpr - Returns true if the expressions evaluate to the same value.
+  static bool IsEqualExpr(ASTContext &Context, Expr *FromExpr, Expr *ToExpr) {
+    if (FromExpr == ToExpr)
+      return true;
+
+    if (!FromExpr || !ToExpr)
+      return false;
+
+    FromExpr = FromExpr->IgnoreParens();
+    ToExpr = ToExpr->IgnoreParens();
+
+    DeclRefExpr *FromDRE = dyn_cast<DeclRefExpr>(FromExpr),
+                *ToDRE = dyn_cast<DeclRefExpr>(ToExpr);
+
+    if (FromDRE || ToDRE) {
+      if (!FromDRE || !ToDRE)
+        return false;
+      return FromDRE->getDecl() == ToDRE->getDecl();
+    }
+
+    Expr::EvalResult FromResult, ToResult;
+    if (!FromExpr->EvaluateAsRValue(FromResult, Context) ||
+        !ToExpr->EvaluateAsRValue(ToResult, Context))
+      assert(0 && "Template arguments must be known at compile time.");
+
+    APValue &FromVal = FromResult.Val;
+    APValue &ToVal = ToResult.Val;
+
+    if (FromVal.getKind() != ToVal.getKind()) return false;
+
+    switch (FromVal.getKind()) {
+      case APValue::Int:
+        return FromVal.getInt() == ToVal.getInt();
+      case APValue::LValue: {
+        APValue::LValueBase FromBase = FromVal.getLValueBase();
+        APValue::LValueBase ToBase = ToVal.getLValueBase();
+        if (FromBase.isNull() && ToBase.isNull())
+          return true;
+        if (FromBase.isNull() || ToBase.isNull())
+          return false;
+        return FromBase.get<const ValueDecl*>() ==
+               ToBase.get<const ValueDecl*>();
+      }
+      case APValue::MemberPointer:
+        return FromVal.getMemberPointerDecl() == ToVal.getMemberPointerDecl();
+      default:
+        llvm_unreachable("Unknown template argument expression.");
+    }
+  }
+
+  // These functions converts the tree representation of the template
+  // differences into the internal character vector.
+
+  /// TreeToString - Converts the Tree object into a character stream which
+  /// will later be turned into the output string.
+  void TreeToString(int Indent = 1) {
+    if (PrintTree) {
+      OS << '\n';
+      for (int i = 0; i < Indent; ++i)
+        OS << "  ";
+      ++Indent;
+    }
+
+    // Handle cases where the difference is not templates with different
+    // arguments.
+    if (!Tree.NodeIsTemplate()) {
+      if (Tree.NodeIsQualType()) {
+        QualType FromType, ToType;
+        Tree.GetNode(FromType, ToType);
+        PrintTypeNames(FromType, ToType, Tree.FromDefault(), Tree.ToDefault(),
+                       Tree.NodeIsSame());
+        return;
+      }
+      if (Tree.NodeIsExpr()) {
+        Expr *FromExpr, *ToExpr;
+        Tree.GetNode(FromExpr, ToExpr);
+        PrintExpr(FromExpr, ToExpr, Tree.FromDefault(), Tree.ToDefault(),
+                  Tree.NodeIsSame());
+        return;
+      }
+      if (Tree.NodeIsTemplateTemplate()) {
+        TemplateDecl *FromTD, *ToTD;
+        Tree.GetNode(FromTD, ToTD);
+        PrintTemplateTemplate(FromTD, ToTD, Tree.FromDefault(),
+                              Tree.ToDefault(), Tree.NodeIsSame());
+        return;
+      }
+      llvm_unreachable("Unable to deduce template difference.");
+    }
+
+    // Node is root of template.  Recurse on children.
+    TemplateDecl *FromTD, *ToTD;
+    Tree.GetNode(FromTD, ToTD);
+
+    assert(Tree.HasChildren() && "Template difference not found in diff tree.");
+
+    OS << FromTD->getNameAsString() << '<'; 
+    Tree.MoveToChild();
+    unsigned NumElideArgs = 0;
+    do {
+      if (ElideType) {
+        if (Tree.NodeIsSame()) {
+          ++NumElideArgs;
+          continue;
+        }
+        if (NumElideArgs > 0) {
+          PrintElideArgs(NumElideArgs, Indent);
+          NumElideArgs = 0;
+          OS << ", ";
+        }
+      }
+      TreeToString(Indent);
+      if (Tree.HasNextSibling())
+        OS << ", ";
+    } while (Tree.AdvanceSibling());
+    if (NumElideArgs > 0)
+      PrintElideArgs(NumElideArgs, Indent);
+
+    Tree.Parent();
+    OS << ">";
+  }
+
+  // To signal to the text printer that a certain text needs to be bolded,
+  // a special character is injected into the character stream which the
+  // text printer will later strip out.
+
+  /// Bold - Start bolding text.
+  void Bold() {
+    assert(!IsBold && "Attempting to bold text that is already bold.");
+    IsBold = true;
+    if (ShowColor)
+      OS << ToggleHighlight;
+  }
+
+  /// Unbold - Stop bolding text.
+  void Unbold() {
+    assert(IsBold && "Attempting to remove bold from unbold text.");
+    IsBold = false;
+    if (ShowColor)
+      OS << ToggleHighlight;
+  }
+
+  // Functions to print out the arguments and highlighting the difference.
+
+  /// PrintTypeNames - prints the typenames, bolding differences.  Will detect
+  /// typenames that are the same and attempt to disambiguate them by using
+  /// canonical typenames.
+  void PrintTypeNames(QualType FromType, QualType ToType,
+                      bool FromDefault, bool ToDefault, bool Same) {
+    assert((!FromType.isNull() || !ToType.isNull()) &&
+           "Only one template argument may be missing.");
+
+    if (Same) {
+      OS << FromType.getAsString();
+      return;
+    }
+
+    std::string FromTypeStr = FromType.isNull() ? "(no argument)"
+                                                : FromType.getAsString();
+    std::string ToTypeStr = ToType.isNull() ? "(no argument)"
+                                            : ToType.getAsString();
+    // Switch to canonical typename if it is better.
+    // TODO: merge this with other aka printing above.
+    if (FromTypeStr == ToTypeStr) {
+      std::string FromCanTypeStr = FromType.getCanonicalType().getAsString();
+      std::string ToCanTypeStr = ToType.getCanonicalType().getAsString();
+      if (FromCanTypeStr != ToCanTypeStr) {
+        FromTypeStr = FromCanTypeStr;
+        ToTypeStr = ToCanTypeStr;
+      }
+    }
+
+    if (PrintTree) OS << '[';
+    OS << (FromDefault ? "(default) " : "");
+    Bold();
+    OS << FromTypeStr;
+    Unbold();
+    if (PrintTree) {
+      OS << " != " << (ToDefault ? "(default) " : "");
+      Bold();
+      OS << ToTypeStr;
+      Unbold();
+      OS << "]";
+    }
+    return;
+  }
+
+  /// PrintExpr - Prints out the expr template arguments, highlighting argument
+  /// differences.
+  void PrintExpr(const Expr *FromExpr, const Expr *ToExpr,
+                 bool FromDefault, bool ToDefault, bool Same) {
+    assert((FromExpr || ToExpr) &&
+            "Only one template argument may be missing.");
+    if (Same) {
+      PrintExpr(FromExpr);
+    } else if (!PrintTree) {
+      OS << (FromDefault ? "(default) " : "");
+      Bold();
+      PrintExpr(FromExpr);
+      Unbold();
+    } else {
+      OS << (FromDefault ? "[(default) " : "[");
+      Bold();
+      PrintExpr(FromExpr);
+      Unbold();
+      OS << " != " << (ToDefault ? "(default) " : "");
+      Bold();
+      PrintExpr(ToExpr);
+      Unbold();
+      OS << ']';
+    }
+  }
+
+  /// PrintExpr - Actual formatting and printing of expressions.
+  void PrintExpr(const Expr *E) {
+    if (!E)
+      OS << "(no argument)";
+    else
+      E->printPretty(OS, Context, 0, Policy); return;
+  }
+
+  /// PrintTemplateTemplate - Handles printing of template template arguments,
+  /// highlighting argument differences.
+  void PrintTemplateTemplate(TemplateDecl *FromTD, TemplateDecl *ToTD,
+                             bool FromDefault, bool ToDefault, bool Same) {
+    assert((FromTD || ToTD) && "Only one template argument may be missing.");
+    if (Same) {
+      OS << "template " << FromTD->getNameAsString();
+    } else if (!PrintTree) {
+      OS << (FromDefault ? "(default) template " : "template ");
+      Bold();
+      OS << (FromTD ? FromTD->getNameAsString() : "(no argument)");
+      Unbold();
+    } else {
+      OS << (FromDefault ? "[(default) template " : "[template ");
+      Bold();
+      OS << (FromTD ? FromTD->getNameAsString() : "(no argument)");
+      Unbold();
+      OS << " != " << (ToDefault ? "(default) template " : "template ");
+      Bold();
+      OS << (ToTD ? ToTD->getNameAsString() : "(no argument)");
+      Unbold();
+      OS << ']';
+    }
+  }
+
+  // Prints the appropriate placeholder for elided template arguments.
+  void PrintElideArgs(unsigned NumElideArgs, unsigned Indent) {
+    if (PrintTree) {
+      OS << '\n';
+      for (unsigned i = 0; i < Indent; ++i)
+        OS << "  ";
+    }
+    if (NumElideArgs == 0) return;
+    if (NumElideArgs == 1)
+      OS << "[...]";
+    else
+      OS << "[" << NumElideArgs << " * ...]";
+  }
+
+public:
+
+  TemplateDiff(ASTContext &Context, QualType FromType, QualType ToType,
+               bool PrintTree, bool PrintFromType, bool ElideType,
+               bool ShowColor)
+    : Context(Context),
+      Policy(Context.getLangOpts()),
+      ElideType(ElideType),
+      PrintTree(PrintTree),
+      ShowColor(ShowColor),
+      // When printing a single type, the FromType is the one printed.
+      FromType(PrintFromType ? FromType : ToType),
+      ToType(PrintFromType ? ToType : FromType),
+      OS(Str),
+      IsBold(false) {
+  }
+
+  /// DiffTemplate - Start the template type diffing.
+  void DiffTemplate() {
+    const TemplateSpecializationType *FromOrigTST =
+        GetTemplateSpecializationType(Context, FromType);
+    const TemplateSpecializationType *ToOrigTST =
+        GetTemplateSpecializationType(Context, ToType);
+
+    // Only checking templates.
+    if (!FromOrigTST || !ToOrigTST)
+      return;
+
+    // Different base templates.
+    if (!hasSameTemplate(FromOrigTST, ToOrigTST)) {
+      return;
+    }
+
+    Tree.SetNode(FromType, ToType);
+
+    // Same base template, but different arguments.
+    Tree.SetNode(FromOrigTST->getTemplateName().getAsTemplateDecl(),
+                 ToOrigTST->getTemplateName().getAsTemplateDecl());
+
+    DiffTemplate(FromOrigTST, ToOrigTST);
+  }
+
+  /// MakeString - When the two types given are templated types with the same
+  /// base template, a string representation of the type difference will be
+  /// loaded into S and return true.  Otherwise, return false.
+  bool MakeString(std::string &S) {
+    Tree.StartTraverse();
+    if (Tree.Empty())
+      return false;
+
+    TreeToString();
+    assert(!IsBold && "Bold is applied to end of string.");
+    S = OS.str();
+    return true;
+  }
+}; // end class TemplateDiff
+}  // end namespace
+
+/// FormatTemplateTypeDiff - A helper static function to start the template
+/// diff and return the properly formatted string.  Returns true if the diff
+/// is successful.
+static bool FormatTemplateTypeDiff(ASTContext &Context, QualType FromType,
+                                   QualType ToType, bool PrintTree,
+                                   bool PrintFromType, bool ElideType, 
+                                   bool ShowColors, std::string &S) {
+  if (PrintTree)
+    PrintFromType = true;
+  TemplateDiff TD(Context, FromType, ToType, PrintTree, PrintFromType,
+                  ElideType, ShowColors);
+  TD.DiffTemplate();
+  return TD.MakeString(S);
+}

Modified: cfe/branches/tooling/lib/AST/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/CMakeLists.txt?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/AST/CMakeLists.txt Sat Jun 30 16:45:28 2012
@@ -8,6 +8,8 @@
   ASTImporter.cpp
   AttrImpl.cpp
   CXXInheritance.cpp
+  CommentBriefParser.cpp
+  CommentLexer.cpp
   Decl.cpp
   DeclarationName.cpp
   DeclBase.cpp

Modified: cfe/branches/tooling/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DeclCXX.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/AST/DeclCXX.cpp Sat Jun 30 16:45:28 2012
@@ -1269,6 +1269,55 @@
 
 void CXXMethodDecl::anchor() { }
 
+static bool recursivelyOverrides(const CXXMethodDecl *DerivedMD,
+                                 const CXXMethodDecl *BaseMD) {
+  for (CXXMethodDecl::method_iterator I = DerivedMD->begin_overridden_methods(),
+         E = DerivedMD->end_overridden_methods(); I != E; ++I) {
+    const CXXMethodDecl *MD = *I;
+    if (MD->getCanonicalDecl() == BaseMD->getCanonicalDecl())
+      return true;
+    if (recursivelyOverrides(MD, BaseMD))
+      return true;
+  }
+  return false;
+}
+
+CXXMethodDecl *
+CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD) {
+  if (this->getParent()->getCanonicalDecl() == RD->getCanonicalDecl())
+    return this;
+
+  // Lookup doesn't work for destructors, so handle them separately.
+  if (isa<CXXDestructorDecl>(this)) {
+    CXXMethodDecl *MD = RD->getDestructor();
+    if (MD && recursivelyOverrides(MD, this))
+      return MD;
+    return NULL;
+  }
+
+  lookup_const_result Candidates = RD->lookup(getDeclName());
+  for (NamedDecl * const * I = Candidates.first; I != Candidates.second; ++I) {
+    CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(*I);
+    if (!MD)
+      continue;
+    if (recursivelyOverrides(MD, this))
+      return MD;
+  }
+
+  for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
+         E = RD->bases_end(); I != E; ++I) {
+    const RecordType *RT = I->getType()->getAs<RecordType>();
+    if (!RT)
+      continue;
+    const CXXRecordDecl *Base = cast<CXXRecordDecl>(RT->getDecl());
+    CXXMethodDecl *T = this->getCorrespondingMethodInClass(Base);
+    if (T)
+      return T;
+  }
+
+  return NULL;
+}
+
 CXXMethodDecl *
 CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
                       SourceLocation StartLoc,

Modified: cfe/branches/tooling/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Expr.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Expr.cpp (original)
+++ cfe/branches/tooling/lib/AST/Expr.cpp Sat Jun 30 16:45:28 2012
@@ -33,6 +33,18 @@
 #include <cstring>
 using namespace clang;
 
+const CXXRecordDecl *Expr::getBestDynamicClassType() const {
+  const Expr *E = ignoreParenBaseCasts();
+
+  QualType DerivedType = E->getType();
+  if (const PointerType *PTy = DerivedType->getAs<PointerType>())
+    DerivedType = PTy->getPointeeType();
+
+  const RecordType *Ty = DerivedType->castAs<RecordType>();
+  Decl *D = Ty->getDecl();
+  return cast<CXXRecordDecl>(D);
+}
+
 /// isKnownToHaveBooleanValue - Return true if this is an integer expression
 /// that is known to return 0 or 1.  This happens for _Bool/bool expressions
 /// but also int expressions which are produced by things like comparisons in
@@ -2205,7 +2217,27 @@
   }
   return E;
 }
-  
+
+Expr *Expr::ignoreParenBaseCasts() {
+  Expr *E = this;
+  while (true) {
+    if (ParenExpr *P = dyn_cast<ParenExpr>(E)) {
+      E = P->getSubExpr();
+      continue;
+    }
+    if (CastExpr *CE = dyn_cast<CastExpr>(E)) {
+      if (CE->getCastKind() == CK_DerivedToBase ||
+          CE->getCastKind() == CK_UncheckedDerivedToBase ||
+          CE->getCastKind() == CK_NoOp) {
+        E = CE->getSubExpr();
+        continue;
+      }
+    }
+
+    return E;
+  }
+}
+
 Expr *Expr::IgnoreParenImpCasts() {
   Expr *E = this;
   while (true) {

Modified: cfe/branches/tooling/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ExprConstant.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ExprConstant.cpp (original)
+++ cfe/branches/tooling/lib/AST/ExprConstant.cpp Sat Jun 30 16:45:28 2012
@@ -363,10 +363,6 @@
     /// NextCallIndex - The next call index to assign.
     unsigned NextCallIndex;
 
-    // Note that we intentionally use std::map here so that references
-    // to values are stable.
-    typedef std::map<const OpaqueValueExpr*, APValue> MapTy;
-
     /// BottomFrame - The frame in which evaluation started. This must be
     /// initialized after CurrentCall and CallStackDepth.
     CallStackFrame BottomFrame;

Modified: cfe/branches/tooling/lib/AST/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Mangle.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Mangle.cpp (original)
+++ cfe/branches/tooling/lib/AST/Mangle.cpp Sat Jun 30 16:45:28 2012
@@ -40,7 +40,11 @@
                                 StringRef Outer,
                                 const BlockDecl *BD,
                                 raw_ostream &Out) {
-  Out << "__" << Outer << "_block_invoke_" << Context.getBlockId(BD, true);
+  unsigned discriminator = Context.getBlockId(BD, true);
+  if (discriminator == 0)
+    Out << "__" << Outer << "_block_invoke";
+  else
+    Out << "__" << Outer << "_block_invoke_" << discriminator+1; 
 }
 
 static void checkMangleDC(const DeclContext *DC, const BlockDecl *BD) {
@@ -62,8 +66,20 @@
 void MangleContext::anchor() { }
 
 void MangleContext::mangleGlobalBlock(const BlockDecl *BD,
+                                      const NamedDecl *ID,
                                       raw_ostream &Out) {
-  Out << "__block_global_" << getBlockId(BD, false);
+  unsigned discriminator = getBlockId(BD, false);
+  if (ID) {
+    if (shouldMangleDeclName(ID))
+      mangleName(ID, Out);
+    else {
+      Out << ID->getIdentifier()->getName();
+    }
+  }
+  if (discriminator == 0)
+    Out << "_block_invoke";
+  else
+    Out << "_block_invoke_" << discriminator+1;
 }
 
 void MangleContext::mangleCtorBlock(const CXXConstructorDecl *CD,
@@ -99,8 +115,8 @@
     mangleObjCMethodName(Method, Stream);
   } else {
     const NamedDecl *ND = cast<NamedDecl>(DC);
-    if (IdentifierInfo *II = ND->getIdentifier())
-      Stream << II->getName();
+    if (!shouldMangleDeclName(ND) && ND->getIdentifier())
+      Stream << ND->getIdentifier()->getName();
     else {
       // FIXME: We were doing a mangleUnqualifiedName() before, but that's
       // a private member of a class that will soon itself be private to the
@@ -131,12 +147,13 @@
 }
 
 void MangleContext::mangleBlock(const BlockDecl *BD,
-                                raw_ostream &Out) {
+                                raw_ostream &Out,
+                                const NamedDecl *ID) {
   const DeclContext *DC = BD->getDeclContext();
   while (isa<BlockDecl>(DC) || isa<EnumDecl>(DC))
     DC = DC->getParent();
   if (DC->isFunctionOrMethod())
     mangleBlock(DC, BD, Out);
   else
-    mangleGlobalBlock(BD, Out);
+    mangleGlobalBlock(BD, ID, Out);
 }

Modified: cfe/branches/tooling/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/MicrosoftMangle.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/branches/tooling/lib/AST/MicrosoftMangle.cpp Sat Jun 30 16:45:28 2012
@@ -706,8 +706,15 @@
   // <template-name> ::= <unscoped-template-name> <template-args>
   //                 ::= <substitution>
   // Always start with the unqualified name.
+
+  // Templates have their own context for back references.
+  BackRefMap TemplateContext;
+  NameBackReferences.swap(TemplateContext);
+
   mangleUnscopedTemplateName(TD);
   mangleTemplateArgs(TemplateArgs);
+  
+  NameBackReferences.swap(TemplateContext);
 }
 
 void

Modified: cfe/branches/tooling/lib/AST/RawCommentList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/RawCommentList.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/RawCommentList.cpp (original)
+++ cfe/branches/tooling/lib/AST/RawCommentList.cpp Sat Jun 30 16:45:28 2012
@@ -8,6 +8,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/AST/RawCommentList.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/CommentLexer.h"
+#include "clang/AST/CommentBriefParser.h"
 #include "llvm/ADT/STLExtras.h"
 
 using namespace clang;
@@ -57,7 +60,8 @@
 
 RawComment::RawComment(const SourceManager &SourceMgr, SourceRange SR,
                        bool Merged) :
-    Range(SR), RawTextValid(false), IsAlmostTrailingComment(false),
+    Range(SR), RawTextValid(false), BriefTextValid(false),
+    IsAlmostTrailingComment(false),
     BeginLineValid(false), EndLineValid(false) {
   // Extract raw comment text, if possible.
   if (SR.getBegin() == SR.getEnd() || getRawText(SourceMgr).empty()) {
@@ -126,6 +130,24 @@
   return StringRef(BufferStart + BeginOffset, Length);
 }
 
+StringRef RawComment::extractBriefText(const ASTContext &Context) const {
+  // Make sure that RawText is valid.
+  getRawText(Context.getSourceManager());
+
+  comments::Lexer L(Range.getBegin(), comments::CommentOptions(),
+                    RawText.begin(), RawText.end());
+  comments::BriefParser P(L);
+
+  const std::string Result = P.Parse();
+  const unsigned BriefTextLength = Result.size();
+  char *BriefTextPtr = new (Context) char[BriefTextLength + 1];
+  memcpy(BriefTextPtr, Result.c_str(), BriefTextLength + 1);
+  BriefText = StringRef(BriefTextPtr, BriefTextLength);
+  BriefTextValid = true;
+
+  return BriefText;
+}
+
 namespace {
 bool containsOnlyWhitespace(StringRef Str) {
   return Str.find_first_not_of(" \t\f\v\r\n") == StringRef::npos;

Modified: cfe/branches/tooling/lib/AST/TypePrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/TypePrinter.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/TypePrinter.cpp (original)
+++ cfe/branches/tooling/lib/AST/TypePrinter.cpp Sat Jun 30 16:45:28 2012
@@ -449,12 +449,12 @@
     AppendTypeQualList(OS, T->getIndexTypeCVRQualifiers());
     OS << ' ';
   }
-  
+
   if (T->getSizeModifier() == VariableArrayType::Static)
     OS << "static";
   else if (T->getSizeModifier() == VariableArrayType::Star)
     OS << '*';
-  
+
   if (T->getSizeExpr())
     T->getSizeExpr()->printPretty(OS, 0, Policy);
   OS << ']';
@@ -1248,6 +1248,7 @@
   if (!SkipBrackets)
     OS << '<';
   
+  bool needSpace = false;
   for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
     if (Arg > 0)
       OS << ", ";
@@ -1270,10 +1271,18 @@
     // to avoid printing the diagraph '<:'.
     if (!Arg && !ArgString.empty() && ArgString[0] == ':')
       OS << ' ';
-    
+
     OS << ArgString;
+
+    needSpace = (!ArgString.empty() && ArgString.back() == '>');
   }
 
+  // If the last character of our string is '>', add another space to
+  // keep the two '>''s separate tokens. We don't *have* to do this in
+  // C++0x, but it's still good hygiene.
+  if (needSpace)
+    OS << ' ';
+
   if (!SkipBrackets)
     OS << '>';
 }
@@ -1284,6 +1293,8 @@
                           const TemplateArgumentLoc *Args, unsigned NumArgs,
                           const PrintingPolicy &Policy) {
   OS << '<';
+
+  bool needSpace = false;
   for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
     if (Arg > 0)
       OS << ", ";
@@ -1306,10 +1317,18 @@
     // to avoid printing the diagraph '<:'.
     if (!Arg && !ArgString.empty() && ArgString[0] == ':')
       OS << ' ';
-    
+
     OS << ArgString;
+
+    needSpace = (!ArgString.empty() && ArgString.back() == '>');
   }
   
+  // If the last character of our string is '>', add another space to
+  // keep the two '>''s separate tokens. We don't *have* to do this in
+  // C++0x, but it's still good hygiene.
+  if (needSpace)
+    OS << ' ';
+
   OS << '>';
 }
 
@@ -1532,7 +1551,7 @@
         OS << ' ';
       addSpace = true;
     }
-    
+
     switch (lifetime) {
     case Qualifiers::OCL_None: llvm_unreachable("none but true");
     case Qualifiers::OCL_ExplicitNone: OS << "__unsafe_unretained"; break;

Modified: cfe/branches/tooling/lib/Analysis/ThreadSafety.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/ThreadSafety.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/ThreadSafety.cpp Sat Jun 30 16:45:28 2012
@@ -349,14 +349,18 @@
   ///
   /// FIXME: add support for re-entrant locking and lock up/downgrading
   LockKind LKind;
-  MutexID UnderlyingMutex;  // for ScopedLockable objects
+  bool     Managed;            // for ScopedLockable objects
+  MutexID  UnderlyingMutex;    // for ScopedLockable objects
 
-  LockData(SourceLocation AcquireLoc, LockKind LKind)
-    : AcquireLoc(AcquireLoc), LKind(LKind), UnderlyingMutex(Decl::EmptyShell())
+  LockData(SourceLocation AcquireLoc, LockKind LKind, bool M = false)
+    : AcquireLoc(AcquireLoc), LKind(LKind), Managed(M),
+      UnderlyingMutex(Decl::EmptyShell())
   {}
 
   LockData(SourceLocation AcquireLoc, LockKind LKind, const MutexID &Mu)
-    : AcquireLoc(AcquireLoc), LKind(LKind), UnderlyingMutex(Mu) {}
+    : AcquireLoc(AcquireLoc), LKind(LKind), Managed(false),
+      UnderlyingMutex(Mu)
+  {}
 
   bool operator==(const LockData &other) const {
     return AcquireLoc == other.AcquireLoc && LKind == other.LKind;
@@ -924,7 +928,8 @@
   Lockset addLock(const Lockset &LSet, Expr *MutexExp, const NamedDecl *D,
                   const LockData &LDat);
   Lockset removeLock(const Lockset &LSet, const MutexID &Mutex,
-                     SourceLocation UnlockLoc);
+                     SourceLocation UnlockLoc,
+                     bool Warn=true, bool FullyRemove=false);
 
   template <class AttrType>
   Lockset addLocksToSet(const Lockset &LSet, LockKind LK, AttrType *Attr,
@@ -986,21 +991,31 @@
 /// \param UnlockLoc The source location of the unlock (only used in error msg)
 Lockset ThreadSafetyAnalyzer::removeLock(const Lockset &LSet,
                                          const MutexID &Mutex,
-                                         SourceLocation UnlockLoc) {
+                                         SourceLocation UnlockLoc,
+                                         bool Warn, bool FullyRemove) {
   const LockData *LDat = LSet.lookup(Mutex);
   if (!LDat) {
-    Handler.handleUnmatchedUnlock(Mutex.getName(), UnlockLoc);
+    if (Warn)
+      Handler.handleUnmatchedUnlock(Mutex.getName(), UnlockLoc);
     return LSet;
   }
   else {
     Lockset Result = LSet;
-    // For scoped-lockable vars, remove the mutex associated with this var.
-    if (LDat->UnderlyingMutex.isValid())
-      Result = removeLock(Result, LDat->UnderlyingMutex, UnlockLoc);
+    if (LDat->UnderlyingMutex.isValid()) {
+      // For scoped-lockable vars, remove the mutex associated with this var.
+      Result = removeLock(Result, LDat->UnderlyingMutex, UnlockLoc,
+                          false, true);
+      // Fully remove the object only when the destructor is called
+      if (FullyRemove)
+        return LocksetFactory.remove(Result, Mutex);
+      else
+        return Result;
+    }
     return LocksetFactory.remove(Result, Mutex);
   }
 }
 
+
 /// \brief This function, parameterized by an attribute type, is used to add a
 /// set of locks specified as attribute arguments to the lockset.
 template <typename AttrType>
@@ -1040,14 +1055,18 @@
     if (!Mutex.isValid())
       MutexID::warnInvalidLock(Handler, *I, Exp, FunDecl);
     else {
-      Result = addLock(Result, Mutex, LockData(ExpLocation, LK));
       if (isScopedVar) {
+        // Mutex is managed by scoped var -- suppress certain warnings.
+        Result = addLock(Result, Mutex, LockData(ExpLocation, LK, true));
         // For scoped lockable vars, map this var to its underlying mutex.
         DeclRefExpr DRE(VD, false, VD->getType(), VK_LValue, VD->getLocation());
         MutexID SMutex(&DRE, 0, 0);
         Result = addLock(Result, SMutex,
                          LockData(VD->getLocation(), LK, Mutex));
       }
+      else {
+        Result = addLock(Result, Mutex, LockData(ExpLocation, LK));
+      }
     }
   }
   return Result;
@@ -1057,9 +1076,11 @@
 /// arguments from the lockset.
 Lockset ThreadSafetyAnalyzer::removeLocksFromSet(const Lockset &LSet,
                                                  UnlockFunctionAttr *Attr,
-                                                 Expr *Exp, NamedDecl* FunDecl) {
+                                                 Expr *Exp,
+                                                 NamedDecl* FunDecl) {
   SourceLocation ExpLocation;
   if (Exp) ExpLocation = Exp->getExprLoc();
+  bool Dtor = isa<CXXDestructorDecl>(FunDecl);
 
   if (Attr->args_size() == 0) {
     // The mutex held is the "this" object.
@@ -1068,7 +1089,7 @@
       MutexID::warnInvalidLock(Handler, 0, Exp, FunDecl);
       return LSet;
     } else {
-      return removeLock(LSet, Mu, ExpLocation);
+      return removeLock(LSet, Mu, ExpLocation, true, Dtor);
     }
   }
 
@@ -1079,7 +1100,7 @@
     if (!Mutex.isValid())
       MutexID::warnInvalidLock(Handler, *I, Exp, FunDecl);
     else
-      Result = removeLock(Result, Mutex, ExpLocation);
+      Result = removeLock(Result, Mutex, ExpLocation, true, Dtor);
   }
   return Result;
 }
@@ -1537,9 +1558,10 @@
                                             LSet2LockData);
       }
     } else {
-      Handler.handleMutexHeldEndOfScope(LSet2Mutex.getName(),
-                                        LSet2LockData.AcquireLoc,
-                                        JoinLoc, LEK);
+      if (!LSet2LockData.Managed)
+        Handler.handleMutexHeldEndOfScope(LSet2Mutex.getName(),
+                                          LSet2LockData.AcquireLoc,
+                                          JoinLoc, LEK);
     }
   }
 
@@ -1547,9 +1569,11 @@
     if (!LSet2.contains(I.getKey())) {
       const MutexID &Mutex = I.getKey();
       const LockData &MissingLock = I.getData();
-      Handler.handleMutexHeldEndOfScope(Mutex.getName(),
-                                        MissingLock.AcquireLoc,
-                                        JoinLoc, LEK);
+
+      if (!MissingLock.Managed)
+        Handler.handleMutexHeldEndOfScope(Mutex.getName(),
+                                          MissingLock.AcquireLoc,
+                                          JoinLoc, LEK);
       Intersection = LocksetFactory.remove(Intersection, Mutex);
     }
   }

Modified: cfe/branches/tooling/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/Diagnostic.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/Diagnostic.cpp (original)
+++ cfe/branches/tooling/lib/Basic/Diagnostic.cpp Sat Jun 30 16:45:28 2012
@@ -48,6 +48,9 @@
   ErrorsAsFatal = false;
   SuppressSystemWarnings = false;
   SuppressAllDiagnostics = false;
+  ElideType = true;
+  PrintTemplateTree = false;
+  ShowColors = false;
   ShowOverloads = Ovl_All;
   ExtBehavior = Ext_Ignore;
 
@@ -660,6 +663,8 @@
   /// QualTypeVals - Pass a vector of arrays so that QualType names can be
   /// compared to see if more information is needed to be printed.
   SmallVector<intptr_t, 2> QualTypeVals;
+  SmallVector<char, 64> Tree;
+
   for (unsigned i = 0, e = getNumArgs(); i < e; ++i)
     if (getArgKind(i) == DiagnosticsEngine::ak_qualtype)
       QualTypeVals.push_back(getRawArg(i));
@@ -711,7 +716,20 @@
     assert(isdigit(*DiagStr) && "Invalid format for argument in diagnostic");
     unsigned ArgNo = *DiagStr++ - '0';
 
+    // Only used for type diffing.
+    unsigned ArgNo2 = ArgNo;
+
     DiagnosticsEngine::ArgumentKind Kind = getArgKind(ArgNo);
+    if (Kind == DiagnosticsEngine::ak_qualtype &&
+        ModifierIs(Modifier, ModifierLen, "diff")) {
+      Kind = DiagnosticsEngine::ak_qualtype_pair;
+      assert(*DiagStr == ',' && isdigit(*(DiagStr + 1)) &&
+             "Invalid format for diff modifier");
+      ++DiagStr;  // Comma.
+      ArgNo2 = *DiagStr++ - '0';
+      assert(getArgKind(ArgNo2) == DiagnosticsEngine::ak_qualtype &&
+             "Second value of type diff must be a qualtype");
+    }
     
     switch (Kind) {
     // ---- STRINGS ----
@@ -796,18 +814,81 @@
                                      FormattedArgs.data(), FormattedArgs.size(),
                                      OutStr, QualTypeVals);
       break;
+    case DiagnosticsEngine::ak_qualtype_pair:
+      // Create a struct with all the info needed for printing.
+      TemplateDiffTypes TDT;
+      TDT.FromType = getRawArg(ArgNo);
+      TDT.ToType = getRawArg(ArgNo2);
+      TDT.ElideType = getDiags()->ElideType;
+      TDT.ShowColors = getDiags()->ShowColors;
+      intptr_t val = reinterpret_cast<intptr_t>(&TDT);
+
+      const char *ArgumentEnd = Argument + ArgumentLen;
+      const char *Pipe = ScanFormat(Argument, ArgumentEnd, '|');
+
+      // Print the tree.
+      if (getDiags()->PrintTemplateTree) {
+        TDT.PrintFromType = true;
+        TDT.PrintTree = true;
+        getDiags()->ConvertArgToString(Kind, val,
+                                       Modifier, ModifierLen,
+                                       Argument, ArgumentLen,
+                                       FormattedArgs.data(),
+                                       FormattedArgs.size(),
+                                       Tree, QualTypeVals);
+        // If there is no tree information, fall back to regular printing.
+        if (!Tree.empty()) {
+          FormatDiagnostic(Pipe + 1, ArgumentEnd, OutStr);
+          break;
+        }
+      }
+
+      // Non-tree printing, also the fall-back when tree printing fails.
+      // The fall-back is triggered when the types compared are not templates.
+      const char *FirstDollar = ScanFormat(Argument, ArgumentEnd, '$');
+      const char *SecondDollar = ScanFormat(FirstDollar + 1, ArgumentEnd, '$');
+
+      // Append before text
+      FormatDiagnostic(Argument, FirstDollar, OutStr);
+
+      // Append first type
+      TDT.PrintTree = false;
+      TDT.PrintFromType = true;
+      getDiags()->ConvertArgToString(Kind, val,
+                                     Modifier, ModifierLen,
+                                     Argument, ArgumentLen,
+                                     FormattedArgs.data(), FormattedArgs.size(),
+                                     OutStr, QualTypeVals);
+      // Append middle text
+      FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
+
+      // Append second type
+      TDT.PrintFromType = false;
+      getDiags()->ConvertArgToString(Kind, val,
+                                     Modifier, ModifierLen,
+                                     Argument, ArgumentLen,
+                                     FormattedArgs.data(), FormattedArgs.size(),
+                                     OutStr, QualTypeVals);
+      // Append end text
+      FormatDiagnostic(SecondDollar + 1, Pipe, OutStr);
+      break;
     }
     
     // Remember this argument info for subsequent formatting operations.  Turn
     // std::strings into a null terminated string to make it be the same case as
     // all the other ones.
-    if (Kind != DiagnosticsEngine::ak_std_string)
+    if (Kind == DiagnosticsEngine::ak_qualtype_pair)
+      continue;
+    else if (Kind != DiagnosticsEngine::ak_std_string)
       FormattedArgs.push_back(std::make_pair(Kind, getRawArg(ArgNo)));
     else
       FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_c_string,
                                         (intptr_t)getArgStdStr(ArgNo).c_str()));
     
   }
+
+  // Append the type tree to the end of the diagnostics.
+  OutStr.append(Tree.begin(), Tree.end());
 }
 
 StoredDiagnostic::StoredDiagnostic() { }

Modified: cfe/branches/tooling/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/FileManager.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/FileManager.cpp (original)
+++ cfe/branches/tooling/lib/Basic/FileManager.cpp Sat Jun 30 16:45:28 2012
@@ -111,6 +111,8 @@
   }
 
   size_t size() const { return UniqueFiles.size(); }
+
+  friend class FileManager;
 };
 
 //===----------------------------------------------------------------------===//
@@ -152,6 +154,8 @@
   }
 
   size_t size() const { return UniqueFiles.size(); }
+
+  friend class FileManager;
 };
 
 #endif
@@ -559,6 +563,19 @@
   return ::stat(FilePath.c_str(), &StatBuf) != 0;
 }
 
+void FileManager::InvalidateCache(const FileEntry* Entry) {
+  if (!Entry)
+    return;
+
+  SeenFileEntries.erase(Entry->getName());
+#ifdef LLVM_ON_WIN32
+  UniqueRealFiles.UniqueFiles.erase(Entry->getName());
+#else
+  UniqueRealFiles.UniqueFiles.erase(*Entry);
+#endif
+}
+
+
 void FileManager::GetUniqueIDMapping(
                    SmallVectorImpl<const FileEntry *> &UIDToFiles) const {
   UIDToFiles.clear();

Modified: cfe/branches/tooling/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/Targets.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/Targets.cpp (original)
+++ cfe/branches/tooling/lib/Basic/Targets.cpp Sat Jun 30 16:45:28 2012
@@ -3557,6 +3557,7 @@
 
 namespace {
 class MipsTargetInfoBase : public TargetInfo {
+  static const Builtin::Info BuiltinInfo[];
   std::string CPU;
   bool SoftFloat;
   bool SingleFloat;
@@ -3606,7 +3607,8 @@
                                 MacroBuilder &Builder) const = 0;
   virtual void getTargetBuiltins(const Builtin::Info *&Records,
                                  unsigned &NumRecords) const {
-    // FIXME: Implement!
+    Records = BuiltinInfo;
+    NumRecords = clang::Mips::LastTSBuiltin - Builtin::FirstTSBuiltin;
   }
   virtual bool hasFeature(StringRef Feature) const {
     return Feature == "mips";
@@ -3695,6 +3697,13 @@
   }
 };
 
+const Builtin::Info MipsTargetInfoBase::BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES },
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\
+                                              ALL_LANGUAGES },
+#include "clang/Basic/BuiltinsMips.def"
+};
+
 class Mips32TargetInfoBase : public MipsTargetInfoBase {
 public:
   Mips32TargetInfoBase(const std::string& triple) :

Modified: cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp Sat Jun 30 16:45:28 2012
@@ -630,7 +630,7 @@
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
   llvm::Constant *blockFn
-    = CodeGenFunction(CGM).GenerateBlockFunction(CurGD, blockInfo,
+    = CodeGenFunction(CGM, true).GenerateBlockFunction(CurGD, blockInfo,
                                                  CurFuncDecl, LocalDeclMap,
                                                  isLambdaConv);
   blockFn = llvm::ConstantExpr::getBitCast(blockFn, VoidPtrTy);
@@ -1003,7 +1003,8 @@
   // Check if we should generate debug info for this block function.
   if (CGM.getModuleDebugInfo())
     DebugInfo = CGM.getModuleDebugInfo();
-
+  CurGD = GD;
+  
   BlockInfo = &blockInfo;
 
   // Arrange for local static and local extern declarations to appear

Modified: cfe/branches/tooling/lib/CodeGen/CGBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGBuilder.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGBuilder.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CGBuilder.h Sat Jun 30 16:45:28 2012
@@ -10,7 +10,7 @@
 #ifndef CLANG_CODEGEN_CGBUILDER_H
 #define CLANG_CODEGEN_CGBUILDER_H
 
-#include "llvm/Support/IRBuilder.h"
+#include "llvm/IRBuilder.h"
 
 namespace clang {
 namespace CodeGen {

Modified: cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp Sat Jun 30 16:45:28 2012
@@ -1378,8 +1378,6 @@
   case llvm::Triple::ppc:
   case llvm::Triple::ppc64:
     return EmitPPCBuiltinExpr(BuiltinID, E);
-  case llvm::Triple::hexagon:
-    return EmitHexagonBuiltinExpr(BuiltinID, E);
   default:
     return 0;
   }
@@ -2453,2588 +2451,6 @@
 }
 
 
-Value *CodeGenFunction::EmitHexagonBuiltinExpr(unsigned BuiltinID,
-                                             const CallExpr *E) {
-  llvm::SmallVector<Value*, 4> Ops;
-
-  for (unsigned i = 0, e = E->getNumArgs(); i != e; i++)
-    Ops.push_back(EmitScalarExpr(E->getArg(i)));
-
-  Intrinsic::ID ID = Intrinsic::not_intrinsic;
-
-  switch (BuiltinID) {
-  default: return 0;
-
-// The builtins below are not autogenerated from iset.py.
-// Make sure you do not overwrite these.
-
-  case Hexagon::BI__builtin_SI_to_SXTHI_asrh:
-    ID = Intrinsic::hexagon_SI_to_SXTHI_asrh; break;
-
-  case Hexagon::BI__builtin_circ_ldd:
-    ID = Intrinsic::hexagon_circ_ldd; break;
-
-// The builtins above are not autogenerated from iset.py.
-// Make sure you do not overwrite these.
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpeq:
-    ID = Intrinsic::hexagon_C2_cmpeq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpgt:
-    ID = Intrinsic::hexagon_C2_cmpgt; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpgtu:
-    ID = Intrinsic::hexagon_C2_cmpgtu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpeqp:
-    ID = Intrinsic::hexagon_C2_cmpeqp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpgtp:
-    ID = Intrinsic::hexagon_C2_cmpgtp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpgtup:
-    ID = Intrinsic::hexagon_C2_cmpgtup; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_rcmpeqi:
-    ID = Intrinsic::hexagon_A4_rcmpeqi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_rcmpneqi:
-    ID = Intrinsic::hexagon_A4_rcmpneqi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_rcmpeq:
-    ID = Intrinsic::hexagon_A4_rcmpeq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_rcmpneq:
-    ID = Intrinsic::hexagon_A4_rcmpneq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_bitsset:
-    ID = Intrinsic::hexagon_C2_bitsset; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_bitsclr:
-    ID = Intrinsic::hexagon_C2_bitsclr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_nbitsset:
-    ID = Intrinsic::hexagon_C4_nbitsset; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_nbitsclr:
-    ID = Intrinsic::hexagon_C4_nbitsclr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpeqi:
-    ID = Intrinsic::hexagon_C2_cmpeqi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpgti:
-    ID = Intrinsic::hexagon_C2_cmpgti; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpgtui:
-    ID = Intrinsic::hexagon_C2_cmpgtui; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpgei:
-    ID = Intrinsic::hexagon_C2_cmpgei; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpgeui:
-    ID = Intrinsic::hexagon_C2_cmpgeui; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmplt:
-    ID = Intrinsic::hexagon_C2_cmplt; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_cmpltu:
-    ID = Intrinsic::hexagon_C2_cmpltu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_bitsclri:
-    ID = Intrinsic::hexagon_C2_bitsclri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_nbitsclri:
-    ID = Intrinsic::hexagon_C4_nbitsclri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_cmpneqi:
-    ID = Intrinsic::hexagon_C4_cmpneqi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_cmpltei:
-    ID = Intrinsic::hexagon_C4_cmpltei; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_cmplteui:
-    ID = Intrinsic::hexagon_C4_cmplteui; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_cmpneq:
-    ID = Intrinsic::hexagon_C4_cmpneq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_cmplte:
-    ID = Intrinsic::hexagon_C4_cmplte; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_cmplteu:
-    ID = Intrinsic::hexagon_C4_cmplteu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_and:
-    ID = Intrinsic::hexagon_C2_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_or:
-    ID = Intrinsic::hexagon_C2_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_xor:
-    ID = Intrinsic::hexagon_C2_xor; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_andn:
-    ID = Intrinsic::hexagon_C2_andn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_not:
-    ID = Intrinsic::hexagon_C2_not; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_orn:
-    ID = Intrinsic::hexagon_C2_orn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_and_and:
-    ID = Intrinsic::hexagon_C4_and_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_and_or:
-    ID = Intrinsic::hexagon_C4_and_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_or_and:
-    ID = Intrinsic::hexagon_C4_or_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_or_or:
-    ID = Intrinsic::hexagon_C4_or_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_and_andn:
-    ID = Intrinsic::hexagon_C4_and_andn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_and_orn:
-    ID = Intrinsic::hexagon_C4_and_orn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_or_andn:
-    ID = Intrinsic::hexagon_C4_or_andn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_or_orn:
-    ID = Intrinsic::hexagon_C4_or_orn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_pxfer_map:
-    ID = Intrinsic::hexagon_C2_pxfer_map; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_any8:
-    ID = Intrinsic::hexagon_C2_any8; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_all8:
-    ID = Intrinsic::hexagon_C2_all8; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_vitpack:
-    ID = Intrinsic::hexagon_C2_vitpack; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_mux:
-    ID = Intrinsic::hexagon_C2_mux; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_muxii:
-    ID = Intrinsic::hexagon_C2_muxii; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_muxir:
-    ID = Intrinsic::hexagon_C2_muxir; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_muxri:
-    ID = Intrinsic::hexagon_C2_muxri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_vmux:
-    ID = Intrinsic::hexagon_C2_vmux; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_mask:
-    ID = Intrinsic::hexagon_C2_mask; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vcmpbeq:
-    ID = Intrinsic::hexagon_A2_vcmpbeq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi:
-    ID = Intrinsic::hexagon_A4_vcmpbeqi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmpbeq_any:
-    ID = Intrinsic::hexagon_A4_vcmpbeq_any; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vcmpbgtu:
-    ID = Intrinsic::hexagon_A2_vcmpbgtu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui:
-    ID = Intrinsic::hexagon_A4_vcmpbgtui; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmpbgt:
-    ID = Intrinsic::hexagon_A4_vcmpbgt; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti:
-    ID = Intrinsic::hexagon_A4_vcmpbgti; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmpbeq:
-    ID = Intrinsic::hexagon_A4_cmpbeq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi:
-    ID = Intrinsic::hexagon_A4_cmpbeqi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmpbgtu:
-    ID = Intrinsic::hexagon_A4_cmpbgtu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmpbgtui:
-    ID = Intrinsic::hexagon_A4_cmpbgtui; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmpbgt:
-    ID = Intrinsic::hexagon_A4_cmpbgt; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmpbgti:
-    ID = Intrinsic::hexagon_A4_cmpbgti; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vcmpheq:
-    ID = Intrinsic::hexagon_A2_vcmpheq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vcmphgt:
-    ID = Intrinsic::hexagon_A2_vcmphgt; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vcmphgtu:
-    ID = Intrinsic::hexagon_A2_vcmphgtu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi:
-    ID = Intrinsic::hexagon_A4_vcmpheqi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmphgti:
-    ID = Intrinsic::hexagon_A4_vcmphgti; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui:
-    ID = Intrinsic::hexagon_A4_vcmphgtui; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmpheq:
-    ID = Intrinsic::hexagon_A4_cmpheq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmphgt:
-    ID = Intrinsic::hexagon_A4_cmphgt; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmphgtu:
-    ID = Intrinsic::hexagon_A4_cmphgtu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmpheqi:
-    ID = Intrinsic::hexagon_A4_cmpheqi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmphgti:
-    ID = Intrinsic::hexagon_A4_cmphgti; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cmphgtui:
-    ID = Intrinsic::hexagon_A4_cmphgtui; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vcmpweq:
-    ID = Intrinsic::hexagon_A2_vcmpweq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vcmpwgt:
-    ID = Intrinsic::hexagon_A2_vcmpwgt; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vcmpwgtu:
-    ID = Intrinsic::hexagon_A2_vcmpwgtu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi:
-    ID = Intrinsic::hexagon_A4_vcmpweqi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti:
-    ID = Intrinsic::hexagon_A4_vcmpwgti; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui:
-    ID = Intrinsic::hexagon_A4_vcmpwgtui; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_boundscheck:
-    ID = Intrinsic::hexagon_A4_boundscheck; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_tlbmatch:
-    ID = Intrinsic::hexagon_A4_tlbmatch; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_tfrpr:
-    ID = Intrinsic::hexagon_C2_tfrpr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C2_tfrrp:
-    ID = Intrinsic::hexagon_C2_tfrrp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_fastcorner9:
-    ID = Intrinsic::hexagon_C4_fastcorner9; break;
-
-  case Hexagon::BI__builtin_HEXAGON_C4_fastcorner9_not:
-    ID = Intrinsic::hexagon_C4_fastcorner9_not; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_acc_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_acc_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpy_acc_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpy_acc_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_acc_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_acc_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpy_acc_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpy_acc_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_nac_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_nac_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpy_nac_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpy_nac_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_nac_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_nac_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpy_nac_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpy_nac_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_acc_sat_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_acc_sat_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpy_acc_sat_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpy_acc_sat_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_acc_sat_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_acc_sat_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpy_acc_sat_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpy_acc_sat_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_nac_sat_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_nac_sat_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpy_nac_sat_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpy_nac_sat_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_nac_sat_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_nac_sat_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpy_nac_sat_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpy_nac_sat_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpy_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpy_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpy_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpy_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_sat_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_sat_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpy_sat_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpy_sat_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_sat_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_sat_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpy_sat_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpy_sat_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_rnd_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_rnd_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpy_rnd_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpy_rnd_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_rnd_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_rnd_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpy_rnd_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpy_rnd_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_sat_rnd_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_sat_rnd_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpy_sat_rnd_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpy_sat_rnd_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpy_sat_rnd_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpy_sat_rnd_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpy_sat_rnd_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpy_sat_rnd_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_acc_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_acc_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_acc_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_acc_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_acc_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_acc_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_acc_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_acc_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_nac_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_nac_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_nac_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_nac_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_nac_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_nac_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_nac_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_nac_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_rnd_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_rnd_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_rnd_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_rnd_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_rnd_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_rnd_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpyd_rnd_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpyd_rnd_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_acc_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_acc_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_acc_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_acc_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_acc_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_acc_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_acc_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_acc_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_nac_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_nac_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_nac_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_nac_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_nac_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_nac_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_nac_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_nac_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpyu_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpyu_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_acc_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_acc_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_acc_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_acc_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_acc_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_acc_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_acc_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_acc_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_nac_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_nac_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_nac_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_nac_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_nac_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_nac_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_nac_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_nac_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_hh_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_hh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_hh_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_hh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_hl_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_hl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_hl_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_hl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_lh_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_lh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_lh_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_lh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_ll_s0:
-    ID = Intrinsic::hexagon_M2_mpyud_ll_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyud_ll_s1:
-    ID = Intrinsic::hexagon_M2_mpyud_ll_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpysmi:
-    ID = Intrinsic::hexagon_M2_mpysmi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_macsip:
-    ID = Intrinsic::hexagon_M2_macsip; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_macsin:
-    ID = Intrinsic::hexagon_M2_macsin; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_dpmpyss_s0:
-    ID = Intrinsic::hexagon_M2_dpmpyss_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_dpmpyss_acc_s0:
-    ID = Intrinsic::hexagon_M2_dpmpyss_acc_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_dpmpyss_nac_s0:
-    ID = Intrinsic::hexagon_M2_dpmpyss_nac_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_dpmpyuu_s0:
-    ID = Intrinsic::hexagon_M2_dpmpyuu_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_dpmpyuu_acc_s0:
-    ID = Intrinsic::hexagon_M2_dpmpyuu_acc_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_dpmpyuu_nac_s0:
-    ID = Intrinsic::hexagon_M2_dpmpyuu_nac_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_up:
-    ID = Intrinsic::hexagon_M2_mpy_up; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_up_s1:
-    ID = Intrinsic::hexagon_M2_mpy_up_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpy_up_s1_sat:
-    ID = Intrinsic::hexagon_M2_mpy_up_s1_sat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyu_up:
-    ID = Intrinsic::hexagon_M2_mpyu_up; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpysu_up:
-    ID = Intrinsic::hexagon_M2_mpysu_up; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_dpmpyss_rnd_s0:
-    ID = Intrinsic::hexagon_M2_dpmpyss_rnd_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_mac_up_s1_sat:
-    ID = Intrinsic::hexagon_M4_mac_up_s1_sat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_nac_up_s1_sat:
-    ID = Intrinsic::hexagon_M4_nac_up_s1_sat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyi:
-    ID = Intrinsic::hexagon_M2_mpyi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mpyui:
-    ID = Intrinsic::hexagon_M2_mpyui; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_maci:
-    ID = Intrinsic::hexagon_M2_maci; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_acci:
-    ID = Intrinsic::hexagon_M2_acci; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_accii:
-    ID = Intrinsic::hexagon_M2_accii; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_nacci:
-    ID = Intrinsic::hexagon_M2_nacci; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_naccii:
-    ID = Intrinsic::hexagon_M2_naccii; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_subacc:
-    ID = Intrinsic::hexagon_M2_subacc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_mpyrr_addr:
-    ID = Intrinsic::hexagon_M4_mpyrr_addr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2:
-    ID = Intrinsic::hexagon_M4_mpyri_addr_u2; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr:
-    ID = Intrinsic::hexagon_M4_mpyri_addr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi:
-    ID = Intrinsic::hexagon_M4_mpyri_addi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_mpyrr_addi:
-    ID = Intrinsic::hexagon_M4_mpyrr_addi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmpy2s_s0:
-    ID = Intrinsic::hexagon_M2_vmpy2s_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmpy2s_s1:
-    ID = Intrinsic::hexagon_M2_vmpy2s_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmac2s_s0:
-    ID = Intrinsic::hexagon_M2_vmac2s_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmac2s_s1:
-    ID = Intrinsic::hexagon_M2_vmac2s_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmpy2su_s0:
-    ID = Intrinsic::hexagon_M2_vmpy2su_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmpy2su_s1:
-    ID = Intrinsic::hexagon_M2_vmpy2su_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmac2su_s0:
-    ID = Intrinsic::hexagon_M2_vmac2su_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmac2su_s1:
-    ID = Intrinsic::hexagon_M2_vmac2su_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmpy2s_s0pack:
-    ID = Intrinsic::hexagon_M2_vmpy2s_s0pack; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmpy2s_s1pack:
-    ID = Intrinsic::hexagon_M2_vmpy2s_s1pack; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmac2:
-    ID = Intrinsic::hexagon_M2_vmac2; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmpy2es_s0:
-    ID = Intrinsic::hexagon_M2_vmpy2es_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmpy2es_s1:
-    ID = Intrinsic::hexagon_M2_vmpy2es_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmac2es_s0:
-    ID = Intrinsic::hexagon_M2_vmac2es_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmac2es_s1:
-    ID = Intrinsic::hexagon_M2_vmac2es_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vmac2es:
-    ID = Intrinsic::hexagon_M2_vmac2es; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrmac_s0:
-    ID = Intrinsic::hexagon_M2_vrmac_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrmpy_s0:
-    ID = Intrinsic::hexagon_M2_vrmpy_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vdmpyrs_s0:
-    ID = Intrinsic::hexagon_M2_vdmpyrs_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vdmpyrs_s1:
-    ID = Intrinsic::hexagon_M2_vdmpyrs_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M5_vrmpybuu:
-    ID = Intrinsic::hexagon_M5_vrmpybuu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M5_vrmacbuu:
-    ID = Intrinsic::hexagon_M5_vrmacbuu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M5_vrmpybsu:
-    ID = Intrinsic::hexagon_M5_vrmpybsu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M5_vrmacbsu:
-    ID = Intrinsic::hexagon_M5_vrmacbsu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M5_vmpybuu:
-    ID = Intrinsic::hexagon_M5_vmpybuu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M5_vmpybsu:
-    ID = Intrinsic::hexagon_M5_vmpybsu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M5_vmacbuu:
-    ID = Intrinsic::hexagon_M5_vmacbuu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M5_vmacbsu:
-    ID = Intrinsic::hexagon_M5_vmacbsu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M5_vdmpybsu:
-    ID = Intrinsic::hexagon_M5_vdmpybsu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M5_vdmacbsu:
-    ID = Intrinsic::hexagon_M5_vdmacbsu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vdmacs_s0:
-    ID = Intrinsic::hexagon_M2_vdmacs_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vdmacs_s1:
-    ID = Intrinsic::hexagon_M2_vdmacs_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vdmpys_s0:
-    ID = Intrinsic::hexagon_M2_vdmpys_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vdmpys_s1:
-    ID = Intrinsic::hexagon_M2_vdmpys_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmpyrs_s0:
-    ID = Intrinsic::hexagon_M2_cmpyrs_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmpyrs_s1:
-    ID = Intrinsic::hexagon_M2_cmpyrs_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmpyrsc_s0:
-    ID = Intrinsic::hexagon_M2_cmpyrsc_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmpyrsc_s1:
-    ID = Intrinsic::hexagon_M2_cmpyrsc_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmacs_s0:
-    ID = Intrinsic::hexagon_M2_cmacs_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmacs_s1:
-    ID = Intrinsic::hexagon_M2_cmacs_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmacsc_s0:
-    ID = Intrinsic::hexagon_M2_cmacsc_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmacsc_s1:
-    ID = Intrinsic::hexagon_M2_cmacsc_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmpys_s0:
-    ID = Intrinsic::hexagon_M2_cmpys_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmpys_s1:
-    ID = Intrinsic::hexagon_M2_cmpys_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmpysc_s0:
-    ID = Intrinsic::hexagon_M2_cmpysc_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmpysc_s1:
-    ID = Intrinsic::hexagon_M2_cmpysc_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cnacs_s0:
-    ID = Intrinsic::hexagon_M2_cnacs_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cnacs_s1:
-    ID = Intrinsic::hexagon_M2_cnacs_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cnacsc_s0:
-    ID = Intrinsic::hexagon_M2_cnacsc_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cnacsc_s1:
-    ID = Intrinsic::hexagon_M2_cnacsc_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmpys_s1:
-    ID = Intrinsic::hexagon_M2_vrcmpys_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmpys_acc_s1:
-    ID = Intrinsic::hexagon_M2_vrcmpys_acc_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmpys_s1rp:
-    ID = Intrinsic::hexagon_M2_vrcmpys_s1rp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmacls_s0:
-    ID = Intrinsic::hexagon_M2_mmacls_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmacls_s1:
-    ID = Intrinsic::hexagon_M2_mmacls_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmachs_s0:
-    ID = Intrinsic::hexagon_M2_mmachs_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmachs_s1:
-    ID = Intrinsic::hexagon_M2_mmachs_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyl_s0:
-    ID = Intrinsic::hexagon_M2_mmpyl_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyl_s1:
-    ID = Intrinsic::hexagon_M2_mmpyl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyh_s0:
-    ID = Intrinsic::hexagon_M2_mmpyh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyh_s1:
-    ID = Intrinsic::hexagon_M2_mmpyh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmacls_rs0:
-    ID = Intrinsic::hexagon_M2_mmacls_rs0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmacls_rs1:
-    ID = Intrinsic::hexagon_M2_mmacls_rs1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmachs_rs0:
-    ID = Intrinsic::hexagon_M2_mmachs_rs0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmachs_rs1:
-    ID = Intrinsic::hexagon_M2_mmachs_rs1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyl_rs0:
-    ID = Intrinsic::hexagon_M2_mmpyl_rs0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyl_rs1:
-    ID = Intrinsic::hexagon_M2_mmpyl_rs1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyh_rs0:
-    ID = Intrinsic::hexagon_M2_mmpyh_rs0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyh_rs1:
-    ID = Intrinsic::hexagon_M2_mmpyh_rs1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_vrmpyeh_s0:
-    ID = Intrinsic::hexagon_M4_vrmpyeh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_vrmpyeh_s1:
-    ID = Intrinsic::hexagon_M4_vrmpyeh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_vrmpyeh_acc_s0:
-    ID = Intrinsic::hexagon_M4_vrmpyeh_acc_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_vrmpyeh_acc_s1:
-    ID = Intrinsic::hexagon_M4_vrmpyeh_acc_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_vrmpyoh_s0:
-    ID = Intrinsic::hexagon_M4_vrmpyoh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_vrmpyoh_s1:
-    ID = Intrinsic::hexagon_M4_vrmpyoh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_vrmpyoh_acc_s0:
-    ID = Intrinsic::hexagon_M4_vrmpyoh_acc_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_vrmpyoh_acc_s1:
-    ID = Intrinsic::hexagon_M4_vrmpyoh_acc_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_hmmpyl_rs1:
-    ID = Intrinsic::hexagon_M2_hmmpyl_rs1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_hmmpyh_rs1:
-    ID = Intrinsic::hexagon_M2_hmmpyh_rs1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_hmmpyl_s1:
-    ID = Intrinsic::hexagon_M2_hmmpyl_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_hmmpyh_s1:
-    ID = Intrinsic::hexagon_M2_hmmpyh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmaculs_s0:
-    ID = Intrinsic::hexagon_M2_mmaculs_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmaculs_s1:
-    ID = Intrinsic::hexagon_M2_mmaculs_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmacuhs_s0:
-    ID = Intrinsic::hexagon_M2_mmacuhs_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmacuhs_s1:
-    ID = Intrinsic::hexagon_M2_mmacuhs_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyul_s0:
-    ID = Intrinsic::hexagon_M2_mmpyul_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyul_s1:
-    ID = Intrinsic::hexagon_M2_mmpyul_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyuh_s0:
-    ID = Intrinsic::hexagon_M2_mmpyuh_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyuh_s1:
-    ID = Intrinsic::hexagon_M2_mmpyuh_s1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmaculs_rs0:
-    ID = Intrinsic::hexagon_M2_mmaculs_rs0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmaculs_rs1:
-    ID = Intrinsic::hexagon_M2_mmaculs_rs1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmacuhs_rs0:
-    ID = Intrinsic::hexagon_M2_mmacuhs_rs0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmacuhs_rs1:
-    ID = Intrinsic::hexagon_M2_mmacuhs_rs1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyul_rs0:
-    ID = Intrinsic::hexagon_M2_mmpyul_rs0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyul_rs1:
-    ID = Intrinsic::hexagon_M2_mmpyul_rs1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyuh_rs0:
-    ID = Intrinsic::hexagon_M2_mmpyuh_rs0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_mmpyuh_rs1:
-    ID = Intrinsic::hexagon_M2_mmpyuh_rs1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmaci_s0:
-    ID = Intrinsic::hexagon_M2_vrcmaci_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmacr_s0:
-    ID = Intrinsic::hexagon_M2_vrcmacr_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmaci_s0c:
-    ID = Intrinsic::hexagon_M2_vrcmaci_s0c; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmacr_s0c:
-    ID = Intrinsic::hexagon_M2_vrcmacr_s0c; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmaci_s0:
-    ID = Intrinsic::hexagon_M2_cmaci_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmacr_s0:
-    ID = Intrinsic::hexagon_M2_cmacr_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmpyi_s0:
-    ID = Intrinsic::hexagon_M2_vrcmpyi_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmpyr_s0:
-    ID = Intrinsic::hexagon_M2_vrcmpyr_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmpyi_s0c:
-    ID = Intrinsic::hexagon_M2_vrcmpyi_s0c; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vrcmpyr_s0c:
-    ID = Intrinsic::hexagon_M2_vrcmpyr_s0c; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmpyi_s0:
-    ID = Intrinsic::hexagon_M2_cmpyi_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_cmpyr_s0:
-    ID = Intrinsic::hexagon_M2_cmpyr_s0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_cmpyi_wh:
-    ID = Intrinsic::hexagon_M4_cmpyi_wh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_cmpyr_wh:
-    ID = Intrinsic::hexagon_M4_cmpyr_wh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_cmpyi_whc:
-    ID = Intrinsic::hexagon_M4_cmpyi_whc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_cmpyr_whc:
-    ID = Intrinsic::hexagon_M4_cmpyr_whc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vcmpy_s0_sat_i:
-    ID = Intrinsic::hexagon_M2_vcmpy_s0_sat_i; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vcmpy_s0_sat_r:
-    ID = Intrinsic::hexagon_M2_vcmpy_s0_sat_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vcmpy_s1_sat_i:
-    ID = Intrinsic::hexagon_M2_vcmpy_s1_sat_i; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vcmpy_s1_sat_r:
-    ID = Intrinsic::hexagon_M2_vcmpy_s1_sat_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vcmac_s0_sat_i:
-    ID = Intrinsic::hexagon_M2_vcmac_s0_sat_i; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vcmac_s0_sat_r:
-    ID = Intrinsic::hexagon_M2_vcmac_s0_sat_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vcrotate:
-    ID = Intrinsic::hexagon_S2_vcrotate; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc:
-    ID = Intrinsic::hexagon_S4_vrcrotate_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_vrcrotate:
-    ID = Intrinsic::hexagon_S4_vrcrotate; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vcnegh:
-    ID = Intrinsic::hexagon_S2_vcnegh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vrcnegh:
-    ID = Intrinsic::hexagon_S2_vrcnegh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_pmpyw:
-    ID = Intrinsic::hexagon_M4_pmpyw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_vpmpyh:
-    ID = Intrinsic::hexagon_M4_vpmpyh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_pmpyw_acc:
-    ID = Intrinsic::hexagon_M4_pmpyw_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_vpmpyh_acc:
-    ID = Intrinsic::hexagon_M4_vpmpyh_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_add:
-    ID = Intrinsic::hexagon_A2_add; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_sub:
-    ID = Intrinsic::hexagon_A2_sub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addsat:
-    ID = Intrinsic::hexagon_A2_addsat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subsat:
-    ID = Intrinsic::hexagon_A2_subsat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addi:
-    ID = Intrinsic::hexagon_A2_addi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_l16_ll:
-    ID = Intrinsic::hexagon_A2_addh_l16_ll; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_l16_hl:
-    ID = Intrinsic::hexagon_A2_addh_l16_hl; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_l16_sat_ll:
-    ID = Intrinsic::hexagon_A2_addh_l16_sat_ll; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_l16_sat_hl:
-    ID = Intrinsic::hexagon_A2_addh_l16_sat_hl; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_l16_ll:
-    ID = Intrinsic::hexagon_A2_subh_l16_ll; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_l16_hl:
-    ID = Intrinsic::hexagon_A2_subh_l16_hl; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_l16_sat_ll:
-    ID = Intrinsic::hexagon_A2_subh_l16_sat_ll; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_l16_sat_hl:
-    ID = Intrinsic::hexagon_A2_subh_l16_sat_hl; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_ll:
-    ID = Intrinsic::hexagon_A2_addh_h16_ll; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_lh:
-    ID = Intrinsic::hexagon_A2_addh_h16_lh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_hl:
-    ID = Intrinsic::hexagon_A2_addh_h16_hl; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_hh:
-    ID = Intrinsic::hexagon_A2_addh_h16_hh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_sat_ll:
-    ID = Intrinsic::hexagon_A2_addh_h16_sat_ll; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_sat_lh:
-    ID = Intrinsic::hexagon_A2_addh_h16_sat_lh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_sat_hl:
-    ID = Intrinsic::hexagon_A2_addh_h16_sat_hl; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_sat_hh:
-    ID = Intrinsic::hexagon_A2_addh_h16_sat_hh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_ll:
-    ID = Intrinsic::hexagon_A2_subh_h16_ll; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_lh:
-    ID = Intrinsic::hexagon_A2_subh_h16_lh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_hl:
-    ID = Intrinsic::hexagon_A2_subh_h16_hl; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_hh:
-    ID = Intrinsic::hexagon_A2_subh_h16_hh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_sat_ll:
-    ID = Intrinsic::hexagon_A2_subh_h16_sat_ll; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_sat_lh:
-    ID = Intrinsic::hexagon_A2_subh_h16_sat_lh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_sat_hl:
-    ID = Intrinsic::hexagon_A2_subh_h16_sat_hl; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_sat_hh:
-    ID = Intrinsic::hexagon_A2_subh_h16_sat_hh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_aslh:
-    ID = Intrinsic::hexagon_A2_aslh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_asrh:
-    ID = Intrinsic::hexagon_A2_asrh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addp:
-    ID = Intrinsic::hexagon_A2_addp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addpsat:
-    ID = Intrinsic::hexagon_A2_addpsat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_addsp:
-    ID = Intrinsic::hexagon_A2_addsp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subp:
-    ID = Intrinsic::hexagon_A2_subp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_neg:
-    ID = Intrinsic::hexagon_A2_neg; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_negsat:
-    ID = Intrinsic::hexagon_A2_negsat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_abs:
-    ID = Intrinsic::hexagon_A2_abs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_abssat:
-    ID = Intrinsic::hexagon_A2_abssat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vconj:
-    ID = Intrinsic::hexagon_A2_vconj; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_negp:
-    ID = Intrinsic::hexagon_A2_negp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_absp:
-    ID = Intrinsic::hexagon_A2_absp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_max:
-    ID = Intrinsic::hexagon_A2_max; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_maxu:
-    ID = Intrinsic::hexagon_A2_maxu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_min:
-    ID = Intrinsic::hexagon_A2_min; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_minu:
-    ID = Intrinsic::hexagon_A2_minu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_maxp:
-    ID = Intrinsic::hexagon_A2_maxp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_maxup:
-    ID = Intrinsic::hexagon_A2_maxup; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_minp:
-    ID = Intrinsic::hexagon_A2_minp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_minup:
-    ID = Intrinsic::hexagon_A2_minup; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_tfr:
-    ID = Intrinsic::hexagon_A2_tfr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_tfrsi:
-    ID = Intrinsic::hexagon_A2_tfrsi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_tfrp:
-    ID = Intrinsic::hexagon_A2_tfrp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_tfrpi:
-    ID = Intrinsic::hexagon_A2_tfrpi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_zxtb:
-    ID = Intrinsic::hexagon_A2_zxtb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_sxtb:
-    ID = Intrinsic::hexagon_A2_sxtb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_zxth:
-    ID = Intrinsic::hexagon_A2_zxth; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_sxth:
-    ID = Intrinsic::hexagon_A2_sxth; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_combinew:
-    ID = Intrinsic::hexagon_A2_combinew; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_combineri:
-    ID = Intrinsic::hexagon_A4_combineri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_combineir:
-    ID = Intrinsic::hexagon_A4_combineir; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_combineii:
-    ID = Intrinsic::hexagon_A2_combineii; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_combine_hh:
-    ID = Intrinsic::hexagon_A2_combine_hh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_combine_hl:
-    ID = Intrinsic::hexagon_A2_combine_hl; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_combine_lh:
-    ID = Intrinsic::hexagon_A2_combine_lh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_combine_ll:
-    ID = Intrinsic::hexagon_A2_combine_ll; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_tfril:
-    ID = Intrinsic::hexagon_A2_tfril; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_tfrih:
-    ID = Intrinsic::hexagon_A2_tfrih; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_and:
-    ID = Intrinsic::hexagon_A2_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_or:
-    ID = Intrinsic::hexagon_A2_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_xor:
-    ID = Intrinsic::hexagon_A2_xor; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_not:
-    ID = Intrinsic::hexagon_A2_not; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_xor_xacc:
-    ID = Intrinsic::hexagon_M2_xor_xacc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_xor_xacc:
-    ID = Intrinsic::hexagon_M4_xor_xacc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_andn:
-    ID = Intrinsic::hexagon_A4_andn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_orn:
-    ID = Intrinsic::hexagon_A4_orn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_andnp:
-    ID = Intrinsic::hexagon_A4_andnp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_ornp:
-    ID = Intrinsic::hexagon_A4_ornp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_addaddi:
-    ID = Intrinsic::hexagon_S4_addaddi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_subaddi:
-    ID = Intrinsic::hexagon_S4_subaddi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_and_and:
-    ID = Intrinsic::hexagon_M4_and_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_and_andn:
-    ID = Intrinsic::hexagon_M4_and_andn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_and_or:
-    ID = Intrinsic::hexagon_M4_and_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_and_xor:
-    ID = Intrinsic::hexagon_M4_and_xor; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_or_and:
-    ID = Intrinsic::hexagon_M4_or_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_or_andn:
-    ID = Intrinsic::hexagon_M4_or_andn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_or_or:
-    ID = Intrinsic::hexagon_M4_or_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_or_xor:
-    ID = Intrinsic::hexagon_M4_or_xor; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_or_andix:
-    ID = Intrinsic::hexagon_S4_or_andix; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_or_andi:
-    ID = Intrinsic::hexagon_S4_or_andi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_or_ori:
-    ID = Intrinsic::hexagon_S4_or_ori; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_xor_and:
-    ID = Intrinsic::hexagon_M4_xor_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_xor_or:
-    ID = Intrinsic::hexagon_M4_xor_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M4_xor_andn:
-    ID = Intrinsic::hexagon_M4_xor_andn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_subri:
-    ID = Intrinsic::hexagon_A2_subri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_andir:
-    ID = Intrinsic::hexagon_A2_andir; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_orir:
-    ID = Intrinsic::hexagon_A2_orir; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_andp:
-    ID = Intrinsic::hexagon_A2_andp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_orp:
-    ID = Intrinsic::hexagon_A2_orp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_xorp:
-    ID = Intrinsic::hexagon_A2_xorp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_notp:
-    ID = Intrinsic::hexagon_A2_notp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_sxtw:
-    ID = Intrinsic::hexagon_A2_sxtw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_sat:
-    ID = Intrinsic::hexagon_A2_sat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_roundsat:
-    ID = Intrinsic::hexagon_A2_roundsat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_sath:
-    ID = Intrinsic::hexagon_A2_sath; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_satuh:
-    ID = Intrinsic::hexagon_A2_satuh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_satub:
-    ID = Intrinsic::hexagon_A2_satub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_satb:
-    ID = Intrinsic::hexagon_A2_satb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vaddub:
-    ID = Intrinsic::hexagon_A2_vaddub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vaddb_map:
-    ID = Intrinsic::hexagon_A2_vaddb_map; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vaddubs:
-    ID = Intrinsic::hexagon_A2_vaddubs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vaddh:
-    ID = Intrinsic::hexagon_A2_vaddh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vaddhs:
-    ID = Intrinsic::hexagon_A2_vaddhs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vadduhs:
-    ID = Intrinsic::hexagon_A2_vadduhs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A5_vaddhubs:
-    ID = Intrinsic::hexagon_A5_vaddhubs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vaddw:
-    ID = Intrinsic::hexagon_A2_vaddw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vaddws:
-    ID = Intrinsic::hexagon_A2_vaddws; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_vxaddsubw:
-    ID = Intrinsic::hexagon_S4_vxaddsubw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_vxsubaddw:
-    ID = Intrinsic::hexagon_S4_vxsubaddw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_vxaddsubh:
-    ID = Intrinsic::hexagon_S4_vxaddsubh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_vxsubaddh:
-    ID = Intrinsic::hexagon_S4_vxsubaddh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_vxaddsubhr:
-    ID = Intrinsic::hexagon_S4_vxaddsubhr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_vxsubaddhr:
-    ID = Intrinsic::hexagon_S4_vxsubaddhr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_svavgh:
-    ID = Intrinsic::hexagon_A2_svavgh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_svavghs:
-    ID = Intrinsic::hexagon_A2_svavghs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_svnavgh:
-    ID = Intrinsic::hexagon_A2_svnavgh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_svaddh:
-    ID = Intrinsic::hexagon_A2_svaddh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_svaddhs:
-    ID = Intrinsic::hexagon_A2_svaddhs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_svadduhs:
-    ID = Intrinsic::hexagon_A2_svadduhs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_svsubh:
-    ID = Intrinsic::hexagon_A2_svsubh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_svsubhs:
-    ID = Intrinsic::hexagon_A2_svsubhs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_svsubuhs:
-    ID = Intrinsic::hexagon_A2_svsubuhs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vraddub:
-    ID = Intrinsic::hexagon_A2_vraddub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vraddub_acc:
-    ID = Intrinsic::hexagon_A2_vraddub_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vraddh:
-    ID = Intrinsic::hexagon_M2_vraddh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vradduh:
-    ID = Intrinsic::hexagon_M2_vradduh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vsubub:
-    ID = Intrinsic::hexagon_A2_vsubub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vsubb_map:
-    ID = Intrinsic::hexagon_A2_vsubb_map; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vsububs:
-    ID = Intrinsic::hexagon_A2_vsububs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vsubh:
-    ID = Intrinsic::hexagon_A2_vsubh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vsubhs:
-    ID = Intrinsic::hexagon_A2_vsubhs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vsubuhs:
-    ID = Intrinsic::hexagon_A2_vsubuhs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vsubw:
-    ID = Intrinsic::hexagon_A2_vsubw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vsubws:
-    ID = Intrinsic::hexagon_A2_vsubws; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vabsh:
-    ID = Intrinsic::hexagon_A2_vabsh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vabshsat:
-    ID = Intrinsic::hexagon_A2_vabshsat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vabsw:
-    ID = Intrinsic::hexagon_A2_vabsw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vabswsat:
-    ID = Intrinsic::hexagon_A2_vabswsat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vabsdiffw:
-    ID = Intrinsic::hexagon_M2_vabsdiffw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_M2_vabsdiffh:
-    ID = Intrinsic::hexagon_M2_vabsdiffh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vrsadub:
-    ID = Intrinsic::hexagon_A2_vrsadub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vrsadub_acc:
-    ID = Intrinsic::hexagon_A2_vrsadub_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavgub:
-    ID = Intrinsic::hexagon_A2_vavgub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavguh:
-    ID = Intrinsic::hexagon_A2_vavguh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavgh:
-    ID = Intrinsic::hexagon_A2_vavgh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vnavgh:
-    ID = Intrinsic::hexagon_A2_vnavgh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavgw:
-    ID = Intrinsic::hexagon_A2_vavgw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vnavgw:
-    ID = Intrinsic::hexagon_A2_vnavgw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavgwr:
-    ID = Intrinsic::hexagon_A2_vavgwr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vnavgwr:
-    ID = Intrinsic::hexagon_A2_vnavgwr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavgwcr:
-    ID = Intrinsic::hexagon_A2_vavgwcr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vnavgwcr:
-    ID = Intrinsic::hexagon_A2_vnavgwcr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavghcr:
-    ID = Intrinsic::hexagon_A2_vavghcr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vnavghcr:
-    ID = Intrinsic::hexagon_A2_vnavghcr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavguw:
-    ID = Intrinsic::hexagon_A2_vavguw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavguwr:
-    ID = Intrinsic::hexagon_A2_vavguwr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavgubr:
-    ID = Intrinsic::hexagon_A2_vavgubr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavguhr:
-    ID = Intrinsic::hexagon_A2_vavguhr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vavghr:
-    ID = Intrinsic::hexagon_A2_vavghr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vnavghr:
-    ID = Intrinsic::hexagon_A2_vnavghr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_round_ri:
-    ID = Intrinsic::hexagon_A4_round_ri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_round_rr:
-    ID = Intrinsic::hexagon_A4_round_rr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat:
-    ID = Intrinsic::hexagon_A4_round_ri_sat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_round_rr_sat:
-    ID = Intrinsic::hexagon_A4_round_rr_sat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cround_ri:
-    ID = Intrinsic::hexagon_A4_cround_ri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_cround_rr:
-    ID = Intrinsic::hexagon_A4_cround_rr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vrminh:
-    ID = Intrinsic::hexagon_A4_vrminh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vrmaxh:
-    ID = Intrinsic::hexagon_A4_vrmaxh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vrminuh:
-    ID = Intrinsic::hexagon_A4_vrminuh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vrmaxuh:
-    ID = Intrinsic::hexagon_A4_vrmaxuh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vrminw:
-    ID = Intrinsic::hexagon_A4_vrminw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vrmaxw:
-    ID = Intrinsic::hexagon_A4_vrmaxw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vrminuw:
-    ID = Intrinsic::hexagon_A4_vrminuw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_vrmaxuw:
-    ID = Intrinsic::hexagon_A4_vrmaxuw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vminb:
-    ID = Intrinsic::hexagon_A2_vminb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vmaxb:
-    ID = Intrinsic::hexagon_A2_vmaxb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vminub:
-    ID = Intrinsic::hexagon_A2_vminub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vmaxub:
-    ID = Intrinsic::hexagon_A2_vmaxub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vminh:
-    ID = Intrinsic::hexagon_A2_vminh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vmaxh:
-    ID = Intrinsic::hexagon_A2_vmaxh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vminuh:
-    ID = Intrinsic::hexagon_A2_vminuh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vmaxuh:
-    ID = Intrinsic::hexagon_A2_vmaxuh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vminw:
-    ID = Intrinsic::hexagon_A2_vminw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vmaxw:
-    ID = Intrinsic::hexagon_A2_vmaxw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vminuw:
-    ID = Intrinsic::hexagon_A2_vminuw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_vmaxuw:
-    ID = Intrinsic::hexagon_A2_vmaxuw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_modwrapu:
-    ID = Intrinsic::hexagon_A4_modwrapu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfadd:
-    ID = Intrinsic::hexagon_F2_sfadd; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfsub:
-    ID = Intrinsic::hexagon_F2_sfsub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfmpy:
-    ID = Intrinsic::hexagon_F2_sfmpy; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sffma:
-    ID = Intrinsic::hexagon_F2_sffma; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sffma_sc:
-    ID = Intrinsic::hexagon_F2_sffma_sc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sffms:
-    ID = Intrinsic::hexagon_F2_sffms; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sffma_lib:
-    ID = Intrinsic::hexagon_F2_sffma_lib; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sffms_lib:
-    ID = Intrinsic::hexagon_F2_sffms_lib; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfcmpeq:
-    ID = Intrinsic::hexagon_F2_sfcmpeq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfcmpgt:
-    ID = Intrinsic::hexagon_F2_sfcmpgt; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfcmpge:
-    ID = Intrinsic::hexagon_F2_sfcmpge; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfcmpuo:
-    ID = Intrinsic::hexagon_F2_sfcmpuo; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfmax:
-    ID = Intrinsic::hexagon_F2_sfmax; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfmin:
-    ID = Intrinsic::hexagon_F2_sfmin; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfclass:
-    ID = Intrinsic::hexagon_F2_sfclass; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfimm_p:
-    ID = Intrinsic::hexagon_F2_sfimm_p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sfimm_n:
-    ID = Intrinsic::hexagon_F2_sfimm_n; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sffixupn:
-    ID = Intrinsic::hexagon_F2_sffixupn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sffixupd:
-    ID = Intrinsic::hexagon_F2_sffixupd; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_sffixupr:
-    ID = Intrinsic::hexagon_F2_sffixupr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfadd:
-    ID = Intrinsic::hexagon_F2_dfadd; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfsub:
-    ID = Intrinsic::hexagon_F2_dfsub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfmpy:
-    ID = Intrinsic::hexagon_F2_dfmpy; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dffma:
-    ID = Intrinsic::hexagon_F2_dffma; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dffms:
-    ID = Intrinsic::hexagon_F2_dffms; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dffma_lib:
-    ID = Intrinsic::hexagon_F2_dffma_lib; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dffms_lib:
-    ID = Intrinsic::hexagon_F2_dffms_lib; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dffma_sc:
-    ID = Intrinsic::hexagon_F2_dffma_sc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfmax:
-    ID = Intrinsic::hexagon_F2_dfmax; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfmin:
-    ID = Intrinsic::hexagon_F2_dfmin; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfcmpeq:
-    ID = Intrinsic::hexagon_F2_dfcmpeq; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfcmpgt:
-    ID = Intrinsic::hexagon_F2_dfcmpgt; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfcmpge:
-    ID = Intrinsic::hexagon_F2_dfcmpge; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfcmpuo:
-    ID = Intrinsic::hexagon_F2_dfcmpuo; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfclass:
-    ID = Intrinsic::hexagon_F2_dfclass; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfimm_p:
-    ID = Intrinsic::hexagon_F2_dfimm_p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dfimm_n:
-    ID = Intrinsic::hexagon_F2_dfimm_n; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dffixupn:
-    ID = Intrinsic::hexagon_F2_dffixupn; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dffixupd:
-    ID = Intrinsic::hexagon_F2_dffixupd; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_dffixupr:
-    ID = Intrinsic::hexagon_F2_dffixupr; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_sf2df:
-    ID = Intrinsic::hexagon_F2_conv_sf2df; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_df2sf:
-    ID = Intrinsic::hexagon_F2_conv_df2sf; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_uw2sf:
-    ID = Intrinsic::hexagon_F2_conv_uw2sf; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_uw2df:
-    ID = Intrinsic::hexagon_F2_conv_uw2df; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_w2sf:
-    ID = Intrinsic::hexagon_F2_conv_w2sf; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_w2df:
-    ID = Intrinsic::hexagon_F2_conv_w2df; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_ud2sf:
-    ID = Intrinsic::hexagon_F2_conv_ud2sf; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_ud2df:
-    ID = Intrinsic::hexagon_F2_conv_ud2df; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_d2sf:
-    ID = Intrinsic::hexagon_F2_conv_d2sf; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_d2df:
-    ID = Intrinsic::hexagon_F2_conv_d2df; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_sf2uw:
-    ID = Intrinsic::hexagon_F2_conv_sf2uw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_sf2w:
-    ID = Intrinsic::hexagon_F2_conv_sf2w; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_sf2ud:
-    ID = Intrinsic::hexagon_F2_conv_sf2ud; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_sf2d:
-    ID = Intrinsic::hexagon_F2_conv_sf2d; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_df2uw:
-    ID = Intrinsic::hexagon_F2_conv_df2uw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_df2w:
-    ID = Intrinsic::hexagon_F2_conv_df2w; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_df2ud:
-    ID = Intrinsic::hexagon_F2_conv_df2ud; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_df2d:
-    ID = Intrinsic::hexagon_F2_conv_df2d; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_sf2uw_chop:
-    ID = Intrinsic::hexagon_F2_conv_sf2uw_chop; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_sf2w_chop:
-    ID = Intrinsic::hexagon_F2_conv_sf2w_chop; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_sf2ud_chop:
-    ID = Intrinsic::hexagon_F2_conv_sf2ud_chop; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_sf2d_chop:
-    ID = Intrinsic::hexagon_F2_conv_sf2d_chop; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_df2uw_chop:
-    ID = Intrinsic::hexagon_F2_conv_df2uw_chop; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_df2w_chop:
-    ID = Intrinsic::hexagon_F2_conv_df2w_chop; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_df2ud_chop:
-    ID = Intrinsic::hexagon_F2_conv_df2ud_chop; break;
-
-  case Hexagon::BI__builtin_HEXAGON_F2_conv_df2d_chop:
-    ID = Intrinsic::hexagon_F2_conv_df2d_chop; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r:
-    ID = Intrinsic::hexagon_S2_asr_r_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r:
-    ID = Intrinsic::hexagon_S2_asl_r_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_r:
-    ID = Intrinsic::hexagon_S2_lsr_r_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_r:
-    ID = Intrinsic::hexagon_S2_lsl_r_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p:
-    ID = Intrinsic::hexagon_S2_asr_r_p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p:
-    ID = Intrinsic::hexagon_S2_asl_r_p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p:
-    ID = Intrinsic::hexagon_S2_lsr_r_p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p:
-    ID = Intrinsic::hexagon_S2_lsl_r_p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r_acc:
-    ID = Intrinsic::hexagon_S2_asr_r_r_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r_acc:
-    ID = Intrinsic::hexagon_S2_asl_r_r_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_r_acc:
-    ID = Intrinsic::hexagon_S2_lsr_r_r_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_r_acc:
-    ID = Intrinsic::hexagon_S2_lsl_r_r_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p_acc:
-    ID = Intrinsic::hexagon_S2_asr_r_p_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p_acc:
-    ID = Intrinsic::hexagon_S2_asl_r_p_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p_acc:
-    ID = Intrinsic::hexagon_S2_lsr_r_p_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p_acc:
-    ID = Intrinsic::hexagon_S2_lsl_r_p_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r_nac:
-    ID = Intrinsic::hexagon_S2_asr_r_r_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r_nac:
-    ID = Intrinsic::hexagon_S2_asl_r_r_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_r_nac:
-    ID = Intrinsic::hexagon_S2_lsr_r_r_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_r_nac:
-    ID = Intrinsic::hexagon_S2_lsl_r_r_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p_nac:
-    ID = Intrinsic::hexagon_S2_asr_r_p_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p_nac:
-    ID = Intrinsic::hexagon_S2_asl_r_p_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p_nac:
-    ID = Intrinsic::hexagon_S2_lsr_r_p_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p_nac:
-    ID = Intrinsic::hexagon_S2_lsl_r_p_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r_and:
-    ID = Intrinsic::hexagon_S2_asr_r_r_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r_and:
-    ID = Intrinsic::hexagon_S2_asl_r_r_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_r_and:
-    ID = Intrinsic::hexagon_S2_lsr_r_r_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_r_and:
-    ID = Intrinsic::hexagon_S2_lsl_r_r_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r_or:
-    ID = Intrinsic::hexagon_S2_asr_r_r_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r_or:
-    ID = Intrinsic::hexagon_S2_asl_r_r_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_r_or:
-    ID = Intrinsic::hexagon_S2_lsr_r_r_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_r_or:
-    ID = Intrinsic::hexagon_S2_lsl_r_r_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p_and:
-    ID = Intrinsic::hexagon_S2_asr_r_p_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p_and:
-    ID = Intrinsic::hexagon_S2_asl_r_p_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p_and:
-    ID = Intrinsic::hexagon_S2_lsr_r_p_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p_and:
-    ID = Intrinsic::hexagon_S2_lsl_r_p_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p_or:
-    ID = Intrinsic::hexagon_S2_asr_r_p_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p_or:
-    ID = Intrinsic::hexagon_S2_asl_r_p_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p_or:
-    ID = Intrinsic::hexagon_S2_lsr_r_p_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p_or:
-    ID = Intrinsic::hexagon_S2_lsl_r_p_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p_xor:
-    ID = Intrinsic::hexagon_S2_asr_r_p_xor; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p_xor:
-    ID = Intrinsic::hexagon_S2_asl_r_p_xor; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p_xor:
-    ID = Intrinsic::hexagon_S2_lsr_r_p_xor; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p_xor:
-    ID = Intrinsic::hexagon_S2_lsl_r_p_xor; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r_sat:
-    ID = Intrinsic::hexagon_S2_asr_r_r_sat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r_sat:
-    ID = Intrinsic::hexagon_S2_asl_r_r_sat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r:
-    ID = Intrinsic::hexagon_S2_asr_i_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r:
-    ID = Intrinsic::hexagon_S2_lsr_i_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r:
-    ID = Intrinsic::hexagon_S2_asl_i_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p:
-    ID = Intrinsic::hexagon_S2_asr_i_p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p:
-    ID = Intrinsic::hexagon_S2_lsr_i_p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p:
-    ID = Intrinsic::hexagon_S2_asl_i_p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc:
-    ID = Intrinsic::hexagon_S2_asr_i_r_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc:
-    ID = Intrinsic::hexagon_S2_lsr_i_r_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc:
-    ID = Intrinsic::hexagon_S2_asl_i_r_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc:
-    ID = Intrinsic::hexagon_S2_asr_i_p_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc:
-    ID = Intrinsic::hexagon_S2_lsr_i_p_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc:
-    ID = Intrinsic::hexagon_S2_asl_i_p_acc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac:
-    ID = Intrinsic::hexagon_S2_asr_i_r_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac:
-    ID = Intrinsic::hexagon_S2_lsr_i_r_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac:
-    ID = Intrinsic::hexagon_S2_asl_i_r_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac:
-    ID = Intrinsic::hexagon_S2_asr_i_p_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac:
-    ID = Intrinsic::hexagon_S2_lsr_i_p_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac:
-    ID = Intrinsic::hexagon_S2_asl_i_p_nac; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc:
-    ID = Intrinsic::hexagon_S2_lsr_i_r_xacc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc:
-    ID = Intrinsic::hexagon_S2_asl_i_r_xacc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc:
-    ID = Intrinsic::hexagon_S2_lsr_i_p_xacc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc:
-    ID = Intrinsic::hexagon_S2_asl_i_p_xacc; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and:
-    ID = Intrinsic::hexagon_S2_asr_i_r_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and:
-    ID = Intrinsic::hexagon_S2_lsr_i_r_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and:
-    ID = Intrinsic::hexagon_S2_asl_i_r_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or:
-    ID = Intrinsic::hexagon_S2_asr_i_r_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or:
-    ID = Intrinsic::hexagon_S2_lsr_i_r_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or:
-    ID = Intrinsic::hexagon_S2_asl_i_r_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and:
-    ID = Intrinsic::hexagon_S2_asr_i_p_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and:
-    ID = Intrinsic::hexagon_S2_lsr_i_p_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and:
-    ID = Intrinsic::hexagon_S2_asl_i_p_and; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or:
-    ID = Intrinsic::hexagon_S2_asr_i_p_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or:
-    ID = Intrinsic::hexagon_S2_lsr_i_p_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or:
-    ID = Intrinsic::hexagon_S2_asl_i_p_or; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat:
-    ID = Intrinsic::hexagon_S2_asl_i_r_sat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd:
-    ID = Intrinsic::hexagon_S2_asr_i_r_rnd; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax:
-    ID = Intrinsic::hexagon_S2_asr_i_r_rnd_goodsyntax; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd:
-    ID = Intrinsic::hexagon_S2_asr_i_p_rnd; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax:
-    ID = Intrinsic::hexagon_S2_asr_i_p_rnd_goodsyntax; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_lsli:
-    ID = Intrinsic::hexagon_S4_lsli; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri:
-    ID = Intrinsic::hexagon_S2_addasl_rrri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri:
-    ID = Intrinsic::hexagon_S4_andi_asl_ri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri:
-    ID = Intrinsic::hexagon_S4_ori_asl_ri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri:
-    ID = Intrinsic::hexagon_S4_addi_asl_ri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri:
-    ID = Intrinsic::hexagon_S4_subi_asl_ri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri:
-    ID = Intrinsic::hexagon_S4_andi_lsr_ri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri:
-    ID = Intrinsic::hexagon_S4_ori_lsr_ri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri:
-    ID = Intrinsic::hexagon_S4_addi_lsr_ri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri:
-    ID = Intrinsic::hexagon_S4_subi_lsr_ri; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_valignib:
-    ID = Intrinsic::hexagon_S2_valignib; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_valignrb:
-    ID = Intrinsic::hexagon_S2_valignrb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vspliceib:
-    ID = Intrinsic::hexagon_S2_vspliceib; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsplicerb:
-    ID = Intrinsic::hexagon_S2_vsplicerb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsplatrh:
-    ID = Intrinsic::hexagon_S2_vsplatrh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsplatrb:
-    ID = Intrinsic::hexagon_S2_vsplatrb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_insert:
-    ID = Intrinsic::hexagon_S2_insert; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax:
-    ID = Intrinsic::hexagon_S2_tableidxb_goodsyntax; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax:
-    ID = Intrinsic::hexagon_S2_tableidxh_goodsyntax; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax:
-    ID = Intrinsic::hexagon_S2_tableidxw_goodsyntax; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax:
-    ID = Intrinsic::hexagon_S2_tableidxd_goodsyntax; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_bitspliti:
-    ID = Intrinsic::hexagon_A4_bitspliti; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A4_bitsplit:
-    ID = Intrinsic::hexagon_A4_bitsplit; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_extract:
-    ID = Intrinsic::hexagon_S4_extract; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_extractu:
-    ID = Intrinsic::hexagon_S2_extractu; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_insertp:
-    ID = Intrinsic::hexagon_S2_insertp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_extractp:
-    ID = Intrinsic::hexagon_S4_extractp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_extractup:
-    ID = Intrinsic::hexagon_S2_extractup; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_insert_rp:
-    ID = Intrinsic::hexagon_S2_insert_rp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_extract_rp:
-    ID = Intrinsic::hexagon_S4_extract_rp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_extractu_rp:
-    ID = Intrinsic::hexagon_S2_extractu_rp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_insertp_rp:
-    ID = Intrinsic::hexagon_S2_insertp_rp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_extractp_rp:
-    ID = Intrinsic::hexagon_S4_extractp_rp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_extractup_rp:
-    ID = Intrinsic::hexagon_S2_extractup_rp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_tstbit_i:
-    ID = Intrinsic::hexagon_S2_tstbit_i; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i:
-    ID = Intrinsic::hexagon_S4_ntstbit_i; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_setbit_i:
-    ID = Intrinsic::hexagon_S2_setbit_i; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_togglebit_i:
-    ID = Intrinsic::hexagon_S2_togglebit_i; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_clrbit_i:
-    ID = Intrinsic::hexagon_S2_clrbit_i; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_tstbit_r:
-    ID = Intrinsic::hexagon_S2_tstbit_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_ntstbit_r:
-    ID = Intrinsic::hexagon_S4_ntstbit_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_setbit_r:
-    ID = Intrinsic::hexagon_S2_setbit_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_togglebit_r:
-    ID = Intrinsic::hexagon_S2_togglebit_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_clrbit_r:
-    ID = Intrinsic::hexagon_S2_clrbit_r; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh:
-    ID = Intrinsic::hexagon_S2_asr_i_vh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh:
-    ID = Intrinsic::hexagon_S2_lsr_i_vh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh:
-    ID = Intrinsic::hexagon_S2_asl_i_vh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_vh:
-    ID = Intrinsic::hexagon_S2_asr_r_vh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax:
-    ID = Intrinsic::hexagon_S5_asrhub_rnd_sat_goodsyntax; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat:
-    ID = Intrinsic::hexagon_S5_asrhub_sat; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax:
-    ID = Intrinsic::hexagon_S5_vasrhrnd_goodsyntax; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_vh:
-    ID = Intrinsic::hexagon_S2_asl_r_vh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_vh:
-    ID = Intrinsic::hexagon_S2_lsr_r_vh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_vh:
-    ID = Intrinsic::hexagon_S2_lsl_r_vh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw:
-    ID = Intrinsic::hexagon_S2_asr_i_vw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun:
-    ID = Intrinsic::hexagon_S2_asr_i_svw_trun; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_svw_trun:
-    ID = Intrinsic::hexagon_S2_asr_r_svw_trun; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw:
-    ID = Intrinsic::hexagon_S2_lsr_i_vw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw:
-    ID = Intrinsic::hexagon_S2_asl_i_vw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asr_r_vw:
-    ID = Intrinsic::hexagon_S2_asr_r_vw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_asl_r_vw:
-    ID = Intrinsic::hexagon_S2_asl_r_vw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_vw:
-    ID = Intrinsic::hexagon_S2_lsr_r_vw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_vw:
-    ID = Intrinsic::hexagon_S2_lsl_r_vw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vrndpackwh:
-    ID = Intrinsic::hexagon_S2_vrndpackwh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vrndpackwhs:
-    ID = Intrinsic::hexagon_S2_vrndpackwhs; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsxtbh:
-    ID = Intrinsic::hexagon_S2_vsxtbh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vzxtbh:
-    ID = Intrinsic::hexagon_S2_vzxtbh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsathub:
-    ID = Intrinsic::hexagon_S2_vsathub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_svsathub:
-    ID = Intrinsic::hexagon_S2_svsathub; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_svsathb:
-    ID = Intrinsic::hexagon_S2_svsathb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsathb:
-    ID = Intrinsic::hexagon_S2_vsathb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vtrunohb:
-    ID = Intrinsic::hexagon_S2_vtrunohb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vtrunewh:
-    ID = Intrinsic::hexagon_S2_vtrunewh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vtrunowh:
-    ID = Intrinsic::hexagon_S2_vtrunowh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vtrunehb:
-    ID = Intrinsic::hexagon_S2_vtrunehb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsxthw:
-    ID = Intrinsic::hexagon_S2_vsxthw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vzxthw:
-    ID = Intrinsic::hexagon_S2_vzxthw; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsatwh:
-    ID = Intrinsic::hexagon_S2_vsatwh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsatwuh:
-    ID = Intrinsic::hexagon_S2_vsatwuh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_packhl:
-    ID = Intrinsic::hexagon_S2_packhl; break;
-
-  case Hexagon::BI__builtin_HEXAGON_A2_swiz:
-    ID = Intrinsic::hexagon_A2_swiz; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsathub_nopack:
-    ID = Intrinsic::hexagon_S2_vsathub_nopack; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsathb_nopack:
-    ID = Intrinsic::hexagon_S2_vsathb_nopack; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsatwh_nopack:
-    ID = Intrinsic::hexagon_S2_vsatwh_nopack; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_vsatwuh_nopack:
-    ID = Intrinsic::hexagon_S2_vsatwuh_nopack; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_shuffob:
-    ID = Intrinsic::hexagon_S2_shuffob; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_shuffeb:
-    ID = Intrinsic::hexagon_S2_shuffeb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_shuffoh:
-    ID = Intrinsic::hexagon_S2_shuffoh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_shuffeh:
-    ID = Intrinsic::hexagon_S2_shuffeh; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S5_popcountp:
-    ID = Intrinsic::hexagon_S5_popcountp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_parity:
-    ID = Intrinsic::hexagon_S4_parity; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_parityp:
-    ID = Intrinsic::hexagon_S2_parityp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_lfsp:
-    ID = Intrinsic::hexagon_S2_lfsp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_clbnorm:
-    ID = Intrinsic::hexagon_S2_clbnorm; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_clbaddi:
-    ID = Intrinsic::hexagon_S4_clbaddi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_clbpnorm:
-    ID = Intrinsic::hexagon_S4_clbpnorm; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S4_clbpaddi:
-    ID = Intrinsic::hexagon_S4_clbpaddi; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_clb:
-    ID = Intrinsic::hexagon_S2_clb; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_cl0:
-    ID = Intrinsic::hexagon_S2_cl0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_cl1:
-    ID = Intrinsic::hexagon_S2_cl1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_clbp:
-    ID = Intrinsic::hexagon_S2_clbp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_cl0p:
-    ID = Intrinsic::hexagon_S2_cl0p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_cl1p:
-    ID = Intrinsic::hexagon_S2_cl1p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_brev:
-    ID = Intrinsic::hexagon_S2_brev; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_brevp:
-    ID = Intrinsic::hexagon_S2_brevp; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_ct0:
-    ID = Intrinsic::hexagon_S2_ct0; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_ct1:
-    ID = Intrinsic::hexagon_S2_ct1; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_ct0p:
-    ID = Intrinsic::hexagon_S2_ct0p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_ct1p:
-    ID = Intrinsic::hexagon_S2_ct1p; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_interleave:
-    ID = Intrinsic::hexagon_S2_interleave; break;
-
-  case Hexagon::BI__builtin_HEXAGON_S2_deinterleave:
-    ID = Intrinsic::hexagon_S2_deinterleave; break;
-  }
-
-  llvm::Function *F = CGM.getIntrinsic(ID);
-  return Builder.CreateCall(F, Ops, "");
-}
-
 Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
                                            const CallExpr *E) {
   SmallVector<Value*, 4> Ops;

Modified: cfe/branches/tooling/lib/CodeGen/CGCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGCXXABI.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGCXXABI.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGCXXABI.cpp Sat Jun 30 16:45:28 2012
@@ -23,7 +23,7 @@
                                 StringRef S) {
   DiagnosticsEngine &Diags = CGF.CGM.getDiags();
   unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
-                                          "cannot yet compile %1 in this ABI");
+                                          "cannot yet compile %0 in this ABI");
   Diags.Report(CGF.getContext().getFullLoc(CGF.CurCodeDecl->getLocation()),
                DiagID)
     << S;

Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp Sat Jun 30 16:45:28 2012
@@ -764,7 +764,7 @@
   const ASTRecordLayout &layout = CGM.getContext().getASTRecordLayout(record);
   const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(record);
 
-  // For C++11 Lambdas a Fields will be the same as a Capture, but the Capture
+  // For C++11 Lambdas a Field will be the same as a Capture, but the Capture
   // has the name and the location of the variable so we should iterate over
   // both concurrently.
   if (CXXDecl && CXXDecl->isLambda()) {

Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h Sat Jun 30 16:45:28 2012
@@ -17,9 +17,9 @@
 #include "clang/AST/Type.h"
 #include "clang/AST/Expr.h"
 #include "clang/Basic/SourceLocation.h"
+#include "llvm/DebugInfo.h"
+#include "llvm/DIBuilder.h"
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/Analysis/DebugInfo.h"
-#include "llvm/Analysis/DIBuilder.h"
 #include "llvm/Support/ValueHandle.h"
 #include "llvm/Support/Allocator.h"
 

Modified: cfe/branches/tooling/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDecl.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDecl.cpp Sat Jun 30 16:45:28 2012
@@ -183,26 +183,20 @@
   else
     Name = GetStaticDeclName(*this, D, Separator);
 
-  llvm::GlobalVariable::ThreadLocalMode TLM;
-  TLM = D.isThreadSpecified() ? llvm::GlobalVariable::GeneralDynamicTLSModel
-                              : llvm::GlobalVariable::NotThreadLocal;
-
-  // Set the TLS mode if it it's explicitly specified.
-  if (D.hasAttr<TLSModelAttr>()) {
-    assert(D.isThreadSpecified() && "Can't have TLS model on non-tls var.");
-    const TLSModelAttr *Attr = D.getAttr<TLSModelAttr>();
-    TLM = CodeGenModule::GetLLVMTLSModel(Attr->getModel());
-  }
-
   llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty);
   llvm::GlobalVariable *GV =
     new llvm::GlobalVariable(CGM.getModule(), LTy,
                              Ty.isConstant(getContext()), Linkage,
-                             CGM.EmitNullConstant(D.getType()), Name, 0, TLM,
+                             CGM.EmitNullConstant(D.getType()), Name, 0,
+                             llvm::GlobalVariable::NotThreadLocal,
                              CGM.getContext().getTargetAddressSpace(Ty));
   GV->setAlignment(getContext().getDeclAlign(&D).getQuantity());
   if (Linkage != llvm::GlobalValue::InternalLinkage)
     GV->setVisibility(CurFn->getVisibility());
+
+  if (D.isThreadSpecified())
+    CGM.setTLSMode(GV, D);
+
   return GV;
 }
 

Modified: cfe/branches/tooling/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDeclCXX.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDeclCXX.cpp Sat Jun 30 16:45:28 2012
@@ -228,6 +228,9 @@
   if (!CGM.getLangOpts().Exceptions)
     Fn->setDoesNotThrow();
 
+  if (CGM.getLangOpts().AddressSanitizer)
+    Fn->addFnAttr(llvm::Attribute::AddressSafety);
+
   return Fn;
 }
 

Modified: cfe/branches/tooling/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExpr.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExpr.cpp Sat Jun 30 16:45:28 2012
@@ -1047,6 +1047,9 @@
   llvm::Value *Res = 0;
   for (unsigned i = 0, e = Info.getNumComponents(); i != e; ++i) {
     const CGBitFieldInfo::AccessInfo &AI = Info.getComponent(i);
+    CharUnits AccessAlignment = AI.AccessAlignment;
+    if (!LV.getAlignment().isZero())
+      AccessAlignment = std::min(AccessAlignment, LV.getAlignment());
 
     // Get the field pointer.
     llvm::Value *Ptr = LV.getBitFieldBaseAddr();
@@ -1070,8 +1073,7 @@
 
     // Perform the load.
     llvm::LoadInst *Load = Builder.CreateLoad(Ptr, LV.isVolatileQualified());
-    if (!AI.AccessAlignment.isZero())
-      Load->setAlignment(AI.AccessAlignment.getQuantity());
+    Load->setAlignment(AccessAlignment.getQuantity());
 
     // Shift out unused low bits and mask out unused high bits.
     llvm::Value *Val = Load;
@@ -1270,6 +1272,9 @@
   // Iterate over the components, writing each piece to memory.
   for (unsigned i = 0, e = Info.getNumComponents(); i != e; ++i) {
     const CGBitFieldInfo::AccessInfo &AI = Info.getComponent(i);
+    CharUnits AccessAlignment = AI.AccessAlignment;
+    if (!Dst.getAlignment().isZero())
+      AccessAlignment = std::min(AccessAlignment, Dst.getAlignment());
 
     // Get the field pointer.
     llvm::Value *Ptr = Dst.getBitFieldBaseAddr();
@@ -1316,8 +1321,7 @@
     // If necessary, load and OR in bits that are outside of the bit-field.
     if (AI.TargetBitWidth != AI.AccessWidth) {
       llvm::LoadInst *Load = Builder.CreateLoad(Ptr, Dst.isVolatileQualified());
-      if (!AI.AccessAlignment.isZero())
-        Load->setAlignment(AI.AccessAlignment.getQuantity());
+      Load->setAlignment(AccessAlignment.getQuantity());
 
       // Compute the mask for zeroing the bits that are part of the bit-field.
       llvm::APInt InvMask =
@@ -1331,8 +1335,7 @@
     // Write the value.
     llvm::StoreInst *Store = Builder.CreateStore(Val, Ptr,
                                                  Dst.isVolatileQualified());
-    if (!AI.AccessAlignment.isZero())
-      Store->setAlignment(AI.AccessAlignment.getQuantity());
+    Store->setAlignment(AccessAlignment.getQuantity());
   }
 }
 
@@ -2084,16 +2087,6 @@
   llvm_unreachable("Unhandled member declaration!");
 }
 
-LValue CodeGenFunction::EmitLValueForBitfield(llvm::Value *BaseValue,
-                                              const FieldDecl *Field,
-                                              unsigned CVRQualifiers) {
-  const CGRecordLayout &RL =
-    CGM.getTypes().getCGRecordLayout(Field->getParent());
-  const CGBitFieldInfo &Info = RL.getBitFieldInfo(Field);
-  return LValue::MakeBitfield(BaseValue, Info,
-                          Field->getType().withCVRQualifiers(CVRQualifiers));
-}
-
 /// EmitLValueForAnonRecordField - Given that the field is a member of
 /// an anonymous struct or union buried inside a record, and given
 /// that the base value is a pointer to the enclosing record, derive
@@ -2118,9 +2111,15 @@
 
 LValue CodeGenFunction::EmitLValueForField(LValue base,
                                            const FieldDecl *field) {
-  if (field->isBitField())
-    return EmitLValueForBitfield(base.getAddress(), field,
-                                 base.getVRQualifiers());
+  if (field->isBitField()) {
+    const CGRecordLayout &RL =
+      CGM.getTypes().getCGRecordLayout(field->getParent());
+    const CGBitFieldInfo &Info = RL.getBitFieldInfo(field);
+    QualType fieldType =
+      field->getType().withCVRQualifiers(base.getVRQualifiers());
+    return LValue::MakeBitfield(base.getAddress(), Info, fieldType,
+                                base.getAlignment());
+  }
 
   const RecordDecl *rec = field->getParent();
   QualType type = field->getType();

Modified: cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp Sat Jun 30 16:45:28 2012
@@ -56,30 +56,6 @@
                   Callee, ReturnValue, Args, MD);
 }
 
-static const CXXRecordDecl *getMostDerivedClassDecl(const Expr *Base) {
-  const Expr *E = Base;
-  
-  while (true) {
-    E = E->IgnoreParens();
-    if (const CastExpr *CE = dyn_cast<CastExpr>(E)) {
-      if (CE->getCastKind() == CK_DerivedToBase || 
-          CE->getCastKind() == CK_UncheckedDerivedToBase ||
-          CE->getCastKind() == CK_NoOp) {
-        E = CE->getSubExpr();
-        continue;
-      }
-    }
-
-    break;
-  }
-
-  QualType DerivedType = E->getType();
-  if (const PointerType *PTy = DerivedType->getAs<PointerType>())
-    DerivedType = PTy->getPointeeType();
-
-  return cast<CXXRecordDecl>(DerivedType->castAs<RecordType>()->getDecl());
-}
-
 // FIXME: Ideally Expr::IgnoreParenNoopCasts should do this, but it doesn't do
 // quite what we want.
 static const Expr *skipNoOpCastsAndParens(const Expr *E) {
@@ -126,7 +102,7 @@
   //   b->f();
   // }
   //
-  const CXXRecordDecl *MostDerivedClassDecl = getMostDerivedClassDecl(Base);
+  const CXXRecordDecl *MostDerivedClassDecl = Base->getBestDynamicClassType();
   if (MostDerivedClassDecl->hasAttr<FinalAttr>())
     return true;
 
@@ -166,6 +142,14 @@
   return false;
 }
 
+static CXXRecordDecl *getCXXRecord(const Expr *E) {
+  QualType T = E->getType();
+  if (const PointerType *PTy = T->getAs<PointerType>())
+    T = PTy->getPointeeType();
+  const RecordType *Ty = T->castAs<RecordType>();
+  return cast<CXXRecordDecl>(Ty->getDecl());
+}
+
 // Note: This function also emit constructor calls to support a MSVC
 // extensions allowing explicit constructor function call.
 RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE,
@@ -196,11 +180,45 @@
   }
 
   // Compute the object pointer.
+  const Expr *Base = ME->getBase();
+  bool CanUseVirtualCall = MD->isVirtual() && !ME->hasQualifier();
+
+  const CXXMethodDecl *DevirtualizedMethod = NULL;
+  if (CanUseVirtualCall &&
+      canDevirtualizeMemberFunctionCalls(getContext(), Base, MD)) {
+    const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType();
+    DevirtualizedMethod = MD->getCorrespondingMethodInClass(BestDynamicDecl);
+    assert(DevirtualizedMethod);
+    const CXXRecordDecl *DevirtualizedClass = DevirtualizedMethod->getParent();
+    const Expr *Inner = Base->ignoreParenBaseCasts();
+    if (getCXXRecord(Inner) == DevirtualizedClass)
+      // If the class of the Inner expression is where the dynamic method
+      // is defined, build the this pointer from it.
+      Base = Inner;
+    else if (getCXXRecord(Base) != DevirtualizedClass) {
+      // If the method is defined in a class that is not the best dynamic
+      // one or the one of the full expression, we would have to build
+      // a derived-to-base cast to compute the correct this pointer, but
+      // we don't have support for that yet, so do a virtual call.
+      DevirtualizedMethod = NULL;
+    }
+    // If the return types are not the same, this might be a case where more
+    // code needs to run to compensate for it. For example, the derived
+    // method might return a type that inherits form from the return
+    // type of MD and has a prefix.
+    // For now we just avoid devirtualizing these covariant cases.
+    if (DevirtualizedMethod &&
+        DevirtualizedMethod->getResultType().getCanonicalType() !=
+        MD->getResultType().getCanonicalType())
+      DevirtualizedMethod = NULL;
+  }
+
   llvm::Value *This;
   if (ME->isArrow())
-    This = EmitScalarExpr(ME->getBase());
+    This = EmitScalarExpr(Base);
   else
-    This = EmitLValue(ME->getBase()).getAddress();
+    This = EmitLValue(Base).getAddress();
+
 
   if (MD->isTrivial()) {
     if (isa<CXXDestructorDecl>(MD)) return RValue::get(0);
@@ -247,10 +265,8 @@
   //
   // We also don't emit a virtual call if the base expression has a record type
   // because then we know what the type is.
-  bool UseVirtualCall;
-  UseVirtualCall = MD->isVirtual() && !ME->hasQualifier()
-                   && !canDevirtualizeMemberFunctionCalls(getContext(),
-                                                          ME->getBase(), MD);
+  bool UseVirtualCall = CanUseVirtualCall && !DevirtualizedMethod;
+
   llvm::Value *Callee;
   if (const CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(MD)) {
     if (UseVirtualCall) {
@@ -260,8 +276,13 @@
           MD->isVirtual() &&
           ME->hasQualifier())
         Callee = BuildAppleKextVirtualCall(MD, ME->getQualifier(), Ty);
-      else
+      else if (!DevirtualizedMethod)
         Callee = CGM.GetAddrOfFunction(GlobalDecl(Dtor, Dtor_Complete), Ty);
+      else {
+        const CXXDestructorDecl *DDtor =
+          cast<CXXDestructorDecl>(DevirtualizedMethod);
+        Callee = CGM.GetAddrOfFunction(GlobalDecl(DDtor, Dtor_Complete), Ty);
+      }
     }
   } else if (const CXXConstructorDecl *Ctor =
                dyn_cast<CXXConstructorDecl>(MD)) {
@@ -273,8 +294,11 @@
         MD->isVirtual() &&
         ME->hasQualifier())
       Callee = BuildAppleKextVirtualCall(MD, ME->getQualifier(), Ty);
-    else 
+    else if (!DevirtualizedMethod)
       Callee = CGM.GetAddrOfFunction(MD, Ty);
+    else {
+      Callee = CGM.GetAddrOfFunction(DevirtualizedMethod, Ty);
+    }
   }
 
   return EmitCXXMemberCall(MD, Callee, ReturnValue, This, /*VTT=*/0,

Modified: cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.cpp Sat Jun 30 16:45:28 2012
@@ -120,6 +120,8 @@
   uint64_t ContainingTypeAlign = CGF.CGM.getContext().getTargetInfo().getCharAlign();
   uint64_t ContainingTypeSize = TypeSizeInBits - (FieldBitOffset - BitOffset);
   uint64_t BitFieldSize = Ivar->getBitWidthValue(CGF.getContext());
+  CharUnits ContainingTypeAlignCharUnits = 
+    CGF.CGM.getContext().toCharUnitsFromBits(ContainingTypeAlign);
 
   // Allocate a new CGBitFieldInfo object to describe this access.
   //
@@ -132,7 +134,8 @@
                              ContainingTypeSize, ContainingTypeAlign));
 
   return LValue::MakeBitfield(V, *Info,
-                              IvarTy.withCVRQualifiers(CVRQualifiers));
+                              IvarTy.withCVRQualifiers(CVRQualifiers),
+                              ContainingTypeAlignCharUnits);
 }
 
 namespace {

Modified: cfe/branches/tooling/lib/CodeGen/CGRecordLayout.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGRecordLayout.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGRecordLayout.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CGRecordLayout.h Sat Jun 30 16:45:28 2012
@@ -64,12 +64,7 @@
     /// Bit width of the memory access to perform.
     unsigned AccessWidth;
 
-    /// The alignment of the memory access, or 0 if the default alignment should
-    /// be used.
-    //
-    // FIXME: Remove use of 0 to encode default, instead have IRgen do the right
-    // thing when it generates the code, if avoiding align directives is
-    // desired.
+    /// The alignment of the memory access, assuming the parent is aligned.
     CharUnits AccessAlignment;
 
     /// Offset for the target value.

Modified: cfe/branches/tooling/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGRecordLayoutBuilder.cpp Sat Jun 30 16:45:28 2012
@@ -235,6 +235,8 @@
                                uint64_t FieldSize,
                                uint64_t ContainingTypeSizeInBits,
                                unsigned ContainingTypeAlign) {
+  assert(ContainingTypeAlign && "Expected alignment to be specified");
+
   llvm::Type *Ty = Types.ConvertTypeForMem(FD->getType());
   CharUnits TypeSizeInBytes =
     CharUnits::fromQuantity(Types.getTargetData().getTypeAllocSize(Ty));

Modified: cfe/branches/tooling/lib/CodeGen/CGValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGValue.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGValue.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CGValue.h Sat Jun 30 16:45:28 2012
@@ -153,7 +153,7 @@
 
 private:
   void Initialize(QualType Type, Qualifiers Quals,
-                  CharUnits Alignment = CharUnits(),
+                  CharUnits Alignment,
                   llvm::MDNode *TBAAInfo = 0) {
     this->Type = Type;
     this->Quals = Quals;
@@ -295,12 +295,12 @@
   /// access.
   static LValue MakeBitfield(llvm::Value *BaseValue,
                              const CGBitFieldInfo &Info,
-                             QualType type) {
+                             QualType type, CharUnits Alignment) {
     LValue R;
     R.LVType = BitField;
     R.V = BaseValue;
     R.BitFieldInfo = &Info;
-    R.Initialize(type, type.getQualifiers());
+    R.Initialize(type, type.getQualifiers(), Alignment);
     return R;
   }
 

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenFunction.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenFunction.cpp Sat Jun 30 16:45:28 2012
@@ -28,7 +28,7 @@
 using namespace clang;
 using namespace CodeGen;
 
-CodeGenFunction::CodeGenFunction(CodeGenModule &cgm)
+CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)
   : CodeGenTypeCache(cgm), CGM(cgm),
     Target(CGM.getContext().getTargetInfo()),
     Builder(cgm.getModule().getContext()),
@@ -42,7 +42,8 @@
     TerminateHandler(0), TrapBB(0) {
 
   CatchUndefined = getContext().getLangOpts().CatchUndefined;
-  CGM.getCXXABI().getMangleContext().startNewFunction();
+  if (!suppressNewContext)
+    CGM.getCXXABI().getMangleContext().startNewFunction();
 }
 
 CodeGenFunction::~CodeGenFunction() {

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h Sat Jun 30 16:45:28 2012
@@ -1198,7 +1198,7 @@
   llvm::BasicBlock *TrapBB;
 
 public:
-  CodeGenFunction(CodeGenModule &cgm);
+  CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext=false);
   ~CodeGenFunction();
 
   CodeGenTypes &getTypes() const { return CGM.getTypes(); }
@@ -2166,9 +2166,6 @@
                            llvm::Value* Base, const ObjCIvarDecl *Ivar,
                            unsigned CVRQualifiers);
 
-  LValue EmitLValueForBitfield(llvm::Value* Base, const FieldDecl* Field,
-                                unsigned CVRQualifiers);
-
   LValue EmitCXXConstructLValue(const CXXConstructExpr *E);
   LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E);
   LValue EmitLambdaLValue(const LambdaExpr *E);
@@ -2267,7 +2264,6 @@
 
   llvm::Value *BuildVector(ArrayRef<llvm::Value*> Ops);
   llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
-  llvm::Value *EmitHexagonBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
   llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
 
   llvm::Value *EmitObjCProtocolExpr(const ObjCProtocolExpr *E);

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp Sat Jun 30 16:45:28 2012
@@ -258,6 +258,45 @@
     GV->setVisibility(GetLLVMVisibility(LV.visibility()));
 }
 
+static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel(StringRef S) {
+  return llvm::StringSwitch<llvm::GlobalVariable::ThreadLocalMode>(S)
+      .Case("global-dynamic", llvm::GlobalVariable::GeneralDynamicTLSModel)
+      .Case("local-dynamic", llvm::GlobalVariable::LocalDynamicTLSModel)
+      .Case("initial-exec", llvm::GlobalVariable::InitialExecTLSModel)
+      .Case("local-exec", llvm::GlobalVariable::LocalExecTLSModel);
+}
+
+static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel(
+    CodeGenOptions::TLSModel M) {
+  switch (M) {
+  case CodeGenOptions::GeneralDynamicTLSModel:
+    return llvm::GlobalVariable::GeneralDynamicTLSModel;
+  case CodeGenOptions::LocalDynamicTLSModel:
+    return llvm::GlobalVariable::LocalDynamicTLSModel;
+  case CodeGenOptions::InitialExecTLSModel:
+    return llvm::GlobalVariable::InitialExecTLSModel;
+  case CodeGenOptions::LocalExecTLSModel:
+    return llvm::GlobalVariable::LocalExecTLSModel;
+  }
+  llvm_unreachable("Invalid TLS model!");
+}
+
+void CodeGenModule::setTLSMode(llvm::GlobalVariable *GV,
+                               const VarDecl &D) const {
+  assert(D.isThreadSpecified() && "setting TLS mode on non-TLS var!");
+
+  llvm::GlobalVariable::ThreadLocalMode TLM;
+  TLM = GetLLVMTLSModel(CodeGenOpts.DefaultTLSModel);
+
+  // Override the TLS model if it is explicitly specified.
+  if (D.hasAttr<TLSModelAttr>()) {
+    const TLSModelAttr *Attr = D.getAttr<TLSModelAttr>();
+    TLM = GetLLVMTLSModel(Attr->getModel());
+  }
+
+  GV->setThreadLocalMode(TLM);
+}
+
 /// Set the symbol visibility of type information (vtable and RTTI)
 /// associated with the given type.
 void CodeGenModule::setTypeVisibility(llvm::GlobalValue *GV,
@@ -347,7 +386,8 @@
   else if (const CXXDestructorDecl *D = dyn_cast<CXXDestructorDecl>(ND))
     getCXXABI().getMangleContext().mangleCXXDtor(D, GD.getDtorType(), Out);
   else if (const BlockDecl *BD = dyn_cast<BlockDecl>(ND))
-    getCXXABI().getMangleContext().mangleBlock(BD, Out);
+    getCXXABI().getMangleContext().mangleBlock(BD, Out,
+      dyn_cast_or_null<VarDecl>(initializedGlobalDecl.getDecl()));
   else
     getCXXABI().getMangleContext().mangleName(ND, Out);
 
@@ -368,7 +408,8 @@
   const Decl *D = GD.getDecl();
   llvm::raw_svector_ostream Out(Buffer.getBuffer());
   if (D == 0)
-    MangleCtx.mangleGlobalBlock(BD, Out);
+    MangleCtx.mangleGlobalBlock(BD, 
+      dyn_cast_or_null<VarDecl>(initializedGlobalDecl.getDecl()), Out);
   else if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
     MangleCtx.mangleCtorBlock(CD, GD.getCtorType(), BD, Out);
   else if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D))
@@ -1210,13 +1251,8 @@
         GV->setVisibility(GetLLVMVisibility(LV.visibility()));
     }
 
-    GV->setThreadLocal(D->isThreadSpecified());
-
-    // Set the TLS model if it it's explicitly specified.
-    if (D->hasAttr<TLSModelAttr>()) {
-      const TLSModelAttr *Attr = D->getAttr<TLSModelAttr>();
-      GV->setThreadLocalMode(GetLLVMTLSModel(Attr->getModel()));
-    }
+    if (D->isThreadSpecified())
+      setTLSMode(GV, *D);
   }
 
   if (AddrSpace != Ty->getAddressSpace())
@@ -1551,8 +1587,10 @@
     // FIXME: It does so in a global constructor, which is *not* what we
     // want.
 
-    if (!Init)
+    if (!Init) {
+      initializedGlobalDecl = GlobalDecl(D);
       Init = EmitConstantInit(*InitDecl);
+    }
     if (!Init) {
       QualType T = InitExpr->getType();
       if (D->getType()->isReferenceType())

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.h Sat Jun 30 16:45:28 2012
@@ -351,6 +351,8 @@
   struct {
     int GlobalUniqueCount;
   } Block;
+  
+  GlobalDecl initializedGlobalDecl;
 
   /// @}
 public:
@@ -472,6 +474,10 @@
   /// GlobalValue.
   void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
 
+  /// setTLSMode - Set the TLS mode for the given LLVM GlobalVariable
+  /// for the thread-local variable declaration D.
+  void setTLSMode(llvm::GlobalVariable *GV, const VarDecl &D) const;
+
   /// TypeVisibilityKind - The kind of global variable that is passed to 
   /// setTypeVisibility
   enum TypeVisibilityKind {
@@ -496,15 +502,6 @@
     llvm_unreachable("unknown visibility!");
   }
 
-  static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel(StringRef S) {
-    return llvm::StringSwitch<llvm::GlobalVariable::ThreadLocalMode>(S)
-        .Case("global-dynamic", llvm::GlobalVariable::GeneralDynamicTLSModel)
-        .Case("local-dynamic", llvm::GlobalVariable::LocalDynamicTLSModel)
-        .Case("initial-exec", llvm::GlobalVariable::InitialExecTLSModel)
-        .Case("local-exec", llvm::GlobalVariable::LocalExecTLSModel)
-        .Default(llvm::GlobalVariable::NotThreadLocal);
-  }
-
   llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) {
     if (isa<CXXConstructorDecl>(GD.getDecl()))
       return GetAddrOfCXXConstructor(cast<CXXConstructorDecl>(GD.getDecl()),
@@ -596,7 +593,7 @@
 
   /// getUniqueBlockCount - Fetches the global unique block count.
   int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; }
-
+  
   /// getBlockDescriptorType - Fetches the type of a generic block
   /// descriptor.
   llvm::Type *getBlockDescriptorType();

Modified: cfe/branches/tooling/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Driver.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Driver.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Driver.cpp Sat Jun 30 16:45:28 2012
@@ -392,6 +392,7 @@
   // Suppress driver output and emit preprocessor output to temp file.
   CCCIsCPP = true;
   CCGenDiagnostics = true;
+  C.getArgs().AddFlagArg(0, Opts->getOption(options::OPT_frewrite_includes));
 
   // Save the original job command(s).
   std::string Cmd;
@@ -1181,7 +1182,10 @@
     if (Args.hasArg(options::OPT_M, options::OPT_MM)) {
       OutputTy = types::TY_Dependencies;
     } else {
-      OutputTy = types::getPreprocessedType(Input->getType());
+      OutputTy = Input->getType();
+      if (!Args.hasFlag(options::OPT_frewrite_includes,
+                        options::OPT_fno_rewrite_includes, false))
+        OutputTy = types::getPreprocessedType(OutputTy);
       assert(OutputTy != types::TY_INVALID &&
              "Cannot preprocess this input type!");
     }

Modified: cfe/branches/tooling/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Tools.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Tools.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Tools.cpp Sat Jun 30 16:45:28 2012
@@ -422,16 +422,47 @@
   getToolChain().AddClangSystemIncludeArgs(Args, CmdArgs);
 }
 
+/// getLLVMArchSuffixForARM - Get the LLVM arch name to use for a particular
+/// CPU.
+//
+// FIXME: This is redundant with -mcpu, why does LLVM use this.
+// FIXME: tblgen this, or kill it!
+static const char *getLLVMArchSuffixForARM(StringRef CPU) {
+  return llvm::StringSwitch<const char *>(CPU)
+    .Cases("arm7tdmi", "arm7tdmi-s", "arm710t", "v4t")
+    .Cases("arm720t", "arm9", "arm9tdmi", "v4t")
+    .Cases("arm920", "arm920t", "arm922t", "v4t")
+    .Cases("arm940t", "ep9312","v4t")
+    .Cases("arm10tdmi",  "arm1020t", "v5")
+    .Cases("arm9e",  "arm926ej-s",  "arm946e-s", "v5e")
+    .Cases("arm966e-s",  "arm968e-s",  "arm10e", "v5e")
+    .Cases("arm1020e",  "arm1022e",  "xscale", "iwmmxt", "v5e")
+    .Cases("arm1136j-s",  "arm1136jf-s",  "arm1176jz-s", "v6")
+    .Cases("arm1176jzf-s",  "mpcorenovfp",  "mpcore", "v6")
+    .Cases("arm1156t2-s",  "arm1156t2f-s", "v6t2")
+    .Cases("cortex-a8", "cortex-a9", "v7")
+    .Case("cortex-m3", "v7m")
+    .Case("cortex-m4", "v7m")
+    .Case("cortex-m0", "v6m")
+    .Default("");
+}
+
 /// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting.
 //
 // FIXME: tblgen this.
-static const char *getARMTargetCPU(const ArgList &Args,
+static std::string getARMTargetCPU(const ArgList &Args,
                                    const llvm::Triple &Triple) {
   // FIXME: Warn on inconsistent use of -mcpu and -march.
 
   // If we have -mcpu=, use that.
-  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
-    return A->getValue(Args);
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+    StringRef MCPU = A->getValue(Args);
+    // Handle -mcpu=native.
+    if (MCPU == "native")
+      return llvm::sys::getHostCPUName();
+    else
+      return MCPU;
+  }
 
   StringRef MArch;
   if (Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
@@ -442,6 +473,18 @@
     MArch = Triple.getArchName();
   }
 
+  // Handle -march=native.
+  std::string NativeMArch;
+  if (MArch == "native") {
+    std::string CPU = llvm::sys::getHostCPUName();
+    if (CPU != "generic") {
+      // Translate the native cpu into the architecture. The switch below will
+      // then chose the minimum cpu for that arch.
+      NativeMArch = std::string("arm") + getLLVMArchSuffixForARM(CPU);
+      MArch = NativeMArch;
+    }
+  }
+
   return llvm::StringSwitch<const char *>(MArch)
     .Cases("armv2", "armv2a","arm2")
     .Case("armv3", "arm6")
@@ -465,31 +508,6 @@
     .Default("arm7tdmi");
 }
 
-/// getLLVMArchSuffixForARM - Get the LLVM arch name to use for a particular
-/// CPU.
-//
-// FIXME: This is redundant with -mcpu, why does LLVM use this.
-// FIXME: tblgen this, or kill it!
-static const char *getLLVMArchSuffixForARM(StringRef CPU) {
-  return llvm::StringSwitch<const char *>(CPU)
-    .Cases("arm7tdmi", "arm7tdmi-s", "arm710t", "v4t")
-    .Cases("arm720t", "arm9", "arm9tdmi", "v4t")
-    .Cases("arm920", "arm920t", "arm922t", "v4t")
-    .Cases("arm940t", "ep9312","v4t")
-    .Cases("arm10tdmi",  "arm1020t", "v5")
-    .Cases("arm9e",  "arm926ej-s",  "arm946e-s", "v5e")
-    .Cases("arm966e-s",  "arm968e-s",  "arm10e", "v5e")
-    .Cases("arm1020e",  "arm1022e",  "xscale", "iwmmxt", "v5e")
-    .Cases("arm1136j-s",  "arm1136jf-s",  "arm1176jz-s", "v6")
-    .Cases("arm1176jzf-s",  "mpcorenovfp",  "mpcore", "v6")
-    .Cases("arm1156t2-s",  "arm1156t2f-s", "v6t2")
-    .Cases("cortex-a8", "cortex-a9", "v7")
-    .Case("cortex-m3", "v7m")
-    .Case("cortex-m4", "v7m")
-    .Case("cortex-m0", "v6m")
-    .Default("");
-}
-
 // FIXME: Move to target hook.
 static bool isSignedCharDefault(const llvm::Triple &Triple) {
   switch (Triple.getArch()) {
@@ -601,9 +619,10 @@
       // Darwin defaults to "softfp" for v6 and v7.
       //
       // FIXME: Factor out an ARM class so we can cache the arch somewhere.
-      StringRef ArchName =
+      std::string ArchName =
         getLLVMArchSuffixForARM(getARMTargetCPU(Args, Triple));
-      if (ArchName.startswith("v6") || ArchName.startswith("v7"))
+      if (StringRef(ArchName).startswith("v6") ||
+          StringRef(ArchName).startswith("v7"))
         FloatABI = "softfp";
       else
         FloatABI = "soft";
@@ -628,9 +647,9 @@
         FloatABI = "softfp";
         break;
       case llvm::Triple::ANDROIDEABI: {
-        StringRef ArchName =
+        std::string ArchName =
           getLLVMArchSuffixForARM(getARMTargetCPU(Args, Triple));
-        if (ArchName.startswith("v7"))
+        if (StringRef(ArchName).startswith("v7"))
           FloatABI = "softfp";
         else
           FloatABI = "soft";
@@ -680,7 +699,7 @@
 
   // Set the CPU based on -march= and -mcpu=.
   CmdArgs.push_back("-target-cpu");
-  CmdArgs.push_back(getARMTargetCPU(Args, Triple));
+  CmdArgs.push_back(Args.MakeArgString(getARMTargetCPU(Args, Triple)));
 
   // Determine floating point ABI from the options & target defaults.
   StringRef FloatABI = getARMFloatABI(D, Args, Triple);
@@ -2190,6 +2209,8 @@
 
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden);
 
+  Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
+
   // -fhosted is default.
   if (Args.hasFlag(options::OPT_ffreestanding, options::OPT_fhosted, false) ||
       KernelOrKext)
@@ -2203,6 +2224,8 @@
   Args.AddLastArg(CmdArgs, options::OPT_fno_limit_debug_info);
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
   Args.AddLastArg(CmdArgs, options::OPT_faltivec);
+  Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_show_template_tree);
+  Args.AddLastArg(CmdArgs, options::OPT_fno_elide_type);
 
   // Report and error for -faltivec on anything other then PowerPC.
   if (const Arg *A = Args.getLastArg(options::OPT_faltivec))
@@ -2788,7 +2811,7 @@
 
   // Set the CPU based on -march= and -mcpu=.
   CmdArgs.push_back("-target-cpu");
-  CmdArgs.push_back(getARMTargetCPU(Args, Triple));
+  CmdArgs.push_back(Args.MakeArgString(getARMTargetCPU(Args, Triple)));
 
   // Honor -mfpu=.
   if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ))

Modified: cfe/branches/tooling/lib/Edit/Commit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Edit/Commit.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Edit/Commit.cpp (original)
+++ cfe/branches/tooling/lib/Edit/Commit.cpp Sat Jun 30 16:45:28 2012
@@ -332,6 +332,7 @@
   if (invalidTemp)
     return false;
 
+  Len = text.size();
   return file.substr(Offs.getOffset()).startswith(text);
 }
 

Modified: cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp Sat Jun 30 16:45:28 2012
@@ -307,6 +307,20 @@
     Res.push_back("-disable-llvm-verifier");
   for (unsigned i = 0, e = Opts.BackendOptions.size(); i != e; ++i)
     Res.push_back("-backend-option", Opts.BackendOptions[i]);
+
+  switch (Opts.DefaultTLSModel) {
+  case CodeGenOptions::GeneralDynamicTLSModel:
+    break;
+  case CodeGenOptions::LocalDynamicTLSModel:
+    Res.push_back("-ftls-model=local-dynamic");
+    break;
+  case CodeGenOptions::InitialExecTLSModel:
+    Res.push_back("-ftls-model=initial-exec");
+    break;
+  case CodeGenOptions::LocalExecTLSModel:
+    Res.push_back("-ftls-model=local-exec");
+    break;
+  }
 }
 
 static void DependencyOutputOptsToArgs(const DependencyOutputOptions &Opts,
@@ -788,7 +802,7 @@
   
   if (Opts.AppleKext)
     Res.push_back("-fapple-kext");
-  
+
   if (Opts.getVisibilityMode() != DefaultVisibility) {
     Res.push_back("-fvisibility");
     if (Opts.getVisibilityMode() == HiddenVisibility) {
@@ -1256,6 +1270,22 @@
     }
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
+    StringRef Name = A->getValue(Args);
+    unsigned Model = llvm::StringSwitch<unsigned>(Name)
+        .Case("global-dynamic", CodeGenOptions::GeneralDynamicTLSModel)
+        .Case("local-dynamic", CodeGenOptions::LocalDynamicTLSModel)
+        .Case("initial-exec", CodeGenOptions::InitialExecTLSModel)
+        .Case("local-exec", CodeGenOptions::LocalExecTLSModel)
+        .Default(~0U);
+    if (Model == ~0U) {
+      Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
+      Success = false;
+    } else {
+      Opts.DefaultTLSModel = static_cast<CodeGenOptions::TLSModel>(Model);
+    }
+  }
+
   return Success;
 }
 
@@ -1349,6 +1379,8 @@
   Opts.ShowSourceRanges = Args.hasArg(OPT_fdiagnostics_print_source_range_info);
   Opts.ShowParseableFixits = Args.hasArg(OPT_fdiagnostics_parseable_fixits);
   Opts.VerifyDiagnostics = Args.hasArg(OPT_verify);
+  Opts.ElideType = !Args.hasArg(OPT_fno_elide_type);
+  Opts.ShowTemplateTree = Args.hasArg(OPT_fdiagnostics_show_template_tree);
   Opts.ErrorLimit = Args.getLastArgIntValue(OPT_ferror_limit, 0, Diags);
   Opts.MacroBacktraceLimit
     = Args.getLastArgIntValue(OPT_fmacro_backtrace_limit,

Modified: cfe/branches/tooling/lib/Frontend/TextDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/TextDiagnostic.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/TextDiagnostic.cpp Sat Jun 30 16:45:28 2012
@@ -31,12 +31,32 @@
   raw_ostream::GREEN;
 static const enum raw_ostream::Colors warningColor =
   raw_ostream::MAGENTA;
+static const enum raw_ostream::Colors templateColor =
+  raw_ostream::CYAN;
 static const enum raw_ostream::Colors errorColor = raw_ostream::RED;
 static const enum raw_ostream::Colors fatalColor = raw_ostream::RED;
 // Used for changing only the bold attribute.
 static const enum raw_ostream::Colors savedColor =
   raw_ostream::SAVEDCOLOR;
 
+/// \brief Add highlights to differences in template strings.
+static void applyTemplateHighlighting(raw_ostream &OS, StringRef Str,
+                                      bool &Normal, bool Bold) {
+  for (unsigned i = 0, e = Str.size(); i < e; ++i)
+    if (Str[i] != ToggleHighlight) {
+      OS << Str[i];
+    } else {
+      if (Normal)
+        OS.changeColor(templateColor, true);
+      else {
+        OS.resetColor();
+        if (Bold)
+          OS.changeColor(savedColor, true);
+      }
+      Normal = !Normal;
+    }
+}
+
 /// \brief Number of spaces to indent when word-wrapping.
 const unsigned WordWrapIndentation = 6;
 
@@ -569,6 +589,7 @@
 /// \param Column the column number at which the first character of \p
 /// Str will be printed. This will be non-zero when part of the first
 /// line has already been printed.
+/// \param Bold if the current text should be bold
 /// \param Indentation the number of spaces to indent any lines beyond
 /// the first line.
 /// \returns true if word-wrapping was required, or false if the
@@ -576,8 +597,10 @@
 static bool printWordWrapped(raw_ostream &OS, StringRef Str,
                              unsigned Columns,
                              unsigned Column = 0,
+                             bool Bold = false,
                              unsigned Indentation = WordWrapIndentation) {
   const unsigned Length = std::min(Str.find('\n'), Str.size());
+  bool TextNormal = true;
 
   // The string used to indent each line.
   SmallString<16> IndentStr;
@@ -601,7 +624,8 @@
         OS << ' ';
         Column += 1;
       }
-      OS << Str.substr(WordStart, WordLength);
+      applyTemplateHighlighting(OS, Str.substr(WordStart, WordLength),
+                                TextNormal, Bold);
       Column += WordLength;
       continue;
     }
@@ -610,13 +634,16 @@
     // line.
     OS << '\n';
     OS.write(&IndentStr[0], Indentation);
-    OS << Str.substr(WordStart, WordLength);
+    applyTemplateHighlighting(OS, Str.substr(WordStart, WordLength),
+                              TextNormal, Bold);
     Column = Indentation + WordLength;
     Wrapped = true;
   }
 
   // Append any remaning text from the message with its existing formatting.
-  OS << Str.substr(Length);
+  applyTemplateHighlighting(OS, Str.substr(Length), TextNormal, Bold);
+
+  assert(TextNormal && "Text highlighted at end of diagnostic message.");
 
   return Wrapped;
 }
@@ -686,20 +713,27 @@
                                        StringRef Message,
                                        unsigned CurrentColumn, unsigned Columns,
                                        bool ShowColors) {
+  bool Bold = false;
   if (ShowColors) {
     // Print warnings, errors and fatal errors in bold, no color
     switch (Level) {
-    case DiagnosticsEngine::Warning: OS.changeColor(savedColor, true); break;
-    case DiagnosticsEngine::Error:   OS.changeColor(savedColor, true); break;
-    case DiagnosticsEngine::Fatal:   OS.changeColor(savedColor, true); break;
+    case DiagnosticsEngine::Warning:
+    case DiagnosticsEngine::Error:
+    case DiagnosticsEngine::Fatal:
+      OS.changeColor(savedColor, true);
+      Bold = true;
+      break;
     default: break; //don't bold notes
     }
   }
 
   if (Columns)
-    printWordWrapped(OS, Message, Columns, CurrentColumn);
-  else
-    OS << Message;
+    printWordWrapped(OS, Message, Columns, CurrentColumn, Bold);
+  else {
+    bool Normal = true;
+    applyTemplateHighlighting(OS, Message, Normal, Bold);
+    assert(Normal && "Formatting should have returned to normal");
+  }
 
   if (ShowColors)
     OS.resetColor();

Modified: cfe/branches/tooling/lib/Frontend/Warnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/Warnings.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/Warnings.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/Warnings.cpp Sat Jun 30 16:45:28 2012
@@ -53,7 +53,11 @@
   Diags.setIgnoreAllWarnings(Opts.IgnoreWarnings);
   Diags.setShowOverloads(
     static_cast<DiagnosticsEngine::OverloadsShown>(Opts.ShowOverloads));
-  
+
+  Diags.setElideType(Opts.ElideType);
+  Diags.setPrintTemplateTree(Opts.ShowTemplateTree);
+  Diags.setShowColors(Opts.ShowColors);
+ 
   // Handle -ferror-limit
   if (Opts.ErrorLimit)
     Diags.setErrorLimit(Opts.ErrorLimit);

Modified: cfe/branches/tooling/lib/Headers/avx2intrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Headers/avx2intrin.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Headers/avx2intrin.h (original)
+++ cfe/branches/tooling/lib/Headers/avx2intrin.h Sat Jun 30 16:45:28 2012
@@ -959,3 +959,243 @@
 {
   return (__m128i)__builtin_ia32_psrlv2di(__X, __Y);
 }
+
+#define _mm_mask_i32gather_pd(a, m, i, mask, s) __extension__ ({ \
+  __m128d __a = (a); \
+  double const *__m = (m); \
+  __m128i __i = (i); \
+  __m128d __mask = (mask); \
+  (__m128d)__builtin_ia32_gatherd_pd((__v2df)__a, (const __v2df *)__m, \
+             (__v4si)__i, (__v2df)__mask, (s)); })
+
+#define _mm256_mask_i32gather_pd(a, m, i, mask, s) __extension__ ({ \
+  __m256d __a = (a); \
+  double const *__m = (m); \
+  __m128i __i = (i); \
+  __m256d __mask = (mask); \
+  (__m256d)__builtin_ia32_gatherd_pd256((__v4df)__a, (const __v4df *)__m, \
+             (__v4si)__i, (__v4df)__mask, (s)); })
+
+#define _mm_mask_i64gather_pd(a, m, i, mask, s) __extension__ ({ \
+  __m128d __a = (a); \
+  double const *__m = (m); \
+  __m128i __i = (i); \
+  __m128d __mask = (mask); \
+  (__m128d)__builtin_ia32_gatherq_pd((__v2df)__a, (const __v2df *)__m, \
+             (__v2di)__i, (__v2df)__mask, (s)); })
+
+#define _mm256_mask_i64gather_pd(a, m, i, mask, s) __extension__ ({ \
+  __m256d __a = (a); \
+  double const *__m = (m); \
+  __m256i __i = (i); \
+  __m256d __mask = (mask); \
+  (__m256d)__builtin_ia32_gatherq_pd256((__v4df)__a, (const __v4df *)__m, \
+             (__v4di)__i, (__v4df)__mask, (s)); })
+
+#define _mm_mask_i32gather_ps(a, m, i, mask, s) __extension__ ({ \
+  __m128 __a = (a); \
+  float const *__m = (m); \
+  __m128i __i = (i); \
+  __m128 __mask = (mask); \
+  (__m128)__builtin_ia32_gatherd_ps((__v4sf)__a, (const __v4sf *)__m, \
+            (__v4si)__i, (__v4sf)__mask, (s)); })
+
+#define _mm256_mask_i32gather_ps(a, m, i, mask, s) __extension__ ({ \
+  __m256 __a = (a); \
+  float const *__m = (m); \
+  __m256i __i = (i); \
+  __m256 __mask = (mask); \
+  (__m256)__builtin_ia32_gatherd_ps256((__v8sf)__a, (const __v8sf *)__m, \
+            (__v8si)__i, (__v8sf)__mask, (s)); })
+
+#define _mm_mask_i64gather_ps(a, m, i, mask, s) __extension__ ({ \
+  __m128 __a = (a); \
+  float const *__m = (m); \
+  __m128i __i = (i); \
+  __m128 __mask = (mask); \
+  (__m128)__builtin_ia32_gatherq_ps((__v4sf)__a, (const __v4sf *)__m, \
+            (__v2di)__i, (__v4sf)__mask, (s)); })
+
+#define _mm256_mask_i64gather_ps(a, m, i, mask, s) __extension__ ({ \
+  __m128 __a = (a); \
+  float const *__m = (m); \
+  __m256i __i = (i); \
+  __m128 __mask = (mask); \
+  (__m128)__builtin_ia32_gatherq_ps256((__v4sf)__a, (const __v4sf *)__m, \
+            (__v4di)__i, (__v4sf)__mask, (s)); })
+
+#define _mm_mask_i32gather_epi32(a, m, i, mask, s) __extension__ ({ \
+  __m128i __a = (a); \
+  int const *__m = (m); \
+  __m128i __i = (i); \
+  __m128i __mask = (mask); \
+  (__m128i)__builtin_ia32_gatherd_d((__v4si)__a, (const __v4si *)__m, \
+            (__v4si)__i, (__v4si)__mask, (s)); })
+
+#define _mm256_mask_i32gather_epi32(a, m, i, mask, s) __extension__ ({ \
+  __m256i __a = (a); \
+  int const *__m = (m); \
+  __m256i __i = (i); \
+  __m256i __mask = (mask); \
+  (__m256i)__builtin_ia32_gatherd_d256((__v8si)__a, (const __v8si *)__m, \
+            (__v8si)__i, (__v8si)__mask, (s)); })
+
+#define _mm_mask_i64gather_epi32(a, m, i, mask, s) __extension__ ({ \
+  __m128i __a = (a); \
+  int const *__m = (m); \
+  __m128i __i = (i); \
+  __m128i __mask = (mask); \
+  (__m128i)__builtin_ia32_gatherq_d((__v4si)__a, (const __v4si *)__m, \
+            (__v2di)__i, (__v4si)__mask, (s)); })
+
+#define _mm256_mask_i64gather_epi32(a, m, i, mask, s) __extension__ ({ \
+  __m128i __a = (a); \
+  int const *__m = (m); \
+  __m256i __i = (i); \
+  __m128i __mask = (mask); \
+  (__m128i)__builtin_ia32_gatherq_d256((__v4si)__a, (const __v4si *)__m, \
+            (__v4di)__i, (__v4si)__mask, (s)); })
+
+#define _mm_mask_i32gather_epi64(a, m, i, mask, s) __extension__ ({ \
+  __m128i __a = (a); \
+  int const *__m = (m); \
+  __m128i __i = (i); \
+  __m128i __mask = (mask); \
+  (__m128i)__builtin_ia32_gatherd_q((__v2di)__a, (const __v2di *)__m, \
+             (__v4si)__i, (__v2di)__mask, (s)); })
+
+#define _mm256_mask_i32gather_epi64(a, m, i, mask, s) __extension__ ({ \
+  __m256i __a = (a); \
+  int const *__m = (m); \
+  __m128i __i = (i); \
+  __m256i __mask = (mask); \
+  (__m256i)__builtin_ia32_gatherd_q256((__v4di)__a, (const __v4di *)__m, \
+             (__v4si)__i, (__v4di)__mask, (s)); })
+
+#define _mm_mask_i64gather_epi64(a, m, i, mask, s) __extension__ ({ \
+  __m128i __a = (a); \
+  int const *__m = (m); \
+  __m128i __i = (i); \
+  __m128i __mask = (mask); \
+  (__m128i)__builtin_ia32_gatherq_q((__v2di)__a, (const __v2di *)__m, \
+             (__v2di)__i, (__v2di)__mask, (s)); })
+
+#define _mm256_mask_i64gather_epi64(a, m, i, mask, s) __extension__ ({ \
+  __m256i __a = (a); \
+  int const *__m = (m); \
+  __m256i __i = (i); \
+  __m256i __mask = (mask); \
+  (__m256i)__builtin_ia32_gatherq_q256((__v4di)__a, (const __v4di *)__m, \
+             (__v4di)__i, (__v4di)__mask, (s)); })
+
+#define _mm_i32gather_pd(m, i, s) __extension__ ({ \
+  double const *__m = (m); \
+  __m128i __i = (i); \
+  (__m128d)__builtin_ia32_gatherd_pd((__v2df)_mm_setzero_pd(), \
+             (const __v2df *)__m, (__v4si)__i, \
+             (__v2df)_mm_set1_pd((double)(long long int)-1), (s)); })
+
+#define _mm256_i32gather_pd(m, i, s) __extension__ ({ \
+  double const *__m = (m); \
+  __m128i __i = (i); \
+  (__m256d)__builtin_ia32_gatherd_pd256((__v4df)_mm256_setzero_pd(), \
+             (const __v4df *)__m, (__v4si)__i, \
+             (__v4df)_mm256_set1_pd((double)(long long int)-1), (s)); })
+
+#define _mm_i64gather_pd(m, i, s) __extension__ ({ \
+  double const *__m = (m); \
+  __m128i __i = (i); \
+  (__m128d)__builtin_ia32_gatherq_pd((__v2df)_mm_setzero_pd(), \
+             (const __v2df *)__m, (__v2di)__i, \
+             (__v2df)_mm_set1_pd((double)(long long int)-1), (s)); })
+
+#define _mm256_i64gather_pd(m, i, s) __extension__ ({ \
+  double const *__m = (m); \
+  __m256i __i = (i); \
+  (__m256d)__builtin_ia32_gatherq_pd256((__v4df)_mm256_setzero_pd(), \
+             (const __v4df *)__m, (__v4di)__i, \
+             (__v4df)_mm256_set1_pd((double)(long long int)-1), (s)); })
+
+#define _mm_i32gather_ps(m, i, s) __extension__ ({ \
+  float const *__m = (m); \
+  __m128i __i = (i); \
+  (__m128)__builtin_ia32_gatherd_ps((__v4sf)_mm_setzero_ps(), \
+             (const __v4sf *)__m, (__v4si)__i, \
+             (__v4sf)_mm_set1_ps((float)(int)-1), (s)); })
+
+#define _mm256_i32gather_ps(m, i, s) __extension__ ({ \
+  float const *__m = (m); \
+  __m256i __i = (i); \
+  (__m256)__builtin_ia32_gatherd_ps256((__v8sf)_mm256_setzero_ps(), \
+             (const __v8sf *)__m, (__v8si)__i, \
+             (__v8sf)_mm256_set1_ps((float)(int)-1), (s)); })
+
+#define _mm_i64gather_ps(m, i, s) __extension__ ({ \
+  float const *__m = (m); \
+  __m128i __i = (i); \
+  (__m128)__builtin_ia32_gatherq_ps((__v4sf)_mm_setzero_ps(), \
+             (const __v4sf *)__m, (__v2di)__i, \
+             (__v4sf)_mm_set1_ps((float)(int)-1), (s)); })
+
+#define _mm256_i64gather_ps(m, i, s) __extension__ ({ \
+  float const *__m = (m); \
+  __m256i __i = (i); \
+  (__m128)__builtin_ia32_gatherq_ps256((__v4sf)_mm_setzero_ps(), \
+             (const __v4sf *)__m, (__v4di)__i, \
+             (__v4sf)_mm_set1_ps((float)(int)-1), (s)); })
+
+#define _mm_i32gather_epi32(m, i, s) __extension__ ({ \
+  int const *__m = (m); \
+  __m128i __i = (i); \
+  (__m128i)__builtin_ia32_gatherd_d((__v4si)_mm_setzero_si128(), \
+            (const __v4si *)__m, (__v4si)__i, \
+            (__v4si)_mm_set1_epi32(-1), (s)); })
+
+#define _mm256_i32gather_epi32(m, i, s) __extension__ ({ \
+  int const *__m = (m); \
+  __m256i __i = (i); \
+  (__m256i)__builtin_ia32_gatherd_d256((__v8si)_mm256_setzero_si256(), \
+            (const __v8si *)__m, (__v8si)__i, \
+            (__v8si)_mm256_set1_epi32(-1), (s)); })
+
+#define _mm_i64gather_epi32(m, i, s) __extension__ ({ \
+  int const *__m = (m); \
+  __m128i __i = (i); \
+  (__m128i)__builtin_ia32_gatherq_d((__v4si)_mm_setzero_si128(), \
+            (const __v4si *)__m, (__v2di)__i, \
+            (__v4si)_mm_set1_epi32(-1), (s)); })
+
+#define _mm256_i64gather_epi32(m, i, s) __extension__ ({ \
+  int const *__m = (m); \
+  __m256i __i = (i); \
+  (__m128i)__builtin_ia32_gatherq_d256((__v4si)_mm_setzero_si128(), \
+            (const __v4si *)__m, (__v4di)__i, \
+            (__v4si)_mm_set1_epi32(-1), (s)); })
+
+#define _mm_i32gather_epi64(m, i, s) __extension__ ({ \
+  int const *__m = (m); \
+  __m128i __i = (i); \
+  (__m128i)__builtin_ia32_gatherd_q((__v2di)_mm_setzero_si128(), \
+             (const __v2di *)__m, (__v4si)__i, \
+             (__v2di)_mm_set1_epi64x(-1), (s)); })
+
+#define _mm256_i32gather_epi64(m, i, s) __extension__ ({ \
+  int const *__m = (m); \
+  __m128i __i = (i); \
+  (__m256i)__builtin_ia32_gatherd_q256((__v4di)_mm256_setzero_si256(), \
+             (const __v4di *)__m, (__v4si)__i, \
+             (__v4di)_mm256_set1_epi64x(-1), (s)); })
+
+#define _mm_i64gather_epi64(m, i, s) __extension__ ({ \
+  int const *__m = (m); \
+  __m128i __i = (i); \
+  (__m128i)__builtin_ia32_gatherq_q((__v2di)_mm_setzero_si128(), \
+             (const __v2di *)__m, (__v2di)__i, \
+             (__v2di)_mm_set1_epi64x(-1), (s)); })
+
+#define _mm256_i64gather_epi64(m, i, s) __extension__ ({ \
+  int const *__m = (m); \
+  __m256i __i = (i); \
+  (__m256i)__builtin_ia32_gatherq_q256((__v4di)_mm256_setzero_si256(), \
+             (const __v4di *)__m, (__v4di)__i, \
+             (__v4di)_mm256_set1_epi64x(-1), (s)); })

Modified: cfe/branches/tooling/lib/Headers/stddef.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Headers/stddef.h?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Headers/stddef.h (original)
+++ cfe/branches/tooling/lib/Headers/stddef.h Sat Jun 30 16:45:28 2012
@@ -52,6 +52,13 @@
 #  define NULL ((void*)0)
 #endif
 
+#ifdef __cplusplus
+#if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED)
+namespace std { typedef decltype(nullptr) nullptr_t; }
+using ::std::nullptr_t;
+#endif
+#endif
+
 #define offsetof(t, d) __builtin_offsetof(t, d)
 
 #endif /* __STDDEF_H */

Modified: cfe/branches/tooling/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Lexer.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Lexer.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Lexer.cpp Sat Jun 30 16:45:28 2012
@@ -1649,7 +1649,7 @@
     if (C == '\n' || C == '\r' ||             // Newline.
         (C == 0 && CurPtr-1 == BufferEnd)) {  // End of file.
       if (!isLexingRawMode() && !LangOpts.AsmPreprocessor)
-        Diag(BufferPtr, diag::warn_unterminated_string);
+        Diag(BufferPtr, diag::ext_unterminated_string);
       FormTokenWithChars(Result, CurPtr-1, tok::unknown);
       return;
     }
@@ -1807,7 +1807,7 @@
   char C = getAndAdvanceChar(CurPtr, Result);
   if (C == '\'') {
     if (!isLexingRawMode() && !LangOpts.AsmPreprocessor)
-      Diag(BufferPtr, diag::err_empty_character);
+      Diag(BufferPtr, diag::ext_empty_character);
     FormTokenWithChars(Result, CurPtr, tok::unknown);
     return;
   }
@@ -1821,7 +1821,7 @@
     } else if (C == '\n' || C == '\r' ||             // Newline.
                (C == 0 && CurPtr-1 == BufferEnd)) {  // End of file.
       if (!isLexingRawMode() && !LangOpts.AsmPreprocessor)
-        Diag(BufferPtr, diag::warn_unterminated_char);
+        Diag(BufferPtr, diag::ext_unterminated_char);
       FormTokenWithChars(Result, CurPtr-1, tok::unknown);
       return;
     } else if (C == 0) {

Modified: cfe/branches/tooling/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PPDirectives.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PPDirectives.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PPDirectives.cpp Sat Jun 30 16:45:28 2012
@@ -804,14 +804,7 @@
     Val = NextVal;
   }
 
-  // Reject 0, this is needed both by #line numbers and flags.
-  if (Val == 0) {
-    PP.Diag(DigitTok, DiagID);
-    PP.DiscardUntilEndOfDirective();
-    return true;
-  }
-
-  if (DigitTokBegin[0] == '0')
+  if (DigitTokBegin[0] == '0' && Val)
     PP.Diag(DigitTok.getLocation(), diag::warn_pp_line_decimal);
 
   return false;
@@ -834,6 +827,9 @@
   unsigned LineNo;
   if (GetLineValue(DigitTok, LineNo, diag::err_pp_line_requires_integer,*this))
     return;
+  
+  if (LineNo == 0)
+    Diag(DigitTok, diag::ext_pp_line_zero);
 
   // Enforce C99 6.10.4p3: "The digit sequence shall not specify ... a
   // number greater than 2147483647".  C90 requires that the line # be <= 32767.

Modified: cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp Sat Jun 30 16:45:28 2012
@@ -632,6 +632,7 @@
            .Case("attribute_objc_method_family", true)
            .Case("attribute_overloadable", true)
            .Case("attribute_unavailable_with_message", true)
+           .Case("attribute_unused_on_fields", true)
            .Case("blocks", LangOpts.Blocks)
            .Case("cxx_exceptions", LangOpts.Exceptions)
            .Case("cxx_rtti", LangOpts.RTTI)

Modified: cfe/branches/tooling/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Pragma.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Pragma.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Pragma.cpp Sat Jun 30 16:45:28 2012
@@ -1010,6 +1010,10 @@
       llvm_unreachable("This is an assertion!");
     } else if (II->isStr("crash")) {
       *(volatile int*) 0x11 = 0;
+    } else if (II->isStr("parser_crash")) {
+      Token Crasher;
+      Crasher.setKind(tok::annot_pragma_parser_crash);
+      PP.EnterToken(Crasher);
     } else if (II->isStr("llvm_fatal_error")) {
       llvm::report_fatal_error("#pragma clang __debug llvm_fatal_error");
     } else if (II->isStr("llvm_unreachable")) {

Modified: cfe/branches/tooling/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Preprocessor.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Preprocessor.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Preprocessor.cpp Sat Jun 30 16:45:28 2012
@@ -515,9 +515,19 @@
 
   // If the information about this identifier is out of date, update it from
   // the external source.
+  // We have to treat __VA_ARGS__ in a special way, since it gets
+  // serialized with isPoisoned = true, but our preprocessor may have
+  // unpoisoned it if we're defining a C99 macro.
   if (II.isOutOfDate()) {
+    bool CurrentIsPoisoned = false;
+    if (&II == Ident__VA_ARGS__)
+      CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
+
     ExternalSource->updateOutOfDateIdentifier(II);
     Identifier.setKind(II.getTokenID());
+
+    if (&II == Ident__VA_ARGS__)
+      II.setIsPoisoned(CurrentIsPoisoned);
   }
   
   // If this identifier was poisoned, and if it was not produced from a macro

Modified: cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp Sat Jun 30 16:45:28 2012
@@ -109,6 +109,7 @@
   // or if we are about to parse function member template then consume
   // the tokens and store them for parsing at the end of the translation unit.
   if (getLangOpts().DelayedTemplateParsing && 
+      DefinitionKind == FDK_Definition && 
       ((Actions.CurContext->isDependentContext() ||
         TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) && 
         !Actions.IsInsideALocalClassWithinATemplateFunction())) {

Modified: cfe/branches/tooling/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseDecl.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseDecl.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseDecl.cpp Sat Jun 30 16:45:28 2012
@@ -282,14 +282,14 @@
   }
 }
 
-/// \brief Parses a single argument for a declspec, including the 
+/// \brief Parses a single argument for a declspec, including the
 /// surrounding parens.
-void Parser::ParseMicrosoftDeclSpecWithSingleArg(IdentifierInfo *AttrName, 
+void Parser::ParseMicrosoftDeclSpecWithSingleArg(IdentifierInfo *AttrName,
                                                  SourceLocation AttrNameLoc,
                                                  ParsedAttributes &Attrs)
 {
   BalancedDelimiterTracker T(*this, tok::l_paren);
-  if (T.expectAndConsume(diag::err_expected_lparen_after, 
+  if (T.expectAndConsume(diag::err_expected_lparen_after,
                          AttrName->getNameStart(), tok::r_paren))
     return;
 
@@ -299,13 +299,13 @@
     return;
   }
   Expr *ExprList = ArgExpr.take();
-  Attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, SourceLocation(), 
+  Attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, SourceLocation(),
                &ExprList, 1, AttributeList::AS_Declspec);
 
   T.consumeClose();
 }
 
-/// \brief Determines whether a declspec is a "simple" one requiring no 
+/// \brief Determines whether a declspec is a "simple" one requiring no
 /// arguments.
 bool Parser::IsSimpleMicrosoftDeclSpec(IdentifierInfo *Ident) {
   return llvm::StringSwitch<bool>(Ident->getName())
@@ -326,10 +326,10 @@
     .Default(false);
 }
 
-/// \brief Attempts to parse a declspec which is not simple (one that takes 
+/// \brief Attempts to parse a declspec which is not simple (one that takes
 /// parameters).  Will return false if we properly handled the declspec, or
 /// true if it is an unknown declspec.
-void Parser::ParseComplexMicrosoftDeclSpec(IdentifierInfo *Ident, 
+void Parser::ParseComplexMicrosoftDeclSpec(IdentifierInfo *Ident,
                                            SourceLocation Loc,
                                            ParsedAttributes &Attrs) {
   // Try to handle the easy case first -- these declspecs all take a single
@@ -341,27 +341,27 @@
       .Default(false)) {
     ParseMicrosoftDeclSpecWithSingleArg(Ident, Loc, Attrs);
   } else if (Ident->getName() == "deprecated") {
-    // The deprecated declspec has an optional single argument, so we will 
-    // check for a l-paren to decide whether we should parse an argument or 
+    // The deprecated declspec has an optional single argument, so we will
+    // check for a l-paren to decide whether we should parse an argument or
     // not.
     if (Tok.getKind() == tok::l_paren)
       ParseMicrosoftDeclSpecWithSingleArg(Ident, Loc, Attrs);
     else
-      Attrs.addNew(Ident, Loc, 0, Loc, 0, SourceLocation(), 0, 0, 
+      Attrs.addNew(Ident, Loc, 0, Loc, 0, SourceLocation(), 0, 0,
                    AttributeList::AS_Declspec);
   } else if (Ident->getName() == "property") {
     // The property declspec is more complex in that it can take one or two
-    // assignment expressions as a parameter, but the lhs of the assignment 
+    // assignment expressions as a parameter, but the lhs of the assignment
     // must be named get or put.
     //
-    // For right now, we will just skip to the closing right paren of the 
+    // For right now, we will just skip to the closing right paren of the
     // property expression.
     //
     // FIXME: we should deal with __declspec(property) at some point because it
     // is used in the platform SDK headers for the Parallel Patterns Library
     // and ATL.
     BalancedDelimiterTracker T(*this, tok::l_paren);
-    if (T.expectAndConsume(diag::err_expected_lparen_after, 
+    if (T.expectAndConsume(diag::err_expected_lparen_after,
                            Ident->getNameStart(), tok::r_paren))
       return;
     T.skipToEnd();
@@ -370,7 +370,7 @@
     // attribute and allowing sema to warn about it, we will warn here instead.
     // This is because some attributes have multiple spellings, but we need to
     // disallow that for declspecs (such as align vs aligned).  If we made the
-    // attribute, we'd have to split the valid declspec spelling logic into 
+    // attribute, we'd have to split the valid declspec spelling logic into
     // both locations.
     Diag(Loc, diag::warn_ms_declspec_unknown) << Ident;
 
@@ -393,17 +393,17 @@
 
   ConsumeToken();
   BalancedDelimiterTracker T(*this, tok::l_paren);
-  if (T.expectAndConsume(diag::err_expected_lparen_after, "__declspec", 
+  if (T.expectAndConsume(diag::err_expected_lparen_after, "__declspec",
                          tok::r_paren))
     return;
 
-  // An empty declspec is perfectly legal and should not warn.  Additionally, 
+  // An empty declspec is perfectly legal and should not warn.  Additionally,
   // you can specify multiple attributes per declspec.
   while (Tok.getKind() != tok::r_paren) {
     // We expect either a well-known identifier or a generic string.  Anything
     // else is a malformed declspec.
     bool IsString = Tok.getKind() == tok::string_literal ? true : false;
-    if (!IsString && Tok.getKind() != tok::identifier && 
+    if (!IsString && Tok.getKind() != tok::identifier &&
         Tok.getKind() != tok::kw_restrict) {
       Diag(Tok, diag::err_ms_declspec_type);
       T.skipToEnd();
@@ -426,15 +426,15 @@
       AttrName = Tok.getIdentifierInfo();
       AttrNameLoc = ConsumeToken();
     }
-  
+
     if (IsString || IsSimpleMicrosoftDeclSpec(AttrName))
-      // If we have a generic string, we will allow it because there is no 
-      // documented list of allowable string declspecs, but we know they exist 
+      // If we have a generic string, we will allow it because there is no
+      // documented list of allowable string declspecs, but we know they exist
       // (for instance, SAL declspecs in older versions of MSVC).
       //
-      // Alternatively, if the identifier is a simple one, then it requires no 
+      // Alternatively, if the identifier is a simple one, then it requires no
       // arguments and can be turned into an attribute directly.
-      Attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, SourceLocation(), 
+      Attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, SourceLocation(),
                    0, 0, AttributeList::AS_Declspec);
     else
       ParseComplexMicrosoftDeclSpec(AttrName, AttrNameLoc, Attrs);
@@ -481,42 +481,42 @@
   switch(Tok.getKind()) {
     // OpenCL qualifiers:
     case tok::kw___private:
-    case tok::kw_private: 
+    case tok::kw_private:
       DS.getAttributes().addNewInteger(
-          Actions.getASTContext(), 
+          Actions.getASTContext(),
           PP.getIdentifierInfo("address_space"), Loc, 0);
       break;
-      
+
     case tok::kw___global:
       DS.getAttributes().addNewInteger(
           Actions.getASTContext(),
           PP.getIdentifierInfo("address_space"), Loc, LangAS::opencl_global);
       break;
-      
+
     case tok::kw___local:
       DS.getAttributes().addNewInteger(
           Actions.getASTContext(),
           PP.getIdentifierInfo("address_space"), Loc, LangAS::opencl_local);
       break;
-      
+
     case tok::kw___constant:
       DS.getAttributes().addNewInteger(
           Actions.getASTContext(),
           PP.getIdentifierInfo("address_space"), Loc, LangAS::opencl_constant);
       break;
-      
+
     case tok::kw___read_only:
       DS.getAttributes().addNewInteger(
-          Actions.getASTContext(), 
+          Actions.getASTContext(),
           PP.getIdentifierInfo("opencl_image_access"), Loc, CLIA_read_only);
       break;
-      
+
     case tok::kw___write_only:
       DS.getAttributes().addNewInteger(
-          Actions.getASTContext(), 
+          Actions.getASTContext(),
           PP.getIdentifierInfo("opencl_image_access"), Loc, CLIA_write_only);
       break;
-      
+
     case tok::kw___read_write:
       DS.getAttributes().addNewInteger(
           Actions.getASTContext(),
@@ -597,21 +597,21 @@
 
   if (AfterMinor == ActualLength) {
     ConsumeToken();
-    
+
     // We had major.minor.
     if (Major == 0 && Minor == 0) {
       Diag(Tok, diag::err_zero_version);
       return VersionTuple();
     }
 
-    return VersionTuple(Major, Minor);      
+    return VersionTuple(Major, Minor);
   }
 
   // If what follows is not a '.', we have a problem.
   if (ThisTokBegin[AfterMinor] != '.') {
     Diag(Tok, diag::err_expected_version);
     SkipUntil(tok::comma, tok::r_paren, true, true, true);
-    return VersionTuple();    
+    return VersionTuple();
   }
 
   // Parse the subminor version.
@@ -706,7 +706,7 @@
       if (UnavailableLoc.isValid()) {
         Diag(KeywordLoc, diag::err_availability_redundant)
           << Keyword << SourceRange(UnavailableLoc);
-      } 
+      }
       UnavailableLoc = KeywordLoc;
 
       if (Tok.isNot(tok::comma))
@@ -714,8 +714,8 @@
 
       ConsumeToken();
       continue;
-    } 
-    
+    }
+
     if (Tok.isNot(tok::equal)) {
       Diag(Tok, diag::err_expected_equal_after)
         << Keyword;
@@ -732,10 +732,10 @@
       MessageExpr = ParseStringLiteralExpression();
       break;
     }
-    
+
     SourceRange VersionRange;
     VersionTuple Version = ParseVersionTuple(VersionRange);
-    
+
     if (Version.empty()) {
       SkipUntil(tok::r_paren);
       return;
@@ -748,13 +748,13 @@
       Index = Deprecated;
     else if (Keyword == Ident_obsoleted)
       Index = Obsoleted;
-    else 
+    else
       Index = Unknown;
 
     if (Index < Unknown) {
       if (!Changes[Index].KeywordLoc.isInvalid()) {
         Diag(KeywordLoc, diag::err_availability_redundant)
-          << Keyword 
+          << Keyword
           << SourceRange(Changes[Index].KeywordLoc,
                          Changes[Index].VersionRange.getEnd());
       }
@@ -800,13 +800,13 @@
   }
 
   // Record this attribute
-  attrs.addNew(&Availability, 
-               SourceRange(AvailabilityLoc, T.getCloseLocation()), 
+  attrs.addNew(&Availability,
+               SourceRange(AvailabilityLoc, T.getCloseLocation()),
                0, AvailabilityLoc,
                Platform, PlatformLoc,
                Changes[Introduced],
                Changes[Deprecated],
-               Changes[Obsoleted], 
+               Changes[Obsoleted],
                UnavailableLoc, MessageExpr.take(),
                AttributeList::AS_GNU);
 }
@@ -848,14 +848,14 @@
                                                 Class.TagOrTemplate);
   if (!Class.LateParsedDeclarations.empty()) {
     // Allow 'this' within late-parsed attributes.
-    Sema::CXXThisScopeRAII ThisScope(Actions, Class.TagOrTemplate, 
+    Sema::CXXThisScopeRAII ThisScope(Actions, Class.TagOrTemplate,
                                      /*TypeQuals=*/0);
-    
+
     for (unsigned i = 0, ni = Class.LateParsedDeclarations.size(); i < ni; ++i){
       Class.LateParsedDeclarations[i]->ParseLexedAttributes();
     }
   }
-  
+
   if (!AlreadyHasClassScope)
     Actions.ActOnFinishDelayedMemberDeclarations(getCurScope(),
                                                  Class.TagOrTemplate);
@@ -877,7 +877,7 @@
 /// \brief Finish parsing an attribute for which parsing was delayed.
 /// This will be called at the end of parsing a class declaration
 /// for each LateParsedAttribute. We consume the saved tokens and
-/// create an attribute with the arguments filled in. We add this 
+/// create an attribute with the arguments filled in. We add this
 /// to the Attribute list for the decl.
 void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
                                  bool EnterScope, bool OnDefinition) {
@@ -992,10 +992,10 @@
 
   BalancedDelimiterTracker T(*this, tok::l_paren);
   T.consumeOpen();
-  
+
   ExprVector ArgExprs(Actions);
   bool ArgExprsOk = true;
-  
+
   // now parse the list of expressions
   while (Tok.isNot(tok::r_paren)) {
     ExprResult ArgExpr(ParseAssignmentExpression());
@@ -1082,7 +1082,7 @@
   // Must temporarily exit the objective-c container scope for
   // parsing c none objective-c decls.
   ObjCDeclContextSwitch ObjCDC(*this);
-  
+
   Decl *SingleDecl = 0;
   Decl *OwnedType = 0;
   switch (Tok.getKind()) {
@@ -1099,7 +1099,7 @@
       SingleDecl = ParseNamespace(Context, DeclEnd, InlineLoc);
       break;
     }
-    return ParseSimpleDeclaration(Stmts, Context, DeclEnd, attrs, 
+    return ParseSimpleDeclaration(Stmts, Context, DeclEnd, attrs,
                                   true);
   case tok::kw_namespace:
     ProhibitAttributes(attrs);
@@ -1117,7 +1117,7 @@
   default:
     return ParseSimpleDeclaration(Stmts, Context, DeclEnd, attrs, true);
   }
-  
+
   // This routine returns a DeclGroup, if the thing we parsed only contains a
   // single decl, convert it now. Alias declarations can also declare a type;
   // include that too if it is present.
@@ -1162,8 +1162,8 @@
     DS.complete(TheDecl);
     return Actions.ConvertDeclToDeclGroup(TheDecl);
   }
-  
-  return ParseDeclGroup(DS, Context, /*FunctionDefs=*/ false, &DeclEnd, FRI);  
+
+  return ParseDeclGroup(DS, Context, /*FunctionDefs=*/ false, &DeclEnd, FRI);
 }
 
 /// Returns true if this might be the start of a declarator, or a common typo
@@ -1323,7 +1323,7 @@
       // declaration.  We have to check this because __attribute__ might be the
       // start of a function definition in GCC-extended K&R C.
       !isDeclarationAfterDeclarator()) {
-    
+
     if (isStartOfFunctionDefinition(D)) {
       if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
         Diag(Tok, diag::err_function_declared_typedef);
@@ -1336,7 +1336,7 @@
         ParseFunctionDefinition(D, ParsedTemplateInfo(), &LateParsedAttrs);
       return Actions.ConvertDeclToDeclGroup(TheDecl);
     }
-    
+
     if (isDeclarationSpecifier()) {
       // If there is an invalid declaration specifier right after the function
       // prototype, then we must be in a missing semicolon case where this isn't
@@ -1412,7 +1412,7 @@
       Decl *ThisDecl = ParseDeclarationAfterDeclarator(D);
       D.complete(ThisDecl);
       if (ThisDecl)
-        DeclsInGroup.push_back(ThisDecl);   
+        DeclsInGroup.push_back(ThisDecl);
     }
   }
 
@@ -1496,7 +1496,7 @@
   case ParsedTemplateInfo::NonTemplate:
     ThisDecl = Actions.ActOnDeclarator(getCurScope(), D);
     break;
-      
+
   case ParsedTemplateInfo::Template:
   case ParsedTemplateInfo::ExplicitSpecialization:
     ThisDecl = Actions.ActOnTemplateDeclarator(getCurScope(),
@@ -1505,9 +1505,9 @@
                                           TemplateInfo.TemplateParams->size()),
                                                D);
     break;
-      
+
   case ParsedTemplateInfo::ExplicitInstantiation: {
-    DeclResult ThisRes 
+    DeclResult ThisRes
       = Actions.ActOnExplicitInstantiation(getCurScope(),
                                            TemplateInfo.ExternLoc,
                                            TemplateInfo.TemplateLoc,
@@ -1516,7 +1516,7 @@
       SkipUntil(tok::semi, true, true);
       return 0;
     }
-    
+
     ThisDecl = ThisRes.get();
     break;
     }
@@ -1552,7 +1552,7 @@
         cutOffParsing();
         return 0;
       }
-      
+
       ExprResult Init(ParseInitializer());
 
       if (getLangOpts().CPlusPlus && D.getCXXScopeSpec().isSet()) {
@@ -1857,7 +1857,7 @@
     }
   }
 
-  // This is almost certainly an invalid type name. Let the action emit a 
+  // This is almost certainly an invalid type name. Let the action emit a
   // diagnostic and attempt to recover.
   ParsedType T;
   IdentifierInfo *II = Tok.getIdentifierInfo();
@@ -1880,7 +1880,7 @@
       // There may be other declaration specifiers after this.
       return true;
     }
-    
+
     // Fall through; the action had no suggestion for us.
   } else {
     // The action did not emit a diagnostic, so emit one now.
@@ -1905,7 +1905,7 @@
 ///
 /// \param Context the declarator context, which is one of the
 /// Declarator::TheContext enumerator values.
-Parser::DeclSpecContext 
+Parser::DeclSpecContext
 Parser::getDeclSpecContextFromDeclaratorContext(unsigned Context) {
   if (Context == Declarator::MemberContext)
     return DSC_class;
@@ -2025,7 +2025,7 @@
     DS.SetRangeStart(Tok.getLocation());
     DS.SetRangeEnd(Tok.getLocation());
   }
-  
+
   bool EnteringContext = (DSContext == DSC_class || DSContext == DSC_top_level);
   bool AttrsLastTime = false;
   ParsedAttributesWithRange attrs(AttrFactory);
@@ -2063,7 +2063,7 @@
 
       ParseCXX11Attributes(attrs);
       AttrsLastTime = true;
-      continue; 
+      continue;
 
     case tok::code_completion: {
       Sema::ParserCompletionContext CCC = Sema::PCC_Namespace;
@@ -2075,25 +2075,25 @@
                                           Scope::FunctionPrototypeScope |
                                           Scope::AtCatchScope)) == 0;
         bool AllowNestedNameSpecifiers
-          = DSContext == DSC_top_level || 
+          = DSContext == DSC_top_level ||
             (DSContext == DSC_class && DS.isFriendSpecified());
 
         Actions.CodeCompleteDeclSpec(getCurScope(), DS,
-                                     AllowNonIdentifiers, 
+                                     AllowNonIdentifiers,
                                      AllowNestedNameSpecifiers);
         return cutOffParsing();
-      } 
-      
+      }
+
       if (getCurScope()->getFnParent() || getCurScope()->getBlockParent())
         CCC = Sema::PCC_LocalDeclarationSpecifiers;
       else if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
-        CCC = DSContext == DSC_class? Sema::PCC_MemberTemplate 
+        CCC = DSContext == DSC_class? Sema::PCC_MemberTemplate
                                     : Sema::PCC_Template;
       else if (DSContext == DSC_class)
         CCC = Sema::PCC_Class;
       else if (CurParsedObjCImpl)
         CCC = Sema::PCC_ObjCImplementation;
-      
+
       Actions.CodeCompleteOrdinaryName(getCurScope(), CCC);
       return cutOffParsing();
     }
@@ -2140,10 +2140,10 @@
         //
         //   the name is instead considered to name the constructor of
         //   class C.
-        // 
+        //
         // Thus, if the template-name is actually the constructor
         // name, then the code is ill-formed; this interpretation is
-        // reinforced by the NAD status of core issue 635. 
+        // reinforced by the NAD status of core issue 635.
         TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Next);
         if ((DSContext == DSC_top_level ||
              (DSContext == DSC_class && DS.isFriendSpecified())) &&
@@ -2180,7 +2180,7 @@
         if (Tok.getAnnotationValue()) {
           ParsedType T = getTypeAnnotation(Tok);
           isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename,
-                                         Tok.getAnnotationEndLoc(), 
+                                         Tok.getAnnotationEndLoc(),
                                          PrevSpec, DiagID, T);
         }
         else
@@ -2196,7 +2196,7 @@
       // check whether this is a constructor declaration.
       if ((DSContext == DSC_top_level ||
            (DSContext == DSC_class && DS.isFriendSpecified())) &&
-          Actions.isCurrentClassName(*Next.getIdentifierInfo(), getCurScope(), 
+          Actions.isCurrentClassName(*Next.getIdentifierInfo(), getCurScope(),
                                      &SS)) {
         if (isConstructorDeclarator())
           goto DoneWithDeclSpec;
@@ -2249,7 +2249,7 @@
                                        DiagID, T);
       } else
         DS.SetTypeSpecError();
-      
+
       if (isInvalid)
         break;
 
@@ -2258,10 +2258,10 @@
 
       // Objective-C supports syntax of the form 'id<proto1,proto2>' where 'id'
       // is a specific typedef and 'itf<proto1,proto2>' where 'itf' is an
-      // Objective-C interface. 
+      // Objective-C interface.
       if (Tok.is(tok::less) && getLangOpts().ObjC1)
         ParseObjCProtocolQualifiers(DS);
-      
+
       continue;
     }
 
@@ -2282,7 +2282,7 @@
 
       // We're done with the declaration-specifiers.
       goto DoneWithDeclSpec;
-        
+
       // typedef-name
     case tok::kw_decltype:
     case tok::identifier: {
@@ -2341,10 +2341,10 @@
 
       // Objective-C supports syntax of the form 'id<proto1,proto2>' where 'id'
       // is a specific typedef and 'itf<proto1,proto2>' where 'itf' is an
-      // Objective-C interface. 
+      // Objective-C interface.
       if (Tok.is(tok::less) && getLangOpts().ObjC1)
         ParseObjCProtocolQualifiers(DS);
-      
+
       // Need to support trailing type qualifiers (e.g. "id<p> const").
       // If a type specifier follows, it will be diagnosed elsewhere.
       continue;
@@ -2497,7 +2497,7 @@
     case tok::kw___module_private__:
       isInvalid = DS.setModulePrivateSpec(Loc, PrevSpec, DiagID);
       break;
-        
+
     // constexpr
     case tok::kw_constexpr:
       isInvalid = DS.SetConstexprSpec(Loc, PrevSpec, DiagID);
@@ -2673,7 +2673,7 @@
       continue;
 
     // OpenCL qualifiers:
-    case tok::kw_private: 
+    case tok::kw_private:
       if (!getLangOpts().OpenCL)
         goto DoneWithDeclSpec;
     case tok::kw___private:
@@ -2685,7 +2685,7 @@
     case tok::kw___read_write:
       ParseOpenCLQualifiers(DS);
       break;
-      
+
     case tok::less:
       // GCC ObjC supports types like "<SomeProtocol>" as a synonym for
       // "id<SomeProtocol>".  This is hopelessly old fashioned and dangerous,
@@ -2697,7 +2697,7 @@
         Diag(Loc, diag::warn_objc_protocol_qualifier_missing_id)
           << FixItHint::CreateInsertion(Loc, "id")
           << SourceRange(Loc, DS.getSourceRange().getEnd());
-      
+
       // Need to support trailing type qualifiers (e.g. "id<p> const").
       // If a type specifier follows, it will be diagnosed elsewhere.
       continue;
@@ -2706,7 +2706,7 @@
     if (isInvalid) {
       assert(PrevSpec && "Method did not return previous specifier!");
       assert(DiagID);
-      
+
       if (DiagID == diag::ext_duplicate_declspec)
         Diag(Tok, DiagID)
           << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation());
@@ -2741,7 +2741,7 @@
 ///
 void Parser::
 ParseStructDeclaration(DeclSpec &DS, FieldCallback &Fields) {
-    
+
   if (Tok.is(tok::kw___extension__)) {
     // __extension__ silences extension warnings in the subexpression.
     ExtensionRAIIObject O(Diags);  // Use RAII to do this.
@@ -2982,7 +2982,7 @@
     Diag(Tok, diag::warn_cxx98_compat_scoped_enum);
     IsScopedUsingClassTag = Tok.is(tok::kw_class);
     ScopedEnumKWLoc = ConsumeToken();
-    
+
     // Attributes are not allowed between these keywords.  Diagnose,
     // but then just treat them like they appeared in the right place.
     ProhibitAttributes(attrs);
@@ -3017,8 +3017,8 @@
     // "enum foo : bar;" is not a potential typo for "enum foo::bar;"
     // if a fixed underlying type is allowed.
     ColonProtectionRAIIObject X(*this, AllowFixedUnderlyingType);
-    
-    if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), 
+
+    if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
                                        /*EnteringContext=*/false))
       return;
 
@@ -3073,20 +3073,20 @@
       // If we're in class scope, this can either be an enum declaration with
       // an underlying type, or a declaration of a bitfield member. We try to
       // use a simple disambiguation scheme first to catch the common cases
-      // (integer literal, sizeof); if it's still ambiguous, we then consider 
-      // anything that's a simple-type-specifier followed by '(' as an 
-      // expression. This suffices because function types are not valid 
+      // (integer literal, sizeof); if it's still ambiguous, we then consider
+      // anything that's a simple-type-specifier followed by '(' as an
+      // expression. This suffices because function types are not valid
       // underlying types anyway.
       TPResult TPR = isExpressionOrTypeSpecifierSimple(NextToken().getKind());
-      // If the next token starts an expression, we know we're parsing a 
+      // If the next token starts an expression, we know we're parsing a
       // bit-field. This is the common case.
       if (TPR == TPResult::True())
         PossibleBitfield = true;
       // If the next token starts a type-specifier-seq, it may be either a
       // a fixed underlying type or the start of a function-style cast in C++;
-      // lookahead one more token to see if it's obvious that we have a 
+      // lookahead one more token to see if it's obvious that we have a
       // fixed underlying type.
-      else if (TPR == TPResult::False() && 
+      else if (TPR == TPResult::False() &&
                GetLookAheadToken(2).getKind() == tok::semi) {
         // Consume the ':'.
         ConsumeToken();
@@ -3124,7 +3124,7 @@
     if (!PossibleBitfield) {
       SourceRange Range;
       BaseType = ParseTypeName(&Range);
-      
+
       if (!getLangOpts().CPlusPlus0x && !getLangOpts().ObjC2)
         Diag(StartLoc, diag::ext_ms_enum_fixed_underlying_type)
           << Range;
@@ -3198,7 +3198,7 @@
     TParams = MultiTemplateParamsArg(TemplateInfo.TemplateParams->data(),
                                      TemplateInfo.TemplateParams->size());
   }
-  
+
   if (TUK == Sema::TUK_Reference)
     ProhibitAttributes(attrs);
 
@@ -3221,38 +3221,38 @@
                                    IsScopedUsingClassTag, BaseType);
 
   if (IsDependent) {
-    // This enum has a dependent nested-name-specifier. Handle it as a 
+    // This enum has a dependent nested-name-specifier. Handle it as a
     // dependent tag.
     if (!Name) {
       DS.SetTypeSpecError();
       Diag(Tok, diag::err_expected_type_name_after_typename);
       return;
     }
-    
+
     TypeResult Type = Actions.ActOnDependentTag(getCurScope(), DeclSpec::TST_enum,
-                                                TUK, SS, Name, StartLoc, 
+                                                TUK, SS, Name, StartLoc,
                                                 NameLoc);
     if (Type.isInvalid()) {
       DS.SetTypeSpecError();
       return;
     }
-    
+
     if (DS.SetTypeSpecType(DeclSpec::TST_typename, StartLoc,
                            NameLoc.isValid() ? NameLoc : StartLoc,
                            PrevSpec, DiagID, Type.get()))
       Diag(StartLoc, DiagID) << PrevSpec;
-    
+
     return;
   }
 
   if (!TagDecl) {
-    // The action failed to produce an enumeration tag. If this is a 
+    // The action failed to produce an enumeration tag. If this is a
     // definition, consume the entire definition.
     if (Tok.is(tok::l_brace) && TUK != Sema::TUK_Reference) {
       ConsumeBrace();
       SkipUntil(tok::r_brace);
     }
-    
+
     DS.SetTypeSpecError();
     return;
   }
@@ -3306,7 +3306,7 @@
     SourceLocation EqualLoc;
     ExprResult AssignedVal;
     ParsingDeclRAIIObject PD(*this, ParsingDeclRAIIObject::NoParent);
-    
+
     if (Tok.is(tok::equal)) {
       EqualLoc = ConsumeToken();
       AssignedVal = ParseConstantExpression();
@@ -3321,18 +3321,18 @@
                                                     attrs.getList(), EqualLoc,
                                                     AssignedVal.release());
     PD.complete(EnumConstDecl);
-    
+
     EnumConstantDecls.push_back(EnumConstDecl);
     LastEnumConstDecl = EnumConstDecl;
 
     if (Tok.is(tok::identifier)) {
       // We're missing a comma between enumerators.
       SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
-      Diag(Loc, diag::err_enumerator_list_missing_comma)      
+      Diag(Loc, diag::err_enumerator_list_missing_comma)
         << FixItHint::CreateInsertion(Loc, ", ");
       continue;
     }
-    
+
     if (Tok.isNot(tok::comma))
       break;
     SourceLocation CommaLoc = ConsumeToken();
@@ -3431,14 +3431,14 @@
   case tok::kw__Decimal64:
   case tok::kw__Decimal128:
   case tok::kw___vector:
-    
+
     // struct-or-union-specifier (C99) or class-specifier (C++)
   case tok::kw_class:
   case tok::kw_struct:
   case tok::kw_union:
     // enum-specifier
   case tok::kw_enum:
-    
+
     // typedef-name
   case tok::annot_typename:
     return true;
@@ -3579,16 +3579,16 @@
       return true;
     if (Tok.is(tok::identifier))
       return false;
-      
+
     // If we're in Objective-C and we have an Objective-C class type followed
-    // by an identifier and then either ':' or ']', in a place where an 
+    // by an identifier and then either ':' or ']', in a place where an
     // expression is permitted, then this is probably a class message send
     // missing the initial '['. In this case, we won't consider this to be
     // the start of a declaration.
-    if (DisambiguatingWithExpression && 
+    if (DisambiguatingWithExpression &&
         isStartOfObjCClassMessageMissingOpenBracket())
       return false;
-      
+
     return isDeclarationSpecifier();
 
   case tok::coloncolon:   // ::foo::bar
@@ -3613,7 +3613,7 @@
 
     // Modules
   case tok::kw___module_private__:
-      
+
     // type-specifiers
   case tok::kw_short:
   case tok::kw_long:
@@ -3683,7 +3683,7 @@
   case tok::annot_typename:
     return !DisambiguatingWithExpression ||
            !isStartOfObjCClassMessageMissingOpenBracket();
-      
+
   case tok::kw___declspec:
   case tok::kw___cdecl:
   case tok::kw___stdcall:
@@ -3713,7 +3713,7 @@
 
   // Parse the C++ scope specifier.
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), 
+  if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
                                      /*EnteringContext=*/true)) {
     TPA.Revert();
     return false;
@@ -3800,10 +3800,10 @@
 /// ParseTypeQualifierListOpt
 ///          type-qualifier-list: [C99 6.7.5]
 ///            type-qualifier
-/// [vendor]   attributes                        
+/// [vendor]   attributes
 ///              [ only if VendorAttributesAllowed=true ]
 ///            type-qualifier-list type-qualifier
-/// [vendor]   type-qualifier-list attributes    
+/// [vendor]   type-qualifier-list attributes
 ///              [ only if VendorAttributesAllowed=true ]
 /// [C++0x]    attribute-specifier[opt] is allowed before cv-qualifier-seq
 ///              [ only if CXX0XAttributesAllowed=true ]
@@ -3831,7 +3831,7 @@
     case tok::code_completion:
       Actions.CodeCompleteTypeQualifiers(DS);
       return cutOffParsing();
-        
+
     case tok::kw_const:
       isInvalid = DS.SetTypeQual(DeclSpec::TQ_const   , Loc, PrevSpec, DiagID,
                                  getLangOpts());
@@ -3846,7 +3846,7 @@
       break;
 
     // OpenCL qualifiers:
-    case tok::kw_private: 
+    case tok::kw_private:
       if (!getLangOpts().OpenCL)
         goto DoneWithTypeQuals;
     case tok::kw___private:
@@ -3952,7 +3952,7 @@
                                      DirectDeclParseFunction DirectDeclParser) {
   if (Diags.hasAllExtensionsSilenced())
     D.setExtension();
-  
+
   // C++ member pointers start with a '::' or a nested-name.
   // Member pointers get special handling, since there's no place for the
   // scope spec in the generic path below.
@@ -4146,7 +4146,7 @@
     if (D.getCXXScopeSpec().isEmpty()) {
       bool EnteringContext = D.getContext() == Declarator::FileContext ||
                              D.getContext() == Declarator::MemberContext;
-      ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), ParsedType(), 
+      ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), ParsedType(),
                                      EnteringContext);
     }
 
@@ -4159,9 +4159,9 @@
 
     // C++0x [dcl.fct]p14:
     //   There is a syntactic ambiguity when an ellipsis occurs at the end
-    //   of a parameter-declaration-clause without a preceding comma. In 
-    //   this case, the ellipsis is parsed as part of the 
-    //   abstract-declarator if the type of the parameter names a template 
+    //   of a parameter-declaration-clause without a preceding comma. In
+    //   this case, the ellipsis is parsed as part of the
+    //   abstract-declarator if the type of the parameter names a template
     //   parameter pack that has not been expanded; otherwise, it is parsed
     //   as part of the parameter-declaration-clause.
     if (Tok.is(tok::ellipsis) && D.getCXXScopeSpec().isEmpty() &&
@@ -4200,9 +4200,9 @@
         AllowConstructorName = (D.getContext() == Declarator::MemberContext);
 
       SourceLocation TemplateKWLoc;
-      if (ParseUnqualifiedId(D.getCXXScopeSpec(), 
-                             /*EnteringContext=*/true, 
-                             /*AllowDestructorName=*/true, 
+      if (ParseUnqualifiedId(D.getCXXScopeSpec(),
+                             /*EnteringContext=*/true,
+                             /*AllowDestructorName=*/true,
                              AllowConstructorName,
                              ParsedType(),
                              TemplateKWLoc,
@@ -4252,6 +4252,8 @@
     // portion is empty), if an abstract-declarator is allowed.
     D.SetIdentifier(0, Tok.getLocation());
   } else {
+    if (Tok.getKind() == tok::annot_pragma_parser_crash)
+      *(volatile int*) 0x11 = 0;
     if (D.getContext() == Declarator::MemberContext)
       Diag(Tok, diag::err_expected_member_name_or_semi)
         << D.getDeclSpec().getSourceRange();
@@ -4298,7 +4300,7 @@
       break;
     }
   }
-} 
+}
 
 /// ParseParenDeclarator - We parsed the declarator D up to a paren.  This is
 /// only called before the identifier, so these are most likely just grouping
@@ -4384,7 +4386,7 @@
     ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
     // Match the ')'.
     T.consumeClose();
-    D.AddTypeInfo(DeclaratorChunk::getParen(T.getOpenLocation(), 
+    D.AddTypeInfo(DeclaratorChunk::getParen(T.getOpenLocation(),
                                             T.getCloseLocation()),
                   attrs, T.getCloseLocation());
 
@@ -4434,7 +4436,7 @@
                                      ParsedAttributes &FirstArgAttrs,
                                      BalancedDelimiterTracker &Tracker,
                                      bool RequiresArg) {
-  assert(getCurScope()->isFunctionPrototypeScope() && 
+  assert(getCurScope()->isFunctionPrototypeScope() &&
          "Should call from a Function scope");
   // lparen is already consumed!
   assert(D.isPastIdentifier() && "Should not call before identifier!");
@@ -4508,16 +4510,16 @@
       }
 
       // C++11 [expr.prim.general]p3:
-      //   If a declaration declares a member function or member function 
-      //   template of a class X, the expression this is a prvalue of type 
+      //   If a declaration declares a member function or member function
+      //   template of a class X, the expression this is a prvalue of type
       //   "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
-      //   and the end of the function-definition, member-declarator, or 
+      //   and the end of the function-definition, member-declarator, or
       //   declarator.
-      bool IsCXX11MemberFunction = 
+      bool IsCXX11MemberFunction =
         getLangOpts().CPlusPlus0x &&
         (D.getContext() == Declarator::MemberContext ||
          (D.getContext() == Declarator::FileContext &&
-          D.getCXXScopeSpec().isValid() && 
+          D.getCXXScopeSpec().isValid() &&
           Actions.CurContext->isRecord()));
       Sema::CXXThisScopeRAII ThisScope(Actions,
                                dyn_cast<CXXRecordDecl>(Actions.CurContext),
@@ -4563,7 +4565,7 @@
                                              DynamicExceptions.size(),
                                              NoexceptExpr.isUsable() ?
                                                NoexceptExpr.get() : 0,
-                                             Tracker.getOpenLocation(), 
+                                             Tracker.getOpenLocation(),
                                              EndLoc, D,
                                              TrailingReturnType),
                 FnAttrs, EndLoc);
@@ -4788,7 +4790,7 @@
           // Consume the '='.
           ConsumeToken();
 
-          // The argument isn't actually potentially evaluated unless it is 
+          // The argument isn't actually potentially evaluated unless it is
           // used.
           EnterExpressionEvaluationContext Eval(Actions,
                                               Sema::PotentiallyEvaluatedIfUsed,
@@ -4820,7 +4822,7 @@
     if (Tok.isNot(tok::comma)) {
       if (Tok.is(tok::ellipsis)) {
         EllipsisLoc = ConsumeToken();     // Consume the ellipsis.
-        
+
         if (!getLangOpts().CPlusPlus) {
           // We have ellipsis without a preceding ',', which is ill-formed
           // in C. Complain and provide the fix.
@@ -4828,7 +4830,7 @@
             << FixItHint::CreateInsertion(EllipsisLoc, ", ");
         }
       }
-      
+
       break;
     }
 
@@ -4858,7 +4860,7 @@
     T.consumeClose();
     ParsedAttributes attrs(AttrFactory);
     MaybeParseCXX0XAttributes(attrs);
-    
+
     // Remember that we parsed the empty array type.
     ExprResult NumElements;
     D.AddTypeInfo(DeclaratorChunk::getArray(0, false, false, 0,

Modified: cfe/branches/tooling/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/Parser.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/Parser.cpp (original)
+++ cfe/branches/tooling/lib/Parse/Parser.cpp Sat Jun 30 16:45:28 2012
@@ -959,6 +959,7 @@
   // In delayed template parsing mode, for function template we consume the
   // tokens and store them for late parsing at the end of the translation unit.
   if (getLangOpts().DelayedTemplateParsing &&
+      Tok.isNot(tok::equal) &&
       TemplateInfo.Kind == ParsedTemplateInfo::Template) {
     MultiTemplateParamsArg TemplateParameterLists(Actions,
                                          TemplateInfo.TemplateParams->data(),

Modified: cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp Sat Jun 30 16:45:28 2012
@@ -367,6 +367,13 @@
                                            Expr **args, unsigned nargs,
                                            SourceLocation StartLoc=SourceLocation(),
                                            SourceLocation EndLoc=SourceLocation());
+    
+    Expr *SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavor,
+                                        QualType msgSendType, 
+                                        QualType returnType, 
+                                        SmallVectorImpl<QualType> &ArgTypes,
+                                        SmallVectorImpl<Expr*> &MsgExprs,
+                                        ObjCMethodDecl *Method);
 
     Stmt *SynthMessageExpr(ObjCMessageExpr *Exp,
                            SourceLocation StartLoc=SourceLocation(),
@@ -3055,6 +3062,110 @@
   return Context->getTagDeclType(ConstantStringDecl);
 }
 
+/// getFunctionSourceLocation - returns start location of a function
+/// definition. Complication arises when function has declared as
+/// extern "C" or extern "C" {...}
+static SourceLocation getFunctionSourceLocation (RewriteModernObjC &R,
+                                                 FunctionDecl *FD) {
+  if (FD->isExternC()  && !FD->isMain()) {
+    const DeclContext *DC = FD->getDeclContext();
+    if (const LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(DC))
+      // if it is extern "C" {...}, return function decl's own location.
+      if (!LSD->getRBraceLoc().isValid())
+        return LSD->getExternLoc();
+  }
+  if (FD->getStorageClassAsWritten() != SC_None)
+    R.RewriteBlockLiteralFunctionDecl(FD);
+  return FD->getTypeSpecStartLoc();
+}
+
+/// SynthMsgSendStretCallExpr - This routine translates message expression
+/// into a call to objc_msgSend_stret() entry point. Tricky part is that
+/// nil check on receiver must be performed before calling objc_msgSend_stret.
+/// MsgSendStretFlavor - function declaration objc_msgSend_stret(...)
+/// msgSendType - function type of objc_msgSend_stret(...)
+/// returnType - Result type of the method being synthesized.
+/// ArgTypes - type of the arguments passed to objc_msgSend_stret, starting with receiver type.
+/// MsgExprs - list of argument expressions being passed to objc_msgSend_stret, 
+/// starting with receiver.
+/// Method - Method being rewritten.
+Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavor,
+                                                 QualType msgSendType, 
+                                                 QualType returnType, 
+                                                 SmallVectorImpl<QualType> &ArgTypes,
+                                                 SmallVectorImpl<Expr*> &MsgExprs,
+                                                 ObjCMethodDecl *Method) {
+  // Now do the "normal" pointer to function cast.
+  QualType castType = getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(),
+                                            Method ? Method->isVariadic() : false);
+  castType = Context->getPointerType(castType);
+  
+  // build type for containing the objc_msgSend_stret object.
+  static unsigned stretCount=0;
+  std::string name = "__Stret"; name += utostr(stretCount);
+  std::string str = "struct "; str += name;
+  str += " {\n\t";
+  str += name;
+  str += "(id receiver, SEL sel";
+  for (unsigned i = 2; i < ArgTypes.size(); i++) {
+    std::string ArgName = "arg"; ArgName += utostr(i);
+    ArgTypes[i].getAsStringInternal(ArgName, Context->getPrintingPolicy());
+    str += ", "; str += ArgName;
+  }
+  // could be vararg.
+  for (unsigned i = ArgTypes.size(); i < MsgExprs.size(); i++) {
+    std::string ArgName = "arg"; ArgName += utostr(i);
+    MsgExprs[i]->getType().getAsStringInternal(ArgName,
+                                               Context->getPrintingPolicy());
+    str += ", "; str += ArgName;
+  }
+  
+  str += ") {\n";
+  str += "\t  if (receiver == 0)\n";
+  str += "\t    memset((void*)&s, 0, sizeof(s));\n";
+  str += "\t  else\n";
+  str += "\t    s = (("; str += castType.getAsString(Context->getPrintingPolicy());
+  str += ")(void *)objc_msgSend_stret)(receiver, sel";
+  for (unsigned i = 2; i < ArgTypes.size(); i++) {
+    str += ", arg"; str += utostr(i);
+  }
+  // could be vararg.
+  for (unsigned i = ArgTypes.size(); i < MsgExprs.size(); i++) {
+    str += ", arg"; str += utostr(i);
+  }
+  
+  str += ");\n";
+  str += "\t}\n";
+  str += "\t"; str += returnType.getAsString(Context->getPrintingPolicy());
+  str += " s;\n";
+  str += "};\n\n";
+  SourceLocation FunLocStart = getFunctionSourceLocation(*this, CurFunctionDef);
+  InsertText(FunLocStart, str);
+  ++stretCount;
+  
+  // AST for __Stretn(receiver, args).s;
+  IdentifierInfo *ID = &Context->Idents.get(name);
+  FunctionDecl *FD = FunctionDecl::Create(*Context, TUDecl, SourceLocation(),
+                                          SourceLocation(), ID, castType, 0, SC_Extern,
+                                          SC_None, false, false);
+  DeclRefExpr *DRE = new (Context) DeclRefExpr(FD, false, castType, VK_RValue,
+                                               SourceLocation());
+  CallExpr *STCE = new (Context) CallExpr(*Context, DRE, &MsgExprs[0], MsgExprs.size(),
+                                          castType, VK_LValue, SourceLocation());
+  
+  FieldDecl *FieldD = FieldDecl::Create(*Context, 0, SourceLocation(),
+                                    SourceLocation(),
+                                    &Context->Idents.get("s"),
+                                    returnType, 0,
+                                    /*BitWidth=*/0, /*Mutable=*/true,
+                                    ICIS_NoInit);
+  MemberExpr *ME = new (Context) MemberExpr(STCE, false, FieldD, SourceLocation(),
+                                            FieldD->getType(), VK_LValue,
+                                            OK_Ordinary);
+
+  return ME;
+}
+
 Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
                                     SourceLocation StartLoc,
                                     SourceLocation EndLoc) {
@@ -3443,29 +3554,10 @@
     // expression which dictate which one to envoke depending on size of
     // method's return type.
 
-    // Create a reference to the objc_msgSend_stret() declaration.
-    DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor,
-                                                   false, msgSendType,
-                                                   VK_LValue, SourceLocation());
-    // Need to cast objc_msgSend_stret to "void *" (see above comment).
-    cast = NoTypeInfoCStyleCastExpr(Context,
-                                    Context->getPointerType(Context->VoidTy),
-                                    CK_BitCast, STDRE);
-    // Now do the "normal" pointer to function cast.
-    castType = getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(),
-      Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false);
-    castType = Context->getPointerType(castType);
-    cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
-                                    cast);
-
-    // Don't forget the parens to enforce the proper binding.
-    PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
-
-    FT = msgSendType->getAs<FunctionType>();
-    CallExpr *STCE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
-                                            MsgExprs.size(),
-                                            FT->getResultType(), VK_RValue,
-                                            SourceLocation());
+    Expr *STCE = SynthMsgSendStretCallExpr(MsgSendStretFlavor, 
+                                           msgSendType, returnType, 
+                                           ArgTypes, MsgExprs,
+                                           Exp->getMethodDecl());
 
     // Build sizeof(returnType)
     UnaryExprOrTypeTraitExpr *sizeofExpr =
@@ -4152,23 +4244,6 @@
   return S;
 }
 
-/// getFunctionSourceLocation - returns start location of a function
-/// definition. Complication arises when function has declared as
-/// extern "C" or extern "C" {...}
-static SourceLocation getFunctionSourceLocation (RewriteModernObjC &R,
-                                                 FunctionDecl *FD) {
-  if (FD->isExternC()  && !FD->isMain()) {
-    const DeclContext *DC = FD->getDeclContext();
-    if (const LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(DC))
-      // if it is extern "C" {...}, return function decl's own location.
-      if (!LSD->getRBraceLoc().isValid())
-        return LSD->getExternLoc();
-  }
-  if (FD->getStorageClassAsWritten() != SC_None)
-    R.RewriteBlockLiteralFunctionDecl(FD);
-  return FD->getTypeSpecStartLoc();
-}
-
 void RewriteModernObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
                                           StringRef FunName) {
   bool RewriteSC = (GlobalVarDecl &&
@@ -5884,6 +5959,7 @@
     Preamble += "#define __block\n";
     Preamble += "#define __weak\n";
   }
+  Preamble += "\nextern \"C\" void * memset(void *b, int c, unsigned long len);\n";
   
   // Declarations required for modern objective-c array and dictionary literals.
   Preamble += "\n#include <stdarg.h>\n";

Modified: cfe/branches/tooling/lib/Rewrite/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Rewrite/RewriteObjC.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Rewrite/RewriteObjC.cpp (original)
+++ cfe/branches/tooling/lib/Rewrite/RewriteObjC.cpp Sat Jun 30 16:45:28 2012
@@ -355,7 +355,12 @@
                                            Expr **args, unsigned nargs,
                                            SourceLocation StartLoc=SourceLocation(),
                                            SourceLocation EndLoc=SourceLocation());
-
+    CallExpr *SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavor,
+                                        QualType msgSendType, 
+                                        QualType returnType, 
+                                        SmallVectorImpl<QualType> &ArgTypes,
+                                        SmallVectorImpl<Expr*> &MsgExprs,
+                                        ObjCMethodDecl *Method);
     Stmt *SynthMessageExpr(ObjCMessageExpr *Exp,
                            SourceLocation StartLoc=SourceLocation(),
                            SourceLocation EndLoc=SourceLocation());
@@ -2633,6 +2638,40 @@
   return Context->getTagDeclType(ConstantStringDecl);
 }
 
+CallExpr *RewriteObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavor,
+                                                QualType msgSendType, 
+                                                QualType returnType, 
+                                                SmallVectorImpl<QualType> &ArgTypes,
+                                                SmallVectorImpl<Expr*> &MsgExprs,
+                                                ObjCMethodDecl *Method) {
+  // Create a reference to the objc_msgSend_stret() declaration.
+  DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor,
+                                                 false, msgSendType,
+                                                 VK_LValue, SourceLocation());
+  // Need to cast objc_msgSend_stret to "void *" (see above comment).
+  CastExpr *cast = NoTypeInfoCStyleCastExpr(Context,
+                                  Context->getPointerType(Context->VoidTy),
+                                  CK_BitCast, STDRE);
+  // Now do the "normal" pointer to function cast.
+  QualType castType = getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(),
+                                            Method ? Method->isVariadic() : false);
+  castType = Context->getPointerType(castType);
+  cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
+                                            cast);
+  
+  // Don't forget the parens to enforce the proper binding.
+  ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
+  
+  const FunctionType *FT = msgSendType->getAs<FunctionType>();
+  CallExpr *STCE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
+                                          MsgExprs.size(),
+                                          FT->getResultType(), VK_RValue,
+                                          SourceLocation());
+  return STCE;
+  
+}
+
+
 Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
                                     SourceLocation StartLoc,
                                     SourceLocation EndLoc) {
@@ -3023,30 +3062,11 @@
     // call to objc_msgSend_stret and hang both varieties on a conditional
     // expression which dictate which one to envoke depending on size of
     // method's return type.
-
-    // Create a reference to the objc_msgSend_stret() declaration.
-    DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor,
-                                                   false, msgSendType,
-                                                   VK_LValue, SourceLocation());
-    // Need to cast objc_msgSend_stret to "void *" (see above comment).
-    cast = NoTypeInfoCStyleCastExpr(Context,
-                                    Context->getPointerType(Context->VoidTy),
-                                    CK_BitCast, STDRE);
-    // Now do the "normal" pointer to function cast.
-    castType = getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(),
-      Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false);
-    castType = Context->getPointerType(castType);
-    cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
-                                    cast);
-
-    // Don't forget the parens to enforce the proper binding.
-    PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
-
-    FT = msgSendType->getAs<FunctionType>();
-    CallExpr *STCE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
-                                            MsgExprs.size(),
-                                            FT->getResultType(), VK_RValue,
-                                            SourceLocation());
+    
+    CallExpr *STCE = SynthMsgSendStretCallExpr(MsgSendStretFlavor, 
+                                               msgSendType, returnType, 
+                                               ArgTypes, MsgExprs,
+                                               Exp->getMethodDecl());
 
     // Build sizeof(returnType)
     UnaryExprOrTypeTraitExpr *sizeofExpr =

Modified: cfe/branches/tooling/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/Sema.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/Sema.cpp (original)
+++ cfe/branches/tooling/lib/Sema/Sema.cpp Sat Jun 30 16:45:28 2012
@@ -682,9 +682,17 @@
           if (isa<CXXMethodDecl>(DiagD))
             Diag(DiagD->getLocation(), diag::warn_unneeded_member_function)
                   << DiagD->getDeclName();
-          else
-            Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
-                  << /*function*/0 << DiagD->getDeclName();
+          else {
+            if (FD->getStorageClassAsWritten() == SC_Static &&
+                !FD->isInlineSpecified() &&
+                !SourceMgr.isFromMainFile(
+                   SourceMgr.getExpansionLoc(FD->getLocation())))
+              Diag(DiagD->getLocation(), diag::warn_unneeded_static_internal_decl)
+                << DiagD->getDeclName();
+            else
+              Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
+                   << /*function*/0 << DiagD->getDeclName();
+          }
         } else {
           Diag(DiagD->getLocation(),
                isa<CXXMethodDecl>(DiagD) ? diag::warn_unused_member_function

Modified: cfe/branches/tooling/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaChecking.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaChecking.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaChecking.cpp Sat Jun 30 16:45:28 2012
@@ -405,6 +405,11 @@
 #undef GET_NEON_IMMEDIATE_CHECK
   };
 
+  // We can't check the value of a dependent argument.
+  if (TheCall->getArg(i)->isTypeDependent() ||
+      TheCall->getArg(i)->isValueDependent())
+    return false;
+
   // Check that the immediate argument is actually a constant.
   if (SemaBuiltinConstantArg(TheCall, i, Result))
     return true;
@@ -1478,7 +1483,11 @@
   // constant integers.
   for (unsigned i = 1; i != NumArgs; ++i) {
     Expr *Arg = TheCall->getArg(i);
-    
+
+    // We can't check the value of a dependent argument.
+    if (Arg->isTypeDependent() || Arg->isValueDependent())
+      continue;
+
     llvm::APSInt Result;
     if (SemaBuiltinConstantArg(TheCall, i, Result))
       return true;
@@ -1523,7 +1532,12 @@
 // For compatibility check 0-3, llvm only handles 0 and 2.
 bool Sema::SemaBuiltinObjectSize(CallExpr *TheCall) {
   llvm::APSInt Result;
-  
+
+  // We can't check the value of a dependent argument.
+  if (TheCall->getArg(1)->isTypeDependent() ||
+      TheCall->getArg(1)->isValueDependent())
+    return false;
+
   // Check constant-ness first.
   if (SemaBuiltinConstantArg(TheCall, 1, Result))
     return true;

Modified: cfe/branches/tooling/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDecl.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDecl.cpp Sat Jun 30 16:45:28 2012
@@ -634,6 +634,19 @@
     if (!SecondTry) {
       SecondTry = true;
       CorrectionCandidateCallback DefaultValidator;
+      // Try to limit which sets of keywords should be included in typo
+      // correction based on what the next token is.
+      DefaultValidator.WantTypeSpecifiers =
+          NextToken.is(tok::l_paren) || NextToken.is(tok::less) ||
+          NextToken.is(tok::identifier) || NextToken.is(tok::star) ||
+          NextToken.is(tok::amp) || NextToken.is(tok::l_square);
+      DefaultValidator.WantExpressionKeywords =
+          NextToken.is(tok::l_paren) || NextToken.is(tok::identifier) ||
+          NextToken.is(tok::arrow) || NextToken.is(tok::period);
+      DefaultValidator.WantRemainingKeywords =
+          NextToken.is(tok::l_paren) || NextToken.is(tok::semi) ||
+          NextToken.is(tok::identifier) || NextToken.is(tok::l_brace);
+      DefaultValidator.WantCXXNamedCasts = false;
       if (TypoCorrection Corrected = CorrectTypo(Result.getLookupNameInfo(),
                                                  Result.getLookupKind(), S, 
                                                  &SS, DefaultValidator)) {
@@ -10364,6 +10377,13 @@
   S.Diag(Enum->getLocation(), diag::warn_identical_enum_values)
       << EnumType << FirstVal.toString(10)
       << Enum->getSourceRange();
+
+  EnumConstantDecl *Last = cast<EnumConstantDecl>(Elements[NumElements - 1]),
+                   *Next = cast<EnumConstantDecl>(Elements[NumElements - 2]);
+
+  S.Diag(Last->getLocation(), diag::note_identical_enum_values)
+    << FixItHint::CreateReplacement(Last->getInitExpr()->getSourceRange(),
+                                    Next->getName());
 }
 
 void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,

Modified: cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp Sat Jun 30 16:45:28 2012
@@ -10318,8 +10318,8 @@
   if (const FunctionDecl *Prev = Fn->getPreviousDecl()) {
     // Don't consider the implicit declaration we generate for explicit
     // specializations. FIXME: Do not generate these implicit declarations.
-    if (Prev->getTemplateSpecializationKind() != TSK_ExplicitSpecialization
-        || Prev->getPreviousDecl()) {
+    if ((Prev->getTemplateSpecializationKind() != TSK_ExplicitSpecialization
+        || Prev->getPreviousDecl()) && !Prev->isDefined()) {
       Diag(DelLoc, diag::err_deleted_decl_not_first);
       Diag(Prev->getLocation(), diag::note_previous_declaration);
     }

Modified: cfe/branches/tooling/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExpr.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExpr.cpp Sat Jun 30 16:45:28 2012
@@ -649,8 +649,7 @@
 /// interfaces passed by value.
 ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT,
                                                   FunctionDecl *FDecl) {
-  const QualType &Ty = E->getType();
-  if (const BuiltinType *PlaceholderTy = Ty->getAsPlaceholderType()) {
+  if (const BuiltinType *PlaceholderTy = E->getType()->getAsPlaceholderType()) {
     // Strip the unbridged-cast placeholder expression off, if applicable.
     if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
         (CT == VariadicMethod ||
@@ -671,15 +670,15 @@
     return ExprError();
   E = ExprRes.take();
 
-  if (Ty->isObjCObjectType() &&
+  if (E->getType()->isObjCObjectType() &&
     DiagRuntimeBehavior(E->getLocStart(), 0,
                         PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
-                          << Ty << CT))
+                          << E->getType() << CT))
     return ExprError();
 
   // Diagnostics regarding non-POD argument types are
   // emitted along with format string checking in Sema::CheckFunctionCall().
-  if (isValidVarArgType(Ty) == VAK_Invalid) {
+  if (isValidVarArgType(E->getType()) == VAK_Invalid) {
     // Turn this into a trap.
     CXXScopeSpec SS;
     SourceLocation TemplateKWLoc;
@@ -2499,7 +2498,7 @@
     unsigned Length = PredefinedExpr::ComputeName(IT, currentDecl).length();
 
     llvm::APInt LengthI(32, Length + 1);
-    if (Kind == tok::kw_L__FUNCTION__)
+    if (IT == PredefinedExpr::LFunction)
       ResTy = Context.WCharTy.withConst();
     else
       ResTy = Context.CharTy.withConst();
@@ -7559,7 +7558,27 @@
   return true;
 }
 
-
+static void CheckIdentityMemvarAssignment(Expr *LHSExpr, Expr *RHSExpr,
+                                          SourceLocation Loc,
+                                          Sema &Sema) {
+  // C / C++ memvars
+  MemberExpr *ML = dyn_cast<MemberExpr>(LHSExpr);
+  MemberExpr *MR = dyn_cast<MemberExpr>(RHSExpr);
+  if (ML && MR && ML->getMemberDecl() == MR->getMemberDecl()) {
+    if (isa<CXXThisExpr>(ML->getBase()) && isa<CXXThisExpr>(MR->getBase()))
+      Sema.Diag(Loc, diag::warn_identity_memvar_assign) << 0;
+  }
+
+  // Objective-C memvars
+  ObjCIvarRefExpr *OL = dyn_cast<ObjCIvarRefExpr>(LHSExpr);
+  ObjCIvarRefExpr *OR = dyn_cast<ObjCIvarRefExpr>(RHSExpr);
+  if (OL && OR && OL->getDecl() == OR->getDecl()) {
+    DeclRefExpr *RL = dyn_cast<DeclRefExpr>(OL->getBase()->IgnoreImpCasts());
+    DeclRefExpr *RR = dyn_cast<DeclRefExpr>(OR->getBase()->IgnoreImpCasts());
+    if (RL && RR && RL->getDecl() == RR->getDecl())
+      Sema.Diag(Loc, diag::warn_identity_memvar_assign) << 1;
+  }
+}
 
 // C99 6.5.16.1
 QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
@@ -7576,6 +7595,10 @@
                                              CompoundType;
   AssignConvertType ConvTy;
   if (CompoundType.isNull()) {
+    Expr *RHSCheck = RHS.get();
+
+    CheckIdentityMemvarAssignment(LHSExpr, RHSCheck, Loc, *this);
+
     QualType LHSTy(LHSType);
     ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
     if (RHS.isInvalid())
@@ -7596,7 +7619,6 @@
     // If the RHS is a unary plus or minus, check to see if they = and + are
     // right next to each other.  If so, the user may have typo'd "x =+ 4"
     // instead of "x += 4".
-    Expr *RHSCheck = RHS.get();
     if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(RHSCheck))
       RHSCheck = ICE->getSubExpr();
     if (UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
@@ -10844,6 +10866,25 @@
   }
 
   SemaRef.MarkAnyDeclReferenced(Loc, D);
+
+  // If this is a call to a method via a cast, also mark the method in the
+  // derived class used in case codegen can devirtualize the call.
+  const MemberExpr *ME = dyn_cast<MemberExpr>(E);
+  if (!ME)
+    return;
+  CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(ME->getMemberDecl());
+  if (!MD)
+    return;
+  const Expr *Base = ME->getBase();
+  if (Base->getType()->isDependentType())
+    return;
+  const CXXRecordDecl *MostDerivedClassDecl = Base->getBestDynamicClassType();
+  if (!MostDerivedClassDecl)
+    return;
+  CXXMethodDecl *DM = MD->getCorrespondingMethodInClass(MostDerivedClassDecl);
+  if (!DM)
+    return;
+  SemaRef.MarkAnyDeclReferenced(Loc, DM);
 } 
 
 /// \brief Perform reference-marking and odr-use handling for a DeclRefExpr.

Modified: cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp Sat Jun 30 16:45:28 2012
@@ -3335,6 +3335,25 @@
   return BuildBinaryTypeTrait(BTT, KWLoc, LhsTSInfo, RhsTSInfo, RParen);
 }
 
+/// \brief Determine whether T has a non-trivial Objective-C lifetime in
+/// ARC mode.
+static bool hasNontrivialObjCLifetime(QualType T) {
+  switch (T.getObjCLifetime()) {
+  case Qualifiers::OCL_ExplicitNone:
+    return false;
+
+  case Qualifiers::OCL_Strong:
+  case Qualifiers::OCL_Weak:
+  case Qualifiers::OCL_Autoreleasing:
+    return true;
+
+  case Qualifiers::OCL_None:
+    return T->isObjCLifetimeType();
+  }
+
+  llvm_unreachable("Unknown ObjC lifetime qualifier");
+}
+
 static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
                               ArrayRef<TypeSourceInfo *> Args,
                               SourceLocation RParenLoc) {
@@ -3408,8 +3427,14 @@
                                                   ArgExprs.size()));
     if (Result.isInvalid() || SFINAE.hasErrorOccurred())
       return false;
-    
-    // The initialization succeeded; not make sure there are no non-trivial 
+
+    // Under Objective-C ARC, if the destination has non-trivial Objective-C
+    // lifetime, this is a non-trivial construction.
+    if (S.getLangOpts().ObjCAutoRefCount &&
+        hasNontrivialObjCLifetime(Args[0]->getType().getNonReferenceType()))
+      return false;
+
+    // The initialization succeeded; now make sure there are no non-trivial
     // calls.
     return !Result.get()->hasNonTrivialCall(S.Context);
   }
@@ -3590,6 +3615,12 @@
     if (Result.isInvalid() || SFINAE.hasErrorOccurred())
       return false;
 
+    // Under Objective-C ARC, if the destination has non-trivial Objective-C
+    // lifetime, this is a non-trivial assignment.
+    if (Self.getLangOpts().ObjCAutoRefCount &&
+        hasNontrivialObjCLifetime(LhsT.getNonReferenceType()))
+      return false;
+
     return !Result.get()->hasNonTrivialCall(Self.Context);
   }
   }

Modified: cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp Sat Jun 30 16:45:28 2012
@@ -1379,10 +1379,12 @@
     ObjCMethodDecl *Method = ME->getMethodDecl();
     if (Method && Method->isSynthesized()) {
       Selector Sel = Method->getSelector();
-      if (Sel.getNumArgs() == 0)
+      if (Sel.getNumArgs() == 0) {
+        const DeclContext *Container = Method->getDeclContext();
         PDecl = 
-          S.LookupPropertyDecl(Method->getClassInterface(), 
+          S.LookupPropertyDecl(cast<ObjCContainerDecl>(Container),
                                Sel.getIdentifierInfoForSlot(0));
+      }
       if (PDecl)
         T = PDecl->getType();
     }

Modified: cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp Sat Jun 30 16:45:28 2012
@@ -829,8 +829,8 @@
       if (originalIvar) {
         Diag(PropertyDiagLoc, 
              diag::warn_autosynthesis_property_ivar_match)
-        << property->getName() << (Ivar == 0) << PropertyIvar->getName() 
-        << originalIvar->getName();
+        << PropertyId << (Ivar == 0) << PropertyIvar 
+        << originalIvar->getIdentifier();
         Diag(property->getLocation(), diag::note_property_declare);
         Diag(originalIvar->getLocation(), diag::note_ivar_decl);
       }
@@ -2143,8 +2143,7 @@
       && getLangOpts().getGC() == LangOptions::GCOnly
       && PropertyTy->isBlockPointerType())
     Diag(Loc, diag::warn_objc_property_copy_missing_on_block);
-  else if (getLangOpts().ObjCAutoRefCount &&
-           (Attributes & ObjCDeclSpec::DQ_PR_retain) &&
+  else if ((Attributes & ObjCDeclSpec::DQ_PR_retain) &&
            !(Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
            !(Attributes & ObjCDeclSpec::DQ_PR_strong) &&
            PropertyTy->isBlockPointerType())

Modified: cfe/branches/tooling/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaType.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaType.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaType.cpp Sat Jun 30 16:45:28 2012
@@ -35,19 +35,19 @@
 using namespace clang;
 
 /// isOmittedBlockReturnType - Return true if this declarator is missing a
-/// return type because this is a omitted return type on a block literal. 
+/// return type because this is a omitted return type on a block literal.
 static bool isOmittedBlockReturnType(const Declarator &D) {
   if (D.getContext() != Declarator::BlockLiteralContext ||
       D.getDeclSpec().hasTypeSpecifier())
     return false;
-  
+
   if (D.getNumTypeObjects() == 0)
     return true;   // ^{ ... }
-  
+
   if (D.getNumTypeObjects() == 1 &&
       D.getTypeObject(0).Kind == DeclaratorChunk::Function)
     return true;   // ^(int X, float Y) { ... }
-  
+
   return false;
 }
 
@@ -412,7 +412,7 @@
       continue;
     }
   }
-  
+
   diagnoseBadTypeAttribute(state.getSema(), attr, type);
 }
 
@@ -587,7 +587,7 @@
   SourceLocation DeclLoc = declarator.getIdentifierLoc();
   if (DeclLoc.isInvalid())
     DeclLoc = DS.getLocStart();
-  
+
   ASTContext &Context = S.Context;
 
   QualType Result;
@@ -640,7 +640,7 @@
       Result = Context.getObjCObjectPointerType(Result);
       break;
     }
-    
+
     // If this is a missing declspec in a block literal return context, then it
     // is inferred from the return statements inside the block.
     // The declspec is always missing in a lambda expr context; it is either
@@ -696,7 +696,7 @@
       case DeclSpec::TSW_long:        Result = Context.LongTy; break;
       case DeclSpec::TSW_longlong:
         Result = Context.LongLongTy;
-          
+
         // long long is a C99 feature.
         if (!S.getLangOpts().C99)
           S.Diag(DS.getTypeSpecWidthLoc(),
@@ -711,7 +711,7 @@
       case DeclSpec::TSW_long:        Result = Context.UnsignedLongTy; break;
       case DeclSpec::TSW_longlong:
         Result = Context.UnsignedLongLongTy;
-          
+
         // long long is a C99 feature.
         if (!S.getLangOpts().C99)
           S.Diag(DS.getTypeSpecWidthLoc(),
@@ -763,10 +763,10 @@
 
     // If the type is deprecated or unavailable, diagnose it.
     S.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeNameLoc());
-    
+
     assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
            DS.getTypeSpecSign() == 0 && "No qualifiers on tag names!");
-    
+
     // TypeQuals handled by caller.
     Result = Context.getTypeDeclType(D);
 
@@ -859,7 +859,7 @@
       Result = Context.IntTy;
       declarator.setInvalidType(true);
     }
-    break; 
+    break;
 
   case DeclSpec::TST_auto: {
     // TypeQuals handled by caller.
@@ -879,7 +879,7 @@
       Result = Context.IntTy;
       declarator.setInvalidType(true);
     }
-    break; 
+    break;
 
   case DeclSpec::TST_error:
     Result = Context.IntTy;
@@ -984,15 +984,15 @@
     // C90 6.5.3 constraints: "The same type qualifier shall not appear more
     // than once in the same specifier-list or qualifier-list, either directly
     // or via one or more typedefs."
-    if (!S.getLangOpts().C99 && !S.getLangOpts().CPlusPlus 
+    if (!S.getLangOpts().C99 && !S.getLangOpts().CPlusPlus
         && TypeQuals & Result.getCVRQualifiers()) {
       if (TypeQuals & DeclSpec::TQ_const && Result.isConstQualified()) {
-        S.Diag(DS.getConstSpecLoc(), diag::ext_duplicate_declspec) 
+        S.Diag(DS.getConstSpecLoc(), diag::ext_duplicate_declspec)
           << "const";
       }
 
       if (TypeQuals & DeclSpec::TQ_volatile && Result.isVolatileQualified()) {
-        S.Diag(DS.getVolatileSpecLoc(), diag::ext_duplicate_declspec) 
+        S.Diag(DS.getVolatileSpecLoc(), diag::ext_duplicate_declspec)
           << "volatile";
       }
 
@@ -1037,7 +1037,7 @@
       if (!PTy->getPointeeType()->isIncompleteOrObjectType()) {
         DiagID = diag::err_typecheck_invalid_restrict_invalid_pointee;
         ProblemTy = T->getAs<PointerType>()->getPointeeType();
-      }      
+      }
     } else if (!Ty->isDependentType()) {
       // FIXME: this deserves a proper diagnostic
       DiagID = diag::err_typecheck_invalid_restrict_invalid_pointee;
@@ -1158,14 +1158,14 @@
 QualType Sema::BuildReferenceType(QualType T, bool SpelledAsLValue,
                                   SourceLocation Loc,
                                   DeclarationName Entity) {
-  assert(Context.getCanonicalType(T) != Context.OverloadTy && 
+  assert(Context.getCanonicalType(T) != Context.OverloadTy &&
          "Unresolved overloaded function type");
-  
+
   // C++0x [dcl.ref]p6:
-  //   If a typedef (7.1.3), a type template-parameter (14.3.1), or a 
-  //   decltype-specifier (7.1.6.2) denotes a type TR that is a reference to a 
-  //   type T, an attempt to create the type "lvalue reference to cv TR" creates 
-  //   the type "lvalue reference to T", while an attempt to create the type 
+  //   If a typedef (7.1.3), a type template-parameter (14.3.1), or a
+  //   decltype-specifier (7.1.6.2) denotes a type TR that is a reference to a
+  //   type T, an attempt to create the type "lvalue reference to cv TR" creates
+  //   the type "lvalue reference to T", while an attempt to create the type
   //   "rvalue reference to cv TR" creates the type TR.
   bool LValueRef = SpelledAsLValue || T->getAs<LValueReferenceType>();
 
@@ -1209,15 +1209,15 @@
   class VLADiagnoser : public Sema::VerifyICEDiagnoser {
   public:
     VLADiagnoser() : Sema::VerifyICEDiagnoser(true) {}
-    
+
     virtual void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR) {
     }
-    
+
     virtual void diagnoseFold(Sema &S, SourceLocation Loc, SourceRange SR) {
       S.Diag(Loc, diag::ext_vla_folded_to_constant) << SR;
     }
   } Diagnoser;
-  
+
   return S.VerifyIntegerConstantExpression(ArraySize, &SizeVal, Diagnoser,
                                            S.LangOpts.GNUMode).isInvalid();
 }
@@ -1246,7 +1246,7 @@
   if (getLangOpts().CPlusPlus) {
     // C++ [dcl.array]p1:
     //   T is called the array element type; this type shall not be a reference
-    //   type, the (possibly cv-qualified) type void, a function type or an 
+    //   type, the (possibly cv-qualified) type void, a function type or an
     //   abstract class type.
     //
     // Note: function types are handled in the common path with C.
@@ -1255,16 +1255,16 @@
       << getPrintableNameForEntity(Entity) << T;
       return QualType();
     }
-    
+
     if (T->isVoidType()) {
       Diag(Loc, diag::err_illegal_decl_array_incomplete_type) << T;
       return QualType();
     }
-    
-    if (RequireNonAbstractType(Brackets.getBegin(), T, 
+
+    if (RequireNonAbstractType(Brackets.getBegin(), T,
                                diag::err_array_of_abstract_type))
       return QualType();
-    
+
   } else {
     // C99 6.7.5.2p1: If the element type is an incomplete or function type,
     // reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())
@@ -1360,7 +1360,7 @@
     if (ConstVal == 0) {
       // GCC accepts zero sized static arrays. We allow them when
       // we're not in a SFINAE context.
-      Diag(ArraySize->getLocStart(), 
+      Diag(ArraySize->getLocStart(),
            isSFINAEContext()? diag::err_typecheck_zero_array_size
                             : diag::ext_typecheck_zero_array_size)
         << ArraySize->getSourceRange();
@@ -1371,9 +1371,9 @@
           << ArraySize->getSourceRange();
         ASM = ArrayType::Normal;
       }
-    } else if (!T->isDependentType() && !T->isVariablyModifiedType() && 
+    } else if (!T->isDependentType() && !T->isVariablyModifiedType() &&
                !T->isIncompleteType()) {
-      // Is the array too large?      
+      // Is the array too large?
       unsigned ActiveSizeBits
         = ConstantArrayType::getNumAddressingBits(Context, T, ConstVal);
       if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context))
@@ -1381,7 +1381,7 @@
           << ConstVal.toString(10)
           << ArraySize->getSourceRange();
     }
-    
+
     T = Context.getConstantArrayType(T, ConstVal, ASM, Quals);
   }
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.
@@ -1389,13 +1389,13 @@
     if (T->isVariableArrayType()) {
       // Prohibit the use of non-POD types in VLAs.
       QualType BaseT = Context.getBaseElementType(T);
-      if (!T->isDependentType() && 
+      if (!T->isDependentType() &&
           !BaseT.isPODType(Context) &&
           !BaseT->isObjCLifetimeType()) {
         Diag(Loc, diag::err_vla_non_pod)
           << BaseT;
         return QualType();
-      } 
+      }
       // Prohibit the use of VLAs during template argument deduction.
       else if (isSFINAEContext()) {
         Diag(Loc, diag::err_vla_in_sfinae);
@@ -1490,7 +1490,7 @@
                                  SourceLocation Loc, DeclarationName Entity,
                                  FunctionType::ExtInfo Info) {
   if (T->isArrayType() || T->isFunctionType()) {
-    Diag(Loc, diag::err_func_returning_array_function) 
+    Diag(Loc, diag::err_func_returning_array_function)
       << T->isFunctionType() << T;
     return QualType();
   }
@@ -1598,7 +1598,7 @@
 ///
 /// \returns A suitable block pointer type, if there are no
 /// errors. Otherwise, returns a NULL type.
-QualType Sema::BuildBlockPointerType(QualType T, 
+QualType Sema::BuildBlockPointerType(QualType T,
                                      SourceLocation Loc,
                                      DeclarationName Entity) {
   if (!T->isFunctionType()) {
@@ -1694,7 +1694,7 @@
 
     // Otherwise, modify the type in-place.
     Qualifiers qs;
-    
+
     if (declSpecType->isObjCARCImplicitlyUnretainedType())
       qs.addObjCLifetime(Qualifiers::OCL_ExplicitNone);
     else
@@ -1792,7 +1792,7 @@
   case UnqualifiedId::IK_LiteralOperatorId:
   case UnqualifiedId::IK_TemplateId:
     T = ConvertDeclSpecToType(state);
-    
+
     if (!D.isInvalidType() && D.getDeclSpec().isTypeSpecOwned()) {
       OwnedTagDecl = cast<TagDecl>(D.getDeclSpec().getRepAsDecl());
       // Owned declaration is embedded in declarator.
@@ -1804,14 +1804,14 @@
   case UnqualifiedId::IK_ConstructorTemplateId:
   case UnqualifiedId::IK_DestructorName:
     // Constructors and destructors don't have return types. Use
-    // "void" instead. 
+    // "void" instead.
     T = SemaRef.Context.VoidTy;
     break;
 
   case UnqualifiedId::IK_ConversionFunctionId:
     // The result type of a conversion function is the type that it
     // converts to.
-    T = SemaRef.GetTypeFromParser(D.getName().ConversionFunctionId, 
+    T = SemaRef.GetTypeFromParser(D.getName().ConversionFunctionId,
                                   &ReturnTypeInfo);
     break;
   }
@@ -2303,7 +2303,7 @@
         EPI.RefQualifier = !FTI.hasRefQualifier()? RQ_None
                     : FTI.RefQualifierIsLValueRef? RQ_LValue
                     : RQ_RValue;
-        
+
         // Otherwise, we have a function with an argument list that is
         // potentially variadic.
         SmallVector<QualType, 16> ArgTys;
@@ -2319,7 +2319,7 @@
           assert(!ArgTy.isNull() && "Couldn't parse type?");
 
           // Adjust the parameter type.
-          assert((ArgTy == Context.getAdjustedParameterType(ArgTy)) && 
+          assert((ArgTy == Context.getAdjustedParameterType(ArgTy)) &&
                  "Unadjusted type?");
 
           // Look for 'void'.  void is allowed only as a single argument to a
@@ -2382,7 +2382,7 @@
         SmallVector<ParsedType, 2> DynamicExceptions;
         SmallVector<SourceRange, 2> DynamicExceptionRanges;
         Expr *NoexceptExpr = 0;
-        
+
         if (FTI.getExceptionSpecType() == EST_Dynamic) {
           // FIXME: It's rather inefficient to have to split into two vectors
           // here.
@@ -2396,14 +2396,14 @@
         } else if (FTI.getExceptionSpecType() == EST_ComputedNoexcept) {
           NoexceptExpr = FTI.NoexceptExpr;
         }
-              
+
         S.checkExceptionSpecification(FTI.getExceptionSpecType(),
                                       DynamicExceptions,
                                       DynamicExceptionRanges,
                                       NoexceptExpr,
                                       Exceptions,
                                       EPI);
-        
+
         if (FTI.getExceptionSpecType() == EST_None &&
             ImplicitlyNoexcept && chunkIndex == 0) {
           // Only the outermost chunk is marked noexcept, of course.
@@ -2483,7 +2483,7 @@
     const FunctionProtoType *FnTy = T->getAs<FunctionProtoType>();
     assert(FnTy && "Why oh why is there not a FunctionProtoType here?");
 
-    // C++ 8.3.5p4: 
+    // C++ 8.3.5p4:
     //   A cv-qualifier-seq shall only be part of the function type
     //   for a nonstatic member function, the function type to which a pointer
     //   to member refers, or the top-level function type of a function typedef
@@ -2511,7 +2511,7 @@
       // Rebuild function type adding a 'const' qualifier.
       FunctionProtoType::ExtProtoInfo EPI = FnTy->getExtProtoInfo();
       EPI.TypeQuals |= DeclSpec::TQ_const;
-      T = Context.getFunctionType(FnTy->getResultType(), 
+      T = Context.getFunctionType(FnTy->getResultType(),
                                   FnTy->arg_type_begin(),
                                   FnTy->getNumArgs(), EPI);
     }
@@ -2564,7 +2564,7 @@
       EPI.TypeQuals = 0;
       EPI.RefQualifier = RQ_None;
 
-      T = Context.getFunctionType(FnTy->getResultType(), 
+      T = Context.getFunctionType(FnTy->getResultType(),
                                   FnTy->arg_type_begin(),
                                   FnTy->getNumArgs(), EPI);
     }
@@ -2580,31 +2580,31 @@
 
   // C++0x [dcl.constexpr]p9:
   //  A constexpr specifier used in an object declaration declares the object
-  //  as const. 
+  //  as const.
   if (D.getDeclSpec().isConstexprSpecified() && T->isObjectType()) {
     T.addConst();
   }
 
-  // If there was an ellipsis in the declarator, the declaration declares a 
+  // If there was an ellipsis in the declarator, the declaration declares a
   // parameter pack whose type may be a pack expansion type.
   if (D.hasEllipsis() && !T.isNull()) {
     // C++0x [dcl.fct]p13:
-    //   A declarator-id or abstract-declarator containing an ellipsis shall 
+    //   A declarator-id or abstract-declarator containing an ellipsis shall
     //   only be used in a parameter-declaration. Such a parameter-declaration
     //   is a parameter pack (14.5.3). [...]
     switch (D.getContext()) {
     case Declarator::PrototypeContext:
       // C++0x [dcl.fct]p13:
-      //   [...] When it is part of a parameter-declaration-clause, the 
-      //   parameter pack is a function parameter pack (14.5.3). The type T 
+      //   [...] When it is part of a parameter-declaration-clause, the
+      //   parameter pack is a function parameter pack (14.5.3). The type T
       //   of the declarator-id of the function parameter pack shall contain
-      //   a template parameter pack; each template parameter pack in T is 
+      //   a template parameter pack; each template parameter pack in T is
       //   expanded by the function parameter pack.
       //
       // We represent function parameter packs as function parameters whose
       // type is a pack expansion.
       if (!T->containsUnexpandedParameterPack()) {
-        S.Diag(D.getEllipsisLoc(), 
+        S.Diag(D.getEllipsisLoc(),
              diag::err_function_parameter_pack_without_parameter_packs)
           << T <<  D.getSourceRange();
         D.setEllipsisLoc(SourceLocation());
@@ -2612,10 +2612,10 @@
         T = Context.getPackExpansionType(T, llvm::Optional<unsigned>());
       }
       break;
-        
+
     case Declarator::TemplateParamContext:
       // C++0x [temp.param]p15:
-      //   If a template-parameter is a [...] is a parameter-declaration that 
+      //   If a template-parameter is a [...] is a parameter-declaration that
       //   declares a parameter pack (8.3.5), then the template-parameter is a
       //   template parameter pack (14.5.3).
       //
@@ -2630,7 +2630,7 @@
                  ? diag::warn_cxx98_compat_variadic_templates
                  : diag::ext_variadic_templates);
       break;
-    
+
     case Declarator::FileContext:
     case Declarator::KNRTypeListContext:
     case Declarator::ObjCParameterContext:  // FIXME: special diagnostic here?
@@ -2683,7 +2683,7 @@
 
   if (D.isPrototypeContext() && getLangOpts().ObjCAutoRefCount)
     inferARCWriteback(state, T);
-  
+
   return GetFullTypeForDeclarator(state, T, ReturnTypeInfo);
 }
 
@@ -2770,7 +2770,7 @@
   if (inner == -1)
     return;
 
-  DeclaratorChunk &chunk = D.getTypeObject(inner); 
+  DeclaratorChunk &chunk = D.getTypeObject(inner);
   if (chunk.Kind == DeclaratorChunk::Pointer) {
     if (declSpecTy->isObjCRetainableType())
       return transferARCOwnershipToDeclSpec(S, declSpecTy, ownership);
@@ -2863,7 +2863,7 @@
     const DeclSpec &DS;
 
   public:
-    TypeSpecLocFiller(ASTContext &Context, const DeclSpec &DS) 
+    TypeSpecLocFiller(ASTContext &Context, const DeclSpec &DS)
       : Context(Context), DS(DS) {}
 
     void VisitAttributedTypeLoc(AttributedTypeLoc TL) {
@@ -3011,7 +3011,7 @@
     void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
       TL.setKWLoc(DS.getTypeSpecTypeLoc());
       TL.setParensRange(DS.getTypeofParensRange());
-      
+
       TypeSourceInfo *TInfo = 0;
       Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo);
       TL.getValueLoc().initializeFullCopy(TInfo->getTypeLoc());
@@ -3153,9 +3153,9 @@
   // Handle parameter packs whose type is a pack expansion.
   if (isa<PackExpansionType>(T)) {
     cast<PackExpansionTypeLoc>(CurrTL).setEllipsisLoc(D.getEllipsisLoc());
-    CurrTL = CurrTL.getNextTypeLoc().getUnqualifiedLoc();    
+    CurrTL = CurrTL.getNextTypeLoc().getUnqualifiedLoc();
   }
-  
+
   for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) {
     while (isa<AttributedTypeLoc>(CurrTL)) {
       AttributedTypeLoc TL = cast<AttributedTypeLoc>(CurrTL);
@@ -3166,7 +3166,7 @@
     DeclaratorLocFiller(Context, D.getTypeObject(i)).Visit(CurrTL);
     CurrTL = CurrTL.getNextTypeLoc().getUnqualifiedLoc();
   }
-  
+
   // If we have different source information for the return type, use
   // that.  This really only applies to C++ conversion functions.
   if (ReturnTypeInfo) {
@@ -3176,7 +3176,7 @@
   } else {
     TypeSpecLocFiller(Context, D.getDeclSpec()).Visit(CurrTL);
   }
-      
+
   return TInfo;
 }
 
@@ -3185,7 +3185,7 @@
   // FIXME: LocInfoTypes are "transient", only needed for passing to/from Parser
   // and Sema during declaration parsing. Try deallocating/caching them when
   // it's appropriate, instead of allocating them and keeping them around.
-  LocInfoType *LocT = (LocInfoType*)BumpAlloc.Allocate(sizeof(LocInfoType), 
+  LocInfoType *LocT = (LocInfoType*)BumpAlloc.Allocate(sizeof(LocInfoType),
                                                        TypeAlignment);
   new (LocT) LocInfoType(T, TInfo);
   assert(LocT->getTypeClass() != T->getTypeClass() &&
@@ -3315,13 +3315,13 @@
     // X *__strong (...)
     } else if (const ParenType *paren = dyn_cast<ParenType>(type)) {
       type = paren->getInnerType();
-   
+
     // That's it for things we want to complain about.  In particular,
     // we do not want to look through typedefs, typeof(expr),
     // typeof(type), or any other way that the type is somehow
     // abstracted.
     } else {
-      
+
       return false;
     }
   }
@@ -3450,8 +3450,8 @@
     attr.setInvalid();
     return true;
   }
-    
-  // Forbid __weak for class objects marked as 
+
+  // Forbid __weak for class objects marked as
   // objc_arc_weak_reference_unavailable
   if (lifetime == Qualifiers::OCL_Weak) {
     QualType T = type;
@@ -3461,12 +3461,12 @@
       ObjCInterfaceDecl *Class = ObjT->getInterfaceDecl();
       if (Class->isArcWeakrefUnavailable()) {
           S.Diag(AttrLoc, diag::err_arc_unsupported_weak_class);
-          S.Diag(ObjT->getInterfaceDecl()->getLocation(), 
+          S.Diag(ObjT->getInterfaceDecl()->getLocation(),
                  diag::note_class_declared);
       }
     }
   }
-  
+
   return true;
 }
 
@@ -3716,7 +3716,7 @@
       return true;
     }
 
-    FunctionType::ExtInfo EI = 
+    FunctionType::ExtInfo EI =
       unwrapped.get()->getExtInfo().withRegParm(value);
     type = unwrapped.wrap(S, S.Context.adjustFunctionType(unwrapped.get(), EI));
     return true;
@@ -3871,11 +3871,11 @@
 
 /// \brief Process the OpenCL-like ext_vector_type attribute when it occurs on
 /// a type.
-static void HandleExtVectorTypeAttr(QualType &CurType, 
-                                    const AttributeList &Attr, 
+static void HandleExtVectorTypeAttr(QualType &CurType,
+                                    const AttributeList &Attr,
                                     Sema &S) {
   Expr *sizeExpr;
-  
+
   // Special case where the argument is a template id.
   if (Attr.getParameterName()) {
     CXXScopeSpec SS;
@@ -3887,7 +3887,7 @@
                                           id, false, false);
     if (Size.isInvalid())
       return;
-    
+
     sizeExpr = Size.get();
   } else {
     // check the attribute arguments.
@@ -3897,7 +3897,7 @@
     }
     sizeExpr = Attr.getArg(0);
   }
-  
+
   // Create the vector type.
   QualType T = S.BuildExtVectorType(CurType, sizeExpr, Attr.getLoc());
   if (!T.isNull())
@@ -4033,7 +4033,7 @@
 
     case AttributeList::AT_NSReturnsRetained:
       if (!state.getSema().getLangOpts().ObjCAutoRefCount)
-	break;
+    break;
       // fallthrough into the function attrs
 
     FUNCTION_TYPE_ATTRS_CASELIST:
@@ -4081,7 +4081,7 @@
       if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
         if (Var->isStaticDataMember() &&
             Var->getInstantiatedFromStaticDataMember()) {
-          
+
           MemberSpecializationInfo *MSInfo = Var->getMemberSpecializationInfo();
           assert(MSInfo && "Missing member specialization information?");
           if (MSInfo->getTemplateSpecializationKind()
@@ -4089,15 +4089,15 @@
             // If we don't already have a point of instantiation, this is it.
             if (MSInfo->getPointOfInstantiation().isInvalid()) {
               MSInfo->setPointOfInstantiation(E->getLocStart());
-              
-              // This is a modification of an existing AST node. Notify 
+
+              // This is a modification of an existing AST node. Notify
               // listeners.
               if (ASTMutationListener *L = getASTMutationListener())
                 L->StaticDataMemberInstantiated(Var);
             }
-            
+
             InstantiateStaticDataMemberDefinition(E->getExprLoc(), Var);
-            
+
             // Update the type to the newly instantiated definition's type both
             // here and within the expression.
             if (VarDecl *Def = Var->getDefinition()) {
@@ -4107,7 +4107,7 @@
               E->setType(T);
             }
           }
-          
+
           // We still go on to try to complete the type independently, as it
           // may also require instantiations or diagnostics if it remains
           // incomplete.
@@ -4129,10 +4129,10 @@
 namespace {
   struct TypeDiagnoserDiag : Sema::TypeDiagnoser {
     unsigned DiagID;
-    
+
     TypeDiagnoserDiag(unsigned DiagID)
       : Sema::TypeDiagnoser(DiagID == 0), DiagID(DiagID) {}
-    
+
     virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) {
       if (Suppressed) return;
       S.Diag(Loc, DiagID) << T;
@@ -4178,7 +4178,7 @@
     // If we know about the definition but it is not visible, complain.
     if (!Diagnoser.Suppressed && Def && !LookupResult::isVisible(Def)) {
       // Suppress this error outside of a SFINAE context if we've already
-      // emitted the error once for this type. There's no usefulness in 
+      // emitted the error once for this type. There's no usefulness in
       // repeating the diagnostic.
       // FIXME: Add a Fix-It that imports the corresponding module or includes
       // the header.
@@ -4187,13 +4187,13 @@
         Diag(Def->getLocation(), diag::note_previous_definition);
       }
     }
-    
+
     return false;
   }
 
   const TagType *Tag = T->getAs<TagType>();
   const ObjCInterfaceType *IFace = 0;
-  
+
   if (Tag) {
     // Avoid diagnosing invalid decls as incomplete.
     if (Tag->getDecl()->isInvalidDecl())
@@ -4210,7 +4210,7 @@
     // Avoid diagnosing invalid decls as incomplete.
     if (IFace->getDecl()->isInvalidDecl())
       return true;
-    
+
     // Give the external AST source a chance to complete the type.
     if (IFace->getDecl()->hasExternalLexicalStorage()) {
       Context.getExternalSource()->CompleteType(IFace->getDecl());
@@ -4218,7 +4218,7 @@
         return false;
     }
   }
-    
+
   // If we have a class template specialization or a class member of a
   // class template specialization, or an array with known size of such,
   // try to instantiate it.
@@ -4254,7 +4254,7 @@
 
   // We have an incomplete type. Produce a diagnostic.
   Diagnoser.diagnose(*this, Loc, T);
-    
+
   // If the type was a forward declaration of a class/struct/union
   // type, produce a note.
   if (Tag && !Tag->getDecl()->isInvalidDecl())
@@ -4262,7 +4262,7 @@
          Tag->isBeingDefined() ? diag::note_type_being_defined
                                : diag::note_forward_declaration)
       << QualType(Tag, 0);
-  
+
   // If the Objective-C class was a forward declaration, produce a note.
   if (IFace && !IFace->getDecl()->isInvalidDecl())
     Diag(IFace->getDecl()->getLocation(), diag::note_forward_class);
@@ -4271,7 +4271,7 @@
 }
 
 bool Sema::RequireCompleteType(SourceLocation Loc, QualType T,
-                               unsigned DiagID) {  
+                               unsigned DiagID) {
   TypeDiagnoserDiag Diagnoser(DiagID);
   return RequireCompleteType(Loc, T, Diagnoser);
 }
@@ -4376,7 +4376,7 @@
   return true;
 }
 
-bool Sema::RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID) {  
+bool Sema::RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID) {
   TypeDiagnoserDiag Diagnoser(DiagID);
   return RequireLiteralType(Loc, T, Diagnoser);
 }
@@ -4422,8 +4422,8 @@
   //   The type denoted by decltype(e) is defined as follows:
   //
   //     - if e is an unparenthesized id-expression or an unparenthesized class
-  //       member access (5.2.5), decltype(e) is the type of the entity named 
-  //       by e. If there is no such entity, or if e names a set of overloaded 
+  //       member access (5.2.5), decltype(e) is the type of the entity named
+  //       by e. If there is no such entity, or if e names a set of overloaded
   //       functions, the program is ill-formed;
   if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
     if (const ValueDecl *VD = dyn_cast<ValueDecl>(DRE->getDecl()))
@@ -4433,7 +4433,7 @@
     if (const FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl()))
       return FD->getType();
   }
-  
+
   // C++11 [expr.lambda.prim]p18:
   //   Every occurrence of decltype((x)) where x is a possibly
   //   parenthesized id-expression that names an entity of automatic
@@ -4459,16 +4459,16 @@
   //   [...]
   QualType T = E->getType();
   switch (E->getValueKind()) {
-  //     - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the 
+  //     - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the
   //       type of e;
   case VK_XValue: T = S.Context.getRValueReferenceType(T); break;
-  //     - otherwise, if e is an lvalue, decltype(e) is T&, where T is the 
+  //     - otherwise, if e is an lvalue, decltype(e) is T&, where T is the
   //       type of e;
   case VK_LValue: T = S.Context.getLValueReferenceType(T); break;
   //  - otherwise, decltype(e) is the type of e.
   case VK_RValue: break;
   }
-  
+
   return T;
 }
 
@@ -4476,7 +4476,7 @@
   ExprResult ER = CheckPlaceholderExpr(E);
   if (ER.isInvalid()) return QualType();
   E = ER.take();
-  
+
   return Context.getDecltypeType(E, getDecltypeForExpr(*this, E));
 }
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt Sat Jun 30 16:45:28 2012
@@ -58,6 +58,7 @@
   StackAddrEscapeChecker.cpp
   StreamChecker.cpp
   TaintTesterChecker.cpp
+  TraversalChecker.cpp
   UndefBranchChecker.cpp
   UndefCapturedBlockVarChecker.cpp
   UndefResultChecker.cpp

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td Sat Jun 30 16:45:28 2012
@@ -479,6 +479,10 @@
   HelpText<"Display Call Graph">,
   DescFile<"DebugCheckers.cpp">;
 
+def TraversalDumper : Checker<"DumpTraversal">,
+  HelpText<"Print branch conditions as they are traversed by the engine">,
+  DescFile<"TraversalChecker.cpp">;
+
 def AnalyzerStatsChecker : Checker<"Stats">,
   HelpText<"Emit warnings with analyzer statistics">,
   DescFile<"AnalyzerStatsChecker.cpp">;

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Sat Jun 30 16:45:28 2012
@@ -67,7 +67,7 @@
 enum ArgEffect { DoNothing, Autorelease, Dealloc, DecRef, DecRefMsg,
                  DecRefBridgedTransfered,
                  IncRefMsg, IncRef, MakeCollectable, MayEscape,
-                 NewAutoreleasePool, SelfOwn, StopTracking };
+                 NewAutoreleasePool, StopTracking };
 
 namespace llvm {
 template <> struct FoldingSetTrait<ArgEffect> {
@@ -3029,9 +3029,6 @@
       }
       break;
 
-    case SelfOwn:
-      V = V ^ RefVal::NotOwned;
-      // Fall-through.
     case DecRef:
     case DecRefBridgedTransfered:
       switch (V.getKind()) {

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/CoreEngine.cpp Sat Jun 30 16:45:28 2012
@@ -76,7 +76,7 @@
   }
 
   virtual void enqueue(const WorkListUnit& U) {
-    Queue.push_front(U);
+    Queue.push_back(U);
   }
 
   virtual WorkListUnit dequeue() {

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp Sat Jun 30 16:45:28 2012
@@ -52,15 +52,6 @@
             "The # of times we re-evaluated a call without inlining");
 
 //===----------------------------------------------------------------------===//
-// Utility functions.
-//===----------------------------------------------------------------------===//
-
-static inline Selector GetNullarySelector(const char* name, ASTContext &Ctx) {
-  IdentifierInfo* II = &Ctx.Idents.get(name);
-  return Ctx.Selectors.getSelector(0, &II);
-}
-
-//===----------------------------------------------------------------------===//
 // Engine construction and deletion.
 //===----------------------------------------------------------------------===//
 

Modified: cfe/branches/tooling/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CMakeLists.txt?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CMakeLists.txt (original)
+++ cfe/branches/tooling/test/CMakeLists.txt Sat Jun 30 16:45:28 2012
@@ -1,117 +1,87 @@
-set(CLANG_TEST_DIRECTORIES
-  "Analysis"
-  "CodeCompletion"
-  "CodeGen"
-  "CodeGenCUDA"
-  "CodeGenCXX"
-  "CodeGenObjC"
-  "CodeGenOpenCL"
-  "Coverage"
-  "CXX"
-  "Driver"
-  "FixIt"
-  "Frontend"
-  "Headers"
-  "Index"
-  "Lexer"
-  "Misc"
-  "PCH"
-  "Parser"
-  "Preprocessor"
-  "Rewriter"
-  "Sema"
-  "SemaCUDA"
-  "SemaCXX"
-  "SemaObjC"
-  "SemaObjCXX"
-  "SemaOpenCL"
-  "SemaTemplate")
-
-set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}")
-set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
-set(LLVM_BUILD_MODE "%(build_mode)s")
-set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
-set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_config)s")
+# Test runner infrastructure for Clang. This configures the Clang test trees
+# for use by Lit, and delegates to LLVM's lit test handlers.
+#
+# If this is a stand-alone Clang build, we fake up our own Lit support here
+# rather than relying on LLVM's.
+
 set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
 set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
-if(BUILD_SHARED_LIBS)
-  set(ENABLE_SHARED 1)
-else()
-  set(ENABLE_SHARED 0)
-endif(BUILD_SHARED_LIBS)
 
-configure_file(
+configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+  )
 
-configure_file(
+configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
-  @ONLY)
+  )
 
-include(FindPythonInterp)
-if(PYTHONINTERP_FOUND)
-  if( LLVM_MAIN_SRC_DIR )
-    set(LIT "${LLVM_SOURCE_DIR}/utils/lit/lit.py")
-  else()
-    set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit")
-    # Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths.
-    if( NOT EXISTS ${LIT} )
-      set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit")
-    endif()
-  endif()
+if( PATH_TO_LLVM_BUILD )
+  set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}")
+endif()
 
-  if( PATH_TO_LLVM_BUILD )
-    set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}")
+option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)
+if(CLANG_TEST_USE_VG)
+  set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
+endif ()
+
+if( NOT CLANG_BUILT_STANDALONE )
+
+  set(CLANG_TEST_DEPS
+    clang clang-headers
+    c-index-test diagtool arcmt-test c-arcmt-test
+    clang-check
+    llvm-dis llc opt FileCheck count not
+    )
+  if(LLVM_INCLUDE_TESTS)
+    list(APPEND CLANG_TEST_DEPS ClangUnitTests)
   endif()
+  add_lit_testsuite(check-clang "Running the Clang regression tests"
+    ${CMAKE_CURRENT_BINARY_DIR}
+    PARAMS clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+           clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
+    DEPENDS ${CLANG_TEST_DEPS}
+    ARGS ${CLANG_TEST_EXTRA_ARGS}
+    )
+  set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
 
-  option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)
-  if(CLANG_TEST_USE_VG)
-    set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
-  endif ()
-
-  set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}")
-  separate_arguments(LIT_ARGS)
-
-  add_custom_target(clang-test.deps)
-  set_target_properties(clang-test.deps PROPERTIES FOLDER "Clang tests")
-
-  add_custom_target(clang-test
-    COMMAND ${PYTHON_EXECUTABLE}
-                ${LIT}
-                --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-                --param clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
-                --param build_config=${CMAKE_CFG_INTDIR}
-                --param build_mode=${RUNTIME_BUILD_MODE}
-                ${LIT_ARGS}
-                ${CMAKE_CURRENT_BINARY_DIR}
-                COMMENT "Running Clang regression tests")
+else()
 
-  if( NOT CLANG_BUILT_STANDALONE )
-    add_custom_target(check-all
+  include(FindPythonInterp)
+  if(PYTHONINTERP_FOUND)
+    if( LLVM_MAIN_SRC_DIR )
+      set(LIT "${LLVM_SOURCE_DIR}/utils/lit/lit.py")
+    else()
+      set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit")
+      # Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths.
+      if( NOT EXISTS ${LIT} )
+        set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit")
+      endif()
+    endif()
+
+    set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}")
+    separate_arguments(LIT_ARGS)
+
+    add_custom_target(check-clang
       COMMAND ${PYTHON_EXECUTABLE}
-                ${LIT}
-                --param build_config=${CMAKE_CFG_INTDIR}
-                --param build_mode=${RUNTIME_BUILD_MODE}
-                ${LIT_ARGS}
-                ${LLVM_BINARY_DIR}/test
-                ${CMAKE_CURRENT_BINARY_DIR}
-                COMMENT "Running Clang and LLVM regression tests")
-    add_dependencies(check-all clang-test.deps)
-    if ( LLVM_INCLUDE_TESTS )
-      add_dependencies(clang-test.deps ClangUnitTests)
-      add_dependencies(check-all check.deps)
-    endif ( LLVM_INCLUDE_TESTS )
-    add_dependencies(clang-test.deps
-                     llvm-dis llc opt
-                     FileCheck count not
-                     )
+              ${LIT}
+              --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+              --param clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
+              --param build_config=${CMAKE_CFG_INTDIR}
+              --param build_mode=${RUNTIME_BUILD_MODE}
+              ${LIT_ARGS}
+              ${CMAKE_CURRENT_BINARY_DIR}
+      COMMENT "Running Clang regression tests"
+      DEPENDS clang clang-headers
+              c-index-test diagtool arcmt-test c-arcmt-test
+              clang-check remove-cstr-calls
+      )
+    set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
   endif()
 
-  add_dependencies(clang-test clang-test.deps)
-  add_dependencies(clang-test.deps
-                 clang clang-headers c-index-test diagtool arcmt-test c-arcmt-test
-                 clang-check remove-cstr-calls
-                 )
-
 endif()
+
+# Add a legacy target spelling: clang-test
+add_custom_target(clang-test DEPENDS check-clang)
+set_target_properties(clang-test PROPERTIES FOLDER "Clang tests")

Modified: cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm (original)
+++ cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm Sat Jun 30 16:45:28 2012
@@ -3,7 +3,7 @@
 namespace PR12746 {
   // CHECK: define zeroext i1 @_ZN7PR127462f1EPi
   bool f1(int *x) {
-    // CHECK: store i8* bitcast (i1 (i8*)* @__f1_block_invoke_0 to i8*)
+    // CHECK: store i8* bitcast (i1 (i8*)* @___ZN7PR127462f1EPi_block_invoke to i8*)
     bool (^outer)() = ^ {
       auto inner = [&]() -> bool {
 	return x == 0;
@@ -13,8 +13,8 @@
     return outer();
   }
 
-  // CHECK: define internal zeroext i1 @__f1_block_invoke_0
-  // CHECK: call zeroext i1 @"_ZNK7PR127462f119__f1_block_invoke_03$_0clEv"
+  // CHECK: define internal zeroext i1 @___ZN7PR127462f1EPi_block_invoke
+  // CHECK: call zeroext i1 @"_ZNK7PR127462f132___ZN7PR127462f1EPi_block_invoke3$_0clEv"
 
   bool f2(int *x) {
     auto outer = [&]() -> bool {

Modified: cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp Sat Jun 30 16:45:28 2012
@@ -13,9 +13,9 @@
 
 eval<A<int>> eA;
 eval<B<int, float>> eB;
-eval<C<17>> eC; // expected-error{{implicit instantiation of undefined template 'eval<C<17>>'}}
-eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined template 'eval<D<int, 17>>'}}
-eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float, 17>>}}
+eval<C<17>> eC; // expected-error{{implicit instantiation of undefined template 'eval<C<17> >'}}
+eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined template 'eval<D<int, 17> >'}}
+eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float, 17> >}}
 
 template<template <int ...N> class TT> struct X0 { }; // expected-note{{previous non-type template parameter with type 'int' is here}}
 template<int I, int J, int ...Rest> struct X0a;

Modified: cfe/branches/tooling/test/CodeGen/2010-02-10-PointerName.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/2010-02-10-PointerName.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/2010-02-10-PointerName.c (original)
+++ cfe/branches/tooling/test/CodeGen/2010-02-10-PointerName.c Sat Jun 30 16:45:28 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -g -o - | grep DW_TAG_pointer_type | grep -v char
+// RUN: %clang_cc1 %s -emit-llvm -g -o - | grep DW_TAG_pointer_type | grep -v {"char"}
 
 char i = 1;
 void foo() {

Modified: cfe/branches/tooling/test/CodeGen/address-safety-attr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/address-safety-attr.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/address-safety-attr.cpp (original)
+++ cfe/branches/tooling/test/CodeGen/address-safety-attr.cpp Sat Jun 30 16:45:28 2012
@@ -33,3 +33,9 @@
 
 int force_instance = TemplateAddressSafetyOk<42>()
                    + TemplateNoAddressSafety<42>();
+
+// Check that __cxx_global_var_init* get the address_safety attribute.
+int global1 = 0;
+int global2 = *(int*)((char*)&global1+1);
+// CHECK-NOT: @__cxx_global_var_init{{.*}}address_safety
+// ASAN: @__cxx_global_var_init{{.*}}address_safety

Modified: cfe/branches/tooling/test/CodeGen/avx2-builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/avx2-builtins.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/avx2-builtins.c (original)
+++ cfe/branches/tooling/test/CodeGen/avx2-builtins.c Sat Jun 30 16:45:28 2012
@@ -10,6 +10,11 @@
   return _mm256_mpsadbw_epu8(x, y, 3);
 }
 
+__m256i test_mm256_sad_epu8(__m256i x, __m256i y) {
+  // CHECK: @llvm.x86.avx2.psad.bw
+  return _mm256_sad_epu8(x, y);
+}
+
 __m256i test_mm256_abs_epi8(__m256i a) {
   // CHECK: @llvm.x86.avx2.pabs.b
   return _mm256_abs_epi8(a);
@@ -780,3 +785,154 @@
   // CHECK: @llvm.x86.avx2.psrlv.q
   return _mm_srlv_epi64(a, b);
 }
+
+__m128d test_mm_mask_i32gather_pd(__m128d a, double const *b, __m128i c,
+                                  __m128d d) {
+  // CHECK: @llvm.x86.avx2.gather.d.pd
+  return _mm_mask_i32gather_pd(a, b, c, d, 2);
+}
+
+__m256d test_mm256_mask_i32gather_pd(__m256d a, double const *b, __m128i c,
+                                      __m256d d) {
+  // CHECK: @llvm.x86.avx2.gather.d.pd.256
+  return _mm256_mask_i32gather_pd(a, b, c, d, 2);
+}
+__m128d test_mm_mask_i64gather_pd(__m128d a, double const *b, __m128i c,
+                                  __m128d d) {
+  // CHECK: @llvm.x86.avx2.gather.q.pd
+  return _mm_mask_i64gather_pd(a, b, c, d, 2);
+}
+__m256d test_mm256_mask_i64gather_pd(__m256d a, double const *b, __m256i c,
+                                      __m256d d) {
+  // CHECK: @llvm.x86.avx2.gather.q.pd.256
+  return _mm256_mask_i64gather_pd(a, b, c, d, 2);
+}
+
+__m128 test_mm_mask_i32gather_ps(__m128 a, float const *b, __m128i c,
+                                 __m128 d) {
+  // CHECK: @llvm.x86.avx2.gather.d.ps
+  return _mm_mask_i32gather_ps(a, b, c, d, 2);
+}
+__m256 test_mm256_mask_i32gather_ps(__m256 a, float const *b, __m256i c,
+                                     __m256 d) {
+  // CHECK: @llvm.x86.avx2.gather.d.ps.256
+  return _mm256_mask_i32gather_ps(a, b, c, d, 2);
+}
+__m128 test_mm_mask_i64gather_ps(__m128 a, float const *b, __m128i c,
+                                 __m128 d) {
+  // CHECK: @llvm.x86.avx2.gather.q.ps
+  return _mm_mask_i64gather_ps(a, b, c, d, 2);
+}
+__m128 test_mm256_mask_i64gather_ps(__m128 a, float const *b, __m256i c,
+                                    __m128 d) {
+  // CHECK: @llvm.x86.avx2.gather.q.ps.256
+  return _mm256_mask_i64gather_ps(a, b, c, d, 2);
+}
+
+__m128i test_mm_mask_i32gather_epi32(__m128i a, int const *b, __m128i c,
+                                     __m128i d) {
+  // CHECK: @llvm.x86.avx2.gather.d.d
+  return _mm_mask_i32gather_epi32(a, b, c, d, 2);
+}
+__m256i test_mm256_mask_i32gather_epi32(__m256i a, int const *b, __m256i c,
+                                        __m256i d) {
+  // CHECK: @llvm.x86.avx2.gather.d.d.256
+  return _mm256_mask_i32gather_epi32(a, b, c, d, 2);
+}
+__m128i test_mm_mask_i64gather_epi32(__m128i a, int const *b, __m128i c,
+                                     __m128i d) {
+  // CHECK: @llvm.x86.avx2.gather.q.d
+  return _mm_mask_i64gather_epi32(a, b, c, d, 2);
+}
+__m128i test_mm256_mask_i64gather_epi32(__m128i a, int const *b, __m256i c,
+                                        __m128i d) {
+  // CHECK: @llvm.x86.avx2.gather.q.d.256
+  return _mm256_mask_i64gather_epi32(a, b, c, d, 2);
+}
+
+__m128i test_mm_mask_i32gather_epi64(__m128i a, int const *b, __m128i c,
+                                     __m128i d) {
+  // CHECK: @llvm.x86.avx2.gather.d.q
+  return _mm_mask_i32gather_epi64(a, b, c, d, 2);
+}
+__m256i test_mm256_mask_i32gather_epi64(__m256i a, int const *b, __m128i c,
+                                        __m256i d) {
+  // CHECK: @llvm.x86.avx2.gather.d.q.256
+  return _mm256_mask_i32gather_epi64(a, b, c, d, 2);
+}
+__m128i test_mm_mask_i64gather_epi64(__m128i a, int const *b, __m128i c,
+                                     __m128i d) {
+  // CHECK: @llvm.x86.avx2.gather.q.q
+  return _mm_mask_i64gather_epi64(a, b, c, d, 2);
+}
+__m256i test_mm256_mask_i64gather_epi64(__m256i a, int const *b, __m256i c,
+                                        __m256i d) {
+  // CHECK: @llvm.x86.avx2.gather.q.q.256
+  return _mm256_mask_i64gather_epi64(a, b, c, d, 2);
+}
+
+__m128d test_mm_i32gather_pd(double const *b, __m128i c) {
+  // CHECK: @llvm.x86.avx2.gather.d.pd
+  return _mm_i32gather_pd(b, c, 2);
+}
+__m256d test_mm256_i32gather_pd(double const *b, __m128i c) {
+  // CHECK: @llvm.x86.avx2.gather.d.pd.256
+  return _mm256_i32gather_pd(b, c, 2);
+}
+__m128d test_mm_i64gather_pd(double const *b, __m128i c) {
+  // CHECK: @llvm.x86.avx2.gather.q.pd
+  return _mm_i64gather_pd(b, c, 2);
+}
+__m256d test_mm256_i64gather_pd(double const *b, __m256i c) {
+  // CHECK: @llvm.x86.avx2.gather.q.pd.256
+  return _mm256_i64gather_pd(b, c, 2);
+}
+__m128 test_mm_i32gather_ps(float const *b, __m128i c) {
+  // CHECK: @llvm.x86.avx2.gather.d.ps
+  return _mm_i32gather_ps(b, c, 2);
+}
+__m256 test_mm256_i32gather_ps(float const *b, __m256i c) {
+  // CHECK: @llvm.x86.avx2.gather.d.ps.256
+  return _mm256_i32gather_ps(b, c, 2);
+}
+__m128 test_mm_i64gather_ps(float const *b, __m128i c) {
+  // CHECK: @llvm.x86.avx2.gather.q.ps
+  return _mm_i64gather_ps(b, c, 2);
+}
+__m128 test_mm256_i64gather_ps(float const *b, __m256i c) {
+  // CHECK: @llvm.x86.avx2.gather.q.ps.256
+  return _mm256_i64gather_ps(b, c, 2);
+}
+
+__m128i test_mm_i32gather_epi32(int const *b, __m128i c) {
+  // CHECK: @llvm.x86.avx2.gather.d.d
+  return _mm_i32gather_epi32(b, c, 2);
+}
+__m256i test_mm256_i32gather_epi32(int const *b, __m256i c) {
+  // CHECK: @llvm.x86.avx2.gather.d.d.256
+  return _mm256_i32gather_epi32(b, c, 2);
+}
+__m128i test_mm_i64gather_epi32(int const *b, __m128i c) {
+  // CHECK: @llvm.x86.avx2.gather.q.d
+  return _mm_i64gather_epi32(b, c, 2);
+}
+__m128i test_mm256_i64gather_epi32(int const *b, __m256i c) {
+  // CHECK: @llvm.x86.avx2.gather.q.d.256
+  return _mm256_i64gather_epi32(b, c, 2);
+}
+__m128i test_mm_i32gather_epi64(int const *b, __m128i c) {
+  // CHECK: @llvm.x86.avx2.gather.d.q
+  return _mm_i32gather_epi64(b, c, 2);
+}
+__m256i test_mm256_i32gather_epi64(int const *b, __m128i c) {
+  // CHECK: @llvm.x86.avx2.gather.d.q.256
+  return _mm256_i32gather_epi64(b, c, 2);
+}
+__m128i test_mm_i64gather_epi64(int const *b, __m128i c) {
+  // CHECK: @llvm.x86.avx2.gather.q.q
+  return _mm_i64gather_epi64(b, c, 2);
+}
+__m256i test_mm256_i64gather_epi64(int const *b, __m256i c) {
+  // CHECK: @llvm.x86.avx2.gather.q.q.256
+  return _mm256_i64gather_epi64(b, c, 2);
+}

Modified: cfe/branches/tooling/test/CodeGen/block-3.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/block-3.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/block-3.c (original)
+++ cfe/branches/tooling/test/CodeGen/block-3.c Sat Jun 30 16:45:28 2012
@@ -6,3 +6,15 @@
                 __attribute__((__blocks__(byref))) int index = ({ int __a; int __b; __a < __b ? __b : __a; });
    };
 }
+
+// PR13229
+// rdar://11777609
+typedef struct {} Z;
+
+typedef int (^B)(Z);
+
+void testPR13229() {
+  Z z1;
+  B b1 = ^(Z z1) { return 1; };
+  b1(z1);
+}

Modified: cfe/branches/tooling/test/CodeGen/blocks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/blocks.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/blocks.c (original)
+++ cfe/branches/tooling/test/CodeGen/blocks.c Sat Jun 30 16:45:28 2012
@@ -12,7 +12,7 @@
   int a[64];
 };
 
-// CHECK: define internal void @__f2_block_invoke_0(%struct.s0* noalias sret {{%.*}}, i8* {{%.*}}, %struct.s0* byval align 4 {{.*}})
+// CHECK: define internal void @__f2_block_invoke(%struct.s0* noalias sret {{%.*}}, i8* {{%.*}}, %struct.s0* byval align 4 {{.*}})
 struct s0 f2(struct s0 a0) {
   return ^(struct s0 a1){ return a1; }(a0);
 }

Modified: cfe/branches/tooling/test/CodeGen/blocksignature.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/blocksignature.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/blocksignature.c (original)
+++ cfe/branches/tooling/test/CodeGen/blocksignature.c Sat Jun 30 16:45:28 2012
@@ -8,7 +8,7 @@
 
 // X32: [[STR1:@.*]] = private unnamed_addr constant [6 x i8] c"v4@?0\00" 
 // X32: @__block_descriptor_tmp = internal constant [[FULL_DESCRIPTOR_T:.*]] { i32 0, i32 20, i8* getelementptr inbounds ([6 x i8]* [[STR1]], i32 0, i32 0), i8* null }
-// X32: @__block_literal_global = internal constant [[GLOBAL_LITERAL_T:.*]] { i8** @_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (void (i8*)* @__block_global_{{.*}} to i8*), [[DESCRIPTOR_T:%.*]]* bitcast ([[FULL_DESCRIPTOR_T]]* @__block_descriptor_tmp to {{%.*}}*) }
+// X32: @__block_literal_global = internal constant [[GLOBAL_LITERAL_T:.*]] { i8** @_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (void (i8*)* @global_block_invoke{{.*}} to i8*), [[DESCRIPTOR_T:%.*]]* bitcast ([[FULL_DESCRIPTOR_T]]* @__block_descriptor_tmp to {{%.*}}*) }
 // X32: [[STR2:@.*]] = private unnamed_addr constant [11 x i8] c"i12@?0c4f8\00"
 // X32: @__block_descriptor_tmp{{.*}} = internal constant [[FULL_DESCRIPTOR_T]] { i32 0, i32 24, i8* getelementptr inbounds ([11 x i8]* [[STR2]], i32 0, i32 0), i8* null }
 // X32:   store i32 1073741824, i32*

Modified: cfe/branches/tooling/test/CodeGen/blockwithlocalstatic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/blockwithlocalstatic.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/blockwithlocalstatic.c (original)
+++ cfe/branches/tooling/test/CodeGen/blockwithlocalstatic.c Sat Jun 30 16:45:28 2012
@@ -1,17 +1,17 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-llvm -o - %s | FileCheck %s
 // pr8707
 
-// CHECK: @__block_global_0.test = internal global i32
+// CHECK: @block_block_invoke.test = internal global i32
 int (^block)(void) = ^ {
 	static int test=0;
 	return test;
 };
-// CHECK: @__block_global_1.test = internal global i32
+// CHECK: @block1_block_invoke_2.test = internal global i32
 void (^block1)(void) = ^ {
 	static int test = 2;
 	return;
 };
-// CHECK: @__block_global_2.test = internal global i32
+// CHECK: @block2_block_invoke_3.test = internal global i32
 int (^block2)(void) = ^ {
 	static int test = 5;
 	return test;

Modified: cfe/branches/tooling/test/CodeGen/capture-complex-expr-in-block.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/capture-complex-expr-in-block.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/capture-complex-expr-in-block.c (original)
+++ cfe/branches/tooling/test/CodeGen/capture-complex-expr-in-block.c Sat Jun 30 16:45:28 2012
@@ -12,7 +12,7 @@
     b();
 }
 
-// CHECK: define internal void @__main_block_invoke_0
+// CHECK: define internal void @__main_block_invoke
 // CHECK:  [[C1:%.*]] = alloca { double, double }, align 8
 // CHECK:  [[RP:%.*]] = getelementptr inbounds { double, double }* [[C1]], i32 0, i32 0
 // CHECK-NEXT:  [[R:%.*]] = load double* [[RP]]

Modified: cfe/branches/tooling/test/CodeGen/func-in-block.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/func-in-block.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/func-in-block.c (original)
+++ cfe/branches/tooling/test/CodeGen/func-in-block.c Sat Jun 30 16:45:28 2012
@@ -15,5 +15,5 @@
     return 0; // not reached
 }
 
-// CHECK: @__func__.__main_block_invoke_0 = private unnamed_addr constant [22 x i8] c"__main_block_invoke_0\00"
-// CHECK: call void @PRINTF({{.*}}@__func__.__main_block_invoke_ 
+// CHECK: @__func__.__main_block_invoke = private unnamed_addr constant [20 x i8] c"__main_block_invoke\00"
+// CHECK: call void @PRINTF({{.*}}@__func__.__main_block_invoke 

Modified: cfe/branches/tooling/test/CodeGen/packed-nest-unpacked.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/packed-nest-unpacked.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/packed-nest-unpacked.c (original)
+++ cfe/branches/tooling/test/CodeGen/packed-nest-unpacked.c Sat Jun 30 16:45:28 2012
@@ -45,3 +45,21 @@
   // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i8* %{{.*}}, i64 24, i32 1, i1 false)
   g.y = foo();
 }
+
+
+struct XBitfield {
+  unsigned b1 : 10;
+  unsigned b2 : 12;
+  unsigned b3 : 10;
+};
+struct YBitfield {
+  char x;
+  struct XBitfield y;
+} __attribute((packed));
+struct YBitfield gbitfield;
+
+unsigned test7() {
+  // CHECK: @test7
+  // CHECK: load i32* bitcast (%struct.XBitfield* getelementptr inbounds (%struct.YBitfield* @gbitfield, i32 0, i32 1) to i32*), align 1
+  return gbitfield.y.b2;
+}

Modified: cfe/branches/tooling/test/CodeGen/varargs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/varargs.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/varargs.c (original)
+++ cfe/branches/tooling/test/CodeGen/varargs.c Sat Jun 30 16:45:28 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
 
 
 // PR6433 - Don't crash on va_arg(typedef).
@@ -9,3 +9,9 @@
     mfloat = __builtin_va_arg((pa), gdouble);
 }
 
+void vararg(int, ...);
+void function_as_vararg() {
+  // CHECK: define {{.*}}function_as_vararg
+  // CHECK-NOT: llvm.trap
+  vararg(0, focus_changed_cb);
+}

Modified: cfe/branches/tooling/test/CodeGenCXX/block-in-ctor-dtor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/block-in-ctor-dtor.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/block-in-ctor-dtor.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/block-in-ctor-dtor.cpp Sat Jun 30 16:45:28 2012
@@ -36,13 +36,13 @@
 };
 
 
+// CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke
 // CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke_
-// CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke_
-// CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke_
+// CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke
 // CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke_
+// CHECK: define internal void @___ZN1XC1Ev_block_invoke
 // CHECK: define internal void @___ZN1XC1Ev_block_invoke_
-// CHECK: define internal void @___ZN1XC1Ev_block_invoke_
+// CHECK: define internal void @___ZN1XC2Ev_block_invoke
 // CHECK: define internal void @___ZN1XC2Ev_block_invoke_
-// CHECK: define internal void @___ZN1XC2Ev_block_invoke_
-// CHECK: define internal void @___ZN1XD2Ev_block_invoke_
+// CHECK: define internal void @___ZN1XD2Ev_block_invoke
 // CHECK: define internal void @___ZN1XD2Ev_block_invoke_

Modified: cfe/branches/tooling/test/CodeGenCXX/blocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/blocks.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/blocks.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/blocks.cpp Sat Jun 30 16:45:28 2012
@@ -2,8 +2,8 @@
 
 namespace test0 {
   // CHECK: define void @_ZN5test04testEi(
-  // CHECK: define internal void @__test_block_invoke_{{.*}}(
-  // CHECK: define internal void @__block_global_{{.*}}(
+  // CHECK: define internal void @___ZN5test04testEi_block_invoke{{.*}}(
+  // CHECK: define internal void @___ZN5test04testEi_block_invoke_2{{.*}}(
   void test(int x) {
     ^{ ^{ (void) x; }; };
   }
@@ -119,7 +119,7 @@
     consume(^{ return foo(A()); });
   }
   // CHECK: define void @_ZN5test44testEv()
-  // CHECK: define internal void @__test_block_invoke
+  // CHECK: define internal void @___ZN5test44testEv_block_invoke
   // CHECK:      [[TMP:%.*]] = alloca [[A:%.*]], align 1
   // CHECK-NEXT: bitcast i8*
   // CHECK-NEXT: call void @_ZN5test41AC1Ev([[A]]* [[TMP]])

Modified: cfe/branches/tooling/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp Sat Jun 30 16:45:28 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - | FileCheck %s
 
 namespace Test1 {
   struct A {
@@ -49,3 +49,140 @@
     return static_cast<B*>(v)->f();
   }
 }
+
+namespace Test4 {
+  struct A {
+    virtual void f();
+  };
+
+  struct B final : A {
+    virtual void f();
+  };
+
+  // CHECK: define void @_ZN5Test41fEPNS_1BE
+  void f(B* d) {
+    // CHECK: call void @_ZN5Test41B1fEv
+    static_cast<A*>(d)->f();
+  }
+}
+
+namespace Test5 {
+  struct A {
+    virtual void f();
+  };
+
+  struct B : A {
+    virtual void f();
+  };
+
+  struct C final : B {
+  };
+
+  // CHECK: define void @_ZN5Test51fEPNS_1CE
+  void f(C* d) {
+    // FIXME: It should be possible to devirtualize this case, but that is
+    // not implemented yet.
+    // CHECK: getelementptr
+    // CHECK-NEXT: %[[FUNC:.*]] = load
+    // CHECK-NEXT: call void %[[FUNC]]
+    static_cast<A*>(d)->f();
+  }
+}
+
+namespace Test6 {
+  struct A {
+    virtual ~A();
+  };
+
+  struct B : public A {
+    virtual ~B();
+  };
+
+  struct C {
+    virtual ~C();
+  };
+
+  struct D final : public C, public B {
+  };
+
+  // CHECK: define void @_ZN5Test61fEPNS_1DE
+  void f(D* d) {
+    // CHECK: call void @_ZN5Test61DD1Ev
+    static_cast<A*>(d)->~A();
+  }
+}
+
+namespace Test7 {
+  struct foo {
+    virtual void g() {}
+  };
+
+  struct bar {
+    virtual int f() { return 0; }
+  };
+
+  struct zed final : public foo, public bar {
+    int z;
+    virtual int f() {return z;}
+  };
+
+  // CHECK: define i32 @_ZN5Test71fEPNS_3zedE
+  int f(zed *z) {
+    // CHECK: alloca
+    // CHECK-NEXT: store
+    // CHECK-NEXT: load
+    // CHECK-NEXT: bitcast
+    // CHECK-NEXT: call {{.*}} @_ZN5Test73zed1fEv
+    // CHECK-NEXT: ret
+    return static_cast<bar*>(z)->f();
+  }
+}
+
+namespace Test8 {
+  struct A { virtual ~A() {} };
+  struct B {
+    int b;
+    virtual int foo() { return b; }
+  };
+  struct C final : A, B {  };
+  // CHECK: define i32 @_ZN5Test84testEPNS_1CE
+  int test(C *c) {
+    // CHECK: %[[THIS:.*]] = phi
+    // CHECK-NEXT: call i32 @_ZN5Test81B3fooEv(%"struct.Test8::B"* %[[THIS]])
+    return static_cast<B*>(c)->foo();
+  }
+}
+
+namespace Test9 {
+  struct A {
+    int a;
+  };
+  struct B {
+    int b;
+  };
+  struct C : public B, public A {
+  };
+  struct RA {
+    virtual A *f() {
+      return 0;
+    }
+  };
+  struct RC final : public RA {
+    virtual C *f() {
+      C *x = new C();
+      x->a = 1;
+      x->b = 2;
+      return x;
+    }
+  };
+  // CHECK: define {{.*}} @_ZN5Test91fEPNS_2RCE
+  A *f(RC *x) {
+    // FIXME: It should be possible to devirtualize this case, but that is
+    // not implemented yet.
+    // CHECK: getelementptr
+    // CHECK-NEXT: %[[FUNC:.*]] = load
+    // CHECK-NEXT: bitcast
+    // CHECK-NEXT: = call {{.*}} %[[FUNC]]
+    return static_cast<RA*>(x)->f();
+  }
+}

Modified: cfe/branches/tooling/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp Sat Jun 30 16:45:28 2012
@@ -53,3 +53,33 @@
   B().h().f();
 }
 
+namespace test2 {
+  struct foo {
+    virtual void f();
+    virtual ~foo();
+  };
+
+  struct bar : public foo {
+    virtual void f();
+    virtual ~bar();
+  };
+
+  void f(bar *b) {
+    // CHECK: call void @_ZN5test23foo1fEv
+    // CHECK: call void @_ZN5test23fooD1Ev
+    b->foo::f();
+    b->foo::~foo();
+  }
+}
+
+namespace test3 {
+  // Test that we don't crash in this case.
+  struct B {
+  };
+  struct D : public B {
+  };
+  void f(D d) {
+    // CHECK: define void @_ZN5test31fENS_1DE
+    d.B::~B();
+  }
+}

Modified: cfe/branches/tooling/test/CodeGenCXX/mangle-ms-back-references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/mangle-ms-back-references.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/mangle-ms-back-references.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/mangle-ms-back-references.cpp Sat Jun 30 16:45:28 2012
@@ -1,5 +1,11 @@
 // RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
 
+// NOTE on the "CURRENT" prefix: some things are mangled incorrectly as of
+// writing. If you find a CURRENT-test that fails with your patch, please test
+// if your patch has actually fixed a problem in the mangler and replace the
+// corresponding CORRECT line with a CHECK.
+// RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck -check-prefix CURRENT %s
+
 void f1(const char* a, const char* b) {}
 // CHECK: "\01?f1@@YAXPBD0 at Z"
 
@@ -9,7 +15,7 @@
 void f3(int a, const char* b, const char* c) {}
 // CHECK: "\01?f3@@YAXHPBD0 at Z"
 
-const char *f4(const char* a, const char* b) {}
+const char *f4(const char* a, const char* b) { return 0; }
 // CHECK: "\01?f4@@YAPBDPBD0 at Z"
 
 void f5(char const* a, unsigned int b, char c, void const* d, char const* e, unsigned int f) {}
@@ -46,7 +52,7 @@
 // built-ins.
 typedef unsigned int uintptr_t;
 typedef unsigned int size_t;
-void *h(size_t a, uintptr_t b) {}
+void *h(size_t a, uintptr_t b) { return 0; }
 // CHECK: "\01?h@@YAPAXII at Z"
 
 // Function pointers might be mangled in a complex way.
@@ -61,3 +67,95 @@
 
 PInt3Func h3(PInt3Func x, PInt3Func y, int* z) { return 0; }
 // CHECK: "\01?h3@@YAP6APAHPAH0 at ZP6APAH00@Z10 at Z"
+
+namespace PR13207 {
+class A {};
+class B {};
+class C {};
+
+template<class X>
+class F {};
+template<class X>
+class I {};
+template<class X, class Y>
+class J {};
+template<class X, class Y, class Z>
+class K {};
+
+class L {
+ public:
+  void foo(I<A> x) {}
+};
+// CHECK: "\01?foo at L@PR13207@@QAEXV?$I at VA@PR13207@@@2@@Z"
+
+void call_l_foo(L* l) { l->foo(I<A>()); }
+
+void foo(I<A> x) {}
+// CHECK: "\01?foo at PR13207@@YAXV?$I at VA@PR13207@@@1@@Z"
+void foo2(I<A> x, I<A> y) { }
+// CHECK "\01?foo2 at PR13207@@YAXV?$I at VA@PR13207@@@1 at 0@Z"
+void bar(J<A,B> x) {}
+// CHECK: "\01?bar at PR13207@@YAXV?$J at VA@PR13207@@VB at 2@@1@@Z"
+void spam(K<A,B,C> x) {}
+// CHECK: "\01?spam at PR13207@@YAXV?$K at VA@PR13207@@VB at 2@VC at 2@@1@@Z"
+
+// The following CURRENT line is here to improve the precision of the "scanning
+// from here" reports of FileCheck.
+// CURRENT: "\01?spam at PR13207@@YAXV?$K at VA@PR13207@@VB at 2@VC at 2@@1@@Z"
+
+// The tests below currently fail:
+void baz(K<char, F<char>, I<char> >) {}
+// CURRENT: "\01?baz at PR13207@@YAXV?$K at DV?$F at D@PR13207@@V?$I at D@1@@1@@Z"
+// CORRECT: "\01?baz at PR13207@@YAXV?$K at DV?$F at D@PR13207@@V?$I at D@2@@1@@Z"
+void qux(K<char, I<char>, I<char> >) {}
+// CURRENT: "\01?qux at PR13207@@YAXV?$K at DV?$I at D@PR13207@@V?$I at D@1@@1@@Z"
+// CORRECT: "\01?qux at PR13207@@YAXV?$K at DV?$I at D@PR13207@@V12@@1@@Z
+
+namespace NA {
+class X {};
+template<class T> class Y {};
+void foo(Y<X> x) {}
+// CHECK: "\01?foo at NA@PR13207@@YAXV?$Y at VX@NA at PR13207@@@12@@Z"
+}
+
+namespace NB {
+class X {};
+template<class T> class Y {};
+void foo(Y<NA::X> x) {}
+// CHECK: "\01?foo at NB@PR13207@@YAXV?$Y at VX@NA at PR13207@@@12@@Z"
+
+void bar(NA::Y<X> x) {}
+// CHECK: "\01?bar at NB@PR13207@@YAXV?$Y at VX@NB at PR13207@@@NA at 2@@Z"
+
+void spam(NA::Y<NA::X> x) {}
+// CHECK: "\01?spam at NB@PR13207@@YAXV?$Y at VX@NA at PR13207@@@NA at 2@@Z"
+
+// The tests below currently fail:
+void foobar(NA::Y<Y<X> > a, Y<Y<X> >) {}
+// CURRENT: "\01?foobar at NB@PR13207@@YAXV?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@NA at 2@V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@12@@Z"
+// CORRECT: "\01?foobar at NB@PR13207@@YAXV?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@NA at 2@V312@@Z"
+
+void foobarspam(Y<X> a, NA::Y<Y<X> > b, Y<Y<X> >) {}
+// CURRENT: "\01?foobarspam at NB@PR13207@@YAXV?$Y at VX@NB at PR13207@@@12 at V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@NA at 2@V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@12@@Z"
+// CORRECT: "\01?foobarspam at NB@PR13207@@YAXV?$Y at VX@NB at PR13207@@@12 at V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@NA at 2@V412@@Z"
+
+void foobarbaz(Y<X> a, NA::Y<Y<X> > b, Y<Y<X> >, Y<Y<X> > c) {}
+// CURRENT: "\01?foobarbaz at NB@PR13207@@YAXV?$Y at VX@NB at PR13207@@@12 at V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@NA at 2@V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@12 at 2@Z"
+// CORRECT: "\01?foobarbaz at NB@PR13207@@YAXV?$Y at VX@NB at PR13207@@@12 at V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@NA at 2@V412 at 2@Z"
+
+void foobarbazqux(Y<X> a, NA::Y<Y<X> > b, Y<Y<X> >, Y<Y<X> > c , NA::Y<Y<Y<X> > > d) {}
+// CURRENT: "\01?foobarbazqux at NB@PR13207@@YAXV?$Y at VX@NB at PR13207@@@12 at V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@NA at 2@V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@12 at 2V?$Y at V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@NB at PR13207@@@32@@Z"
+// CORRECT: "\01?foobarbazqux at NB@PR13207@@YAXV?$Y at VX@NB at PR13207@@@12 at V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@NA at 2@V412 at 2V?$Y at V?$Y at V?$Y at VX@NB at PR13207@@@NB at PR13207@@@NB at PR13207@@@52@@Z"
+}
+
+namespace NC {
+class X {};
+template<class T> class Y {};
+
+void foo(Y<NB::X> x) {}
+// CHECK: "\01?foo at NC@PR13207@@YAXV?$Y at VX@NB at PR13207@@@12@@Z"
+
+void foobar(NC::Y<NB::Y<NA::Y<NA::X> > > x) {}
+// CHECK: "\01?foobar at NC@PR13207@@YAXV?$Y at V?$Y at V?$Y at VX@NA at PR13207@@@NA at PR13207@@@NB at PR13207@@@12@@Z"
+}
+}

Modified: cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp Sat Jun 30 16:45:28 2012
@@ -42,6 +42,9 @@
 
   foo(char *q){}
 //CHECK: @"\01??0foo@@QAE at PAD@Z"
+
+  static foo* static_method() { return 0; }
+
 }f,s1(1),s2((char*)0);
 
 typedef foo (foo2);
@@ -62,8 +65,17 @@
   qthree
 };
 
-int foo::operator+(int a) {return a;}
-// CHECK: @"\01??Hfoo@@QAEHH at Z"
+foo bar() { return foo(); }
+//CHECK: @"\01?bar@@YA?AVfoo@@XZ"
+
+int foo::operator+(int a) {
+//CHECK: @"\01??Hfoo@@QAEHH at Z"
+
+  foo::static_method();
+//CHECK: @"\01?static_method at foo@@SAPAV1 at XZ"
+  bar();
+  return a;
+}
 
 const short foo::d = 0;
 volatile long foo::e;

Modified: cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m Sat Jun 30 16:45:28 2012
@@ -124,7 +124,7 @@
   // CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]]
   // CHECK-NEXT: call void @objc_release(i8* [[T1]])
 
-  // CHECK:    define internal void @__test4_block_invoke_
+  // CHECK:    define internal void @__test4_block_invoke
   // CHECK:      [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
   // CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]], align 8
   // CHECK-NEXT: store i8* null, i8** [[SLOT]],
@@ -200,7 +200,7 @@
   // CHECK:      [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]])
 
-  // CHECK:    define internal void @__test6_block_invoke_
+  // CHECK:    define internal void @__test6_block_invoke
   // CHECK:      [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
   // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null)
   // CHECK-NEXT: ret void
@@ -238,7 +238,7 @@
   // CHECK-NEXT: call void @objc_destroyWeak(i8** [[VAR]])
   // CHECK-NEXT: ret void
 
-  // CHECK:    define internal void @__test7_block_invoke_
+  // CHECK:    define internal void @__test7_block_invoke
   // CHECK:      [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* {{%.*}}, i32 0, i32 5
   // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[SLOT]])
   // CHECK-NEXT: call void @test7_consume(i8* [[T0]])

Modified: cfe/branches/tooling/test/CodeGenObjC/blocks-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/blocks-2.m?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/blocks-2.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/blocks-2.m Sat Jun 30 16:45:28 2012
@@ -4,7 +4,7 @@
 
 
 // CHECK: define i8* @{{.*}}test0
-// CHECK: define internal void @__test0_block_invoke_0(
+// CHECK: define internal void @{{.*}}_block_invoke(
 // CHECK:      call i8* @objc_assign_strongCast(
 // CHECK-NEXT: ret void
 id test0(id x) {

Modified: cfe/branches/tooling/test/CodeGenObjC/blocks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/blocks.m?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/blocks.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/blocks.m Sat Jun 30 16:45:28 2012
@@ -18,7 +18,7 @@
 -(void) im0;
 @end
 
-// CHECK: define internal i32 @"__8-[A im0]_block_invoke_0"(
+// CHECK: define internal i32 @"__8-[A im0]_block_invoke"(
 @implementation A
 -(void) im0 {
   (void) ^{ return 1; }();
@@ -91,7 +91,7 @@
 // rdar://problem/9124263
 // In the test above, check that the use in the invocation function
 // doesn't require a read barrier.
-// CHECK:    define internal void @__test2_block_invoke_
+// CHECK:    define internal void @__test2_block_invoke
 // CHECK:      [[BLOCK:%.*]] = bitcast i8* {{%.*}} to [[BLOCK_T]]*
 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
 // CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]]

Modified: cfe/branches/tooling/test/CodeGenObjCXX/lambda-expressions.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjCXX/lambda-expressions.mm?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjCXX/lambda-expressions.mm (original)
+++ cfe/branches/tooling/test/CodeGenObjCXX/lambda-expressions.mm Sat Jun 30 16:45:28 2012
@@ -9,7 +9,7 @@
 // MRC: define i32 ()* @_Z1fv(
 // MRC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv"
 // MRC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*)
-// MRC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke_0" to i8*)
+// MRC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke" to i8*)
 // MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*)
 // MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*)
 // MRC: ret i32 ()*
@@ -17,7 +17,7 @@
 // ARC: define i32 ()* @_Z1fv(
 // ARC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv"
 // ARC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*)
-// ARC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke_0" to i8*)
+// ARC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke" to i8*)
 // ARC: call i8* @objc_retainBlock
 // ARC: call i8* @objc_autoreleaseReturnValue
 
@@ -26,14 +26,14 @@
 void f2() { global = []{ return 3; }; }
 
 // MRC: define void @_Z2f2v() nounwind {
-// MRC: store i8* bitcast (i32 (i8*)* @__f2_block_invoke_0 to i8*),
+// MRC: store i8* bitcast (i32 (i8*)* @___Z2f2v_block_invoke to i8*),
 // MRC-NOT: call
 // MRC: ret void
 // ("global" contains a dangling pointer after this function runs.)
 
 // ARC: define void @_Z2f2v() nounwind {
-// ARC: store i8* bitcast (i32 (i8*)* @__f2_block_invoke_0 to i8*),
+// ARC: store i8* bitcast (i32 (i8*)* @___Z2f2v_block_invoke to i8*),
 // ARC: call i8* @objc_retainBlock
 // ARC: call void @objc_release
-// ARC: define internal i32 @__f2_block_invoke_0
+// ARC: define internal i32 @___Z2f2v_block_invoke
 // ARC: call i32 @"_ZZ2f2vENK3$_1clEv

Modified: cfe/branches/tooling/test/CodeGenObjCXX/mangle-blocks.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjCXX/mangle-blocks.mm?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjCXX/mangle-blocks.mm (original)
+++ cfe/branches/tooling/test/CodeGenObjCXX/mangle-blocks.mm Sat Jun 30 16:45:28 2012
@@ -1,19 +1,19 @@
 // RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s
 
-// CHECK: @_ZGVN3foo20__foo_block_invoke_05valueE = internal global i64 0
+// CHECK: @_ZGVN3foo22___Z3foov_block_invoke5valueE = internal global i64 0
 
 int f();
 
 void foo() {
-  // CHECK: define internal i32 @__foo_block_invoke_0
-  // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN3foo20__foo_block_invoke_05value
+  // CHECK: define internal i32 @___Z3foov_block_invoke
+  // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN3foo22___Z3foov_block_invoke5valueE
   (void)^(int x) { 
     static int value = f();
     return x + value;
   };
 }
 
-// CHECK: define internal i32 @__block_global_0
+// CHECK: define internal i32 @i_block_invoke
 int i = ^(int x) { return x;}(i);
 
 @interface A
@@ -22,9 +22,9 @@
 
 @implementation A
 - (void)method { 
-  // CHECK: define internal signext i8 @"__11-[A method]_block_invoke_0"
+  // CHECK: define internal signext i8 @"__11-[A method]_block_invoke"
   (void)^(int x) {
-    // CHECK: @"_ZN11-[A method]30__11-[A method]_block_invoke_04nameE"
+    // CHECK: @"_ZN11-[A method]28__11-[A method]_block_invoke4nameE"
     static const char *name = "hello";
     return name[x];
   };
@@ -39,10 +39,10 @@
 }
 
 namespace N {
-  // CHECK: define internal signext i8 @__bar_block_invoke_0
+  // CHECK: define internal signext i8 @___Z3fooi_block_invoke
   void bar() {
     (void)^(int x) { 
-      // CHECK: @_ZN1N3bar20__bar_block_invoke_04nameE
+      // CHECK: @_ZN1N3bar26___ZN1N3barEv_block_invoke4nameE
       static const char *name = "hello";
       return name[x];
     };

Modified: cfe/branches/tooling/test/CodeGenObjCXX/nrvo.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjCXX/nrvo.mm?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjCXX/nrvo.mm (original)
+++ cfe/branches/tooling/test/CodeGenObjCXX/nrvo.mm Sat Jun 30 16:45:28 2012
@@ -22,7 +22,7 @@
 
 X blocksNRVO() {
   return ^{
-    // CHECK: define internal void @__blocksNRVO_block_invoke_0
+    // CHECK: define internal void @___Z10blocksNRVOv_block_invoke
     X x;
     // CHECK: tail call void @_ZN1XC1Ev
     // CHECK-NEXT: ret void

Modified: cfe/branches/tooling/test/Driver/apple-kext-i386.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/apple-kext-i386.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/apple-kext-i386.cpp (original)
+++ cfe/branches/tooling/test/Driver/apple-kext-i386.cpp Sat Jun 30 16:45:28 2012
@@ -41,6 +41,11 @@
 // CHECK-UNSUPPORTED2: cc1plus"
 // CHECK-UNSUPPORTED2-NOT: "-Wconstant-logical-operand"
 
+// Check that -serialize-diagnostics does not cause an "argument unused" error.
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN:   -Wall -fapple-kext -### -serialize-diagnostics %t.dia -c %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-UNUSED %s
+
 // Check that --serialize-diagnostics does not cause an "argument unused" error.
 // RUN: %clang -target i386-apple-darwin10 \
 // RUN:   -Wall -fapple-kext -### --serialize-diagnostics %t.dia -c %s 2>&1 | \

Modified: cfe/branches/tooling/test/Index/annotate-comments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/annotate-comments.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/annotate-comments.cpp (original)
+++ cfe/branches/tooling/test/Index/annotate-comments.cpp Sat Jun 30 16:45:28 2012
@@ -163,6 +163,46 @@
   int isdoxy42; /* NOT_DOXYGEN */ ///< isdoxy42 IS_DOXYGEN_SINGLE
 };
 
+/// IS_DOXYGEN_START
+/// It is fine to have a command at the end of comment.
+///\brief
+///
+/// Some malformed command.
+/* \*/
+/**
+ * \brief Aaa aaaaaaa aaaa.
+ * IS_DOXYGEN_END
+ */
+void isdoxy43(void);
+
+/// IS_DOXYGEN_START Aaa bbb
+/// ccc.
+///
+/// Ddd eee.
+/// Fff.
+///
+/// Ggg. IS_DOXYGEN_END
+void isdoxy44(void);
+
+/// IS_DOXYGEN_START Aaa bbb
+/// ccc.
+///
+/// \brief
+/// Ddd eee.
+/// Fff.
+///
+/// Ggg. IS_DOXYGEN_END
+void isdoxy45(void);
+
+/// IS_DOXYGEN_NOT_ATTACHED
+#define FOO
+void notdoxy46(void);
+
+/// IS_DOXYGEN_START Aaa bbb
+/// \param ccc
+/// \returns ddd IS_DOXYGEN_END
+void isdoxy47(int);
+
 #endif
 
 // RUN: rm -rf %t
@@ -187,8 +227,8 @@
 // WRONG-NOT: IS_DOXYGEN_NOT_ATTACHED
 
 // Ensure we don't pick up extra comments.
-// WRONG-NOT: IS_DOXYGEN_START{{.*}}IS_DOXYGEN_START
-// WRONG-NOT: IS_DOXYGEN_END{{.*}}IS_DOXYGEN_END
+// WRONG-NOT: IS_DOXYGEN_START{{.*}}IS_DOXYGEN_START{{.*}}BriefComment=
+// WRONG-NOT: IS_DOXYGEN_END{{.*}}IS_DOXYGEN_END{{.*}}BriefComment=
 
 // RUN: FileCheck %s < %t/out.c-index-direct
 // RUN: FileCheck %s < %t/out.c-index-pch
@@ -226,4 +266,9 @@
 // CHECK: annotate-comments.cpp:155:6: FunctionDecl=isdoxy40:{{.*}} isdoxy40 IS_DOXYGEN_SINGLE
 // CHECK: annotate-comments.cpp:160:5: FunctionDecl=isdoxy41:{{.*}} isdoxy41 IS_DOXYGEN_SINGLE
 // CHECK: annotate-comments.cpp:163:7: FieldDecl=isdoxy42:{{.*}} isdoxy42 IS_DOXYGEN_SINGLE
+// CHECK: annotate-comments.cpp:176:6: FunctionDecl=isdoxy43:{{.*}} IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
+
+// CHECK: annotate-comments.cpp:185:6: FunctionDecl=isdoxy44:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb ccc.]
+// CHECK: annotate-comments.cpp:195:6: FunctionDecl=isdoxy45:{{.*}} BriefComment=[Ddd eee. Fff.]
+// CHECK: annotate-comments.cpp:204:6: FunctionDecl=isdoxy47:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb]
 

Modified: cfe/branches/tooling/test/Misc/diag-aka-types.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/diag-aka-types.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/diag-aka-types.cpp (original)
+++ cfe/branches/tooling/test/Misc/diag-aka-types.cpp Sat Jun 30 16:45:28 2012
@@ -30,27 +30,6 @@
   bar::f(x); // expected-error{{cannot initialize a parameter of type 'Foo::foo *' (aka 'bar::Foo::foo *') with an lvalue of type 'Foo::foo *'}}
 }
 
-// PR9548 - "no known conversion from 'vector<string>' to 'vector<string>'"
-// vector<string> refers to two different types here.  Make sure the message
-// gives a way to tell them apart.
-class versa_string;
-typedef versa_string string;
-
-namespace std {template <typename T> class vector;}
-using std::vector;
-
-void f(vector<string> v);  // expected-note {{candidate function not viable: no known conversion from 'vector<string>' (aka 'std::vector<std::basic_string>') to 'vector<string>' (aka 'std::vector<versa_string>') for 1st argument}}
-
-namespace std {
-  class basic_string;
-  typedef basic_string string;
-  template <typename T> class vector {};
-  void g() {
-    vector<string> v;
-    f(v);  // expected-error{{no matching function for call to 'f'}}
-  }
-}
-
 namespace ns {
  struct str {
    static void method(struct data *) {}
@@ -61,7 +40,7 @@
 
 typedef void (*callback)(struct data *);
 
-void helper(callback cb) {} // expected-note{{candidate function not viable: no known conversion from 'void (*)(struct data *)' (aka 'void (*)(ns::data *)') to 'callback' (aka 'void (*)(struct data *)') for 1st argument;}}
+void helper(callback cb) {} // expected-note{{candidate function not viable: no known conversion from 'void (*)(struct data *)' (aka 'void (*)(ns::data *)') to 'callback' (aka 'void (*)(struct data *)') for 1st argument}}
 
 void test() {
  helper(&ns::str::method); // expected-error{{no matching function for call to 'helper'}}

Modified: cfe/branches/tooling/test/Misc/warning-flags-enabled.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/warning-flags-enabled.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/warning-flags-enabled.c (original)
+++ cfe/branches/tooling/test/Misc/warning-flags-enabled.c Sat Jun 30 16:45:28 2012
@@ -3,9 +3,9 @@
 // This shows warnings which are on by default.
 // We just check a few to make sure it's doing something sensible.
 //
+// CHECK: ext_unterminated_string
 // CHECK: warn_condition_is_assignment
 // CHECK: warn_null_arg
-// CHECK: warn_unterminated_string
 
 
 // RUN: diagtool show-enabled -Wno-everything %s | count 0

Modified: cfe/branches/tooling/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/warning-flags.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/warning-flags.c (original)
+++ cfe/branches/tooling/test/Misc/warning-flags.c Sat Jun 30 16:45:28 2012
@@ -17,7 +17,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (238):
+CHECK: Warnings without flags (230):
 CHECK-NEXT:   ext_anonymous_struct_union_qualified
 CHECK-NEXT:   ext_binary_literal
 CHECK-NEXT:   ext_cast_fn_obj
@@ -105,7 +105,6 @@
 CHECK-NEXT:   warn_attribute_weak_on_field
 CHECK-NEXT:   warn_attribute_weak_on_local
 CHECK-NEXT:   warn_attribute_wrong_decl_type
-CHECK-NEXT:   warn_bad_receiver_type
 CHECK-NEXT:   warn_bitfield_width_exceeds_type_size
 CHECK-NEXT:   warn_bool_switch_condition
 CHECK-NEXT:   warn_braces_around_scalar_init
@@ -114,7 +113,6 @@
 CHECK-NEXT:   warn_call_wrong_number_of_arguments
 CHECK-NEXT:   warn_case_empty_range
 CHECK-NEXT:   warn_char_constant_too_large
-CHECK-NEXT:   warn_class_method_not_found
 CHECK-NEXT:   warn_cmdline_missing_macro_defs
 CHECK-NEXT:   warn_collection_expr_type
 CHECK-NEXT:   warn_conflicting_param_types
@@ -159,8 +157,6 @@
 CHECK-NEXT:   warn_incompatible_qualified_id
 CHECK-NEXT:   warn_initializer_string_for_char_array_too_long
 CHECK-NEXT:   warn_inline_namespace_reopened_noninline
-CHECK-NEXT:   warn_inst_method_not_found
-CHECK-NEXT:   warn_instance_method_on_class_found
 CHECK-NEXT:   warn_integer_too_large
 CHECK-NEXT:   warn_integer_too_large_for_signed
 CHECK-NEXT:   warn_invalid_asm_cast_lvalue
@@ -224,13 +220,11 @@
 CHECK-NEXT:   warn_property_getter_owning_mismatch
 CHECK-NEXT:   warn_property_types_are_incompatible
 CHECK-NEXT:   warn_readonly_property
-CHECK-NEXT:   warn_receiver_forward_class
 CHECK-NEXT:   warn_redecl_library_builtin
 CHECK-NEXT:   warn_redeclaration_without_attribute_prev_attribute_ignored
 CHECK-NEXT:   warn_register_objc_catch_parm
 CHECK-NEXT:   warn_related_result_type_compatibility_class
 CHECK-NEXT:   warn_related_result_type_compatibility_protocol
-CHECK-NEXT:   warn_root_inst_method_not_found
 CHECK-NEXT:   warn_second_parameter_of_va_start_not_last_named_argument
 CHECK-NEXT:   warn_second_parameter_to_va_arg_never_compatible
 CHECK-NEXT:   warn_standalone_specifier
@@ -251,8 +245,6 @@
 CHECK-NEXT:   warn_undefined_internal
 CHECK-NEXT:   warn_unknown_analyzer_checker
 CHECK-NEXT:   warn_unknown_method_family
-CHECK-NEXT:   warn_unterminated_char
-CHECK-NEXT:   warn_unterminated_string
 CHECK-NEXT:   warn_use_out_of_scope_declaration
 CHECK-NEXT:   warn_weak_identifier_undeclared
 CHECK-NEXT:   warn_weak_import

Modified: cfe/branches/tooling/test/Parser/DelayedTemplateParsing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/DelayedTemplateParsing.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/DelayedTemplateParsing.cpp (original)
+++ cfe/branches/tooling/test/Parser/DelayedTemplateParsing.cpp Sat Jun 30 16:45:28 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify -std=c++11 %s
 
 template <class T>
 class A {
@@ -90,3 +90,14 @@
 }
 
 }
+
+namespace rdar11700604 {
+  template<typename T> void foo() = delete;
+
+  struct X {
+    X() = default;
+
+    template<typename T> void foo() = delete;
+  };
+}
+

Modified: cfe/branches/tooling/test/Preprocessor/line-directive.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/line-directive.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/line-directive.c (original)
+++ cfe/branches/tooling/test/Preprocessor/line-directive.c Sat Jun 30 16:45:28 2012
@@ -3,8 +3,8 @@
 // RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: DEF'
 
 #line 'a'            // expected-error {{#line directive requires a positive integer argument}}
-#line 0              // expected-error {{#line directive requires a positive integer argument}}
-#line 00             // expected-error {{#line directive requires a positive integer argument}}
+#line 0              // expected-warning {{#line directive with zero argument is a GNU extension}}
+#line 00             // expected-warning {{#line directive with zero argument is a GNU extension}}
 #line 2147483648     // expected-warning {{C requires #line number to be less than 2147483648, allowed as extension}}
 #line 42             // ok
 #line 42 'a'         // expected-error {{invalid filename for #line directive}}
@@ -88,5 +88,8 @@
 _\
 _LINE__ == 42 ? 1: -1];  /* line marker is location of first _ */
 
+// rdar://11550996
+#line 0 "line-directive.c" // expected-warning {{#line directive with zero argument is a GNU extension}}
+undefined t; // expected-error {{unknown type name 'undefined'}}
 
 

Modified: cfe/branches/tooling/test/Rewriter/objc-modern-container-subscript.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/objc-modern-container-subscript.mm?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/objc-modern-container-subscript.mm (original)
+++ cfe/branches/tooling/test/Rewriter/objc-modern-container-subscript.mm Sat Jun 30 16:45:28 2012
@@ -2,9 +2,10 @@
 // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
 // rdar://11203853
 
+typedef unsigned long size_t;
+
 void *sel_registerName(const char *);
 
-typedef unsigned int size_t;
 @protocol P @end
 
 @interface NSMutableArray

Modified: cfe/branches/tooling/test/SemaCXX/deleted-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/deleted-function.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/deleted-function.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/deleted-function.cpp Sat Jun 30 16:45:28 2012
@@ -63,3 +63,6 @@
 template<typename> void test3() = delete; // expected-note {{explicit instantiation refers here}}
 template<typename> void test3();
 template void test3<int>(); // expected-error {{explicit instantiation of undefined function template 'test3'}}
+
+void test4() {} // expected-note {{previous definition is here}}
+void test4() = delete; // expected-error {{redefinition of 'test4'}}

Modified: cfe/branches/tooling/test/SemaCXX/neon-vector-types.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/neon-vector-types.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/neon-vector-types.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/neon-vector-types.cpp Sat Jun 30 16:45:28 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify "-triple" "thumbv7-apple-ios3.0.0" %s
 // rdar://9208404
 
 typedef int MP4Err;
@@ -25,3 +25,20 @@
   return 0;
 }
 
+namespace rdar11688587 {
+  typedef float float32_t;
+  typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
+
+  template<int I>
+  float test()
+  {
+    extern float32x4_t vec;
+    return __extension__ ({ 
+        float32x4_t __a = (vec); 
+        (float32_t)__builtin_neon_vgetq_lane_f32(__a, I);  // expected-error{{argument should be a value from 0 to 3}}
+      });
+  }
+
+  template float test<1>();
+  template float test<4>(); // expected-note{{in instantiation of function template specialization 'rdar11688587::test<4>' requested here}}
+}

Modified: cfe/branches/tooling/test/SemaCXX/typo-correction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/typo-correction.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/typo-correction.cpp Sat Jun 30 16:45:28 2012
@@ -227,3 +227,10 @@
 // 'boo' to 'bool' is the same edit distance as correcting 'boo' to 'foo'.
 class bar : boo { }; // expected-error{{unknown class name 'boo'; did you mean 'foo'?}}
 }
+
+namespace bogus_keyword_suggestion {
+void test() {
+   status = "OK"; // expected-error-re{{use of undeclared identifier 'status'$}}
+   return status; // expected-error-re{{use of undeclared identifier 'status'$}}
+ }
+}

Modified: cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp Sat Jun 30 16:45:28 2012
@@ -49,6 +49,13 @@
   ~ReaderMutexLock() __attribute__((unlock_function));
 };
 
+class SCOPED_LOCKABLE ReleasableMutexLock {
+ public:
+  ReleasableMutexLock(Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu);
+  ~ReleasableMutexLock() UNLOCK_FUNCTION();
+
+  void Release() UNLOCK_FUNCTION();
+};
 
 Mutex sls_mu;
 
@@ -1578,7 +1585,7 @@
     MutexLock mulock_a(&mu1);
     MutexLock mulock_b(&mu1); // \
       // expected-warning {{locking 'mu1' that is already locked}}
-  }   // expected-warning {{unlocking 'mu1' that was not locked}}
+  }
 
   void foo4() {
     MutexLock mulock1(&mu1), mulock2(&mu2);
@@ -2361,3 +2368,42 @@
 } // end namespace LockReturned
 
 
+namespace ReleasableScopedLock {
+
+class Foo {
+  Mutex mu_;
+  bool c;
+  int a GUARDED_BY(mu_);
+
+  void test1();
+  void test2();
+  void test3();
+};
+
+
+void Foo::test1() {
+  ReleasableMutexLock rlock(&mu_);
+  rlock.Release();
+}
+
+void Foo::test2() {
+  ReleasableMutexLock rlock(&mu_);
+  if (c) {            // test join point -- held/not held during release
+    rlock.Release();
+  }
+}
+
+void Foo::test3() {
+  ReleasableMutexLock rlock(&mu_);
+  a = 0;
+  rlock.Release();
+  a = 1;  // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+}
+
+} // end namespace ReleasableScopedLock
+
+
+
+
+
+

Modified: cfe/branches/tooling/test/SemaCXX/warn-unique-enum.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/warn-unique-enum.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-unique-enum.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-unique-enum.cpp Sat Jun 30 16:45:28 2012
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -Wunique-enum
-enum A { A1 = 1, A2 = 1, A3 = 1 };  // expected-warning {{all elements of 'A' are initialized with literals to value 1}}
+enum A { A1 = 1, A2 = 1, A3 = 1 };  // expected-warning {{all elements of 'A' are initialized with literals to value 1}} \
+// expected-note {{initialize the last element with the previous element to silence this warning}}
 enum { B1 = 1, B2 = 1, B3 = 1 }; // no warning
-enum C { C1 = true, C2 = true}; // expected-warning {{all elements of 'C' are initialized with literals to value 1}}
-enum D { D1 = 5, D2 = 5L, D3 = 5UL, D4 = 5LL, D5 = 5ULL };  // expected-warning {{all elements of 'D' are initialized with literals to value 5}}
+enum C { // expected-warning {{all elements of 'C' are initialized with literals to value 1}}
+  C1 = true,
+  C2 = true  // expected-note {{initialize the last element with the previous element to silence this warning}}
+};
+enum D { D1 = 5, D2 = 5L, D3 = 5UL, D4 = 5LL, D5 = 5ULL };  // expected-warning {{all elements of 'D' are initialized with literals to value 5}} \
+// expected-note {{initialize the last element with the previous element to silence this warning}}
 
 // Don't warn on enums with less than 2 elements.
 enum E { E1 = 4 };

Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jun 30 16:45:28 2012
@@ -1,2 +1,2 @@
 /cfe/branches/type-system-rewrite/test/SemaCXX/warn-unreachable.cpp:134693-134817
-/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-159190
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-159493

Modified: cfe/branches/tooling/test/SemaCXX/warn-unused-member.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/warn-unused-member.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-unused-member.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-unused-member.cpp Sat Jun 30 16:45:28 2012
@@ -144,6 +144,13 @@
   int by_initializer_;
 };
 
+class HasFeatureTest {
+#if __has_feature(attribute_unused_on_fields)
+  int unused_; // expected-warning{{private field 'unused_' is not used}}
+  int unused2_ __attribute__((unused)); // no-warning
+#endif
+};
+
 namespace templates {
 class B {
   template <typename T> void f(T t);

Removed: cfe/branches/tooling/test/SemaObjC/arc-retain-block-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-retain-block-property.m?rev=159495&view=auto
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-retain-block-property.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-retain-block-property.m (removed)
@@ -1,30 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify -Wno-objc-root-class %s
-// rdar://9829425
-
-extern void doSomething();
-
- at interface Test
-{
- at public
-  void (^aBlock)(void);
-}
- at property (retain) void (^aBlock)(void); // expected-warning {{retain'ed block property does not copy the block - use copy attribute instead}}
- at property (weak, retain) void (^aBlockW)(void); // expected-error {{property attributes 'retain' and 'weak' are mutually exclusive}} 
- at property (strong, retain) void (^aBlockS)(void); // OK
- at property (readonly, retain) void (^aBlockR)(void); // OK
- at property (copy, retain) void (^aBlockC)(void); // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}}
- at property (assign, retain) void (^aBlockA)(void); // expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}}
- at end
-
- at implementation Test
- at synthesize aBlock;
- at dynamic aBlockW, aBlockS, aBlockR, aBlockC, aBlockA;
- at end
-
-int main() {
-  Test *t;
-  t.aBlock = ^{ doSomething(); };
-  t.aBlockW = ^{ doSomething(); };
-  t.aBlockS = ^{ doSomething(); };
-}
-

Modified: cfe/branches/tooling/test/SemaObjC/provisional-ivar-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/provisional-ivar-lookup.m?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/provisional-ivar-lookup.m (original)
+++ cfe/branches/tooling/test/SemaObjC/provisional-ivar-lookup.m Sat Jun 30 16:45:28 2012
@@ -36,7 +36,7 @@
 
 @synthesize PROP=PROP;
 - (void)setPROP:(int)value {
-    PROP = PROP;        // OK
+    PROP = value;        // OK
 }
 
 @end

Modified: cfe/branches/tooling/test/SemaObjC/weak-receiver-warn.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/weak-receiver-warn.m?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/weak-receiver-warn.m (original)
+++ cfe/branches/tooling/test/SemaObjC/weak-receiver-warn.m Sat Jun 30 16:45:28 2012
@@ -66,3 +66,15 @@
 }
 
 @end
+
+
+// Weak properties on protocols can be synthesized by an adopting class.
+ at protocol MyProtocol
+ at property (weak) id object; // expected-note 2 {{property declared here}}
+ at end
+
+void testProtocol(id <MyProtocol> input) {
+  [[input object] Meth]; // expected-warning {{weak property may be unpredictably null in ARC mode}}
+  [input.object Meth]; // expected-warning {{weak property may be unpredictably null in ARC mode}}
+}
+

Modified: cfe/branches/tooling/test/SemaObjCXX/arc-type-traits.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjCXX/arc-type-traits.mm?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjCXX/arc-type-traits.mm (original)
+++ cfe/branches/tooling/test/SemaObjCXX/arc-type-traits.mm Sat Jun 30 16:45:28 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -std=c++11 %s
 
 // Check the results of the various type-trait query functions on
 // lifetime-qualified types in ARC.
@@ -9,6 +9,8 @@
 
 #define TRAIT_IS_TRUE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? 1 : -1]
 #define TRAIT_IS_FALSE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? -1 : 1]
+#define TRAIT_IS_TRUE_2(Trait, Type1, Type2) char JOIN2(Trait,__LINE__)[Trait(Type1, Type2)? 1 : -1]
+#define TRAIT_IS_FALSE_2(Trait, Type1, Type2) char JOIN2(Trait,__LINE__)[Trait(Type1, Type2)? -1 : 1]
   
 // __has_nothrow_assign
 TRAIT_IS_TRUE(__has_nothrow_assign, __strong id);
@@ -88,3 +90,80 @@
 TRAIT_IS_TRUE(__is_standard_layout, __autoreleasing id);
 TRAIT_IS_TRUE(__is_standard_layout, __unsafe_unretained id);
 
+// __is_trivally_assignable
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __unsafe_unretained id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __unsafe_unretained id&&);
+
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __unsafe_unretained id&&);
+
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __strong id);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __weak id);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __autoreleasing id);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __unsafe_unretained id);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __strong id&&);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __weak id&&);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __autoreleasing id&&);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __unsafe_unretained id&&);
+
+// __is_trivally_constructible
+TRAIT_IS_FALSE(__is_trivially_constructible, __strong id);
+TRAIT_IS_FALSE(__is_trivially_constructible, __weak id);
+TRAIT_IS_FALSE(__is_trivially_constructible, __autoreleasing id);
+TRAIT_IS_TRUE(__is_trivially_constructible, __unsafe_unretained id);
+
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __unsafe_unretained id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __unsafe_unretained id&&);
+
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __unsafe_unretained id&&);
+
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __strong id);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __weak id);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __autoreleasing id);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __unsafe_unretained id);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __strong id&&);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __weak id&&);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __autoreleasing id&&);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __unsafe_unretained id&&);
+

Modified: cfe/branches/tooling/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/c-index-test/c-index-test.c?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/tools/c-index-test/c-index-test.c (original)
+++ cfe/branches/tooling/tools/c-index-test/c-index-test.c Sat Jun 30 16:45:28 2012
@@ -1,6 +1,7 @@
 /* c-index-test.c */
 
 #include "clang-c/Index.h"
+#include "clang-c/CXCompilationDatabase.h"
 #include <ctype.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -25,8 +26,25 @@
 
     return((char*)path);
 }
+char *dirname(char* path)
+{
+    char* base1 = (char*)strrchr(path, '/');
+    char* base2 = (char*)strrchr(path, '\\');
+    if (base1 && base2)
+        if (base1 > base2)
+          *base1 = 0;
+        else
+          *base2 = 0;
+    else if (base1)
+        *base1 = 0;
+    else if (base2)
+        *base2 = 0;
+
+    return path;
+}
 #else
 extern char *basename(const char *);
+extern char *dirname(char *);
 #endif
 
 /** \brief Return the default parsing options. */
@@ -162,6 +180,24 @@
 /* Pretty-printing.                                                           */
 /******************************************************************************/
 
+static void PrintCString(const char *Prefix, const char *CStr) {
+  printf(" %s=[", Prefix);
+  if (CStr != NULL && CStr[0] != '\0') {
+    for ( ; *CStr; ++CStr) {
+      const char C = *CStr;
+      switch (C) {
+        case '\n': printf("\\n"); break;
+        case '\r': printf("\\r"); break;
+        case '\t': printf("\\t"); break;
+        case '\v': printf("\\v"); break;
+        case '\f': printf("\\f"); break;
+        default:   putchar(C);    break;
+      }
+    }
+  }
+  printf("]");
+}
+
 static void PrintRange(CXSourceRange R, const char *str) {
   CXFile begin_file, end_file;
   unsigned begin_line, begin_column, end_line, end_column;
@@ -218,8 +254,10 @@
     CXPlatformAvailability PlatformAvailability[2];
     int NumPlatformAvailability;
     int I;
-    CXString Comment;
-    const char *CommentCString;
+    CXString RawComment;
+    const char *RawCommentCString;
+    CXString BriefComment;
+    const char *BriefCommentCString;
 
     ks = clang_getCursorKindSpelling(Cursor.kind);
     string = want_display_name? clang_getCursorDisplayName(Cursor) 
@@ -401,21 +439,19 @@
         PrintRange(RefNameRange, "RefName");
     }
 
-    Comment = clang_Cursor_getRawCommentText(Cursor);
-    CommentCString = clang_getCString(Comment);
-    if (CommentCString != NULL && CommentCString[0] != '\0') {
-      printf(" Comment=[");
-      for ( ; *CommentCString; ++CommentCString) {
-        if (*CommentCString != '\n')
-          putchar(*CommentCString);
-        else
-          printf("\\n");
-      }
-      printf("]");
-
-      PrintRange(clang_Cursor_getCommentRange(Cursor), "CommentRange");
+    RawComment = clang_Cursor_getRawCommentText(Cursor);
+    RawCommentCString = clang_getCString(RawComment);
+    if (RawCommentCString != NULL && RawCommentCString[0] != '\0') {
+      PrintCString("RawComment", RawCommentCString);
+      PrintRange(clang_Cursor_getCommentRange(Cursor), "RawCommentRange");
+
+      BriefComment = clang_Cursor_getBriefCommentText(Cursor);
+      BriefCommentCString = clang_getCString(BriefComment);
+      if (BriefCommentCString != NULL && BriefCommentCString[0] != '\0')
+        PrintCString("BriefComment", BriefCommentCString);
+      clang_disposeString(BriefComment);
     }
-    clang_disposeString(Comment);
+    clang_disposeString(RawComment);
   }
 }
 
@@ -2343,6 +2379,89 @@
   return errorCode;
 }
 
+static int
+perform_test_compilation_db(const char *database, int argc, const char **argv) {
+  CXCompilationDatabase db;
+  CXCompileCommands CCmds;
+  CXCompileCommand CCmd;
+  CXCompilationDatabase_Error ec;
+  CXString wd;
+  CXString arg;
+  int errorCode = 0;
+  char *tmp;
+  unsigned len;
+  char *buildDir;
+  int i, j, a, numCmds, numArgs;
+
+  len = strlen(database);
+  tmp = (char *) malloc(len+1);
+  memcpy(tmp, database, len+1);
+  buildDir = dirname(tmp);
+
+  db = clang_tooling_CompilationDatabase_fromDirectory(buildDir, &ec);
+
+  if (db) {
+
+    if (ec!=CXCompilationDatabase_NoError) {
+      printf("unexpected error %d code while loading compilation database\n", ec);
+      errorCode = -1;
+      goto cdb_end;
+    }
+
+    for (i=0; i<argc && errorCode==0; ) {
+      if (strcmp(argv[i],"lookup")==0){
+        CCmds = clang_tooling_CompilationDatabase_getCompileCommands(db, argv[i+1]);
+
+        if (!CCmds) {
+          printf("file %s not found in compilation db\n", argv[i+1]);
+          errorCode = -1;
+          break;
+        }
+
+        numCmds = clang_tooling_CompileCommands_getSize(CCmds);
+
+        if (numCmds==0) {
+          fprintf(stderr, "should not get an empty compileCommand set for file"
+                          " '%s'\n", argv[i+1]);
+          errorCode = -1;
+          break;
+        }
+
+        for (j=0; j<numCmds; ++j) {
+          CCmd = clang_tooling_CompileCommands_getCommand(CCmds, j);
+
+          wd = clang_tooling_CompileCommand_getDirectory(CCmd);
+          printf("workdir:'%s'", clang_getCString(wd));
+          clang_disposeString(wd);
+
+          printf(" cmdline:'");
+          numArgs = clang_tooling_CompileCommand_getNumArgs(CCmd);
+          for (a=0; a<numArgs; ++a) {
+            if (a) printf(" ");
+            arg = clang_tooling_CompileCommand_getArg(CCmd, a);
+            printf("%s", clang_getCString(arg));
+            clang_disposeString(arg);
+          }
+          printf("'\n");
+        }
+
+        clang_tooling_CompileCommands_dispose(CCmds);
+
+        i += 2;
+      }
+    }
+    clang_tooling_CompilationDatabase_dispose(db);
+  } else {
+    printf("database loading failed with error code %d.\n", ec);
+    errorCode = -1;
+  }
+
+cdb_end:
+  free(tmp);
+
+  return errorCode;
+}
+
 /******************************************************************************/
 /* USR printing.                                                              */
 /******************************************************************************/
@@ -2783,6 +2902,8 @@
     "       c-index-test -print-usr-file <file>\n"
     "       c-index-test -write-pch <file> <compiler arguments>\n");
   fprintf(stderr,
+    "       c-index-test -compilation-db [lookup <filename>] database\n");
+  fprintf(stderr,
     "       c-index-test -read-diagnostics <file>\n\n");
   fprintf(stderr,
     " <symbol filter> values:\n%s",
@@ -2868,7 +2989,9 @@
     return print_usrs_file(argv[2]);
   else if (argc > 2 && strcmp(argv[1], "-write-pch") == 0)
     return write_pch_file(argv[2], argc - 3, argv + 3);
-           
+  else if (argc > 2 && strcmp(argv[1], "-compilation-db") == 0)
+    return perform_test_compilation_db(argv[argc-1], argc - 3, argv + 2);
+
   print_usage();
   return 1;
 }

Modified: cfe/branches/tooling/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CIndex.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CIndex.cpp Sat Jun 30 16:45:28 2012
@@ -5707,6 +5707,24 @@
 
 } // end: extern "C"
 
+CXString clang_Cursor_getBriefCommentText(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+    return createCXString((const char *) NULL);
+
+  const Decl *D = getCursorDecl(C);
+  const ASTContext &Context = getCursorContext(C);
+  const RawComment *RC = Context.getRawCommentForDecl(D);
+
+  if (RC) {
+    StringRef BriefText = RC->getBriefText(Context);
+
+    // Don't duplicate the string because RawComment ensures that this memory
+    // will not go away.
+    return createCXString(BriefText, false);
+  }
+
+  return createCXString((const char *) NULL);
+}
 
 //===----------------------------------------------------------------------===//
 // C++ AST instrospection.

Modified: cfe/branches/tooling/tools/libclang/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CMakeLists.txt?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CMakeLists.txt (original)
+++ cfe/branches/tooling/tools/libclang/CMakeLists.txt Sat Jun 30 16:45:28 2012
@@ -17,6 +17,7 @@
   CIndexer.h
   CXCursor.cpp
   CXCursor.h
+  CXCompilationDatabase.cpp
   CXLoadedDiagnostic.cpp
   CXLoadedDiagnostic.h
   CXSourceLocation.cpp
@@ -47,6 +48,7 @@
   clangEdit
   clangAST
   clangLex
+  clangTooling
   clangBasic
   )
 

Modified: cfe/branches/tooling/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/Indexing.cpp?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/Indexing.cpp (original)
+++ cfe/branches/tooling/tools/libclang/Indexing.cpp Sat Jun 30 16:45:28 2012
@@ -369,7 +369,6 @@
     IndexActionCleanup(IndexAction.get());
 
   bool Persistent = requestedToGetTU;
-  StringRef ResourceFilesPath = CXXIdx->getClangResourcesPath();
   bool OnlyLocalDecls = false;
   bool PrecompilePreamble = false;
   bool CacheCodeCompletionResults = false;
@@ -393,7 +392,7 @@
                                                        IndexAction.get(),
                                                        Unit,
                                                        Persistent,
-                                                       ResourceFilesPath,
+                                                CXXIdx->getClangResourcesPath(),
                                                        OnlyLocalDecls,
                                                     /*CaptureDiagnostics=*/true,
                                                        PrecompilePreamble,

Modified: cfe/branches/tooling/tools/libclang/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/Makefile?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/Makefile (original)
+++ cfe/branches/tooling/tools/libclang/Makefile Sat Jun 30 16:45:28 2012
@@ -19,7 +19,7 @@
 USEDLIBS = clangARCMigrate.a clangRewrite.a clangFrontend.a clangDriver.a \
      clangSerialization.a \
 		 clangParse.a clangSema.a clangEdit.a clangAnalysis.a \
-		 clangAST.a clangLex.a clangBasic.a
+		 clangAST.a clangLex.a clangTooling.a clangBasic.a
 
 include $(CLANG_LEVEL)/Makefile
 

Modified: cfe/branches/tooling/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/libclang.exports?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/libclang.exports (original)
+++ cfe/branches/tooling/tools/libclang/libclang.exports Sat Jun 30 16:45:28 2012
@@ -5,6 +5,7 @@
 clang_CXXMethod_isStatic
 clang_CXXMethod_isVirtual
 clang_Cursor_getArgument
+clang_Cursor_getBriefCommentText
 clang_Cursor_getCommentRange
 clang_Cursor_getRawCommentText
 clang_Cursor_getNumArguments
@@ -203,5 +204,14 @@
 clang_sortCodeCompletionResults
 clang_toggleCrashRecovery
 clang_tokenize
+clang_tooling_CompilationDatabase_fromDirectory
+clang_tooling_CompilationDatabase_dispose
+clang_tooling_CompilationDatabase_getCompileCommands
+clang_tooling_CompileCommands_dispose
+clang_tooling_CompileCommands_getSize
+clang_tooling_CompileCommands_getCommand
+clang_tooling_CompileCommand_getDirectory
+clang_tooling_CompileCommand_getNumArgs
+clang_tooling_CompileCommand_getArg
 clang_visitChildren
 clang_visitChildrenWithBlock

Modified: cfe/branches/tooling/unittests/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/Makefile?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/Makefile (original)
+++ cfe/branches/tooling/unittests/Makefile Sat Jun 30 16:45:28 2012
@@ -14,7 +14,7 @@
 
 IS_UNITTEST_LEVEL := 1
 CLANG_LEVEL := ..
-PARALLEL_DIRS = ASTMatchers Basic Frontend Lex Tooling
+PARALLEL_DIRS = ASTMatchers Basic AST Frontend Lex Tooling
 
 endif  # CLANG_LEVEL
 

Modified: cfe/branches/tooling/www/content.css
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/content.css?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/www/content.css (original)
+++ cfe/branches/tooling/www/content.css Sat Jun 30 16:45:28 2012
@@ -27,6 +27,7 @@
 span.warning { color:purple }
 span.note { color:gray }
 span.caret { color:green; font-weight:bold }
+span.template-highlight { color:cyan }
 
 /* Tables */
 tr { vertical-align:top }

Modified: cfe/branches/tooling/www/diagnostics.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/diagnostics.html?rev=159496&r1=159495&r2=159496&view=diff
==============================================================================
--- cfe/branches/tooling/www/diagnostics.html (original)
+++ cfe/branches/tooling/www/diagnostics.html Sat Jun 30 16:45:28 2012
@@ -263,6 +263,39 @@
     <span class="snip">template<> </span>
 </pre>
 
+<h2>Template Type Diffing</h2>
+
+<p>Templates types can be long and difficult to read.  Moreso when part of an
+error message.  Instead of just printing out the type name, Clang has enough
+information to remove the common elements and highlight the differences.  To
+show the template structure more clearly, the templated type can also be
+printed as an indented text tree.</p>
+
+Default: template diff with type elision
+<pre>
+t.cc:4:5: <span class="note">note:</span> candidate function not viable: no known conversion from 'vector<map<[...], <span class="template-highlight">float</span>>>' to 'vector<map<[...], <span class="template-highlight">double</span>>>' for 1st argument;
+</pre>
+-fno-elide-type: template diff without elision
+<pre>
+t.cc:4:5: <span class="note">note:</span> candidate function not viable: no known conversion from 'vector<map<int, <span class="template-highlight">float</span>>>' to 'vector<map<int, <span class="template-highlight">double</span>>>' for 1st argument;
+</pre>
+-fdiagnostics-show-template-tree: template tree printing with elision
+<pre>
+t.cc:4:5: <span class="note">note:</span> candidate function not viable: no known conversion for 1st argument;
+  vector<
+    map<
+      [...], 
+      [<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]>>
+</pre>
+-fdiagnostics-show-template-tree -fno-elide-type: template tree printing with no elision
+<pre>
+t.cc:4:5: <span class="note">note:M</span> candidate function not viable: no known conversion for 1st argument;
+  vector<
+    map<
+      int, 
+      [<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]>>
+</pre>
+
 <h2>Automatic Macro Expansion</h2>
 
 <p>Many errors happen in macros that are sometimes deeply nested.  With





More information about the llvm-branch-commits mailing list