[llvm-branch-commits] [cfe-branch] r148958 - in /cfe/branches/tooling: ./ docs/ include/clang/Basic/ include/clang/Driver/ include/clang/Frontend/ include/clang/Lex/ include/clang/Sema/ include/clang/Serialization/ include/clang/StaticAnalyzer/Core/PathSensitive/ lib/ARCMigrate/ lib/AST/ lib/Analysis/ lib/CodeGen/ lib/Driver/ lib/Frontend/ lib/Headers/ lib/Lex/ lib/Parse/ lib/Sema/ lib/Serialization/ lib/StaticAnalyzer/Checkers/ lib/StaticAnalyzer/Core/ test/ARCMT/ test/Analysis/ test/CodeGen/ test/CodeGenCXX/ test/Driver/ te...

Manuel Klimek klimek at google.com
Wed Jan 25 07:40:57 PST 2012


Author: klimek
Date: Wed Jan 25 09:40:56 2012
New Revision: 148958

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

Added:
    cfe/branches/tooling/include/clang/Frontend/MigratorOptions.h
      - copied unchanged from r148957, cfe/trunk/include/clang/Frontend/MigratorOptions.h
    cfe/branches/tooling/test/ARCMT/GC-check-warn-nsalloc.m
      - copied unchanged from r148957, cfe/trunk/test/ARCMT/GC-check-warn-nsalloc.m
    cfe/branches/tooling/test/Analysis/taint-tester.cpp
      - copied unchanged from r148957, cfe/trunk/test/Analysis/taint-tester.cpp
    cfe/branches/tooling/test/CodeGen/address-safety-attr.cpp
      - copied unchanged from r148957, cfe/trunk/test/CodeGen/address-safety-attr.cpp
    cfe/branches/tooling/test/CodeGen/avx-builtins.c
      - copied unchanged from r148957, cfe/trunk/test/CodeGen/avx-builtins.c
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd64_tree/
      - copied from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd64_tree/
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd64_tree/lib/
      - copied from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd64_tree/lib/
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd64_tree/lib/.keep
      - copied unchanged from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd64_tree/lib/.keep
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd64_tree/usr/
      - copied from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd64_tree/usr/
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/
      - copied from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep
      - copied unchanged from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/
      - copied from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep
      - copied unchanged from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd_tree/
      - copied from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd_tree/
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd_tree/lib/
      - copied from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd_tree/lib/
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd_tree/lib/.keep
      - copied unchanged from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd_tree/lib/.keep
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd_tree/usr/
      - copied from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd_tree/usr/
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd_tree/usr/lib/
      - copied from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd_tree/usr/lib/
    cfe/branches/tooling/test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep
      - copied unchanged from r148957, cfe/trunk/test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep
    cfe/branches/tooling/test/Misc/diag-macro-backtrace.c
      - copied unchanged from r148957, cfe/trunk/test/Misc/diag-macro-backtrace.c
    cfe/branches/tooling/test/Modules/Inputs/MethodPoolA.h
      - copied unchanged from r148957, cfe/trunk/test/Modules/Inputs/MethodPoolA.h
    cfe/branches/tooling/test/Modules/Inputs/MethodPoolB.h
      - copied unchanged from r148957, cfe/trunk/test/Modules/Inputs/MethodPoolB.h
    cfe/branches/tooling/test/Modules/method_pool.m
      - copied unchanged from r148957, cfe/trunk/test/Modules/method_pool.m
    cfe/branches/tooling/test/SemaCXX/Inputs/warn-new-overaligned-3.h
      - copied unchanged from r148957, cfe/trunk/test/SemaCXX/Inputs/warn-new-overaligned-3.h
    cfe/branches/tooling/test/SemaCXX/PR11358.cpp
      - copied unchanged from r148957, cfe/trunk/test/SemaCXX/PR11358.cpp
    cfe/branches/tooling/test/SemaCXX/warn-new-overaligned-2.cpp
      - copied unchanged from r148957, cfe/trunk/test/SemaCXX/warn-new-overaligned-2.cpp
    cfe/branches/tooling/test/SemaCXX/warn-new-overaligned-3.cpp
      - copied unchanged from r148957, cfe/trunk/test/SemaCXX/warn-new-overaligned-3.cpp
    cfe/branches/tooling/test/SemaCXX/warn-new-overaligned.cpp
      - copied unchanged from r148957, cfe/trunk/test/SemaCXX/warn-new-overaligned.cpp
    cfe/branches/tooling/test/SemaObjC/builtin_objc_nslog.m
      - copied unchanged from r148957, cfe/trunk/test/SemaObjC/builtin_objc_nslog.m
    cfe/branches/tooling/test/SemaObjCXX/fragile-abi-object-assign.m
      - copied unchanged from r148957, cfe/trunk/test/SemaObjCXX/fragile-abi-object-assign.m
Removed:
    cfe/branches/tooling/include/clang/Driver/HostInfo.h
    cfe/branches/tooling/lib/Driver/HostInfo.cpp
Modified:
    cfe/branches/tooling/   (props changed)
    cfe/branches/tooling/docs/LanguageExtensions.html
    cfe/branches/tooling/include/clang/Basic/Attr.td
    cfe/branches/tooling/include/clang/Basic/Builtins.def
    cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def
    cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/branches/tooling/include/clang/Driver/CC1Options.td
    cfe/branches/tooling/include/clang/Driver/Driver.h
    cfe/branches/tooling/include/clang/Driver/ToolChain.h
    cfe/branches/tooling/include/clang/Frontend/ChainedIncludesSource.h
    cfe/branches/tooling/include/clang/Frontend/CompilerInvocation.h
    cfe/branches/tooling/include/clang/Lex/Preprocessor.h
    cfe/branches/tooling/include/clang/Sema/AttributeList.h
    cfe/branches/tooling/include/clang/Sema/ExternalSemaSource.h
    cfe/branches/tooling/include/clang/Sema/Sema.h
    cfe/branches/tooling/include/clang/Serialization/ASTReader.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
    cfe/branches/tooling/lib/ARCMigrate/ARCMT.cpp
    cfe/branches/tooling/lib/ARCMigrate/Internals.h
    cfe/branches/tooling/lib/ARCMigrate/TransGCCalls.cpp
    cfe/branches/tooling/lib/ARCMigrate/TransformActions.cpp
    cfe/branches/tooling/lib/AST/ASTImporter.cpp
    cfe/branches/tooling/lib/AST/Type.cpp
    cfe/branches/tooling/lib/Analysis/FormatString.cpp
    cfe/branches/tooling/lib/Analysis/PrintfFormatString.cpp
    cfe/branches/tooling/lib/Analysis/ScanfFormatString.cpp
    cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp
    cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
    cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h
    cfe/branches/tooling/lib/CodeGen/CGExpr.cpp
    cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp
    cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
    cfe/branches/tooling/lib/Driver/CMakeLists.txt
    cfe/branches/tooling/lib/Driver/Driver.cpp
    cfe/branches/tooling/lib/Driver/ToolChain.cpp
    cfe/branches/tooling/lib/Driver/ToolChains.cpp
    cfe/branches/tooling/lib/Driver/ToolChains.h
    cfe/branches/tooling/lib/Driver/Tools.cpp
    cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp
    cfe/branches/tooling/lib/Frontend/ChainedIncludesSource.cpp
    cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
    cfe/branches/tooling/lib/Frontend/DiagnosticRenderer.cpp
    cfe/branches/tooling/lib/Headers/avxintrin.h
    cfe/branches/tooling/lib/Headers/unwind.h
    cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp
    cfe/branches/tooling/lib/Parse/ParseTentative.cpp
    cfe/branches/tooling/lib/Sema/AttributeList.cpp
    cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp
    cfe/branches/tooling/lib/Sema/Sema.cpp
    cfe/branches/tooling/lib/Sema/SemaChecking.cpp
    cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp
    cfe/branches/tooling/lib/Sema/SemaDecl.cpp
    cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp
    cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp
    cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp
    cfe/branches/tooling/lib/Sema/SemaExpr.cpp
    cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp
    cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp
    cfe/branches/tooling/lib/Sema/TreeTransform.h
    cfe/branches/tooling/lib/Serialization/ASTReader.cpp
    cfe/branches/tooling/lib/Serialization/ASTReaderInternals.h
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
    cfe/branches/tooling/test/Analysis/reference.cpp
    cfe/branches/tooling/test/Analysis/taint-tester.c
    cfe/branches/tooling/test/CodeGen/builtins-x86.c
    cfe/branches/tooling/test/CodeGenCXX/conditional-gnu-ext.cpp
    cfe/branches/tooling/test/Driver/freebsd.c
    cfe/branches/tooling/test/Index/TestClassDecl.m
    cfe/branches/tooling/test/Index/TestClassForwardDecl.m
    cfe/branches/tooling/test/Index/annotate-tokens.m
    cfe/branches/tooling/test/Index/file-refs.m
    cfe/branches/tooling/test/Index/properties-class-extensions.m
    cfe/branches/tooling/test/Modules/Inputs/module.map
    cfe/branches/tooling/test/Sema/block-printf-attribute-1.c
    cfe/branches/tooling/test/Sema/format-strings-scanf.c
    cfe/branches/tooling/test/Sema/format-strings.c
    cfe/branches/tooling/test/SemaCXX/exceptions.cpp
    cfe/branches/tooling/test/SemaCXX/type-traits.cpp
    cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp   (props changed)
    cfe/branches/tooling/test/SemaObjC/builtin_objc_lib_functions.m
    cfe/branches/tooling/test/SemaObjC/deref-interface.m
    cfe/branches/tooling/test/SemaObjC/format-strings-objc.m
    cfe/branches/tooling/test/SemaTemplate/alias-templates.cpp
    cfe/branches/tooling/test/SemaTemplate/instantiate-function-1.cpp
    cfe/branches/tooling/tools/libclang/CIndex.cpp
    cfe/branches/tooling/tools/scan-build/scan-build
    cfe/branches/tooling/utils/analyzer/CmpRuns.py
    cfe/branches/tooling/utils/analyzer/SATestBuild.py

Propchange: cfe/branches/tooling/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 25 09:40:56 2012
@@ -1,3 +1,3 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:146581-148800
+/cfe/trunk:146581-148957
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/tooling/docs/LanguageExtensions.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/LanguageExtensions.html?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/docs/LanguageExtensions.html (original)
+++ cfe/branches/tooling/docs/LanguageExtensions.html Wed Jan 25 09:40:56 2012
@@ -1453,6 +1453,10 @@
 to check if the code is being built with <a
   href="AddressSanitizer.html">AddressSanitizer</a>.
 </p>
+<p>Use <tt>__attribute__((no_address_safety_analysis))</tt> on a function
+declaration to specify that address safety instrumentation (e.g.
+AddressSanitizer) should not be applied to that function.
+</p>
 
 <!-- ======================================================================= -->
 <h2 id="threadsafety">Thread-Safety Annotation Checking</h2>

Modified: cfe/branches/tooling/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/Attr.td?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/Attr.td (original)
+++ cfe/branches/tooling/include/clang/Basic/Attr.td Wed Jan 25 09:40:56 2012
@@ -576,6 +576,10 @@
   let Spellings = [];
 }
 
+// AddressSafety attribute (e.g. for AddressSanitizer)
+def NoAddressSafetyAnalysis : InheritableAttr {
+  let Spellings = ["no_address_safety_analysis"];
+}
 
 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
 

Modified: cfe/branches/tooling/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/Builtins.def?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/Builtins.def (original)
+++ cfe/branches/tooling/include/clang/Basic/Builtins.def Wed Jan 25 09:40:56 2012
@@ -728,34 +728,39 @@
 LIBBUILTIN(objc_enumerationMutation, "vG", "f", "objc/runtime.h", OBJC_LANG)
 
 // id objc_read_weak(id *location)
-LIBBUILTIN(objc_read_weak, "GG*", "f", "/objc/objc-auto.h", OBJC_LANG)
+LIBBUILTIN(objc_read_weak, "GG*", "f", "objc/objc-auto.h", OBJC_LANG)
 // id objc_assign_weak(id value, id *location)
-LIBBUILTIN(objc_assign_weak, "GGG*", "f", "/objc/objc-auto.h", OBJC_LANG)
+LIBBUILTIN(objc_assign_weak, "GGG*", "f", "objc/objc-auto.h", OBJC_LANG)
 // id objc_assign_ivar(id value, id dest, ptrdiff_t offset)
-LIBBUILTIN(objc_assign_ivar, "GGGY", "f", "/objc/objc-auto.h", OBJC_LANG)
+LIBBUILTIN(objc_assign_ivar, "GGGY", "f", "objc/objc-auto.h", OBJC_LANG)
 // id objc_assign_global(id val, id *dest)
-LIBBUILTIN(objc_assign_global, "GGG*", "f", "/objc/objc-auto.h", OBJC_LANG)
+LIBBUILTIN(objc_assign_global, "GGG*", "f", "objc/objc-auto.h", OBJC_LANG)
 // id objc_assign_strongCast(id val, id *dest
-LIBBUILTIN(objc_assign_strongCast, "GGG*", "f", "/objc/objc-auto.h", OBJC_LANG)
+LIBBUILTIN(objc_assign_strongCast, "GGG*", "f", "objc/objc-auto.h", OBJC_LANG)
 
 // id objc_exception_extract(void *localExceptionData)
-LIBBUILTIN(objc_exception_extract, "Gv*", "f", "/objc/objc-exception.h", OBJC_LANG)
+LIBBUILTIN(objc_exception_extract, "Gv*", "f", "objc/objc-exception.h", OBJC_LANG)
 // void objc_exception_try_enter(void *localExceptionData)
-LIBBUILTIN(objc_exception_try_enter, "vv*", "f", "/objc/objc-exception.h", OBJC_LANG)
+LIBBUILTIN(objc_exception_try_enter, "vv*", "f", "objc/objc-exception.h", OBJC_LANG)
 // void objc_exception_try_exit(void *localExceptionData)
-LIBBUILTIN(objc_exception_try_exit, "vv*", "f", "/objc/objc-exception.h", OBJC_LANG)
+LIBBUILTIN(objc_exception_try_exit, "vv*", "f", "objc/objc-exception.h", OBJC_LANG)
 // int objc_exception_match(Class exceptionClass, id exception)
-LIBBUILTIN(objc_exception_match, "iGG", "f", "/objc/objc-exception.h", OBJC_LANG)
+LIBBUILTIN(objc_exception_match, "iGG", "f", "objc/objc-exception.h", OBJC_LANG)
 // void objc_exception_throw(id exception)
-LIBBUILTIN(objc_exception_throw, "vG", "f", "/objc/objc-exception.h", OBJC_LANG)
+LIBBUILTIN(objc_exception_throw, "vG", "f", "objc/objc-exception.h", OBJC_LANG)
 
 // int objc_sync_enter(id obj)
-LIBBUILTIN(objc_sync_enter, "iG", "f", "/objc/objc-sync.h", OBJC_LANG)
+LIBBUILTIN(objc_sync_enter, "iG", "f", "objc/objc-sync.h", OBJC_LANG)
 // int objc_sync_exit(id obj)
-LIBBUILTIN(objc_sync_exit, "iG", "f", "/objc/objc-sync.h", OBJC_LANG)
+LIBBUILTIN(objc_sync_exit, "iG", "f", "objc/objc-sync.h", OBJC_LANG)
 
 BUILTIN(__builtin_objc_memmove_collectable, "v*v*vC*z", "nF")
 
+// void NSLog(NSString *fmt, ...)
+LIBBUILTIN(NSLog, "vG.", "fp:0:", "Foundation/NSObjCRuntime.h", OBJC_LANG)
+// void NSLogv(NSString *fmt, va_list args)
+LIBBUILTIN(NSLogv, "vGa", "fP:0:", "Foundation/NSObjCRuntime.h", OBJC_LANG)
+
 // Builtin math library functions
 LIBBUILTIN(pow, "ddd", "fe", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(powl, "LdLdLd", "fe", "math.h", ALL_LANGUAGES)

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=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def Wed Jan 25 09:40:56 2012
@@ -453,11 +453,8 @@
 BUILTIN(__builtin_ia32_vbroadcastss256, "V8ffC*", "")
 BUILTIN(__builtin_ia32_vbroadcastf128_pd256, "V4dV2dC*", "")
 BUILTIN(__builtin_ia32_vbroadcastf128_ps256, "V8fV4fC*", "")
-BUILTIN(__builtin_ia32_loadupd256, "V4ddC*", "")
-BUILTIN(__builtin_ia32_loadups256, "V8ffC*", "")
 BUILTIN(__builtin_ia32_storeupd256, "vd*V4d", "")
 BUILTIN(__builtin_ia32_storeups256, "vf*V8f", "")
-BUILTIN(__builtin_ia32_loaddqu256, "V32ccC*", "")
 BUILTIN(__builtin_ia32_storedqu256, "vc*V32c", "")
 BUILTIN(__builtin_ia32_lddqu256, "V32ccC*", "")
 BUILTIN(__builtin_ia32_movntdq256, "vV4LLi*V4LLi", "")

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=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td Wed Jan 25 09:40:56 2012
@@ -31,7 +31,6 @@
 def CXXCompat: DiagGroup<"c++-compat">;
 def CastAlign : DiagGroup<"cast-align">;
 def : DiagGroup<"cast-qual">;
-def CatchIncompleteExtension : DiagGroup<"catch-incomplete-type-extensions">;
 def : DiagGroup<"char-align">;
 def Comment : DiagGroup<"comment">;
 def : DiagGroup<"ctor-dtor-privacy">;
@@ -123,6 +122,7 @@
 def NonNull : DiagGroup<"nonnull">;
 def : DiagGroup<"nonportable-cfstrings">;
 def NonVirtualDtor : DiagGroup<"non-virtual-dtor">;
+def OveralignedType : DiagGroup<"over-aligned">;
 def : DiagGroup<"old-style-cast">;
 def : DiagGroup<"old-style-definition">;
 def OutOfLineDeclaration : DiagGroup<"out-of-line-declaration">;

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=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td Wed Jan 25 09:40:56 2012
@@ -3606,8 +3606,8 @@
   "behavior.">,
   InGroup<DiagGroup<"undefined-reinterpret-cast">>, DefaultIgnore;
 
-def err_assignment_requires_nonfragile_object : Error<
-  "cannot assign to class object in non-fragile ABI (%0 invalid)">;
+def err_objc_object_assignment : Error<
+  "cannot assign to class object (%0 invalid)">;
 def err_direct_interface_unsupported : Error<
   "indirection to an interface is not supported (%0 invalid)">;
 def err_typecheck_invalid_operands : Error<
@@ -3984,12 +3984,10 @@
 def err_decrement_bool : Error<"cannot decrement expression of type bool">;
 def warn_increment_bool : Warning<
   "incrementing expression of type bool is deprecated">, InGroup<Deprecated>;
-def ext_catch_incomplete_ptr : ExtWarn<
-  "ISO C++ forbids catching a pointer to incomplete type %0">,
-  InGroup<CatchIncompleteExtension>;
-def ext_catch_incomplete_ref : ExtWarn<
-  "ISO C++ forbids catching a reference to incomplete type %0">,
-  InGroup<CatchIncompleteExtension>;
+def err_catch_incomplete_ptr : Error<
+  "cannot catch pointer to incomplete type %0">;
+def err_catch_incomplete_ref : Error<
+  "cannot catch reference to incomplete type %0">;
 def err_catch_incomplete : Error<"cannot catch incomplete type %0">;
 def err_catch_rvalue_ref : Error<"cannot catch exceptions by rvalue reference">;
 def err_qualified_catch_declarator : Error<
@@ -4026,6 +4024,11 @@
 def warn_using_directive_in_header : Warning<
   "using namespace directive in global context in header">,
   InGroup<HeaderHygiene>, DefaultIgnore;
+def warn_overaligned_type : Warning<
+  "type %0 requires %1 bytes of alignment and the default allocator only "
+  "guarantees %2 bytes">,
+  InGroup<OveralignedType>, DefaultIgnore;
+def note_overaligned_type : Note<"over-aligned here">;
 
 def err_conditional_void_nonvoid : Error<
   "%select{left|right}1 operand to ? is void, but %select{right|left}1 operand "

Modified: cfe/branches/tooling/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/CC1Options.td?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/CC1Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/CC1Options.td Wed Jan 25 09:40:56 2012
@@ -101,6 +101,12 @@
   HelpText<"Display the list of analyzer checkers that are available">;
 
 //===----------------------------------------------------------------------===//
+// Migrator Options
+//===----------------------------------------------------------------------===//
+def migrator_no_nsalloc_error : Flag<"-no-ns-alloc-error">,
+  HelpText<"Do not error on use of NSAllocateCollectable/NSReallocateCollectable">;
+
+//===----------------------------------------------------------------------===//
 // CodeGen Options
 //===----------------------------------------------------------------------===//
 

Modified: cfe/branches/tooling/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/Driver.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/Driver.h (original)
+++ cfe/branches/tooling/include/clang/Driver/Driver.h Wed Jan 25 09:40:56 2012
@@ -16,6 +16,7 @@
 #include "clang/Driver/Types.h"
 #include "clang/Driver/Util.h"
 
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Path.h" // FIXME: Kill when CompilationInfo
@@ -35,7 +36,6 @@
   class Command;
   class Compilation;
   class DerivedArgList;
-  class HostInfo;
   class InputArgList;
   class InputInfo;
   class JobAction;
@@ -95,18 +95,9 @@
   /// Driver title to use with help.
   std::string DriverTitle;
 
-  /// Host information for the platform the driver is running as. This
-  /// will generally be the actual host platform, but not always.
-  const HostInfo *Host;
-
   /// Information about the host which can be overridden by the user.
   std::string HostBits, HostMachine, HostSystem, HostRelease;
 
-  /// \brief Target triple.
-  /// Represents which platforms this driver will target at each stage of the
-  /// compilation.
-  llvm::Triple TargetTriple;
-
   /// The file to log CC_PRINT_OPTIONS output to, if enabled.
   const char *CCPrintOptionsFilename;
 
@@ -180,6 +171,13 @@
   std::list<std::string> TempFiles;
   std::list<std::string> ResultFiles;
 
+  /// \brief Cache of all the ToolChains in use by the driver.
+  ///
+  /// This maps from the string representation of a triple to a ToolChain
+  /// created targetting that triple. The driver owns all the ToolChain objects
+  /// stored in it, and will clean them up when torn down.
+  mutable llvm::StringMap<ToolChain *> ToolChains;
+
 private:
   /// TranslateInputArgs - Create a new derived argument list from the input
   /// arguments, after applying the standard argument translations.
@@ -384,10 +382,6 @@
   /// GCC goes to extra lengths here to be a bit more robust.
   std::string GetTemporaryPath(StringRef Prefix, const char *Suffix) const;
 
-  /// GetHostInfo - Construct a new host info object for the given
-  /// host triple.
-  const HostInfo *GetHostInfo(const llvm::Triple &Triple) const;
-
   /// ShouldUseClangCompilar - Should the clang compiler be used to
   /// handle this action.
   bool ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
@@ -395,8 +389,17 @@
 
   bool IsUsingLTO(const ArgList &Args) const;
 
+private:
+  /// \brief Retrieves a ToolChain for a particular target triple.
+  ///
+  /// Will cache ToolChains for the life of the driver object, and create them
+  /// on-demand.
+  const ToolChain &getToolChain(const ArgList &Args,
+                                StringRef DarwinArchName = "") const;
+
   /// @}
 
+public:
   /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
   /// return the grouped values as integers. Numbers which are not
   /// provided are set to 0.

Removed: cfe/branches/tooling/include/clang/Driver/HostInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/HostInfo.h?rev=148957&view=auto
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/HostInfo.h (original)
+++ cfe/branches/tooling/include/clang/Driver/HostInfo.h (removed)
@@ -1,90 +0,0 @@
-//===--- HostInfo.h - Host specific information -----------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef CLANG_DRIVER_HOSTINFO_H_
-#define CLANG_DRIVER_HOSTINFO_H_
-
-#include "llvm/ADT/Triple.h"
-#include <string>
-
-namespace clang {
-namespace driver {
-  class ArgList;
-  class Driver;
-  class ToolChain;
-
-/// HostInfo - Config information about a particular host which may interact
-/// with driver behavior.
-///
-/// The host information is used for controlling the parts of the driver which
-/// interact with the platform the driver is ostensibly being run from. For
-/// testing purposes, the HostInfo used by the driver may differ from the actual
-/// host.
-class HostInfo {
-protected:
-  const Driver &TheDriver;
-  const llvm::Triple Triple;
-
-  HostInfo(const Driver &D, const llvm::Triple &_Triple);
-
-public:
-  virtual ~HostInfo();
-
-  const Driver &getDriver() const { return TheDriver; }
-
-  const llvm::Triple& getTriple() const { return Triple; }
-  std::string getArchName() const { return Triple.getArchName(); }
-  std::string getPlatformName() const { return Triple.getVendorName(); }
-  std::string getOSName() const { return Triple.getOSName(); }
-
-  /// CreateToolChain - Construct the toolchain to use for this host (which the
-  /// host retains ownership of).
-  ///
-  /// \param Args - The argument list, which may be used to alter the default
-  /// toolchain, for example in the presence of -m32 or -m64.
-  ///
-  /// \param ArchName - The architecture to return a toolchain for, or 0 if
-  /// unspecified. This will only ever be non-zero for hosts which support a
-  /// driver driver.
-
-  // FIXME: Pin down exactly what the HostInfo is allowed to use Args
-  // for here. Currently this is for -m32 / -m64 defaulting.
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName=0) const = 0;
-};
-
-const HostInfo *createAuroraUXHostInfo(const Driver &D,
-                                       const llvm::Triple& Triple);
-const HostInfo *createDarwinHostInfo(const Driver &D,
-                                     const llvm::Triple& Triple);
-const HostInfo *createOpenBSDHostInfo(const Driver &D,
-                                      const llvm::Triple& Triple);
-const HostInfo *createFreeBSDHostInfo(const Driver &D,
-                                      const llvm::Triple& Triple);
-const HostInfo *createNetBSDHostInfo(const Driver &D,
-                                      const llvm::Triple& Triple);
-const HostInfo *createMinixHostInfo(const Driver &D,
-                                      const llvm::Triple& Triple);
-const HostInfo *createDragonFlyHostInfo(const Driver &D,
-                                        const llvm::Triple& Triple);
-const HostInfo *createLinuxHostInfo(const Driver &D,
-                                    const llvm::Triple& Triple);
-const HostInfo *createTCEHostInfo(const Driver &D, 
-                                  const llvm::Triple& Triple);
-const HostInfo *createWindowsHostInfo(const Driver &D,
-                                      const llvm::Triple &Triple);
-const HostInfo *createMinGWHostInfo(const Driver &D,
-                                    const llvm::Triple &Triple);
-const HostInfo *createUnknownHostInfo(const Driver &D,
-                                      const llvm::Triple& Triple);
-
-} // end namespace driver
-} // end namespace clang
-
-#endif

Modified: cfe/branches/tooling/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/ToolChain.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/ToolChain.h (original)
+++ cfe/branches/tooling/include/clang/Driver/ToolChain.h Wed Jan 25 09:40:56 2012
@@ -23,7 +23,6 @@
   class Compilation;
   class DerivedArgList;
   class Driver;
-  class HostInfo;
   class InputArgList;
   class JobAction;
   class ObjCRuntime;
@@ -45,7 +44,7 @@
   };
 
 private:
-  const HostInfo &Host;
+  const Driver &D;
   const llvm::Triple Triple;
 
   /// The list of toolchain specific path prefixes to search for
@@ -57,7 +56,7 @@
   path_list ProgramPaths;
 
 protected:
-  ToolChain(const HostInfo &Host, const llvm::Triple &_Triple);
+  ToolChain(const Driver &D, const llvm::Triple &T);
 
   /// \name Utilities for implementing subclasses.
   ///@{

Modified: cfe/branches/tooling/include/clang/Frontend/ChainedIncludesSource.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/ChainedIncludesSource.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/ChainedIncludesSource.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/ChainedIncludesSource.h Wed Jan 25 09:40:56 2012
@@ -66,7 +66,7 @@
 
   virtual void InitializeSema(Sema &S);
   virtual void ForgetSema();
-  virtual std::pair<ObjCMethodList,ObjCMethodList> ReadMethodPool(Selector Sel);
+  virtual void ReadMethodPool(Selector Sel);
   virtual bool LookupUnqualified(LookupResult &R, Scope *S);
 };
 

Modified: cfe/branches/tooling/include/clang/Frontend/CompilerInvocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/CompilerInvocation.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/CompilerInvocation.h Wed Jan 25 09:40:56 2012
@@ -14,6 +14,7 @@
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Frontend/AnalyzerOptions.h"
+#include "clang/Frontend/MigratorOptions.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Frontend/DependencyOutputOptions.h"
 #include "clang/Frontend/DiagnosticOptions.h"
@@ -56,6 +57,8 @@
   /// Options controlling the static analyzer.
   AnalyzerOptions AnalyzerOpts;
 
+  MigratorOptions MigratorOpts;
+  
   /// Options controlling IRgen and the backend.
   CodeGenOptions CodeGenOpts;
 
@@ -147,6 +150,11 @@
     return AnalyzerOpts;
   }
 
+  MigratorOptions &getMigratorOpts() { return MigratorOpts; }
+  const MigratorOptions &getMigratorOpts() const {
+    return MigratorOpts;
+  }
+  
   CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; }
   const CodeGenOptions &getCodeGenOpts() const {
     return CodeGenOpts;

Modified: cfe/branches/tooling/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/Preprocessor.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/Preprocessor.h (original)
+++ cfe/branches/tooling/include/clang/Lex/Preprocessor.h Wed Jan 25 09:40:56 2012
@@ -433,7 +433,8 @@
 
   /// setMacroInfo - Specify a macro for this identifier.
   ///
-  void setMacroInfo(IdentifierInfo *II, MacroInfo *MI);
+  void setMacroInfo(IdentifierInfo *II, MacroInfo *MI,
+                    bool LoadedFromAST = false);
 
   /// macro_iterator/macro_begin/macro_end - This allows you to walk the current
   /// state of the macro table.  This visits every currently-defined macro.

Modified: cfe/branches/tooling/include/clang/Sema/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/AttributeList.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/AttributeList.h (original)
+++ cfe/branches/tooling/include/clang/Sema/AttributeList.h Wed Jan 25 09:40:56 2012
@@ -218,6 +218,7 @@
     AT_naked,
     AT_neon_polyvector_type,    // Clang-specific.
     AT_neon_vector_type,        // Clang-specific.
+    AT_no_address_safety_analysis,
     AT_no_instrument_function,
     AT_no_thread_safety_analysis,
     AT_nocommon,

Modified: cfe/branches/tooling/include/clang/Sema/ExternalSemaSource.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/ExternalSemaSource.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/ExternalSemaSource.h (original)
+++ cfe/branches/tooling/include/clang/Sema/ExternalSemaSource.h Wed Jan 25 09:40:56 2012
@@ -59,10 +59,7 @@
 
   /// \brief Load the contents of the global method pool for a given
   /// selector.
-  ///
-  /// \returns a pair of Objective-C methods lists containing the
-  /// instance and factory methods, respectively, with this selector.
-  virtual std::pair<ObjCMethodList,ObjCMethodList> ReadMethodPool(Selector Sel);
+  virtual void ReadMethodPool(Selector Sel);
 
   /// \brief Load the set of namespaces that are known to the external source,
   /// which will be used during typo correction.

Modified: cfe/branches/tooling/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Sema.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Sema.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Sema.h Wed Jan 25 09:40:56 2012
@@ -650,7 +650,7 @@
   /// of -Wselector.
   llvm::DenseMap<Selector, SourceLocation> ReferencedSelectors;
 
-  GlobalMethodPool::iterator ReadMethodPool(Selector Sel);
+  void ReadMethodPool(Selector Sel);
 
   /// Private Helper predicate to check for 'self'.
   bool isSelfExpr(Expr *RExpr);
@@ -1963,6 +1963,9 @@
   /// warns each time an exact match is found.
   void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP);
 
+  /// \brief Add the given method to the list of globally-known methods.
+  void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method);
+  
 private:
   /// AddMethodToGlobalPool - Add an instance or factory method to the global
   /// pool. See descriptoin of AddInstanceMethodToGlobalPool.

Modified: cfe/branches/tooling/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Serialization/ASTReader.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Serialization/ASTReader.h (original)
+++ cfe/branches/tooling/include/clang/Serialization/ASTReader.h Wed Jan 25 09:40:56 2012
@@ -424,6 +424,10 @@
   /// global selector ID to produce a local ID.
   GlobalSelectorMapType GlobalSelectorMap;
 
+  /// \brief The generation number of the last time we loaded data from the
+  /// global method pool for this selector.
+  llvm::DenseMap<Selector, unsigned> SelectorGeneration;
+
   /// \brief Mapping from identifiers that represent macros whose definitions
   /// have not yet been deserialized to the global offset where the macro
   /// record resides.
@@ -656,7 +660,8 @@
   /// loaded once the recursive loading has completed.
   std::deque<PendingIdentifierInfo> PendingIdentifierInfos;
 
-  /// \brief The generation number of 
+  /// \brief The generation number of each identifier, which keeps track of
+  /// the last time we loaded information about this identifier.
   llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
   
   /// \brief Contains declarations and definitions that will be
@@ -1197,11 +1202,7 @@
 
   /// \brief Load the contents of the global method pool for a given
   /// selector.
-  ///
-  /// \returns a pair of Objective-C methods lists containing the
-  /// instance and factory methods, respectively, with this selector.
-  virtual std::pair<ObjCMethodList, ObjCMethodList>
-    ReadMethodPool(Selector Sel);
+  virtual void ReadMethodPool(Selector Sel);
 
   /// \brief Load the set of namespaces that are known to the external source,
   /// which will be used during typo correction.

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Wed Jan 25 09:40:56 2012
@@ -275,6 +275,9 @@
   
   /// A flag that indicates whether nodes should be recycled.
   bool reclaimNodes;
+  
+  /// Counter to determine when to reclaim nodes.
+  unsigned reclaimCounter;
 
 public:
 
@@ -302,9 +305,7 @@
     return V;
   }
 
-  ExplodedGraph()
-    : NumNodes(0), recentlyAllocatedNodes(0),
-      freeNodes(0), reclaimNodes(false) {}
+  ExplodedGraph();
 
   ~ExplodedGraph();
   

Modified: cfe/branches/tooling/lib/ARCMigrate/ARCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/ARCMT.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/ARCMT.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/ARCMT.cpp Wed Jan 25 09:40:56 2012
@@ -229,6 +229,7 @@
     return false;
 
   LangOptions::GCMode OrigGCMode = origCI.getLangOpts()->getGC();
+  bool NoNSAllocReallocError = origCI.getMigratorOpts().NoNSAllocReallocError;
 
   std::vector<TransformFn> transforms = arcmt::getAllTransformations(OrigGCMode);
   assert(!transforms.empty());
@@ -292,6 +293,7 @@
 
   TransformActions testAct(*Diags, capturedDiags, Ctx, Unit->getPreprocessor());
   MigrationPass pass(Ctx, OrigGCMode, Unit->getSema(), testAct, ARCMTMacroLocs);
+  pass.setNSAllocReallocError(NoNSAllocReallocError);
 
   for (unsigned i=0, e = transforms.size(); i != e; ++i)
     transforms[i](pass);

Modified: cfe/branches/tooling/lib/ARCMigrate/Internals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/Internals.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/Internals.h (original)
+++ cfe/branches/tooling/lib/ARCMigrate/Internals.h Wed Jan 25 09:40:56 2012
@@ -94,6 +94,8 @@
 
   void reportError(StringRef error, SourceLocation loc,
                    SourceRange range = SourceRange());
+  void reportWarning(StringRef warning, SourceLocation loc,
+                   SourceRange range = SourceRange());
   void reportNote(StringRef note, SourceLocation loc,
                   SourceRange range = SourceRange());
 
@@ -138,6 +140,7 @@
 public:
   ASTContext &Ctx;
   LangOptions::GCMode OrigGCMode;
+  MigratorOptions MigOptions;
   Sema &SemaRef;
   TransformActions &TA;
   std::vector<SourceLocation> &ARCMTMacroLocs;
@@ -145,10 +148,13 @@
   MigrationPass(ASTContext &Ctx, LangOptions::GCMode OrigGCMode,
                 Sema &sema, TransformActions &TA,
                 std::vector<SourceLocation> &ARCMTMacroLocs)
-    : Ctx(Ctx), OrigGCMode(OrigGCMode), SemaRef(sema), TA(TA),
+    : Ctx(Ctx), OrigGCMode(OrigGCMode), MigOptions(),
+      SemaRef(sema), TA(TA),
       ARCMTMacroLocs(ARCMTMacroLocs) { }
 
   bool isGCMigration() const { return OrigGCMode != LangOptions::NonGC; }
+  bool noNSAllocReallocError() const { return MigOptions.NoNSAllocReallocError; }
+  void setNSAllocReallocError(bool val) { MigOptions.NoNSAllocReallocError = val; }
 };
 
 static inline StringRef getARCMTMacroName() {

Modified: cfe/branches/tooling/lib/ARCMigrate/TransGCCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransGCCalls.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransGCCalls.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransGCCalls.cpp Wed Jan 25 09:40:56 2012
@@ -38,9 +38,14 @@
     TransformActions &TA = MigrateCtx.Pass.TA;
 
     if (MigrateCtx.isGCOwnedNonObjC(E->getType())) {
-      TA.reportError("call returns pointer to GC managed memory; "
-                     "it will become unmanaged in ARC",
-                     E->getLocStart(), E->getSourceRange());
+      if (MigrateCtx.Pass.noNSAllocReallocError())
+        TA.reportWarning("call returns pointer to GC managed memory; "
+                       "it will become unmanaged in ARC",
+                       E->getLocStart(), E->getSourceRange());
+      else 
+        TA.reportError("call returns pointer to GC managed memory; "
+                       "it will become unmanaged in ARC",
+                       E->getLocStart(), E->getSourceRange());
       return true;
     }
 

Modified: cfe/branches/tooling/lib/ARCMigrate/TransformActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransformActions.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransformActions.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransformActions.cpp Wed Jan 25 09:40:56 2012
@@ -692,6 +692,25 @@
   ReportedErrors = true;
 }
 
+void TransformActions::reportWarning(StringRef warning, SourceLocation loc,
+                                   SourceRange range) {
+  assert(!static_cast<TransformActionsImpl*>(Impl)->isInTransaction() &&
+         "Warning should be emitted out of a transaction");
+  
+  SourceManager &SM = static_cast<TransformActionsImpl*>(Impl)->
+    getASTContext().getSourceManager();
+  if (SM.isInSystemHeader(SM.getExpansionLoc(loc)))
+    return;
+  
+  // FIXME: Use a custom category name to distinguish rewriter errors.
+  std::string rewriterWarn = "[rewriter] ";
+  rewriterWarn += warning;
+  unsigned diagID
+  = Diags.getDiagnosticIDs()->getCustomDiagID(DiagnosticIDs::Warning,
+                                              rewriterWarn);
+  Diags.Report(loc, diagID) << range;
+}
+
 void TransformActions::reportNote(StringRef note, SourceLocation loc,
                                   SourceRange range) {
   assert(!static_cast<TransformActionsImpl*>(Impl)->isInTransaction() &&

Modified: cfe/branches/tooling/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTImporter.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTImporter.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTImporter.cpp Wed Jan 25 09:40:56 2012
@@ -78,7 +78,7 @@
     QualType VisitObjCObjectType(const ObjCObjectType *T);
     QualType VisitObjCObjectPointerType(const ObjCObjectPointerType *T);
                             
-    // Importing declarations
+    // Importing declarations                            
     bool ImportDeclParts(NamedDecl *D, DeclContext *&DC, 
                          DeclContext *&LexicalDC, DeclarationName &Name, 
                          SourceLocation &Loc);
@@ -86,10 +86,28 @@
     void ImportDeclarationNameLoc(const DeclarationNameInfo &From,
                                   DeclarationNameInfo& To);
     void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false);
+                            
+    /// \brief What we should import from the definition.
+    enum ImportDefinitionKind { 
+      /// \brief Import the default subset of the definition, which might be
+      /// nothing (if minimal import is set) or might be everything (if minimal
+      /// import is not set).
+      IDK_Default,
+      /// \brief Import everything.
+      IDK_Everything,
+      /// \brief Import only the bare bones needed to establish a valid
+      /// DeclContext.
+      IDK_Basic
+    };
+
     bool ImportDefinition(RecordDecl *From, RecordDecl *To, 
-                          bool ForceImport = false);
+                          ImportDefinitionKind Kind = IDK_Default);
     bool ImportDefinition(EnumDecl *From, EnumDecl *To,
                           bool ForceImport = false);
+    bool ImportDefinition(ObjCInterfaceDecl *From, ObjCInterfaceDecl *To,
+                          bool ForceImport = false);
+    bool ImportDefinition(ObjCProtocolDecl *From, ObjCProtocolDecl *To,
+                          bool ForceImport = false);
     TemplateParameterList *ImportTemplateParameterList(
                                                  TemplateParameterList *Params);
     TemplateArgument ImportTemplateArgument(const TemplateArgument &From);
@@ -1789,9 +1807,13 @@
 }
 
 bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To, 
-                                       bool ForceImport) {
-  if (To->getDefinition() || To->isBeingDefined())
+                                       ImportDefinitionKind Kind) {
+  if (To->getDefinition() || To->isBeingDefined()) {
+    if (Kind == IDK_Everything)
+      ImportDeclContext(From, /*ForceImport=*/true);
+    
     return false;
+  }
   
   To->startDefinition();
   
@@ -1870,7 +1892,10 @@
       ToCXX->setBases(Bases.data(), Bases.size());
   }
   
-  ImportDeclContext(From, ForceImport);
+  if (Kind == IDK_Everything || 
+      (Kind == IDK_Default && !Importer.isMinimalImport()))
+    ImportDeclContext(From, /*ForceImport=*/true);
+  
   To->completeDefinition();
   return false;
 }
@@ -2346,7 +2371,7 @@
   
   Importer.Imported(D, D2);
 
-  if (D->isCompleteDefinition() && ImportDefinition(D, D2))
+  if (D->isCompleteDefinition() && ImportDefinition(D, D2, IDK_Default))
     return 0;
   
   return D2;
@@ -3098,7 +3123,56 @@
   return ToCategory;
 }
 
+bool ASTNodeImporter::ImportDefinition(ObjCProtocolDecl *From, 
+                                       ObjCProtocolDecl *To,
+                                       bool ForceImport) {
+  if (To->getDefinition()) {
+    ImportDeclContext(From);
+    return false;
+  }
+
+  // Start the protocol definition
+  To->startDefinition();
+  
+  // Import protocols
+  SmallVector<ObjCProtocolDecl *, 4> Protocols;
+  SmallVector<SourceLocation, 4> ProtocolLocs;
+  ObjCProtocolDecl::protocol_loc_iterator 
+  FromProtoLoc = From->protocol_loc_begin();
+  for (ObjCProtocolDecl::protocol_iterator FromProto = From->protocol_begin(),
+                                        FromProtoEnd = From->protocol_end();
+       FromProto != FromProtoEnd;
+       ++FromProto, ++FromProtoLoc) {
+    ObjCProtocolDecl *ToProto
+      = cast_or_null<ObjCProtocolDecl>(Importer.Import(*FromProto));
+    if (!ToProto)
+      return true;
+    Protocols.push_back(ToProto);
+    ProtocolLocs.push_back(Importer.Import(*FromProtoLoc));
+  }
+  
+  // FIXME: If we're merging, make sure that the protocol list is the same.
+  To->setProtocolList(Protocols.data(), Protocols.size(),
+                      ProtocolLocs.data(), Importer.getToContext());
+
+  // Import all of the members of this protocol.
+  ImportDeclContext(From);
+  return false;
+}
+
 Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
+  // If this protocol has a definition in the translation unit we're coming 
+  // from, but this particular declaration is not that definition, import the
+  // definition and map to that.
+  ObjCProtocolDecl *Definition = D->getDefinition();
+  if (Definition && Definition != D) {
+    Decl *ImportedDef = Importer.Import(Definition);
+    if (!ImportedDef)
+      return 0;
+    
+    return Importer.Imported(D, ImportedDef);
+  }
+
   // Import the major distinguishing characteristics of a protocol.
   DeclContext *DC, *LexicalDC;
   DeclarationName Name;
@@ -3118,51 +3192,131 @@
   }
   
   ObjCProtocolDecl *ToProto = MergeWithProtocol;
-  if (!ToProto || !ToProto->hasDefinition()) {
-    if (!ToProto) {
-      ToProto = ObjCProtocolDecl::Create(Importer.getToContext(), DC,
-                                         Name.getAsIdentifierInfo(), Loc,
-                                         Importer.Import(D->getAtStartLoc()),
-                                         /*PrevDecl=*/0);
-      ToProto->setLexicalDeclContext(LexicalDC);
-      LexicalDC->addDeclInternal(ToProto);
-    }
-    if (!ToProto->hasDefinition())
-      ToProto->startDefinition();
+  if (!ToProto) {
+    ToProto = ObjCProtocolDecl::Create(Importer.getToContext(), DC,
+                                       Name.getAsIdentifierInfo(), Loc,
+                                       Importer.Import(D->getAtStartLoc()),
+                                       /*PrevDecl=*/0);
+    ToProto->setLexicalDeclContext(LexicalDC);
+    LexicalDC->addDeclInternal(ToProto);
+  }
     
-    Importer.Imported(D, ToProto);
+  Importer.Imported(D, ToProto);
 
-    // Import protocols
-    SmallVector<ObjCProtocolDecl *, 4> Protocols;
-    SmallVector<SourceLocation, 4> ProtocolLocs;
-    ObjCProtocolDecl::protocol_loc_iterator 
-      FromProtoLoc = D->protocol_loc_begin();
-    for (ObjCProtocolDecl::protocol_iterator FromProto = D->protocol_begin(),
-                                          FromProtoEnd = D->protocol_end();
-       FromProto != FromProtoEnd;
-       ++FromProto, ++FromProtoLoc) {
-      ObjCProtocolDecl *ToProto
-        = cast_or_null<ObjCProtocolDecl>(Importer.Import(*FromProto));
-      if (!ToProto)
-        return 0;
-      Protocols.push_back(ToProto);
-      ProtocolLocs.push_back(Importer.Import(*FromProtoLoc));
+  if (D->isThisDeclarationADefinition() && ImportDefinition(D, ToProto))
+    return 0;
+  
+  return ToProto;
+}
+
+bool ASTNodeImporter::ImportDefinition(ObjCInterfaceDecl *From, 
+                                       ObjCInterfaceDecl *To,
+                                       bool ForceImport) {
+  if (To->getDefinition()) {
+    // Check consistency of superclass.
+    ObjCInterfaceDecl *FromSuper = From->getSuperClass();
+    if (FromSuper) {
+      FromSuper = cast_or_null<ObjCInterfaceDecl>(Importer.Import(FromSuper));
+      if (!FromSuper)
+        return true;
     }
     
-    // FIXME: If we're merging, make sure that the protocol list is the same.
-    ToProto->setProtocolList(Protocols.data(), Protocols.size(),
-                             ProtocolLocs.data(), Importer.getToContext());
-  } else {
-    Importer.Imported(D, ToProto);
+    ObjCInterfaceDecl *ToSuper = To->getSuperClass();    
+    if ((bool)FromSuper != (bool)ToSuper ||
+        (FromSuper && !declaresSameEntity(FromSuper, ToSuper))) {
+      Importer.ToDiag(To->getLocation(), 
+                      diag::err_odr_objc_superclass_inconsistent)
+        << To->getDeclName();
+      if (ToSuper)
+        Importer.ToDiag(To->getSuperClassLoc(), diag::note_odr_objc_superclass)
+          << To->getSuperClass()->getDeclName();
+      else
+        Importer.ToDiag(To->getLocation(), 
+                        diag::note_odr_objc_missing_superclass);
+      if (From->getSuperClass())
+        Importer.FromDiag(From->getSuperClassLoc(), 
+                          diag::note_odr_objc_superclass)
+        << From->getSuperClass()->getDeclName();
+      else
+        Importer.FromDiag(From->getLocation(), 
+                          diag::note_odr_objc_missing_superclass);        
+    }
+    
+    ImportDeclContext(From);
+    return false;
   }
+  
+  // Start the definition.
+  To->startDefinition();
+  
+  // If this class has a superclass, import it.
+  if (From->getSuperClass()) {
+    ObjCInterfaceDecl *Super = cast_or_null<ObjCInterfaceDecl>(
+                                 Importer.Import(From->getSuperClass()));
+    if (!Super)
+      return true;
+    
+    To->setSuperClass(Super);
+    To->setSuperClassLoc(Importer.Import(From->getSuperClassLoc()));
+  }
+  
+  // Import protocols
+  SmallVector<ObjCProtocolDecl *, 4> Protocols;
+  SmallVector<SourceLocation, 4> ProtocolLocs;
+  ObjCInterfaceDecl::protocol_loc_iterator 
+  FromProtoLoc = From->protocol_loc_begin();
+  
+  for (ObjCInterfaceDecl::protocol_iterator FromProto = From->protocol_begin(),
+                                         FromProtoEnd = From->protocol_end();
+       FromProto != FromProtoEnd;
+       ++FromProto, ++FromProtoLoc) {
+    ObjCProtocolDecl *ToProto
+      = cast_or_null<ObjCProtocolDecl>(Importer.Import(*FromProto));
+    if (!ToProto)
+      return true;
+    Protocols.push_back(ToProto);
+    ProtocolLocs.push_back(Importer.Import(*FromProtoLoc));
+  }
+  
+  // FIXME: If we're merging, make sure that the protocol list is the same.
+  To->setProtocolList(Protocols.data(), Protocols.size(),
+                      ProtocolLocs.data(), Importer.getToContext());
+  
+  // Import categories. When the categories themselves are imported, they'll
+  // hook themselves into this interface.
+  for (ObjCCategoryDecl *FromCat = From->getCategoryList(); FromCat;
+       FromCat = FromCat->getNextClassCategory())
+    Importer.Import(FromCat);
 
-  // Import all of the members of this protocol.
-  ImportDeclContext(D);
+  // If we have an @implementation, import it as well.
+  if (From->getImplementation()) {
+    ObjCImplementationDecl *Impl = cast_or_null<ObjCImplementationDecl>(
+                                     Importer.Import(From->getImplementation()));
+    if (!Impl)
+      return true;
+    
+    To->setImplementation(Impl);
+  }
 
-  return ToProto;
+  // Import all of the members of this class.
+  ImportDeclContext(From);
+  
+  return false;
 }
 
 Decl *ASTNodeImporter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
+  // If this class has a definition in the translation unit we're coming from,
+  // but this particular declaration is not that definition, import the
+  // definition and map to that.
+  ObjCInterfaceDecl *Definition = D->getDefinition();
+  if (Definition && Definition != D) {
+    Decl *ImportedDef = Importer.Import(Definition);
+    if (!ImportedDef)
+      return 0;
+    
+    return Importer.Imported(D, ImportedDef);
+  }
+
   // Import the major distinguishing characteristics of an @interface.
   DeclContext *DC, *LexicalDC;
   DeclarationName Name;
@@ -3170,6 +3324,7 @@
   if (ImportDeclParts(D, DC, LexicalDC, Name, Loc))
     return 0;
 
+  // Look for an existing interface with the same name.
   ObjCInterfaceDecl *MergeWithIface = 0;
   llvm::SmallVector<NamedDecl *, 2> FoundDecls;
   DC->localUncachedLookup(Name, FoundDecls);
@@ -3181,127 +3336,22 @@
       break;
   }
   
+  // Create an interface declaration, if one does not already exist.
   ObjCInterfaceDecl *ToIface = MergeWithIface;
-  if (!ToIface || !ToIface->hasDefinition()) {
-    if (!ToIface) {
-      ToIface = ObjCInterfaceDecl::Create(Importer.getToContext(), DC,
-                                          Importer.Import(D->getAtStartLoc()),
-                                          Name.getAsIdentifierInfo(), 
-                                          /*PrevDecl=*/0,Loc,
-                                          D->isImplicitInterfaceDecl());
-      ToIface->setLexicalDeclContext(LexicalDC);
-      LexicalDC->addDeclInternal(ToIface);
-    }
-    Importer.Imported(D, ToIface);
-
-    if (D->hasDefinition()) {
-      if (!ToIface->hasDefinition())
-        ToIface->startDefinition();
-      
-      if (D->getSuperClass()) {
-        ObjCInterfaceDecl *Super
-          = cast_or_null<ObjCInterfaceDecl>(
-              Importer.Import(D->getSuperClass()));
-        if (!Super)
-          return 0;
-        
-        ToIface->setSuperClass(Super);
-        ToIface->setSuperClassLoc(Importer.Import(D->getSuperClassLoc()));
-      }
-      
-      // Import protocols
-      SmallVector<ObjCProtocolDecl *, 4> Protocols;
-      SmallVector<SourceLocation, 4> ProtocolLocs;
-      ObjCInterfaceDecl::protocol_loc_iterator 
-        FromProtoLoc = D->protocol_loc_begin();
-      
-      for (ObjCInterfaceDecl::protocol_iterator FromProto = D->protocol_begin(),
-                                             FromProtoEnd = D->protocol_end();
-         FromProto != FromProtoEnd;
-         ++FromProto, ++FromProtoLoc) {
-        ObjCProtocolDecl *ToProto
-          = cast_or_null<ObjCProtocolDecl>(Importer.Import(*FromProto));
-        if (!ToProto)
-          return 0;
-        Protocols.push_back(ToProto);
-        ProtocolLocs.push_back(Importer.Import(*FromProtoLoc));
-      }
-      
-      // FIXME: If we're merging, make sure that the protocol list is the same.
-      ToIface->setProtocolList(Protocols.data(), Protocols.size(),
-                               ProtocolLocs.data(), Importer.getToContext());
-    }
-    
-    // Import @end range
-    ToIface->setAtEndRange(Importer.Import(D->getAtEndRange()));
-  } else {
-    Importer.Imported(D, ToIface);
-
-    if (D->hasDefinition()) {
-      // Check for consistency of superclasses.
-      DeclarationName FromSuperName, ToSuperName;
-      
-      // If the superclass hasn't been imported yet, do so before checking.
-      ObjCInterfaceDecl *DSuperClass = D->getSuperClass();
-      ObjCInterfaceDecl *ToIfaceSuperClass = ToIface->getSuperClass();
-      
-      if (DSuperClass && !ToIfaceSuperClass) {
-        Decl *ImportedSuperClass = Importer.Import(DSuperClass);
-        ObjCInterfaceDecl *ImportedSuperIface
-          = cast<ObjCInterfaceDecl>(ImportedSuperClass);
-        
-        ToIface->setSuperClass(ImportedSuperIface);
-      }
-
-      if (D->getSuperClass())
-        FromSuperName = Importer.Import(D->getSuperClass()->getDeclName());
-      if (ToIface->getSuperClass())
-        ToSuperName = ToIface->getSuperClass()->getDeclName();
-      if (FromSuperName != ToSuperName) {
-        Importer.ToDiag(ToIface->getLocation(), 
-                        diag::err_odr_objc_superclass_inconsistent)
-          << ToIface->getDeclName();
-        if (ToIface->getSuperClass())
-          Importer.ToDiag(ToIface->getSuperClassLoc(), 
-                          diag::note_odr_objc_superclass)
-            << ToIface->getSuperClass()->getDeclName();
-        else
-          Importer.ToDiag(ToIface->getLocation(), 
-                          diag::note_odr_objc_missing_superclass);
-        if (D->getSuperClass())
-          Importer.FromDiag(D->getSuperClassLoc(), 
-                            diag::note_odr_objc_superclass)
-            << D->getSuperClass()->getDeclName();
-        else
-          Importer.FromDiag(D->getLocation(), 
-                            diag::note_odr_objc_missing_superclass);
-        return 0;
-      }
-    }
+  if (!ToIface) {
+    ToIface = ObjCInterfaceDecl::Create(Importer.getToContext(), DC,
+                                        Importer.Import(D->getAtStartLoc()),
+                                        Name.getAsIdentifierInfo(), 
+                                        /*PrevDecl=*/0,Loc,
+                                        D->isImplicitInterfaceDecl());
+    ToIface->setLexicalDeclContext(LexicalDC);
+    LexicalDC->addDeclInternal(ToIface);
   }
+  Importer.Imported(D, ToIface);
   
-  if (!D->hasDefinition())
-    return ToIface;
-  
-  // Import categories. When the categories themselves are imported, they'll
-  // hook themselves into this interface.
-  for (ObjCCategoryDecl *FromCat = D->getCategoryList(); FromCat;
-       FromCat = FromCat->getNextClassCategory())
-    Importer.Import(FromCat);
-  
-  // Import all of the members of this class.
-  ImportDeclContext(D);
-  
-  // If we have an @implementation, import it as well.
-  if ( D->getImplementation()) {
-    ObjCImplementationDecl *Impl = cast_or_null<ObjCImplementationDecl>(
-                                       Importer.Import(D->getImplementation()));
-    if (!Impl)
-      return 0;
+  if (D->isThisDeclarationADefinition() && ImportDefinition(D, ToIface))
+    return 0;
     
-    ToIface->setImplementation(Impl);
-  }
-  
   return ToIface;
 }
 
@@ -4138,7 +4188,19 @@
   if (!FromDC)
     return FromDC;
 
-  return cast_or_null<DeclContext>(Import(cast<Decl>(FromDC)));
+  DeclContext *ToDC = cast_or_null<DeclContext>(Import(cast<Decl>(FromDC)));
+  if (RecordDecl *ToRecord = dyn_cast_or_null<RecordDecl>(ToDC)) {
+    // When we're using a record declaration as a context, we need it to have
+    // a definition.
+    ASTNodeImporter Importer(*this);
+    
+    RecordDecl *FromRecord = cast<RecordDecl>(FromDC);
+    if (FromRecord->isCompleteDefinition())
+      Importer.ImportDefinition(FromRecord, ToRecord,
+                                ASTNodeImporter::IDK_Basic);
+  }
+  
+  return ToDC;
 }
 
 Expr *ASTImporter::Import(Expr *FromE) {
@@ -4379,7 +4441,7 @@
     if (RecordDecl *ToRecord = dyn_cast<RecordDecl>(To)) {
       if (!ToRecord->getDefinition()) {
         Importer.ImportDefinition(cast<RecordDecl>(FromDC), ToRecord, 
-                                  /*ForceImport=*/true);
+                                  ASTNodeImporter::IDK_Everything);
         return;
       }      
     }
@@ -4391,7 +4453,23 @@
         return;
       }      
     }
+    
+    if (ObjCInterfaceDecl *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
+      if (!ToIFace->getDefinition()) {
+        Importer.ImportDefinition(cast<ObjCInterfaceDecl>(FromDC), ToIFace,
+                                  /*ForceImport=*/true);
+        return;
+      }
+    }
 
+    if (ObjCProtocolDecl *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
+      if (!ToProto->getDefinition()) {
+        Importer.ImportDefinition(cast<ObjCProtocolDecl>(FromDC), ToProto,
+                                  /*ForceImport=*/true);
+        return;
+      }
+    }
+    
     Importer.ImportDeclContext(FromDC, true);
   }
 }

Modified: cfe/branches/tooling/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Type.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Type.cpp (original)
+++ cfe/branches/tooling/lib/AST/Type.cpp Wed Jan 25 09:40:56 2012
@@ -1889,7 +1889,9 @@
          Canon.isNull()? T.isDependent() : Canon->isDependentType(),
          Canon.isNull()? T.isDependent() 
                        : Canon->isInstantiationDependentType(),
-         false, T.containsUnexpandedParameterPack()),
+         false,
+         Canon.isNull()? T.containsUnexpandedParameterPack()
+                       : Canon->containsUnexpandedParameterPack()),
     Template(T), NumArgs(NumArgs) {
   assert(!T.getAsDependentTemplateName() && 
          "Use DependentTemplateSpecializationType for dependent template-name");
@@ -1922,7 +1924,7 @@
     if (Args[Arg].getKind() == TemplateArgument::Type &&
         Args[Arg].getAsType()->isVariablyModifiedType())
       setVariablyModified();
-    if (Args[Arg].containsUnexpandedParameterPack())
+    if (Canon.isNull() && Args[Arg].containsUnexpandedParameterPack())
       setContainsUnexpandedParameterPack();
 
     new (&TemplateArgs[Arg]) TemplateArgument(Args[Arg]);

Modified: cfe/branches/tooling/lib/Analysis/FormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/FormatString.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/FormatString.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/FormatString.cpp Wed Jan 25 09:40:56 2012
@@ -337,7 +337,8 @@
         argTy->isNullPtrType();
 
     case ObjCPointerTy:
-      return argTy->getAs<ObjCObjectPointerType>() != NULL;
+      return argTy->getAs<ObjCObjectPointerType>() ||
+             argTy->getAs<BlockPointerType>();
   }
 
   llvm_unreachable("Invalid ArgTypeResult Kind!");
@@ -548,6 +549,14 @@
         case ConversionSpecifier::gArg:
         case ConversionSpecifier::GArg:
           return true;
+        // GNU extension.
+        case ConversionSpecifier::dArg:
+        case ConversionSpecifier::iArg:
+        case ConversionSpecifier::oArg:
+        case ConversionSpecifier::uArg:
+        case ConversionSpecifier::xArg:
+        case ConversionSpecifier::XArg:
+          return true;
         default:
           return false;
       }

Modified: cfe/branches/tooling/lib/Analysis/PrintfFormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/PrintfFormatString.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/PrintfFormatString.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/PrintfFormatString.cpp Wed Jan 25 09:40:56 2012
@@ -259,7 +259,8 @@
   if (CS.isIntArg())
     switch (LM.getKind()) {
       case LengthModifier::AsLongDouble:
-        return ArgTypeResult::Invalid();
+        // GNU extension.
+        return Ctx.LongLongTy;
       case LengthModifier::None: return Ctx.IntTy;
       case LengthModifier::AsChar: return ArgTypeResult::AnyCharTy;
       case LengthModifier::AsShort: return Ctx.ShortTy;
@@ -280,7 +281,8 @@
   if (CS.isUIntArg())
     switch (LM.getKind()) {
       case LengthModifier::AsLongDouble:
-        return ArgTypeResult::Invalid();
+        // GNU extension.
+        return Ctx.UnsignedLongLongTy;
       case LengthModifier::None: return Ctx.UnsignedIntTy;
       case LengthModifier::AsChar: return Ctx.UnsignedCharTy;
       case LengthModifier::AsShort: return Ctx.UnsignedShortTy;
@@ -317,6 +319,8 @@
       return ArgTypeResult(Ctx.WCharTy, "wchar_t");
     case ConversionSpecifier::pArg:
       return ArgTypeResult::CPointerTy;
+    case ConversionSpecifier::ObjCObjArg:
+      return ArgTypeResult::ObjCPointerTy;
     default:
       break;
   }

Modified: cfe/branches/tooling/lib/Analysis/ScanfFormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/ScanfFormatString.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/ScanfFormatString.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/ScanfFormatString.cpp Wed Jan 25 09:40:56 2012
@@ -218,7 +218,9 @@
           return ScanfArgTypeResult();
         case LengthModifier::AsPtrDiff:
           return ScanfArgTypeResult(Ctx.getPointerDiffType(), "ptrdiff_t *");
-        case LengthModifier::AsLongDouble: return ScanfArgTypeResult::Invalid();
+        case LengthModifier::AsLongDouble:
+          // GNU extension.
+          return ArgTypeResult(Ctx.LongLongTy);
         case LengthModifier::AsAllocate: return ScanfArgTypeResult::Invalid();
         case LengthModifier::AsMAllocate: return ScanfArgTypeResult::Invalid();
       }
@@ -242,7 +244,9 @@
         case LengthModifier::AsPtrDiff:
           // FIXME: Unsigned version of ptrdiff_t?
           return ScanfArgTypeResult();
-        case LengthModifier::AsLongDouble: return ScanfArgTypeResult::Invalid();
+        case LengthModifier::AsLongDouble:
+          // GNU extension.
+          return ArgTypeResult(Ctx.UnsignedLongLongTy);
         case LengthModifier::AsAllocate: return ScanfArgTypeResult::Invalid();
         case LengthModifier::AsMAllocate: return ScanfArgTypeResult::Invalid();
       }

Modified: cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp Wed Jan 25 09:40:56 2012
@@ -1212,8 +1212,7 @@
 
 Value *CodeGenFunction::EmitNeonSplat(Value *V, Constant *C) {
   unsigned nElts = cast<llvm::VectorType>(V->getType())->getNumElements();
-  SmallVector<Constant*, 16> Indices(nElts, C);
-  Value* SV = llvm::ConstantVector::get(Indices);
+  Value* SV = llvm::ConstantVector::getSplat(nElts, C);
   return Builder.CreateShuffleVector(V, V, SV, "lane");
 }
 
@@ -1233,13 +1232,11 @@
 
 Value *CodeGenFunction::EmitNeonShiftVector(Value *V, llvm::Type *Ty, 
                                             bool neg) {
-  ConstantInt *CI = cast<ConstantInt>(V);
-  int SV = CI->getSExtValue();
+  int SV = cast<ConstantInt>(V)->getSExtValue();
   
   llvm::VectorType *VTy = cast<llvm::VectorType>(Ty);
   llvm::Constant *C = ConstantInt::get(VTy->getElementType(), neg ? -SV : SV);
-  SmallVector<llvm::Constant*, 16> CV(VTy->getNumElements(), C);
-  return llvm::ConstantVector::get(CV);
+  return llvm::ConstantVector::getSplat(VTy->getNumElements(), C);
 }
 
 /// GetPointeeAlignment - Given an expression with a pointer type, find the
@@ -1957,8 +1954,8 @@
     for (unsigned vi = 0; vi != 2; ++vi) {
       SmallVector<Constant*, 16> Indices;
       for (unsigned i = 0, e = VTy->getNumElements(); i != e; i += 2) {
-        Indices.push_back(ConstantInt::get(Int32Ty, i+vi));
-        Indices.push_back(ConstantInt::get(Int32Ty, i+e+vi));
+        Indices.push_back(Builder.getInt32(i+vi));
+        Indices.push_back(Builder.getInt32(i+e+vi));
       }
       Value *Addr = Builder.CreateConstInBoundsGEP1_32(Ops[0], vi);
       SV = llvm::ConstantVector::get(Indices);
@@ -2019,7 +2016,7 @@
 
   // If this is a constant vector, create a ConstantVector.
   if (AllConstants) {
-    std::vector<llvm::Constant*> CstOps;
+    SmallVector<llvm::Constant*, 16> CstOps;
     for (unsigned i = 0, e = Ops.size(); i != e; ++i)
       CstOps.push_back(cast<Constant>(Ops[i]));
     return llvm::ConstantVector::get(CstOps);
@@ -2030,8 +2027,7 @@
     llvm::UndefValue::get(llvm::VectorType::get(Ops[0]->getType(), Ops.size()));
 
   for (unsigned i = 0, e = Ops.size(); i != e; ++i)
-    Result = Builder.CreateInsertElement(Result, Ops[i],
-               llvm::ConstantInt::get(llvm::Type::getInt32Ty(getLLVMContext()), i));
+    Result = Builder.CreateInsertElement(Result, Ops[i], Builder.getInt32(i));
 
   return Result;
 }

Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp Wed Jan 25 09:40:56 2012
@@ -479,6 +479,31 @@
                                Ty->getPointeeType(), Unit);
 }
 
+// Creates a forward declaration for a RecordDecl in the given context.
+llvm::DIType CGDebugInfo::createRecordFwdDecl(const RecordDecl *RD,
+					      llvm::DIDescriptor Ctx) {
+
+  llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation());
+  unsigned Line = getLineNumber(RD->getLocation());
+  const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD);
+  
+  if (CXXDecl)
+    return DBuilder.createClassType(Ctx, RD->getName(), DefUnit,
+				    Line, 0, 0, 0,
+				    llvm::DIType::FlagFwdDecl,
+				    llvm::DIType(), llvm::DIArray());
+  else if (RD->isStruct())
+    return DBuilder.createStructType(Ctx, RD->getName(), DefUnit,
+				     Line, 0, 0, llvm::DIType::FlagFwdDecl,
+				     llvm::DIArray());
+  else if (RD->isUnion())
+    return DBuilder.createUnionType(Ctx, RD->getName(), DefUnit,
+				    Line, 0, 0, llvm::DIType::FlagFwdDecl,
+				    llvm::DIArray());
+  else
+    llvm_unreachable("Unknown RecordDecl type!");
+}
+
 // Walk up the context chain and create forward decls for record decls,
 // and normal descriptors for namespaces.
 llvm::DIDescriptor CGDebugInfo::createContextChain(const Decl *Context) {
@@ -497,27 +522,9 @@
 
   if (const RecordDecl *RD = dyn_cast<RecordDecl>(Context)) {
     if (!RD->isDependentType()) {
-      llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation());
-      unsigned Line = getLineNumber(RD->getLocation());
       llvm::DIDescriptor FDContext =
         createContextChain(cast<Decl>(RD->getDeclContext()));
-      
-      const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD);
-      llvm::DIType Ty = llvm::DIType();
-      
-      if (CXXDecl)
-        Ty = DBuilder.createClassType(FDContext, RD->getName(), DefUnit,
-                                      Line, 0, 0, 0,
-                                      llvm::DIType::FlagFwdDecl,
-                                      llvm::DIType(), llvm::DIArray());
-      else if (RD->isStruct())
-        Ty = DBuilder.createStructType(FDContext, RD->getName(), DefUnit,
-                                       Line, 0, 0, llvm::DIType::FlagFwdDecl,
-                                       llvm::DIArray());
-      else if (RD->isUnion())
-        Ty = DBuilder.createUnionType(FDContext, RD->getName(), DefUnit,
-                                      Line, 0, 0, llvm::DIType::FlagFwdDecl,
-                                      llvm::DIArray());
+      llvm::DIType Ty = createRecordFwdDecl(RD, FDContext);
 
       RegionMap[Context] = llvm::WeakVH(Ty);
       return llvm::DIDescriptor(Ty);
@@ -546,26 +553,9 @@
 
   if (const RecordType *RTy = dyn_cast<RecordType>(PointeeTy)) {
     RecordDecl *RD = RTy->getDecl();
-    llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation());
-    unsigned Line = getLineNumber(RD->getLocation());
     llvm::DIDescriptor FDContext =
       getContextDescriptor(cast<Decl>(RD->getDeclContext()));
-
-    CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD);
-    if (CXXDecl)
-      return DBuilder.createClassType(FDContext, RD->getName(), DefUnit,
-                                      Line, 0, 0, 0, llvm::DIType::FlagFwdDecl,
-                                      llvm::DIType(), llvm::DIArray());
-    else if (RD->isStruct())
-      return DBuilder.createStructType(FDContext, RD->getName(), DefUnit,
-                                       Line, 0, 0, llvm::DIType::FlagFwdDecl,
-                                       llvm::DIArray());
-    else if (RD->isUnion())
-      return DBuilder.createUnionType(FDContext, RD->getName(), DefUnit,
-                                      Line, 0, 0, llvm::DIType::FlagFwdDecl,
-                                      llvm::DIArray());
-    else
-      llvm_unreachable("Unknown RecordDecl type!");
+    return createRecordFwdDecl(RD, FDContext);
   }
   return getOrCreateType(PointeeTy, Unit);
 

Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h Wed Jan 25 09:40:56 2012
@@ -232,7 +232,11 @@
   /// getContextDescriptor - Get context info for the decl.
   llvm::DIDescriptor getContextDescriptor(const Decl *Decl);
 
-  /// CreateContextChain - Create a set of decls for the context chain.
+  /// createRecordFwdDecl - Create a forward decl for a RecordType in a given
+  /// context.
+  llvm::DIType createRecordFwdDecl(const RecordDecl *, llvm::DIDescriptor);
+  
+  /// createContextChain - Create a set of decls for the context chain.
   llvm::DIDescriptor createContextChain(const Decl *Decl);
 
   /// getCurrentDirname - Return current directory name.

Modified: cfe/branches/tooling/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExpr.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExpr.cpp Wed Jan 25 09:40:56 2012
@@ -952,10 +952,8 @@
   unsigned NumResultElts = ExprVT->getNumElements();
 
   SmallVector<llvm::Constant*, 4> Mask;
-  for (unsigned i = 0; i != NumResultElts; ++i) {
-    unsigned InIdx = getAccessedFieldNo(i, Elts);
-    Mask.push_back(llvm::ConstantInt::get(Int32Ty, InIdx));
-  }
+  for (unsigned i = 0; i != NumResultElts; ++i)
+    Mask.push_back(Builder.getInt32(getAccessedFieldNo(i, Elts)));
 
   llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
   Vec = Builder.CreateShuffleVector(Vec, llvm::UndefValue::get(Vec->getType()),
@@ -1175,10 +1173,8 @@
       // elements and restore the vector mask since it is on the side it will be
       // stored.
       SmallVector<llvm::Constant*, 4> Mask(NumDstElts);
-      for (unsigned i = 0; i != NumSrcElts; ++i) {
-        unsigned InIdx = getAccessedFieldNo(i, Elts);
-        Mask[InIdx] = llvm::ConstantInt::get(Int32Ty, i);
-      }
+      for (unsigned i = 0; i != NumSrcElts; ++i)
+        Mask[getAccessedFieldNo(i, Elts)] = Builder.getInt32(i);
 
       llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
       Vec = Builder.CreateShuffleVector(SrcVal,
@@ -1192,7 +1188,7 @@
       SmallVector<llvm::Constant*, 4> ExtMask;
       unsigned i;
       for (i = 0; i != NumSrcElts; ++i)
-        ExtMask.push_back(llvm::ConstantInt::get(Int32Ty, i));
+        ExtMask.push_back(Builder.getInt32(i));
       for (; i != NumDstElts; ++i)
         ExtMask.push_back(llvm::UndefValue::get(Int32Ty));
       llvm::Value *ExtMaskV = llvm::ConstantVector::get(ExtMask);
@@ -1203,13 +1199,11 @@
       // build identity
       SmallVector<llvm::Constant*, 4> Mask;
       for (unsigned i = 0; i != NumDstElts; ++i)
-        Mask.push_back(llvm::ConstantInt::get(Int32Ty, i));
+        Mask.push_back(Builder.getInt32(i));
 
       // modify when what gets shuffled in
-      for (unsigned i = 0; i != NumSrcElts; ++i) {
-        unsigned Idx = getAccessedFieldNo(i, Elts);
-        Mask[Idx] = llvm::ConstantInt::get(Int32Ty, i+NumDstElts);
-      }
+      for (unsigned i = 0; i != NumSrcElts; ++i)
+        Mask[getAccessedFieldNo(i, Elts)] = Builder.getInt32(i+NumDstElts);
       llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
       Vec = Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV);
     } else {
@@ -1734,13 +1728,11 @@
 }
 
 static
-llvm::Constant *GenerateConstantVector(llvm::LLVMContext &VMContext,
+llvm::Constant *GenerateConstantVector(CGBuilderTy &Builder,
                                        SmallVector<unsigned, 4> &Elts) {
   SmallVector<llvm::Constant*, 4> CElts;
-
-  llvm::Type *Int32Ty = llvm::Type::getInt32Ty(VMContext);
   for (unsigned i = 0, e = Elts.size(); i != e; ++i)
-    CElts.push_back(llvm::ConstantInt::get(Int32Ty, Elts[i]));
+    CElts.push_back(Builder.getInt32(Elts[i]));
 
   return llvm::ConstantVector::get(CElts);
 }
@@ -1783,7 +1775,7 @@
   E->getEncodedElementAccess(Indices);
 
   if (Base.isSimple()) {
-    llvm::Constant *CV = GenerateConstantVector(getLLVMContext(), Indices);
+    llvm::Constant *CV = GenerateConstantVector(Builder, Indices);
     return LValue::MakeExtVectorElt(Base.getAddress(), CV, type);
   }
   assert(Base.isExtVectorElt() && "Can only subscript lvalue vec elts here!");
@@ -1999,6 +1991,8 @@
     return EmitAggExprToLValue(expr);
   }
 
+  OpaqueValueMapping binding(*this, expr);
+
   const Expr *condExpr = expr->getCond();
   bool CondExprBool;
   if (ConstantFoldsToSimpleInteger(condExpr, CondExprBool)) {
@@ -2009,8 +2003,6 @@
       return EmitLValue(live);
   }
 
-  OpaqueValueMapping binding(*this, expr);
-
   llvm::BasicBlock *lhsBlock = createBasicBlock("cond.true");
   llvm::BasicBlock *rhsBlock = createBasicBlock("cond.false");
   llvm::BasicBlock *contBlock = createBasicBlock("cond.end");

Modified: cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp Wed Jan 25 09:40:56 2012
@@ -610,12 +610,9 @@
     UnV = Builder.CreateInsertElement(UnV, Elt, Idx);
 
     // Splat the element across to all elements
-    SmallVector<llvm::Constant*, 16> Args;
     unsigned NumElements = cast<llvm::VectorType>(DstTy)->getNumElements();
-    for (unsigned i = 0; i != NumElements; ++i)
-      Args.push_back(Builder.getInt32(0));
-
-    llvm::Constant *Mask = llvm::ConstantVector::get(Args);
+    llvm::Constant *Mask = llvm::ConstantVector::getSplat(NumElements,
+                                                          Builder.getInt32(0));
     llvm::Value *Yay = Builder.CreateShuffleVector(UnV, UnV, Mask, "splat");
     return Yay;
   }
@@ -749,11 +746,8 @@
                                        (1 << llvm::Log2_32(LHSElts))-1);
              
     // Mask off the high bits of each shuffle index.
-    SmallVector<llvm::Constant *, 32> MaskV;
-    for (unsigned i = 0, e = MTy->getNumElements(); i != e; ++i)
-      MaskV.push_back(EltMask);
-    
-    Value* MaskBits = llvm::ConstantVector::get(MaskV);
+    Value *MaskBits = llvm::ConstantVector::getSplat(MTy->getNumElements(),
+                                                     EltMask);
     Mask = Builder.CreateAnd(Mask, MaskBits, "mask");
     
     // newv = undef
@@ -1203,13 +1197,9 @@
     UnV = Builder.CreateInsertElement(UnV, Elt, Idx);
 
     // Splat the element across to all elements
-    SmallVector<llvm::Constant*, 16> Args;
     unsigned NumElements = cast<llvm::VectorType>(DstTy)->getNumElements();
     llvm::Constant *Zero = Builder.getInt32(0);
-    for (unsigned i = 0; i < NumElements; i++)
-      Args.push_back(Zero);
-
-    llvm::Constant *Mask = llvm::ConstantVector::get(Args);
+    llvm::Constant *Mask = llvm::ConstantVector::getSplat(NumElements, Zero);
     llvm::Value *Yay = Builder.CreateShuffleVector(UnV, UnV, Mask, "splat");
     return Yay;
   }
@@ -2596,11 +2586,7 @@
     unsigned numElem = vecTy->getNumElements();      
     llvm::Type *elemType = vecTy->getElementType();
     
-    std::vector<llvm::Constant*> Zvals;
-    for (unsigned i = 0; i < numElem; ++i)
-      Zvals.push_back(llvm::ConstantInt::get(elemType, 0));
-
-    llvm::Value *zeroVec = llvm::ConstantVector::get(Zvals);    
+    llvm::Value *zeroVec = llvm::Constant::getNullValue(vecTy);
     llvm::Value *TestMSB = Builder.CreateICmpSLT(CondV, zeroVec);
     llvm::Value *tmp = Builder.CreateSExt(TestMSB, 
                                           llvm::VectorType::get(elemType,

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp Wed Jan 25 09:40:56 2012
@@ -1019,6 +1019,14 @@
   if (ExtraAttrs != llvm::Attribute::None)
     F->addFnAttr(ExtraAttrs);
 
+  if (Features.AddressSanitizer) {
+    // When AddressSanitizer is enabled, set AddressSafety attribute
+    // unless __attribute__((no_address_safety_analysis)) is used.
+    const FunctionDecl *FD = cast_or_null<FunctionDecl>(D.getDecl());
+    if (!FD || !FD->hasAttr<NoAddressSafetyAnalysisAttr>())
+      F->addFnAttr(llvm::Attribute::AddressSafety);
+  }
+
   // This is the first use or definition of a mangled name.  If there is a
   // deferred decl with this name, remember that we need to emit it at the end
   // of the file.

Modified: cfe/branches/tooling/lib/Driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/CMakeLists.txt?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/Driver/CMakeLists.txt Wed Jan 25 09:40:56 2012
@@ -9,7 +9,6 @@
   Compilation.cpp
   Driver.cpp
   DriverOptions.cpp
-  HostInfo.cpp
   Job.cpp
   Option.cpp
   OptTable.cpp

Modified: cfe/branches/tooling/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Driver.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Driver.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Driver.cpp Wed Jan 25 09:40:56 2012
@@ -18,7 +18,6 @@
 #include "clang/Driver/ArgList.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/HostInfo.h"
 #include "clang/Driver/Job.h"
 #include "clang/Driver/OptTable.h"
 #include "clang/Driver/Option.h"
@@ -40,6 +39,7 @@
 #include "llvm/Support/Program.h"
 
 #include "InputInfo.h"
+#include "ToolChains.h"
 
 #include <map>
 
@@ -56,8 +56,6 @@
     DefaultTargetTriple(DefaultTargetTriple), 
     DefaultImageName(DefaultImageName),
     DriverTitle("clang \"gcc-compatible\" driver"),
-    Host(0),
-    TargetTriple(llvm::Triple::normalize(DefaultTargetTriple)),
     CCPrintOptionsFilename(0), CCPrintHeadersFilename(0),
     CCLogDiagnosticsFilename(0), CCCIsCXX(false),
     CCCIsCPP(false),CCCEcho(false), CCCPrintBindings(false),
@@ -92,7 +90,11 @@
 
 Driver::~Driver() {
   delete Opts;
-  delete Host;
+
+  for (llvm::StringMap<ToolChain *>::iterator I = ToolChains.begin(),
+                                              E = ToolChains.end();
+       I != E; ++I)
+    delete I->second;
 }
 
 InputArgList *Driver::ParseArgStrings(ArrayRef<const char *> ArgList) {
@@ -305,10 +307,6 @@
       Cur = Split.second;
     }
   }
-  // FIXME: We shouldn't overwrite the default host triple here, but we have
-  // nowhere else to put this currently.
-  if (const Arg *A = Args->getLastArg(options::OPT_target))
-    DefaultTargetTriple = A->getValue(*Args);
   if (const Arg *A = Args->getLastArg(options::OPT_ccc_install_dir))
     Dir = InstalledDir = A->getValue(*Args);
   for (arg_iterator it = Args->filtered_begin(options::OPT_B),
@@ -322,18 +320,14 @@
   if (Args->hasArg(options::OPT_nostdlib))
     UseStdLib = false;
 
-  // Reset the target triple here as we may have adjusted the
-  // DefaultTargetTriple string for flags above.
-  // FIXME: Same fix is needed here when the above flag management is fixed.
-  TargetTriple = llvm::Triple(llvm::Triple::normalize(DefaultTargetTriple));
-  Host = GetHostInfo(TargetTriple);
-
   // Perform the default argument translations.
   DerivedArgList *TranslatedArgs = TranslateInputArgs(*Args);
 
+  // Owned by the host.
+  const ToolChain &TC = getToolChain(*Args);
+
   // The compilation takes ownership of Args.
-  Compilation *C = new Compilation(*this, *Host->CreateToolChain(*Args), Args,
-                                   TranslatedArgs);
+  Compilation *C = new Compilation(*this, TC, Args, TranslatedArgs);
 
   // FIXME: This behavior shouldn't be here.
   if (CCCPrintOptions) {
@@ -350,7 +344,7 @@
 
   // Construct the list of abstract actions to perform for this compilation. On
   // Darwin target OSes this uses the driver-driver and universal actions.
-  if (TargetTriple.isOSDarwin())
+  if (TC.getTriple().isOSDarwin())
     BuildUniversalActions(C->getDefaultToolChain(), C->getArgs(),
                           Inputs, C->getActions());
   else
@@ -440,12 +434,11 @@
 
   // Construct the list of abstract actions to perform for this compilation. On
   // Darwin OSes this uses the driver-driver and builds universal actions.
-  if (TargetTriple.isOSDarwin())
-    BuildUniversalActions(C.getDefaultToolChain(), C.getArgs(),
-                          Inputs, C.getActions());
+  const ToolChain &TC = C.getDefaultToolChain();
+  if (TC.getTriple().isOSDarwin())
+    BuildUniversalActions(TC, C.getArgs(), Inputs, C.getActions());
   else
-    BuildActions(C.getDefaultToolChain(), C.getArgs(), Inputs,
-                 C.getActions());
+    BuildActions(TC, C.getArgs(), Inputs, C.getActions());
 
   BuildJobs(C);
 
@@ -1322,9 +1315,8 @@
   if (const BindArchAction *BAA = dyn_cast<BindArchAction>(A)) {
     const ToolChain *TC = &C.getDefaultToolChain();
 
-    std::string Arch;
     if (BAA->getArchName())
-      TC = Host->CreateToolChain(C.getArgs(), BAA->getArchName());
+      TC = &getToolChain(C.getArgs(), BAA->getArchName());
 
     BuildJobsForAction(C, *BAA->begin(), TC, BAA->getArchName(),
                        AtTopLevel, LinkingOutput, Result);
@@ -1578,39 +1570,118 @@
   return P.str();
 }
 
-const HostInfo *Driver::GetHostInfo(const llvm::Triple &Triple) const {
-  llvm::PrettyStackTraceString CrashInfo("Constructing host");
+/// \brief Compute target triple from args.
+///
+/// This routine provides the logic to compute a target triple from various
+/// args passed to the driver and the default triple string.
+static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple,
+                                        const ArgList &Args,
+                                        StringRef DarwinArchName) {
+  if (const Arg *A = Args.getLastArg(options::OPT_target))
+    DefaultTargetTriple = A->getValue(Args);
+
+  llvm::Triple Target(llvm::Triple::normalize(DefaultTargetTriple));
+
+  // Handle Darwin-specific options available here.
+  if (Target.isOSDarwin()) {
+    // If an explict Darwin arch name is given, that trumps all.
+    if (!DarwinArchName.empty()) {
+      Target.setArch(
+        llvm::Triple::getArchTypeForDarwinArchName(DarwinArchName));
+      return Target;
+    }
+
+    // Handle the Darwin '-arch' flag.
+    if (Arg *A = Args.getLastArg(options::OPT_arch)) {
+      llvm::Triple::ArchType DarwinArch
+        = llvm::Triple::getArchTypeForDarwinArchName(A->getValue(Args));
+      if (DarwinArch != llvm::Triple::UnknownArch)
+        Target.setArch(DarwinArch);
+    }
+  }
+
+  // Skip further flag support on OSes which don't support '-m32' or '-m64'.
+  if (Target.getArchName() == "tce" ||
+      Target.getOS() == llvm::Triple::AuroraUX ||
+      Target.getOS() == llvm::Triple::Minix)
+    return Target;
+
+  // Handle pseudo-target flags '-m32' and '-m64'.
+  // FIXME: Should this information be in llvm::Triple?
+  if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
+    if (A->getOption().matches(options::OPT_m32)) {
+      if (Target.getArch() == llvm::Triple::x86_64)
+        Target.setArch(llvm::Triple::x86);
+      if (Target.getArch() == llvm::Triple::ppc64)
+        Target.setArch(llvm::Triple::ppc);
+    } else {
+      if (Target.getArch() == llvm::Triple::x86)
+        Target.setArch(llvm::Triple::x86_64);
+      if (Target.getArch() == llvm::Triple::ppc)
+        Target.setArch(llvm::Triple::ppc64);
+    }
+  }
+
+  return Target;
+}
+
+const ToolChain &Driver::getToolChain(const ArgList &Args,
+                                      StringRef DarwinArchName) const {
+  llvm::Triple Target = computeTargetTriple(DefaultTargetTriple, Args,
+                                            DarwinArchName);
+
+  ToolChain *&TC = ToolChains[Target.str()];
+  if (!TC) {
+    switch (Target.getOS()) {
+    case llvm::Triple::AuroraUX:
+      TC = new toolchains::AuroraUX(*this, Target);
+      break;
+    case llvm::Triple::Darwin:
+    case llvm::Triple::MacOSX:
+    case llvm::Triple::IOS:
+      if (Target.getArch() == llvm::Triple::x86 ||
+          Target.getArch() == llvm::Triple::x86_64 ||
+          Target.getArch() == llvm::Triple::arm ||
+          Target.getArch() == llvm::Triple::thumb)
+        TC = new toolchains::DarwinClang(*this, Target);
+      else
+        TC = new toolchains::Darwin_Generic_GCC(*this, Target);
+      break;
+    case llvm::Triple::DragonFly:
+      TC = new toolchains::DragonFly(*this, Target);
+      break;
+    case llvm::Triple::OpenBSD:
+      TC = new toolchains::OpenBSD(*this, Target);
+      break;
+    case llvm::Triple::NetBSD:
+      TC = new toolchains::NetBSD(*this, Target);
+      break;
+    case llvm::Triple::FreeBSD:
+      TC = new toolchains::FreeBSD(*this, Target);
+      break;
+    case llvm::Triple::Minix:
+      TC = new toolchains::Minix(*this, Target);
+      break;
+    case llvm::Triple::Linux:
+      TC = new toolchains::Linux(*this, Target);
+      break;
+    case llvm::Triple::Win32:
+      TC = new toolchains::Windows(*this, Target);
+      break;
+    case llvm::Triple::MinGW32:
+      // FIXME: We need a MinGW toolchain. Fallthrough for now.
+    default:
+      // TCE is an OSless target
+      if (Target.getArchName() == "tce") {
+        TC = new toolchains::TCEToolChain(*this, Target);
+        break;
+      }
 
-  // TCE is an osless target
-  if (Triple.getArchName() == "tce")
-    return createTCEHostInfo(*this, Triple);
-
-  switch (Triple.getOS()) {
-  case llvm::Triple::AuroraUX:
-    return createAuroraUXHostInfo(*this, Triple);
-  case llvm::Triple::Darwin:
-  case llvm::Triple::MacOSX:
-  case llvm::Triple::IOS:
-    return createDarwinHostInfo(*this, Triple);
-  case llvm::Triple::DragonFly:
-    return createDragonFlyHostInfo(*this, Triple);
-  case llvm::Triple::OpenBSD:
-    return createOpenBSDHostInfo(*this, Triple);
-  case llvm::Triple::NetBSD:
-    return createNetBSDHostInfo(*this, Triple);
-  case llvm::Triple::FreeBSD:
-    return createFreeBSDHostInfo(*this, Triple);
-  case llvm::Triple::Minix:
-    return createMinixHostInfo(*this, Triple);
-  case llvm::Triple::Linux:
-    return createLinuxHostInfo(*this, Triple);
-  case llvm::Triple::Win32:
-    return createWindowsHostInfo(*this, Triple);
-  case llvm::Triple::MinGW32:
-    return createMinGWHostInfo(*this, Triple);
-  default:
-    return createUnknownHostInfo(*this, Triple);
+      TC = new toolchains::Generic_GCC(*this, Target);
+      break;
+    }
   }
+  return *TC;
 }
 
 bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,

Removed: cfe/branches/tooling/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/HostInfo.cpp?rev=148957&view=auto
==============================================================================
--- cfe/branches/tooling/lib/Driver/HostInfo.cpp (original)
+++ cfe/branches/tooling/lib/Driver/HostInfo.cpp (removed)
@@ -1,670 +0,0 @@
-//===--- HostInfo.cpp - Host specific information -------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Driver/HostInfo.h"
-
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
-#include "clang/Driver/Driver.h"
-#include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/Option.h"
-#include "clang/Driver/Options.h"
-
-#include "llvm/ADT/StringMap.h"
-#include "llvm/Support/Compiler.h"
-
-#include "ToolChains.h"
-
-#include <cassert>
-
-using namespace clang::driver;
-
-HostInfo::HostInfo(const Driver &D, const llvm::Triple &_Triple)
-  : TheDriver(D), Triple(_Triple) {
-}
-
-HostInfo::~HostInfo() {
-}
-
-namespace {
-
-// Darwin Host Info
-
-/// DarwinHostInfo - Darwin host information implementation.
-class DarwinHostInfo : public HostInfo {
-  /// Cache of tool chains we have created.
-  mutable llvm::DenseMap<unsigned, ToolChain*> ToolChains;
-
-public:
-  DarwinHostInfo(const Driver &D, const llvm::Triple &Triple);
-  ~DarwinHostInfo();
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName) const;
-};
-
-DarwinHostInfo::DarwinHostInfo(const Driver &D, const llvm::Triple& Triple)
-  : HostInfo(D, Triple) {
-}
-
-DarwinHostInfo::~DarwinHostInfo() {
-  for (llvm::DenseMap<unsigned, ToolChain*>::iterator
-         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
-    delete it->second;
-}
-
-ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args,
-                                           const char *ArchName) const {
-  llvm::Triple::ArchType Arch;
-
-  if (!ArchName) {
-    // If we aren't looking for a specific arch, infer the default architecture
-    // based on -arch and -m32/-m64 command line options.
-    if (Arg *A = Args.getLastArg(options::OPT_arch)) {
-      // The gcc driver behavior with multiple -arch flags wasn't consistent for
-      // things which rely on a default architecture. We just use the last -arch
-      // to find the default tool chain (assuming it is valid).
-      Arch = llvm::Triple::getArchTypeForDarwinArchName(A->getValue(Args));
-
-      // If it was invalid just use the host, we will reject this command line
-      // later.
-      if (Arch == llvm::Triple::UnknownArch)
-        Arch = getTriple().getArch();
-    } else {
-      // Otherwise default to the arch of the host.
-      Arch = getTriple().getArch();
-    }
-
-    // Honor -m32 and -m64 when finding the default tool chain.
-    //
-    // FIXME: Should this information be in llvm::Triple?
-    if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
-      if (A->getOption().matches(options::OPT_m32)) {
-        if (Arch == llvm::Triple::x86_64)
-          Arch = llvm::Triple::x86;
-        if (Arch == llvm::Triple::ppc64)
-          Arch = llvm::Triple::ppc;
-      } else {
-        if (Arch == llvm::Triple::x86)
-          Arch = llvm::Triple::x86_64;
-        if (Arch == llvm::Triple::ppc)
-          Arch = llvm::Triple::ppc64;
-      }
-    }
-  } else
-    Arch = llvm::Triple::getArchTypeForDarwinArchName(ArchName);
-
-  assert(Arch != llvm::Triple::UnknownArch && "Unexpected arch!");
-  ToolChain *&TC = ToolChains[Arch];
-  if (!TC) {
-    llvm::Triple TCTriple(getTriple());
-    TCTriple.setArch(Arch);
-
-    // If we recognized the arch, match it to the toolchains we support.
-    if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64 ||
-        Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb) {
-      TC = new toolchains::DarwinClang(*this, TCTriple);
-    } else
-      TC = new toolchains::Darwin_Generic_GCC(*this, TCTriple);
-  }
-
-  return TC;
-}
-
-// TCE Host Info
-
-/// TCEHostInfo - TCE host information implementation (see http://tce.cs.tut.fi)
-class TCEHostInfo : public HostInfo {
-
-public:
-  TCEHostInfo(const Driver &D, const llvm::Triple &Triple);
-  ~TCEHostInfo() {}
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args, 
-                                     const char *ArchName) const;
-};
-
-TCEHostInfo::TCEHostInfo(const Driver &D, const llvm::Triple& Triple)
-  : HostInfo(D, Triple) {
-}
-
-ToolChain *TCEHostInfo::CreateToolChain(const ArgList &Args, 
-                                        const char *ArchName) const {
-  llvm::Triple TCTriple(getTriple());
-//  TCTriple.setArchName(ArchName);
-  return new toolchains::TCEToolChain(*this, TCTriple);
-}
-
-
-// Unknown Host Info
-
-/// UnknownHostInfo - Generic host information to use for unknown hosts.
-class UnknownHostInfo : public HostInfo {
-  /// Cache of tool chains we have created.
-  mutable llvm::StringMap<ToolChain*> ToolChains;
-
-public:
-  UnknownHostInfo(const Driver &D, const llvm::Triple& Triple);
-  ~UnknownHostInfo();
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName) const;
-};
-
-UnknownHostInfo::UnknownHostInfo(const Driver &D, const llvm::Triple& Triple)
-  : HostInfo(D, Triple) {
-}
-
-UnknownHostInfo::~UnknownHostInfo() {
-  for (llvm::StringMap<ToolChain*>::iterator
-         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
-    delete it->second;
-}
-
-ToolChain *UnknownHostInfo::CreateToolChain(const ArgList &Args,
-                                            const char *ArchName) const {
-  assert(!ArchName &&
-         "Unexpected arch name on platform without driver support.");
-
-  // Automatically handle some instances of -m32/-m64 we know about.
-  std::string Arch = getArchName();
-  ArchName = Arch.c_str();
-  if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
-    if (Triple.getArch() == llvm::Triple::x86 ||
-        Triple.getArch() == llvm::Triple::x86_64) {
-      ArchName =
-        (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64";
-    } else if (Triple.getArch() == llvm::Triple::ppc ||
-               Triple.getArch() == llvm::Triple::ppc64) {
-      ArchName =
-        (A->getOption().matches(options::OPT_m32)) ? "powerpc" : "powerpc64";
-    }
-  }
-
-  ToolChain *&TC = ToolChains[ArchName];
-  if (!TC) {
-    llvm::Triple TCTriple(getTriple());
-    TCTriple.setArchName(ArchName);
-
-    TC = new toolchains::Generic_GCC(*this, TCTriple);
-  }
-
-  return TC;
-}
-
-// OpenBSD Host Info
-
-/// OpenBSDHostInfo -  OpenBSD host information implementation.
-class OpenBSDHostInfo : public HostInfo {
-  /// Cache of tool chains we have created.
-  mutable llvm::StringMap<ToolChain*> ToolChains;
-
-public:
-  OpenBSDHostInfo(const Driver &D, const llvm::Triple& Triple)
-    : HostInfo(D, Triple) {}
-  ~OpenBSDHostInfo();
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName) const;
-};
-
-OpenBSDHostInfo::~OpenBSDHostInfo() {
-  for (llvm::StringMap<ToolChain*>::iterator
-         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
-    delete it->second;
-}
-
-ToolChain *OpenBSDHostInfo::CreateToolChain(const ArgList &Args,
-                                            const char *ArchName) const {
-  assert(!ArchName &&
-         "Unexpected arch name on platform without driver driver support.");
-
-  std::string Arch = getArchName();
-  ArchName = Arch.c_str();
-
-  ToolChain *&TC = ToolChains[ArchName];
-  if (!TC) {
-    llvm::Triple TCTriple(getTriple());
-    TCTriple.setArchName(ArchName);
-
-    TC = new toolchains::OpenBSD(*this, TCTriple);
-  }
-
-  return TC;
-}
-
-// AuroraUX Host Info
-
-/// AuroraUXHostInfo - AuroraUX host information implementation.
-class AuroraUXHostInfo : public HostInfo {
-  /// Cache of tool chains we have created.
-  mutable llvm::StringMap<ToolChain*> ToolChains;
-
-public:
-  AuroraUXHostInfo(const Driver &D, const llvm::Triple& Triple)
-    : HostInfo(D, Triple) {}
-  ~AuroraUXHostInfo();
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName) const;
-};
-
-AuroraUXHostInfo::~AuroraUXHostInfo() {
-  for (llvm::StringMap<ToolChain*>::iterator
-         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
-    delete it->second;
-}
-
-ToolChain *AuroraUXHostInfo::CreateToolChain(const ArgList &Args,
-                                             const char *ArchName) const {
-  assert(!ArchName &&
-         "Unexpected arch name on platform without driver driver support.");
-
-  ToolChain *&TC = ToolChains[getArchName()];
-
-  if (!TC) {
-    llvm::Triple TCTriple(getTriple());
-    TCTriple.setArchName(getArchName());
-
-    TC = new toolchains::AuroraUX(*this, TCTriple);
-  }
-
-  return TC;
-}
-
-// FreeBSD Host Info
-
-/// FreeBSDHostInfo -  FreeBSD host information implementation.
-class FreeBSDHostInfo : public HostInfo {
-  /// Cache of tool chains we have created.
-  mutable llvm::StringMap<ToolChain*> ToolChains;
-
-public:
-  FreeBSDHostInfo(const Driver &D, const llvm::Triple& Triple)
-    : HostInfo(D, Triple) {}
-  ~FreeBSDHostInfo();
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName) const;
-};
-
-FreeBSDHostInfo::~FreeBSDHostInfo() {
-  for (llvm::StringMap<ToolChain*>::iterator
-         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
-    delete it->second;
-}
-
-ToolChain *FreeBSDHostInfo::CreateToolChain(const ArgList &Args,
-                                            const char *ArchName) const {
-  assert(!ArchName &&
-         "Unexpected arch name on platform without driver driver support.");
-
-  // Automatically handle some instances of -m32/-m64 we know about.
-  std::string Arch = getArchName();
-  ArchName = Arch.c_str();
-  if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
-    if (Triple.getArch() == llvm::Triple::x86 ||
-        Triple.getArch() == llvm::Triple::x86_64) {
-      ArchName =
-        (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64";
-    } else if (Triple.getArch() == llvm::Triple::ppc ||
-               Triple.getArch() == llvm::Triple::ppc64) {
-      ArchName =
-        (A->getOption().matches(options::OPT_m32)) ? "powerpc" : "powerpc64";
-    }
-  }
-
-  ToolChain *&TC = ToolChains[ArchName];
-  if (!TC) {
-    llvm::Triple TCTriple(getTriple());
-    TCTriple.setArchName(ArchName);
-
-    TC = new toolchains::FreeBSD(*this, TCTriple);
-  }
-
-  return TC;
-}
-
-// NetBSD Host Info
-
-/// NetBSDHostInfo -  NetBSD host information implementation.
-class NetBSDHostInfo : public HostInfo {
-  /// Cache of tool chains we have created.
-  mutable llvm::StringMap<ToolChain*> ToolChains;
-
-public:
-  NetBSDHostInfo(const Driver &D, const llvm::Triple& Triple)
-    : HostInfo(D, Triple) {}
-  ~NetBSDHostInfo();
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName) const;
-};
-
-NetBSDHostInfo::~NetBSDHostInfo() {
-  for (llvm::StringMap<ToolChain*>::iterator
-         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
-    delete it->second;
-}
-
-ToolChain *NetBSDHostInfo::CreateToolChain(const ArgList &Args,
-                                            const char *ArchName) const {
-  assert(!ArchName &&
-         "Unexpected arch name on platform without driver driver support.");
-
-  // Automatically handle some instances of -m32/-m64 we know about.
-  std::string Arch = getArchName();
-  ArchName = Arch.c_str();
-  if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
-    if (Triple.getArch() == llvm::Triple::x86 ||
-        Triple.getArch() == llvm::Triple::x86_64) {
-      ArchName =
-        (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64";
-    } else if (Triple.getArch() == llvm::Triple::ppc ||
-               Triple.getArch() == llvm::Triple::ppc64) {
-      ArchName =
-        (A->getOption().matches(options::OPT_m32)) ? "powerpc" : "powerpc64";
-    }
-  }
-  llvm::Triple TargetTriple(getTriple());
-  TargetTriple.setArchName(ArchName);
-
-  ToolChain *TC;
-
-  // XXX Cache toolchain even if -m32 is used
-  if (Arch == ArchName) {
-    TC = ToolChains[ArchName];
-    if (TC)
-      return TC;
-  }
-
-  TC = new toolchains::NetBSD(*this, TargetTriple, getTriple());
-
-  return TC;
-}
-
-// Minix Host Info
-
-/// MinixHostInfo -  Minix host information implementation.
-class MinixHostInfo : public HostInfo {
-  /// Cache of tool chains we have created.
-  mutable llvm::StringMap<ToolChain*> ToolChains;
-
-public:
-  MinixHostInfo(const Driver &D, const llvm::Triple& Triple)
-    : HostInfo(D, Triple) {}
-  ~MinixHostInfo();
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName) const;
-};
-
-MinixHostInfo::~MinixHostInfo() {
-  for (llvm::StringMap<ToolChain*>::iterator
-         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it){
-    delete it->second;
-  }
-}
-
-ToolChain *MinixHostInfo::CreateToolChain(const ArgList &Args,
-                                            const char *ArchName) const {
-  assert(!ArchName &&
-         "Unexpected arch name on platform without driver driver support.");
-
-  std::string Arch = getArchName();
-  ArchName = Arch.c_str();
-
-  ToolChain *&TC = ToolChains[ArchName];
-  if (!TC) {
-    llvm::Triple TCTriple(getTriple());
-    TCTriple.setArchName(ArchName);
-
-    TC = new toolchains::Minix(*this, TCTriple);
-  }
-
-  return TC;
-}
-
-// DragonFly Host Info
-
-/// DragonFlyHostInfo -  DragonFly host information implementation.
-class DragonFlyHostInfo : public HostInfo {
-  /// Cache of tool chains we have created.
-  mutable llvm::StringMap<ToolChain*> ToolChains;
-
-public:
-  DragonFlyHostInfo(const Driver &D, const llvm::Triple& Triple)
-    : HostInfo(D, Triple) {}
-  ~DragonFlyHostInfo();
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName) const;
-};
-
-DragonFlyHostInfo::~DragonFlyHostInfo() {
-  for (llvm::StringMap<ToolChain*>::iterator
-         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
-    delete it->second;
-}
-
-ToolChain *DragonFlyHostInfo::CreateToolChain(const ArgList &Args,
-                                              const char *ArchName) const {
-  assert(!ArchName &&
-         "Unexpected arch name on platform without driver driver support.");
-
-  ToolChain *&TC = ToolChains[getArchName()];
-
-  if (!TC) {
-    llvm::Triple TCTriple(getTriple());
-    TCTriple.setArchName(getArchName());
-
-    TC = new toolchains::DragonFly(*this, TCTriple);
-  }
-
-  return TC;
-}
-
-// Linux Host Info
-
-/// LinuxHostInfo -  Linux host information implementation.
-class LinuxHostInfo : public HostInfo {
-  /// Cache of tool chains we have created.
-  mutable llvm::StringMap<ToolChain*> ToolChains;
-
-public:
-  LinuxHostInfo(const Driver &D, const llvm::Triple& Triple)
-    : HostInfo(D, Triple) {}
-  ~LinuxHostInfo();
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName) const;
-};
-
-LinuxHostInfo::~LinuxHostInfo() {
-  for (llvm::StringMap<ToolChain*>::iterator
-         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
-    delete it->second;
-}
-
-ToolChain *LinuxHostInfo::CreateToolChain(const ArgList &Args,
-                                          const char *ArchName) const {
-
-  assert(!ArchName &&
-         "Unexpected arch name on platform without driver driver support.");
-
-  // Automatically handle some instances of -m32/-m64 we know about.
-  std::string Arch = getArchName();
-  ArchName = Arch.c_str();
-  if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
-    if (Triple.getArch() == llvm::Triple::x86 ||
-        Triple.getArch() == llvm::Triple::x86_64) {
-      ArchName =
-        (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64";
-    } else if (Triple.getArch() == llvm::Triple::ppc ||
-               Triple.getArch() == llvm::Triple::ppc64) {
-      ArchName =
-        (A->getOption().matches(options::OPT_m32)) ? "powerpc" : "powerpc64";
-    }
-  }
-
-  ToolChain *&TC = ToolChains[ArchName];
-
-  if (!TC && !Arch.compare ("hexagon")) {
-    llvm::Triple TCTriple (getTriple());
-    TC = new toolchains::Hexagon_TC (*this, TCTriple);
-  }
-
-  if (!TC) {
-    llvm::Triple TCTriple(getTriple());
-    TCTriple.setArchName(ArchName);
-
-    TC = new toolchains::Linux(*this, TCTriple);
-  }
-
-  return TC;
-}
-
-// Windows Host Info
-
-/// WindowsHostInfo - Host information to use on Microsoft Windows.
-class WindowsHostInfo : public HostInfo {
-  /// Cache of tool chains we have created.
-  mutable llvm::StringMap<ToolChain*> ToolChains;
-
-public:
-  WindowsHostInfo(const Driver &D, const llvm::Triple& Triple);
-  ~WindowsHostInfo();
-
-  virtual types::ID lookupTypeForExtension(const char *Ext) const {
-    return types::lookupTypeForExtension(Ext);
-  }
-
-  virtual ToolChain *CreateToolChain(const ArgList &Args,
-                                     const char *ArchName) const;
-};
-
-WindowsHostInfo::WindowsHostInfo(const Driver &D, const llvm::Triple& Triple)
-  : HostInfo(D, Triple) {
-}
-
-WindowsHostInfo::~WindowsHostInfo() {
-  for (llvm::StringMap<ToolChain*>::iterator
-         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
-    delete it->second;
-}
-
-ToolChain *WindowsHostInfo::CreateToolChain(const ArgList &Args,
-                                            const char *ArchName) const {
-  assert(!ArchName &&
-         "Unexpected arch name on platform without driver driver support.");
-
-  // Automatically handle some instances of -m32/-m64 we know about.
-  std::string Arch = getArchName();
-  ArchName = Arch.c_str();
-  if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
-    if (Triple.getArch() == llvm::Triple::x86 ||
-        Triple.getArch() == llvm::Triple::x86_64) {
-      ArchName =
-        (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64";
-    }
-  }
-
-  ToolChain *&TC = ToolChains[ArchName];
-  if (!TC) {
-    llvm::Triple TCTriple(getTriple());
-    TCTriple.setArchName(ArchName);
-
-    TC = new toolchains::Windows(*this, TCTriple);
-  }
-
-  return TC;
-}
-
-// FIXME: This is a placeholder.
-class MinGWHostInfo : public UnknownHostInfo {
-public:
-  MinGWHostInfo(const Driver &D, const llvm::Triple& Triple);
-};
-
-MinGWHostInfo::MinGWHostInfo(const Driver &D, const llvm::Triple& Triple)
-  : UnknownHostInfo(D, Triple) {}
-
-} // end anon namespace
-
-const HostInfo *
-clang::driver::createAuroraUXHostInfo(const Driver &D,
-                                      const llvm::Triple& Triple){
-  return new AuroraUXHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createDarwinHostInfo(const Driver &D,
-                                    const llvm::Triple& Triple){
-  return new DarwinHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createOpenBSDHostInfo(const Driver &D,
-                                     const llvm::Triple& Triple) {
-  return new OpenBSDHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createFreeBSDHostInfo(const Driver &D,
-                                     const llvm::Triple& Triple) {
-  return new FreeBSDHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createNetBSDHostInfo(const Driver &D,
-                                     const llvm::Triple& Triple) {
-  return new NetBSDHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createMinixHostInfo(const Driver &D,
-                                     const llvm::Triple& Triple) {
-  return new MinixHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createDragonFlyHostInfo(const Driver &D,
-                                       const llvm::Triple& Triple) {
-  return new DragonFlyHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createLinuxHostInfo(const Driver &D,
-                                   const llvm::Triple& Triple) {
-  return new LinuxHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createTCEHostInfo(const Driver &D,
-                                   const llvm::Triple& Triple) {
-  return new TCEHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createWindowsHostInfo(const Driver &D,
-                                     const llvm::Triple& Triple) {
-  return new WindowsHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createMinGWHostInfo(const Driver &D,
-                                   const llvm::Triple& Triple) {
-  return new MinGWHostInfo(D, Triple);
-}
-
-const HostInfo *
-clang::driver::createUnknownHostInfo(const Driver &D,
-                                     const llvm::Triple& Triple) {
-  return new UnknownHostInfo(D, Triple);
-}

Modified: cfe/branches/tooling/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChain.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChain.cpp (original)
+++ cfe/branches/tooling/lib/Driver/ToolChain.cpp Wed Jan 25 09:40:56 2012
@@ -14,31 +14,30 @@
 #include "clang/Driver/ArgList.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/HostInfo.h"
 #include "clang/Driver/ObjCRuntime.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Support/ErrorHandling.h"
 using namespace clang::driver;
 using namespace clang;
 
-ToolChain::ToolChain(const HostInfo &H, const llvm::Triple &T)
-  : Host(H), Triple(T) {
+ToolChain::ToolChain(const Driver &D, const llvm::Triple &T)
+  : D(D), Triple(T) {
 }
 
 ToolChain::~ToolChain() {
 }
 
 const Driver &ToolChain::getDriver() const {
- return Host.getDriver();
+ return D;
 }
 
 std::string ToolChain::GetFilePath(const char *Name) const {
-  return Host.getDriver().GetFilePath(Name, *this);
+  return D.GetFilePath(Name, *this);
 
 }
 
 std::string ToolChain::GetProgramPath(const char *Name, bool WantFile) const {
-  return Host.getDriver().GetProgramPath(Name, *this, WantFile);
+  return D.GetProgramPath(Name, *this, WantFile);
 }
 
 types::ID ToolChain::LookupTypeForExtension(const char *Ext) const {

Modified: cfe/branches/tooling/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChains.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChains.cpp (original)
+++ cfe/branches/tooling/lib/Driver/ToolChains.cpp Wed Jan 25 09:40:56 2012
@@ -18,7 +18,6 @@
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/HostInfo.h"
 #include "clang/Driver/ObjCRuntime.h"
 #include "clang/Driver/OptTable.h"
 #include "clang/Driver/Option.h"
@@ -46,8 +45,8 @@
 
 /// Darwin - Darwin tool chain for i386 and x86_64.
 
-Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple)
-  : ToolChain(Host, Triple), TargetInitialized(false),
+Darwin::Darwin(const Driver &D, const llvm::Triple& Triple)
+  : ToolChain(D, Triple), TargetInitialized(false),
     ARCRuntimeForSimulator(ARCSimulator_None),
     LibCXXForSimulator(LibCXXSimulator_None)
 {
@@ -251,8 +250,8 @@
 }
 
 
-DarwinClang::DarwinClang(const HostInfo &Host, const llvm::Triple& Triple)
-  : Darwin(Host, Triple)
+DarwinClang::DarwinClang(const Driver &D, const llvm::Triple& Triple)
+  : Darwin(D, Triple)
 {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
@@ -1093,13 +1092,31 @@
   return false;
 }
 
+// FIXME: Factor this helper into llvm::Triple itself.
+static llvm::Triple getMultiarchAlternateTriple(llvm::Triple Triple) {
+  switch (Triple.getArch()) {
+  default: break;
+  case llvm::Triple::x86:    Triple.setArchName("x86_64");    break;
+  case llvm::Triple::x86_64: Triple.setArchName("i386");      break;
+  case llvm::Triple::ppc:    Triple.setArchName("powerpc64"); break;
+  case llvm::Triple::ppc64:  Triple.setArchName("powerpc");   break;
+  }
+  return Triple;
+}
+
 /// \brief Construct a GCCInstallationDetector from the driver.
 ///
 /// This performs all of the autodetection and sets up the various paths.
 /// Once constructed, a GCCInstallation is esentially immutable.
-Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(const Driver &D)
-  : IsValid(false),
-    GccTriple(D.DefaultTargetTriple) {
+///
+/// FIXME: We shouldn't need an explicit TargetTriple parameter here, and
+/// should instead pull the target out of the driver. This is currently
+/// necessary because the driver doesn't store the final version of the target
+/// triple.
+Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(
+    const Driver &D,
+    const llvm::Triple &TargetTriple)
+    : IsValid(false) {
   // FIXME: Using CXX_INCLUDE_ROOT is here is a bit of a hack, but
   // avoids adding yet another option to configure/cmake.
   // It would probably be cleaner to break it in two variables
@@ -1118,26 +1135,27 @@
     llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the version
     llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the c++
     llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the include
-    GccInstallPath = CxxIncludeRoot.str();
-    GccInstallPath.append("/lib/gcc/");
-    GccInstallPath.append(CXX_INCLUDE_ARCH);
-    GccInstallPath.append("/");
-    GccInstallPath.append(Version);
-    GccParentLibPath = GccInstallPath + "/../../..";
+    GCCInstallPath = CxxIncludeRoot.str();
+    GCCInstallPath.append("/lib/gcc/");
+    GCCInstallPath.append(CXX_INCLUDE_ARCH);
+    GCCInstallPath.append("/");
+    GCCInstallPath.append(Version);
+    GCCParentLibPath = GCCInstallPath + "/../../..";
     IsValid = true;
     return;
   }
 
-  llvm::Triple::ArchType HostArch = llvm::Triple(GccTriple).getArch();
+  llvm::Triple MultiarchTriple = getMultiarchAlternateTriple(TargetTriple);
+  llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
   // The library directories which may contain GCC installations.
-  SmallVector<StringRef, 4> CandidateLibDirs;
+  SmallVector<StringRef, 4> CandidateLibDirs, CandidateMultiarchLibDirs;
   // The compatible GCC triples for this particular architecture.
-  SmallVector<StringRef, 10> CandidateTriples;
-  CollectLibDirsAndTriples(HostArch, CandidateLibDirs, CandidateTriples);
-
-  // Always include the default host triple as the final fallback if no
-  // specific triple is detected.
-  CandidateTriples.push_back(D.DefaultTargetTriple);
+  SmallVector<StringRef, 10> CandidateTripleAliases;
+  SmallVector<StringRef, 10> CandidateMultiarchTripleAliases;
+  CollectLibDirsAndTriples(TargetTriple, MultiarchTriple, CandidateLibDirs,
+                           CandidateTripleAliases,
+                           CandidateMultiarchLibDirs,
+                           CandidateMultiarchTripleAliases);
 
   // Compute the set of prefixes for our search.
   SmallVector<std::string, 8> Prefixes(D.PrefixDirs.begin(),
@@ -1156,99 +1174,162 @@
       const std::string LibDir = Prefixes[i] + CandidateLibDirs[j].str();
       if (!llvm::sys::fs::exists(LibDir))
         continue;
-      for (unsigned k = 0, ke = CandidateTriples.size(); k < ke; ++k)
-        ScanLibDirForGCCTriple(HostArch, LibDir, CandidateTriples[k]);
+      for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k)
+        ScanLibDirForGCCTriple(TargetArch, LibDir, CandidateTripleAliases[k]);
+    }
+    for (unsigned j = 0, je = CandidateMultiarchLibDirs.size(); j < je; ++j) {
+      const std::string LibDir
+        = Prefixes[i] + CandidateMultiarchLibDirs[j].str();
+      if (!llvm::sys::fs::exists(LibDir))
+        continue;
+      for (unsigned k = 0, ke = CandidateMultiarchTripleAliases.size(); k < ke;
+           ++k)
+        ScanLibDirForGCCTriple(TargetArch, LibDir,
+                               CandidateMultiarchTripleAliases[k],
+                               /*NeedsMultiarchSuffix=*/true);
     }
   }
 }
 
 /*static*/ void Generic_GCC::GCCInstallationDetector::CollectLibDirsAndTriples(
-    llvm::Triple::ArchType HostArch, SmallVectorImpl<StringRef> &LibDirs,
-    SmallVectorImpl<StringRef> &Triples) {
-  if (HostArch == llvm::Triple::arm || HostArch == llvm::Triple::thumb) {
-    static const char *const ARMLibDirs[] = { "/lib" };
-    static const char *const ARMTriples[] = {
-      "arm-linux-gnueabi",
-      "arm-linux-androideabi"
-    };
+    const llvm::Triple &TargetTriple,
+    const llvm::Triple &MultiarchTriple,
+    SmallVectorImpl<StringRef> &LibDirs,
+    SmallVectorImpl<StringRef> &TripleAliases,
+    SmallVectorImpl<StringRef> &MultiarchLibDirs,
+    SmallVectorImpl<StringRef> &MultiarchTripleAliases) {
+  // Declare a bunch of static data sets that we'll select between below. These
+  // are specifically designed to always refer to string literals to avoid any
+  // lifetime or initialization issues.
+  static const char *const ARMLibDirs[] = { "/lib" };
+  static const char *const ARMTriples[] = {
+    "arm-linux-gnueabi",
+    "arm-linux-androideabi"
+  };
+
+  static const char *const X86_64LibDirs[] = { "/lib64", "/lib" };
+  static const char *const X86_64Triples[] = {
+    "x86_64-linux-gnu",
+    "x86_64-unknown-linux-gnu",
+    "x86_64-pc-linux-gnu",
+    "x86_64-redhat-linux6E",
+    "x86_64-redhat-linux",
+    "x86_64-suse-linux",
+    "x86_64-manbo-linux-gnu",
+    "x86_64-linux-gnu",
+    "x86_64-slackware-linux"
+  };
+  static const char *const X86LibDirs[] = { "/lib32", "/lib" };
+  static const char *const X86Triples[] = {
+    "i686-linux-gnu",
+    "i686-pc-linux-gnu",
+    "i486-linux-gnu",
+    "i386-linux-gnu",
+    "i686-redhat-linux",
+    "i586-redhat-linux",
+    "i386-redhat-linux",
+    "i586-suse-linux",
+    "i486-slackware-linux"
+  };
+
+  static const char *const MIPSLibDirs[] = { "/lib" };
+  static const char *const MIPSTriples[] = { "mips-linux-gnu" };
+  static const char *const MIPSELLibDirs[] = { "/lib" };
+  static const char *const MIPSELTriples[] = { "mipsel-linux-gnu" };
+
+  static const char *const PPCLibDirs[] = { "/lib32", "/lib" };
+  static const char *const PPCTriples[] = {
+    "powerpc-linux-gnu",
+    "powerpc-unknown-linux-gnu",
+    "powerpc-suse-linux"
+  };
+  static const char *const PPC64LibDirs[] = { "/lib64", "/lib" };
+  static const char *const PPC64Triples[] = {
+    "powerpc64-unknown-linux-gnu",
+    "powerpc64-suse-linux",
+    "ppc64-redhat-linux"
+  };
+
+  switch (TargetTriple.getArch()) {
+  case llvm::Triple::arm:
+  case llvm::Triple::thumb:
     LibDirs.append(ARMLibDirs, ARMLibDirs + llvm::array_lengthof(ARMLibDirs));
-    Triples.append(ARMTriples, ARMTriples + llvm::array_lengthof(ARMTriples));
-  } else if (HostArch == llvm::Triple::x86_64) {
-    static const char *const X86_64LibDirs[] = { "/lib64", "/lib" };
-    static const char *const X86_64Triples[] = {
-      "x86_64-linux-gnu",
-      "x86_64-unknown-linux-gnu",
-      "x86_64-pc-linux-gnu",
-      "x86_64-redhat-linux6E",
-      "x86_64-redhat-linux",
-      "x86_64-suse-linux",
-      "x86_64-manbo-linux-gnu",
-      "x86_64-linux-gnu",
-      "x86_64-slackware-linux"
-    };
-    LibDirs.append(X86_64LibDirs,
-                   X86_64LibDirs + llvm::array_lengthof(X86_64LibDirs));
-    Triples.append(X86_64Triples,
-                   X86_64Triples + llvm::array_lengthof(X86_64Triples));
-  } else if (HostArch == llvm::Triple::x86) {
-    static const char *const X86LibDirs[] = { "/lib32", "/lib" };
-    static const char *const X86Triples[] = {
-      "i686-linux-gnu",
-      "i686-pc-linux-gnu",
-      "i486-linux-gnu",
-      "i386-linux-gnu",
-      "i686-redhat-linux",
-      "i586-redhat-linux",
-      "i386-redhat-linux",
-      "i586-suse-linux",
-      "i486-slackware-linux"
-    };
+    TripleAliases.append(
+      ARMTriples, ARMTriples + llvm::array_lengthof(ARMTriples));
+    break;
+  case llvm::Triple::x86_64:
+    LibDirs.append(
+      X86_64LibDirs, X86_64LibDirs + llvm::array_lengthof(X86_64LibDirs));
+    TripleAliases.append(
+      X86_64Triples, X86_64Triples + llvm::array_lengthof(X86_64Triples));
+    MultiarchLibDirs.append(
+      X86LibDirs, X86LibDirs + llvm::array_lengthof(X86LibDirs));
+    MultiarchTripleAliases.append(
+      X86Triples, X86Triples + llvm::array_lengthof(X86Triples));
+    break;
+  case llvm::Triple::x86:
     LibDirs.append(X86LibDirs, X86LibDirs + llvm::array_lengthof(X86LibDirs));
-    Triples.append(X86Triples, X86Triples + llvm::array_lengthof(X86Triples));
-  } else if (HostArch == llvm::Triple::mips) {
-    static const char *const MIPSLibDirs[] = { "/lib" };
-    static const char *const MIPSTriples[] = { "mips-linux-gnu" };
-    LibDirs.append(MIPSLibDirs,
-                   MIPSLibDirs + llvm::array_lengthof(MIPSLibDirs));
-    Triples.append(MIPSTriples,
-                   MIPSTriples + llvm::array_lengthof(MIPSTriples));
-  } else if (HostArch == llvm::Triple::mipsel) {
-    static const char *const MIPSELLibDirs[] = { "/lib" };
-    static const char *const MIPSELTriples[] = { "mipsel-linux-gnu" };
-    LibDirs.append(MIPSELLibDirs,
-                   MIPSELLibDirs + llvm::array_lengthof(MIPSELLibDirs));
-    Triples.append(MIPSELTriples,
-                   MIPSELTriples + llvm::array_lengthof(MIPSELTriples));
-  } else if (HostArch == llvm::Triple::ppc) {
-    static const char *const PPCLibDirs[] = { "/lib32", "/lib" };
-    static const char *const PPCTriples[] = {
-      "powerpc-linux-gnu",
-      "powerpc-unknown-linux-gnu",
-      "powerpc-suse-linux"
-    };
+    TripleAliases.append(
+      X86Triples, X86Triples + llvm::array_lengthof(X86Triples));
+    MultiarchLibDirs.append(
+      X86_64LibDirs, X86_64LibDirs + llvm::array_lengthof(X86_64LibDirs));
+    MultiarchTripleAliases.append(
+      X86_64Triples, X86_64Triples + llvm::array_lengthof(X86_64Triples));
+    break;
+  case llvm::Triple::mips:
+    LibDirs.append(
+      MIPSLibDirs, MIPSLibDirs + llvm::array_lengthof(MIPSLibDirs));
+    TripleAliases.append(
+      MIPSTriples, MIPSTriples + llvm::array_lengthof(MIPSTriples));
+    break;
+  case llvm::Triple::mipsel:
+    LibDirs.append(
+      MIPSELLibDirs, MIPSELLibDirs + llvm::array_lengthof(MIPSELLibDirs));
+    TripleAliases.append(
+      MIPSELTriples, MIPSELTriples + llvm::array_lengthof(MIPSELTriples));
+    break;
+  case llvm::Triple::ppc:
     LibDirs.append(PPCLibDirs, PPCLibDirs + llvm::array_lengthof(PPCLibDirs));
-    Triples.append(PPCTriples, PPCTriples + llvm::array_lengthof(PPCTriples));
-  } else if (HostArch == llvm::Triple::ppc64) {
-    static const char *const PPC64LibDirs[] = { "/lib64", "/lib" };
-    static const char *const PPC64Triples[] = {
-      "powerpc64-unknown-linux-gnu",
-      "powerpc64-suse-linux",
-      "ppc64-redhat-linux"
-    };
-    LibDirs.append(PPC64LibDirs,
-                   PPC64LibDirs + llvm::array_lengthof(PPC64LibDirs));
-    Triples.append(PPC64Triples,
-                   PPC64Triples + llvm::array_lengthof(PPC64Triples));
+    TripleAliases.append(
+      PPCTriples, PPCTriples + llvm::array_lengthof(PPCTriples));
+    MultiarchLibDirs.append(
+      PPC64LibDirs, PPC64LibDirs + llvm::array_lengthof(PPC64LibDirs));
+    MultiarchTripleAliases.append(
+      PPC64Triples, PPC64Triples + llvm::array_lengthof(PPC64Triples));
+    break;
+  case llvm::Triple::ppc64:
+    LibDirs.append(
+      PPC64LibDirs, PPC64LibDirs + llvm::array_lengthof(PPC64LibDirs));
+    TripleAliases.append(
+      PPC64Triples, PPC64Triples + llvm::array_lengthof(PPC64Triples));
+    MultiarchLibDirs.append(
+      PPCLibDirs, PPCLibDirs + llvm::array_lengthof(PPCLibDirs));
+    MultiarchTripleAliases.append(
+      PPCTriples, PPCTriples + llvm::array_lengthof(PPCTriples));
+    break;
+
+  default:
+    // By default, just rely on the standard lib directories and the original
+    // triple.
+    break;
   }
+
+  // Always append the drivers target triple to the end, in case it doesn't
+  // match any of our aliases.
+  TripleAliases.push_back(TargetTriple.str());
+
+  // Also include the multiarch variant if it's different.
+  if (TargetTriple.str() != MultiarchTriple.str())
+    MultiarchTripleAliases.push_back(MultiarchTriple.str());
 }
 
 void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
-    llvm::Triple::ArchType HostArch, const std::string &LibDir,
-    StringRef CandidateTriple) {
+    llvm::Triple::ArchType TargetArch, const std::string &LibDir,
+    StringRef CandidateTriple, bool NeedsMultiarchSuffix) {
   // There are various different suffixes involving the triple we
   // check for. We also record what is necessary to walk from each back
   // up to the lib directory.
-  const std::string Suffixes[] = {
+  const std::string LibSuffixes[] = {
     "/gcc/" + CandidateTriple.str(),
     "/" + CandidateTriple.str() + "/gcc/" + CandidateTriple.str(),
 
@@ -1264,12 +1345,12 @@
     "/../../../.."
   };
   // Only look at the final, weird Ubuntu suffix for i386-linux-gnu.
-  const unsigned NumSuffixes = (llvm::array_lengthof(Suffixes) -
-                                (HostArch != llvm::Triple::x86));
-  for (unsigned i = 0; i < NumSuffixes; ++i) {
-    StringRef Suffix = Suffixes[i];
+  const unsigned NumLibSuffixes = (llvm::array_lengthof(LibSuffixes) -
+                                   (TargetArch != llvm::Triple::x86));
+  for (unsigned i = 0; i < NumLibSuffixes; ++i) {
+    StringRef LibSuffix = LibSuffixes[i];
     llvm::error_code EC;
-    for (llvm::sys::fs::directory_iterator LI(LibDir + Suffix, EC), LE;
+    for (llvm::sys::fs::directory_iterator LI(LibDir + LibSuffix, EC), LE;
          !EC && LI != LE; LI = LI.increment(EC)) {
       StringRef VersionText = llvm::sys::path::filename(LI->path());
       GCCVersion CandidateVersion = GCCVersion::Parse(VersionText);
@@ -1280,32 +1361,37 @@
         continue;
 
       // Some versions of SUSE and Fedora on ppc64 put 32-bit libs
-      // in what would normally be GccInstallPath and put the 64-bit
-      // libs in a subdirectory named 64. We need the 64-bit libs
-      // for linking.
-      bool UseSlash64 = false;
-      if (HostArch == llvm::Triple::ppc64 &&
-            llvm::sys::fs::exists(LI->path() + "/64/crtbegin.o"))
-        UseSlash64 = true;
-
-      if (!llvm::sys::fs::exists(LI->path() + "/crtbegin.o"))
-        continue;
+      // in what would normally be GCCInstallPath and put the 64-bit
+      // libs in a subdirectory named 64. The simple logic we follow is that
+      // *if* there is a subdirectory of the right name with crtbegin.o in it,
+      // we use that. If not, and if not a multiarch triple, we look for
+      // crtbegin.o without the subdirectory.
+      StringRef MultiarchSuffix
+        = (TargetArch == llvm::Triple::x86_64 ||
+           TargetArch == llvm::Triple::ppc64) ? "/64" : "/32";
+      if (llvm::sys::fs::exists(LI->path() + MultiarchSuffix + "/crtbegin.o")) {
+        GCCMultiarchSuffix = MultiarchSuffix.str();
+      } else {
+        if (NeedsMultiarchSuffix ||
+            !llvm::sys::fs::exists(LI->path() + "/crtbegin.o"))
+          continue;
+        GCCMultiarchSuffix.clear();
+      }
 
       Version = CandidateVersion;
-      GccTriple = CandidateTriple.str();
+      GCCTriple.setTriple(CandidateTriple);
       // FIXME: We hack together the directory name here instead of
       // using LI to ensure stable path separators across Windows and
       // Linux.
-      GccInstallPath = LibDir + Suffixes[i] + "/" + VersionText.str();
-      GccParentLibPath = GccInstallPath + InstallSuffixes[i];
-      if (UseSlash64) GccInstallPath = GccInstallPath + "/64";
+      GCCInstallPath = LibDir + LibSuffixes[i] + "/" + VersionText.str();
+      GCCParentLibPath = GCCInstallPath + InstallSuffixes[i];
       IsValid = true;
     }
   }
 }
 
-Generic_GCC::Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple)
-  : ToolChain(Host, Triple), GCCInstallation(getDriver()) {
+Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple& Triple)
+  : ToolChain(D, Triple), GCCInstallation(getDriver(), Triple) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
     getProgramPaths().push_back(getDriver().Dir);
@@ -1375,8 +1461,8 @@
 }
 /// Hexagon Toolchain
 
-Hexagon_TC::Hexagon_TC(const HostInfo &Host, const llvm::Triple& Triple)
-  : ToolChain(Host, Triple) {
+Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple& Triple)
+  : ToolChain(D, Triple) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir.c_str())
     getProgramPaths().push_back(getDriver().Dir);
@@ -1445,8 +1531,8 @@
 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
 /// Currently does not support anything else but compilation.
 
-TCEToolChain::TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple)
-  : ToolChain(Host, Triple) {
+TCEToolChain::TCEToolChain(const Driver &D, const llvm::Triple& Triple)
+  : ToolChain(D, Triple) {
   // Path mangling to find libexec
   std::string Path(getDriver().Dir);
 
@@ -1498,8 +1584,8 @@
 
 /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
 
-OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple)
-  : Generic_ELF(Host, Triple) {
+OpenBSD::OpenBSD(const Driver &D, const llvm::Triple& Triple)
+  : Generic_ELF(D, Triple) {
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
 }
@@ -1538,26 +1624,17 @@
 
 /// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly.
 
-FreeBSD::FreeBSD(const HostInfo &Host, const llvm::Triple& Triple)
-  : Generic_ELF(Host, Triple) {
+FreeBSD::FreeBSD(const Driver &D, const llvm::Triple& Triple)
+  : Generic_ELF(D, Triple) {
 
-  // Determine if we are compiling 32-bit code on an x86_64 platform.
-  bool Lib32 = false;
-  if (Triple.getArch() == llvm::Triple::x86 &&
-      llvm::Triple(getDriver().DefaultTargetTriple).getArch() ==
-        llvm::Triple::x86_64)
-    Lib32 = true;
-
-  if (Triple.getArch() == llvm::Triple::ppc &&
-      llvm::Triple(getDriver().DefaultTargetTriple).getArch() ==
-        llvm::Triple::ppc64)
-    Lib32 = true;
-
-  if (Lib32) {
-    getFilePaths().push_back("/usr/lib32");
-  } else {
-    getFilePaths().push_back("/usr/lib");
-  }
+  // When targeting 32-bit platforms, look for '/usr/lib32' first and fall back
+  // to '/usr/lib' for the remaining cases.
+  if ((Triple.getArch() == llvm::Triple::x86 ||
+       Triple.getArch() == llvm::Triple::ppc) &&
+      llvm::sys::fs::exists(getDriver().SysRoot + "/usr/lib32"))
+    getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32");
+  else
+    getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
 }
 
 Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA,
@@ -1593,21 +1670,20 @@
 
 /// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly.
 
-NetBSD::NetBSD(const HostInfo &Host, const llvm::Triple& Triple,
-               const llvm::Triple& ToolTriple)
-  : Generic_ELF(Host, Triple), ToolTriple(ToolTriple) {
-
-  // Determine if we are compiling 32-bit code on an x86_64 platform.
-  bool Lib32 = false;
-  if (ToolTriple.getArch() == llvm::Triple::x86_64 &&
-      Triple.getArch() == llvm::Triple::x86)
-    Lib32 = true;
+NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple)
+  : Generic_ELF(D, Triple) {
 
   if (getDriver().UseStdLib) {
-    if (Lib32)
+    // When targeting a 32-bit platform, try the special directory used on
+    // 64-bit hosts, and only fall back to the main library directory if that
+    // doesn't work.
+    // FIXME: It'd be nicer to test if this directory exists, but I'm not sure
+    // what all logic is needed to emulate the '=' prefix here.
+    if (Triple.getArch() == llvm::Triple::x86 ||
+        Triple.getArch() == llvm::Triple::ppc)
       getFilePaths().push_back("=/usr/lib/i386");
-    else
-      getFilePaths().push_back("=/usr/lib");
+
+    getFilePaths().push_back("=/usr/lib");
   }
 }
 
@@ -1630,10 +1706,10 @@
       if (UseIntegratedAs)
         T = new tools::ClangAs(*this);
       else
-        T = new tools::netbsd::Assemble(*this, ToolTriple);
+        T = new tools::netbsd::Assemble(*this, getTriple());
       break;
     case Action::LinkJobClass:
-      T = new tools::netbsd::Link(*this, ToolTriple);
+      T = new tools::netbsd::Link(*this, getTriple());
       break;
     default:
       T = &Generic_GCC::SelectTool(C, JA, Inputs);
@@ -1645,8 +1721,8 @@
 
 /// Minix - Minix tool chain which can call as(1) and ld(1) directly.
 
-Minix::Minix(const HostInfo &Host, const llvm::Triple& Triple)
-  : Generic_ELF(Host, Triple) {
+Minix::Minix(const Driver &D, const llvm::Triple& Triple)
+  : Generic_ELF(D, Triple) {
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
 }
@@ -1676,8 +1752,8 @@
 
 /// AuroraUX - AuroraUX tool chain which can call as(1) and ld(1) directly.
 
-AuroraUX::AuroraUX(const HostInfo &Host, const llvm::Triple& Triple)
-  : Generic_GCC(Host, Triple) {
+AuroraUX::AuroraUX(const Driver &D, const llvm::Triple& Triple)
+  : Generic_GCC(D, Triple) {
 
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
@@ -1851,10 +1927,6 @@
   return UnknownDistro;
 }
 
-static void addPathIfExists(Twine Path, ToolChain::path_list &Paths) {
-  if (llvm::sys::fs::exists(Path)) Paths.push_back(Path.str());
-}
-
 /// \brief Get our best guess at the multiarch triple for a target.
 ///
 /// Debian-based systems are starting to use a multiarch setup where they use
@@ -1892,17 +1964,20 @@
   }
 }
 
-Linux::Linux(const HostInfo &Host, const llvm::Triple &Triple)
-  : Generic_ELF(Host, Triple) {
-  llvm::Triple::ArchType Arch =
-    llvm::Triple(getDriver().DefaultTargetTriple).getArch();
+static void addPathIfExists(Twine Path, ToolChain::path_list &Paths) {
+  if (llvm::sys::fs::exists(Path)) Paths.push_back(Path.str());
+}
+
+Linux::Linux(const Driver &D, const llvm::Triple &Triple)
+  : Generic_ELF(D, Triple) {
+  llvm::Triple::ArchType Arch = Triple.getArch();
   const std::string &SysRoot = getDriver().SysRoot;
 
   // OpenSuse stores the linker with the compiler, add that to the search
   // path.
   ToolChain::path_list &PPaths = getProgramPaths();
   PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
-                         GCCInstallation.getTriple() + "/bin").str());
+                         GCCInstallation.getTriple().str() + "/bin").str());
 
   Linker = GetProgramPath("ld");
 
@@ -1958,30 +2033,23 @@
   // possible permutations of these directories, and seeing which ones it added
   // to the link paths.
   path_list &Paths = getFilePaths();
-  const bool Is32Bits = (getArch() == llvm::Triple::x86 ||
-                         getArch() == llvm::Triple::mips ||
-                         getArch() == llvm::Triple::mipsel ||
-                         getArch() == llvm::Triple::ppc);
-
-  StringRef Suffix32;
-  StringRef Suffix64;
-  if (Arch == llvm::Triple::x86_64 || Arch == llvm::Triple::ppc64) {
-    Suffix32 = "/32";
-    Suffix64 = "";
-  } else {
-    Suffix32 = "";
-    Suffix64 = "/64";
-  }
-  const std::string Suffix = Is32Bits ? Suffix32 : Suffix64;
+
+  const bool Is32Bits = (Arch == llvm::Triple::x86 ||
+                         Arch == llvm::Triple::mips ||
+                         Arch == llvm::Triple::mipsel ||
+                         Arch == llvm::Triple::ppc);
+
   const std::string Multilib = Is32Bits ? "lib32" : "lib64";
   const std::string MultiarchTriple = getMultiarchTriple(Triple, SysRoot);
 
   // Add the multilib suffixed paths where they are available.
   if (GCCInstallation.isValid()) {
+    const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
     const std::string &LibPath = GCCInstallation.getParentLibPath();
-    const std::string &GccTriple = GCCInstallation.getTriple();
-    addPathIfExists(GCCInstallation.getInstallPath() + Suffix, Paths);
-    addPathIfExists(LibPath + "/../" + GccTriple + "/lib/../" + Multilib,
+    addPathIfExists((GCCInstallation.getInstallPath() +
+                     GCCInstallation.getMultiarchSuffix()),
+                    Paths);
+    addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib/../" + Multilib,
                     Paths);
     addPathIfExists(LibPath + "/" + MultiarchTriple, Paths);
     addPathIfExists(LibPath + "/../" + Multilib, Paths);
@@ -1994,16 +2062,16 @@
   // Try walking via the GCC triple path in case of multiarch GCC
   // installations with strange symlinks.
   if (GCCInstallation.isValid())
-    addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple() +
+    addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() +
                     "/../../" + Multilib, Paths);
 
   // Add the non-multilib suffixed paths (if potentially different).
   if (GCCInstallation.isValid()) {
     const std::string &LibPath = GCCInstallation.getParentLibPath();
-    const std::string &GccTriple = GCCInstallation.getTriple();
-    if (!Suffix.empty())
+    const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
+    if (!GCCInstallation.getMultiarchSuffix().empty())
       addPathIfExists(GCCInstallation.getInstallPath(), Paths);
-    addPathIfExists(LibPath + "/../" + GccTriple + "/lib", Paths);
+    addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib", Paths);
     addPathIfExists(LibPath, Paths);
   }
   addPathIfExists(SysRoot + "/lib", Paths);
@@ -2183,19 +2251,10 @@
     return;
   }
 
-  // Check if the target architecture specific dirs need a suffix. Note that we
-  // only support the suffix-based bi-arch-like header scheme for host/target
-  // mismatches of just bit width.
-  llvm::Triple::ArchType HostArch =
-    llvm::Triple(getDriver().DefaultTargetTriple).getArch();
-  llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
-  StringRef Suffix;
-  if ((HostArch == llvm::Triple::x86 && TargetArch == llvm::Triple::x86_64) ||
-      (HostArch == llvm::Triple::ppc && TargetArch == llvm::Triple::ppc64))
-    Suffix = "/64";
-  if ((HostArch == llvm::Triple::x86_64 && TargetArch == llvm::Triple::x86) ||
-      (HostArch == llvm::Triple::ppc64 && TargetArch == llvm::Triple::ppc))
-    Suffix = "/32";
+  // We need a detected GCC installation on Linux to provide libstdc++'s
+  // headers. We handled the libc++ case above.
+  if (!GCCInstallation.isValid())
+    return;
 
   // By default, look for the C++ headers in an include directory adjacent to
   // the lib directory of the GCC installation. Note that this is expect to be
@@ -2204,20 +2263,22 @@
   StringRef InstallDir = GCCInstallation.getInstallPath();
   StringRef Version = GCCInstallation.getVersion();
   if (!addLibStdCXXIncludePaths(LibDir + "/../include/c++/" + Version,
-                                GCCInstallation.getTriple() + Suffix,
+                                (GCCInstallation.getTriple().str() +
+                                 GCCInstallation.getMultiarchSuffix()),
                                 DriverArgs, CC1Args)) {
     // Gentoo is weird and places its headers inside the GCC install, so if the
     // first attempt to find the headers fails, try this pattern.
     addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4",
-                             GCCInstallation.getTriple() + Suffix,
+                             (GCCInstallation.getTriple().str() +
+                              GCCInstallation.getMultiarchSuffix()),
                              DriverArgs, CC1Args);
   }
 }
 
 /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
 
-DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple)
-  : Generic_ELF(Host, Triple) {
+DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple)
+  : Generic_ELF(D, Triple) {
 
   // Path mangling to find libexec
   getProgramPaths().push_back(getDriver().getInstalledDir());

Modified: cfe/branches/tooling/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChains.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChains.h (original)
+++ cfe/branches/tooling/lib/Driver/ToolChains.h Wed Jan 25 09:40:56 2012
@@ -69,40 +69,49 @@
   class GCCInstallationDetector {
 
     bool IsValid;
-    std::string GccTriple;
+    llvm::Triple GCCTriple;
 
     // FIXME: These might be better as path objects.
-    std::string GccInstallPath;
-    std::string GccParentLibPath;
+    std::string GCCInstallPath;
+    std::string GCCMultiarchSuffix;
+    std::string GCCParentLibPath;
 
     GCCVersion Version;
 
   public:
-    GCCInstallationDetector(const Driver &D);
+    GCCInstallationDetector(const Driver &D, const llvm::Triple &TargetTriple);
 
     /// \brief Check whether we detected a valid GCC install.
     bool isValid() const { return IsValid; }
 
     /// \brief Get the GCC triple for the detected install.
-    StringRef getTriple() const { return GccTriple; }
+    const llvm::Triple &getTriple() const { return GCCTriple; }
 
     /// \brief Get the detected GCC installation path.
-    StringRef getInstallPath() const { return GccInstallPath; }
+    StringRef getInstallPath() const { return GCCInstallPath; }
+
+    /// \brief Get the detected GCC installation path suffix for multiarch GCCs.
+    StringRef getMultiarchSuffix() const { return GCCMultiarchSuffix; }
 
     /// \brief Get the detected GCC parent lib path.
-    StringRef getParentLibPath() const { return GccParentLibPath; }
+    StringRef getParentLibPath() const { return GCCParentLibPath; }
 
     /// \brief Get the detected GCC version string.
     StringRef getVersion() const { return Version.Text; }
 
   private:
-    static void CollectLibDirsAndTriples(llvm::Triple::ArchType HostArch,
-                                         SmallVectorImpl<StringRef> &LibDirs,
-                                         SmallVectorImpl<StringRef> &Triples);
+    static void CollectLibDirsAndTriples(
+      const llvm::Triple &TargetTriple,
+      const llvm::Triple &MultiarchTriple,
+      SmallVectorImpl<StringRef> &LibDirs,
+      SmallVectorImpl<StringRef> &TripleAliases,
+      SmallVectorImpl<StringRef> &MultiarchLibDirs,
+      SmallVectorImpl<StringRef> &MultiarchTripleAliases);
 
-    void ScanLibDirForGCCTriple(llvm::Triple::ArchType HostArch,
+    void ScanLibDirForGCCTriple(llvm::Triple::ArchType TargetArch,
                                 const std::string &LibDir,
-                                StringRef CandidateTriple);
+                                StringRef CandidateTriple,
+                                bool NeedsMultiarchSuffix = false);
   };
 
   GCCInstallationDetector GCCInstallation;
@@ -110,7 +119,7 @@
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
 public:
-  Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple);
+  Generic_GCC(const Driver &D, const llvm::Triple& Triple);
   ~Generic_GCC();
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -141,7 +150,7 @@
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
 public:
-  Hexagon_TC(const HostInfo &Host, const llvm::Triple& Triple);
+  Hexagon_TC(const Driver &D, const llvm::Triple& Triple);
   ~Hexagon_TC();
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -203,7 +212,7 @@
   void AddDeploymentTarget(DerivedArgList &Args) const;
 
 public:
-  Darwin(const HostInfo &Host, const llvm::Triple& Triple);
+  Darwin(const Driver &D, const llvm::Triple& Triple);
   ~Darwin();
 
   std::string ComputeEffectiveClangTriple(const ArgList &Args,
@@ -386,7 +395,7 @@
   void AddGCCLibexecPath(unsigned darwinVersion);
 
 public:
-  DarwinClang(const HostInfo &Host, const llvm::Triple& Triple);
+  DarwinClang(const Driver &D, const llvm::Triple& Triple);
 
   /// @name Darwin ToolChain Implementation
   /// {
@@ -413,8 +422,8 @@
 /// Darwin_Generic_GCC - Generic Darwin tool chain using gcc.
 class LLVM_LIBRARY_VISIBILITY Darwin_Generic_GCC : public Generic_GCC {
 public:
-  Darwin_Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple)
-    : Generic_GCC(Host, Triple) {}
+  Darwin_Generic_GCC(const Driver &D, const llvm::Triple& Triple)
+    : Generic_GCC(D, Triple) {}
 
   std::string ComputeEffectiveClangTriple(const ArgList &Args,
                                           types::ID InputType) const;
@@ -425,8 +434,8 @@
 class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC {
   virtual void anchor();
 public:
-  Generic_ELF(const HostInfo &Host, const llvm::Triple& Triple)
-    : Generic_GCC(Host, Triple) {}
+  Generic_ELF(const Driver &D, const llvm::Triple& Triple)
+    : Generic_GCC(D, Triple) {}
 
   virtual bool IsIntegratedAssemblerDefault() const {
     // Default integrated assembler to on for x86.
@@ -437,7 +446,7 @@
 
 class LLVM_LIBRARY_VISIBILITY AuroraUX : public Generic_GCC {
 public:
-  AuroraUX(const HostInfo &Host, const llvm::Triple& Triple);
+  AuroraUX(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -445,7 +454,7 @@
 
 class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
 public:
-  OpenBSD(const HostInfo &Host, const llvm::Triple& Triple);
+  OpenBSD(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -453,18 +462,15 @@
 
 class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
 public:
-  FreeBSD(const HostInfo &Host, const llvm::Triple& Triple);
+  FreeBSD(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
 };
 
 class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
-  const llvm::Triple ToolTriple;
-
 public:
-  NetBSD(const HostInfo &Host, const llvm::Triple& Triple,
-         const llvm::Triple& ToolTriple);
+  NetBSD(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -472,7 +478,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF {
 public:
-  Minix(const HostInfo &Host, const llvm::Triple& Triple);
+  Minix(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -480,7 +486,7 @@
 
 class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
 public:
-  DragonFly(const HostInfo &Host, const llvm::Triple& Triple);
+  DragonFly(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -488,7 +494,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
 public:
-  Linux(const HostInfo &Host, const llvm::Triple& Triple);
+  Linux(const Driver &D, const llvm::Triple& Triple);
 
   virtual bool HasNativeLLVMSupport() const;
 
@@ -514,7 +520,7 @@
 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
 class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
 public:
-  TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple);
+  TCEToolChain(const Driver &D, const llvm::Triple& Triple);
   ~TCEToolChain();
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -533,7 +539,7 @@
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
 public:
-  Windows(const HostInfo &Host, const llvm::Triple& Triple);
+  Windows(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;

Modified: cfe/branches/tooling/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Tools.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Tools.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Tools.cpp Wed Jan 25 09:40:56 2012
@@ -16,7 +16,6 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Job.h"
-#include "clang/Driver/HostInfo.h"
 #include "clang/Driver/ObjCRuntime.h"
 #include "clang/Driver/Option.h"
 #include "clang/Driver/Options.h"

Modified: cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp (original)
+++ cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp Wed Jan 25 09:40:56 2012
@@ -17,7 +17,6 @@
 #include "clang/Driver/ArgList.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
-#include "clang/Driver/HostInfo.h"
 #include "clang/Driver/Options.h"
 #include "clang/Basic/Version.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -36,8 +35,8 @@
 using namespace clang::driver::toolchains;
 using namespace clang;
 
-Windows::Windows(const HostInfo &Host, const llvm::Triple& Triple)
-  : ToolChain(Host, Triple) {
+Windows::Windows(const Driver &D, const llvm::Triple& Triple)
+  : ToolChain(D, Triple) {
 }
 
 Tool &Windows::SelectTool(const Compilation &C, const JobAction &JA,

Modified: cfe/branches/tooling/lib/Frontend/ChainedIncludesSource.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/ChainedIncludesSource.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/ChainedIncludesSource.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/ChainedIncludesSource.cpp Wed Jan 25 09:40:56 2012
@@ -231,9 +231,8 @@
 void ChainedIncludesSource::ForgetSema() {
   return getFinalReader().ForgetSema();
 }
-std::pair<ObjCMethodList,ObjCMethodList>
-ChainedIncludesSource::ReadMethodPool(Selector Sel) {
-  return getFinalReader().ReadMethodPool(Sel);
+void ChainedIncludesSource::ReadMethodPool(Selector Sel) {
+  getFinalReader().ReadMethodPool(Sel);
 }
 bool ChainedIncludesSource::LookupUnqualified(LookupResult &R, Scope *S) {
   return getFinalReader().LookupUnqualified(R, S);

Modified: cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp Wed Jan 25 09:40:56 2012
@@ -1053,6 +1053,11 @@
   return Success;
 }
 
+static bool ParseMigratorArgs(MigratorOptions &Opts, ArgList &Args) {
+  Opts.NoNSAllocReallocError = Args.hasArg(OPT_migrator_no_nsalloc_error);
+  return true;
+}
+
 static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
                              DiagnosticsEngine &Diags) {
   using namespace cc1options;
@@ -2051,6 +2056,7 @@
   }
 
   Success = ParseAnalyzerArgs(Res.getAnalyzerOpts(), *Args, Diags) && Success;
+  Success = ParseMigratorArgs(Res.getMigratorOpts(), *Args) && Success;
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), *Args);
   Success = ParseDiagnosticArgs(Res.getDiagnosticOpts(), *Args, Diags)
             && Success;

Modified: cfe/branches/tooling/lib/Frontend/DiagnosticRenderer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/DiagnosticRenderer.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/DiagnosticRenderer.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/DiagnosticRenderer.cpp Wed Jan 25 09:40:56 2012
@@ -260,7 +260,8 @@
   Loc = getImmediateMacroCalleeLoc(SM, Loc);
   
   unsigned MacroSkipStart = 0, MacroSkipEnd = 0;
-  if (MacroDepth > DiagOpts.MacroBacktraceLimit) {
+  if (MacroDepth > DiagOpts.MacroBacktraceLimit &&
+      DiagOpts.MacroBacktraceLimit != 0) {
     MacroSkipStart = DiagOpts.MacroBacktraceLimit / 2 +
     DiagOpts.MacroBacktraceLimit % 2;
     MacroSkipEnd = MacroDepth - DiagOpts.MacroBacktraceLimit / 2;

Modified: cfe/branches/tooling/lib/Headers/avxintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Headers/avxintrin.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Headers/avxintrin.h (original)
+++ cfe/branches/tooling/lib/Headers/avxintrin.h Wed Jan 25 09:40:56 2012
@@ -751,13 +751,19 @@
 static __inline __m256d __attribute__((__always_inline__, __nodebug__))
 _mm256_loadu_pd(double const *p)
 {
-  return (__m256d)__builtin_ia32_loadupd256(p);
+  struct __loadu_pd {
+    __m256d v;
+  } __attribute__((packed, may_alias));
+  return ((struct __loadu_pd*)p)->v;
 }
 
 static __inline __m256 __attribute__((__always_inline__, __nodebug__))
 _mm256_loadu_ps(float const *p)
 {
-  return (__m256)__builtin_ia32_loadups256(p);
+  struct __loadu_ps {
+    __m256 v;
+  } __attribute__((packed, may_alias));
+  return ((struct __loadu_ps*)p)->v;
 }
 
 static __inline __m256i __attribute__((__always_inline__, __nodebug__))
@@ -769,7 +775,10 @@
 static __inline __m256i __attribute__((__always_inline__, __nodebug__))
 _mm256_loadu_si256(__m256i const *p)
 {
-  return (__m256i)__builtin_ia32_loaddqu256((char const *)p);
+  struct __loadu_si256 {
+    __m256i v;
+  } __attribute__((packed, may_alias));
+  return ((struct __loadu_si256*)p)->v;
 }
 
 static __inline __m256i __attribute__((__always_inline__, __nodebug__))

Modified: cfe/branches/tooling/lib/Headers/unwind.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Headers/unwind.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Headers/unwind.h (original)
+++ cfe/branches/tooling/lib/Headers/unwind.h Wed Jan 25 09:40:56 2012
@@ -23,10 +23,9 @@
 
 /* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/
 
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
-    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >=  1070
-/* Starting in OS X Lion the SDK includes a unwind.h. We should just use it. */
-#include_next <unwind.h>
+#if defined(__APPLE__) && __has_include_next(<unwind.h>)
+/* Darwin typically has its own unwind.h; use it. */
+#  include_next <unwind.h>
 #else
 
 #include <stdint.h>

Modified: cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp Wed Jan 25 09:40:56 2012
@@ -47,16 +47,17 @@
 
 /// setMacroInfo - Specify a macro for this identifier.
 ///
-void Preprocessor::setMacroInfo(IdentifierInfo *II, MacroInfo *MI) {
+void Preprocessor::setMacroInfo(IdentifierInfo *II, MacroInfo *MI,
+                                bool LoadedFromAST) {
   if (MI) {
     Macros[II] = MI;
     II->setHasMacroDefinition(true);
-    if (II->isFromAST())
+    if (II->isFromAST() && !LoadedFromAST)
       II->setChangedSinceDeserialization();
   } else if (II->hasMacroDefinition()) {
     Macros.erase(II);
     II->setHasMacroDefinition(false);
-    if (II->isFromAST())
+    if (II->isFromAST() && !LoadedFromAST)
       II->setChangedSinceDeserialization();
   }
 }

Modified: cfe/branches/tooling/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseTentative.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseTentative.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseTentative.cpp Wed Jan 25 09:40:56 2012
@@ -864,7 +864,7 @@
     if (TryAnnotateTypeOrScopeToken())
       return TPResult::Error();
     return isCXXDeclarationSpecifier();
-      
+
     // decl-specifier:
     //   storage-class-specifier
     //   type-specifier
@@ -950,8 +950,31 @@
     // We've already annotated a scope; try to annotate a type.
     if (TryAnnotateTypeOrScopeToken())
       return TPResult::Error();
-    if (!Tok.is(tok::annot_typename))
+    if (!Tok.is(tok::annot_typename)) {
+      // If the next token is an identifier or a type qualifier, then this
+      // can't possibly be a valid expression either.
+      if (Tok.is(tok::annot_cxxscope) && NextToken().is(tok::identifier)) {
+        CXXScopeSpec SS;
+        Actions.RestoreNestedNameSpecifierAnnotation(Tok.getAnnotationValue(),
+                                                     Tok.getAnnotationRange(),
+                                                     SS);
+        if (SS.getScopeRep() && SS.getScopeRep()->isDependent()) {
+          TentativeParsingAction PA(*this);
+          ConsumeToken();
+          ConsumeToken();
+          bool isIdentifier = Tok.is(tok::identifier);
+          TPResult TPR = TPResult::False();
+          if (!isIdentifier)
+            TPR = isCXXDeclarationSpecifier();
+          PA.Revert();
+
+          if (isIdentifier ||
+              TPR == TPResult::True() || TPR == TPResult::Error())
+            return TPResult::Error();
+        }
+      }
       return TPResult::False();
+    }
     // If that succeeded, fallthrough into the generic simple-type-id case.
 
     // The ambiguity resides in a simple-type-specifier/typename-specifier

Modified: cfe/branches/tooling/lib/Sema/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/AttributeList.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/AttributeList.cpp (original)
+++ cfe/branches/tooling/lib/Sema/AttributeList.cpp Wed Jan 25 09:40:56 2012
@@ -218,6 +218,7 @@
     .Case("pt_guarded_var", AT_pt_guarded_var)
     .Case("scoped_lockable", AT_scoped_lockable)
     .Case("lockable", AT_lockable)
+    .Case("no_address_safety_analysis", AT_no_address_safety_analysis)
     .Case("no_thread_safety_analysis", AT_no_thread_safety_analysis)
     .Case("guarded_by", AT_guarded_by)
     .Case("pt_guarded_by", AT_pt_guarded_by)

Modified: cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp Wed Jan 25 09:40:56 2012
@@ -202,10 +202,6 @@
     return;
   }
 
-  if (IdentifierInfo *II = Name.getAsIdentifierInfo())
-    if (II->isFromAST())
-      II->setChangedSinceDeserialization();
-  
   // General case: insert the declaration at the appropriate point in the 
   // list, which already has at least two elements.
   IdDeclInfo *IDI = toIdDeclInfo(Ptr);
@@ -323,7 +319,7 @@
 
 bool IdentifierResolver::tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name){
   if (IdentifierInfo *II = Name.getAsIdentifierInfo())
-    updatingIdentifier(*II);
+    readingIdentifier(*II);
   
   void *Ptr = Name.getFETokenInfo<void>();
     

Modified: cfe/branches/tooling/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/Sema.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/Sema.cpp (original)
+++ cfe/branches/tooling/lib/Sema/Sema.cpp Wed Jan 25 09:40:56 2012
@@ -879,10 +879,7 @@
 // Pin this vtable to this file.
 ExternalSemaSource::~ExternalSemaSource() {}
 
-std::pair<ObjCMethodList, ObjCMethodList>
-ExternalSemaSource::ReadMethodPool(Selector Sel) {
-  return std::pair<ObjCMethodList, ObjCMethodList>();
-}
+void ExternalSemaSource::ReadMethodPool(Selector Sel) { }
 
 void ExternalSemaSource::ReadKnownNamespaces(
                            SmallVectorImpl<NamespaceDecl *> &Namespaces) {  

Modified: cfe/branches/tooling/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaChecking.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaChecking.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaChecking.cpp Wed Jan 25 09:40:56 2012
@@ -508,11 +508,6 @@
 }
 
 bool Sema::CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall) {
-  // Printf checking.
-  const FormatAttr *Format = NDecl->getAttr<FormatAttr>();
-  if (!Format)
-    return false;
-
   const VarDecl *V = dyn_cast<VarDecl>(NDecl);
   if (!V)
     return false;
@@ -521,7 +516,12 @@
   if (!Ty->isBlockPointerType())
     return false;
 
-  CheckFormatArguments(Format, TheCall);
+  // format string checking.
+  for (specific_attr_iterator<FormatAttr>
+       i = NDecl->specific_attr_begin<FormatAttr>(),
+       e = NDecl->specific_attr_end<FormatAttr>(); i != e ; ++i) {
+    CheckFormatArguments(*i, TheCall);
+  }
 
   return false;
 }
@@ -1441,6 +1441,10 @@
       } else if (const PointerType *PT = T->getAs<PointerType>()) {
         isConstant = T.isConstant(Context) &&
                      PT->getPointeeType().isConstant(Context);
+      } else if (T->isObjCObjectPointerType()) {
+        // In ObjC, there is usually no "const ObjectPointer" type,
+        // so don't check if the pointee type is constant.
+        isConstant = T.isConstant(Context);
       }
 
       if (isConstant) {

Modified: cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp Wed Jan 25 09:40:56 2012
@@ -2782,13 +2782,7 @@
     case Decl::ObjCCategoryImpl:   return CXCursor_ObjCCategoryImplDecl;
     case Decl::ObjCImplementation: return CXCursor_ObjCImplementationDecl;
 
-    case Decl::ObjCInterface:
-      if (cast<ObjCInterfaceDecl>(D)->isThisDeclarationADefinition())
-        return CXCursor_ObjCInterfaceDecl;
-      
-      // Forward declarations are not directly exposed.
-      return CXCursor_UnexposedDecl;
-
+    case Decl::ObjCInterface:      return CXCursor_ObjCInterfaceDecl;
     case Decl::ObjCIvar:           return CXCursor_ObjCIvarDecl; 
     case Decl::ObjCMethod:
       return cast<ObjCMethodDecl>(D)->isInstanceMethod()
@@ -2798,12 +2792,7 @@
     case Decl::CXXDestructor:      return CXCursor_Destructor;
     case Decl::CXXConversion:      return CXCursor_ConversionFunction;
     case Decl::ObjCProperty:       return CXCursor_ObjCPropertyDecl;
-    case Decl::ObjCProtocol:       
-      if (cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition())
-        return CXCursor_ObjCProtocolDecl;
-      
-      return CXCursor_UnexposedDecl;
-      
+    case Decl::ObjCProtocol:       return CXCursor_ObjCProtocolDecl;
     case Decl::ParmVar:            return CXCursor_ParmDecl;
     case Decl::Typedef:            return CXCursor_TypedefDecl;
     case Decl::TypeAlias:          return CXCursor_TypeAliasDecl;

Modified: cfe/branches/tooling/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDecl.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDecl.cpp Wed Jan 25 09:40:56 2012
@@ -604,19 +604,19 @@
         // Update the name, so that the caller has the new name.
         Name = Corrected.getCorrectionAsIdentifierInfo();
         
+        // Typo correction corrected to a keyword.
+        if (Corrected.isKeyword())
+          return Corrected.getCorrectionAsIdentifierInfo();
+
         // Also update the LookupResult...
         // FIXME: This should probably go away at some point
         Result.clear();
         Result.setLookupName(Corrected.getCorrection());
-        if (FirstDecl) Result.addDecl(FirstDecl);
-
-        // Typo correction corrected to a keyword.
-        if (Corrected.isKeyword())
-          return Corrected.getCorrectionAsIdentifierInfo();
-        
-        if (FirstDecl)
+        if (FirstDecl) {
+          Result.addDecl(FirstDecl);
           Diag(FirstDecl->getLocation(), diag::note_previous_decl)
             << CorrectedQuotedStr;
+        }
 
         // If we found an Objective-C instance variable, let
         // LookupInObjCMethod build the appropriate expression to
@@ -7420,10 +7420,16 @@
     unsigned FormatIdx;
     bool HasVAListArg;
     if (Context.BuiltinInfo.isPrintfLike(BuiltinID, FormatIdx, HasVAListArg)) {
-      if (!FD->getAttr<FormatAttr>())
+      if (!FD->getAttr<FormatAttr>()) {
+        const char *fmt = "printf";
+        unsigned int NumParams = FD->getNumParams();
+        if (FormatIdx < NumParams && // NumParams may be 0 (e.g. vfprintf)
+            FD->getParamDecl(FormatIdx)->getType()->isObjCObjectPointerType())
+          fmt = "NSString";
         FD->addAttr(::new (Context) FormatAttr(FD->getLocation(), Context,
-                                                "printf", FormatIdx+1,
+                                               fmt, FormatIdx+1,
                                                HasVAListArg ? 0 : FormatIdx+2));
+      }
     }
     if (Context.BuiltinInfo.isScanfLike(BuiltinID, FormatIdx,
                                              HasVAListArg)) {
@@ -7464,16 +7470,7 @@
   } else
     return;
 
-  if (Name->isStr("NSLog") || Name->isStr("NSLogv")) {
-    // FIXME: NSLog and NSLogv should be target specific
-    if (const FormatAttr *Format = FD->getAttr<FormatAttr>()) {
-      // FIXME: We known better than our headers.
-      const_cast<FormatAttr *>(Format)->setType(Context, "printf");
-    } else
-      FD->addAttr(::new (Context) FormatAttr(FD->getLocation(), Context,
-                                             "printf", 1,
-                                             Name->isStr("NSLogv") ? 0 : 2));
-  } else if (Name->isStr("asprintf") || Name->isStr("vasprintf")) {
+  if (Name->isStr("asprintf") || Name->isStr("vasprintf")) {
     // FIXME: asprintf and vasprintf aren't C99 functions. Should they be
     // target-specific builtins, perhaps?
     if (!FD->getAttr<FormatAttr>())

Modified: cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp Wed Jan 25 09:40:56 2012
@@ -444,6 +444,23 @@
                                                           S.Context));
 }
 
+static void handleNoAddressSafetyAttr(Sema &S, Decl *D,
+                                     const AttributeList &Attr) {
+  assert(!Attr.isInvalid());
+
+  if (!checkAttributeNumArgs(S, Attr, 0))
+    return;
+
+  if (!isa<FunctionDecl>(D) && !isa<FunctionTemplateDecl>(D)) {
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << Attr.getName() << ExpectedFunctionOrMethod;
+    return;
+  }
+
+  D->addAttr(::new (S.Context) NoAddressSafetyAnalysisAttr(Attr.getRange(),
+                                                          S.Context));
+}
+
 static void handleAcquireOrderAttr(Sema &S, Decl *D, const AttributeList &Attr,
                                    bool before) {
   assert(!Attr.isInvalid());
@@ -3678,6 +3695,9 @@
   case AttributeList::AT_scoped_lockable:
     handleLockableAttr(S, D, Attr, /*scoped = */true);
     break;
+  case AttributeList::AT_no_address_safety_analysis:
+    handleNoAddressSafetyAttr(S, D, Attr);
+    break;
   case AttributeList::AT_no_thread_safety_analysis:
     handleNoThreadSafetyAttr(S, D, Attr);
     break;

Modified: cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp Wed Jan 25 09:40:56 2012
@@ -9734,28 +9734,21 @@
     Invalid = true;
   }
 
-  // GCC allows catching pointers and references to incomplete types
-  // as an extension; so do we, but we warn by default.
-
   QualType BaseType = ExDeclType;
   int Mode = 0; // 0 for direct type, 1 for pointer, 2 for reference
   unsigned DK = diag::err_catch_incomplete;
-  bool IncompleteCatchIsInvalid = true;
   if (const PointerType *Ptr = BaseType->getAs<PointerType>()) {
     BaseType = Ptr->getPointeeType();
     Mode = 1;
-    DK = diag::ext_catch_incomplete_ptr;
-    IncompleteCatchIsInvalid = false;
+    DK = diag::err_catch_incomplete_ptr;
   } else if (const ReferenceType *Ref = BaseType->getAs<ReferenceType>()) {
     // For the purpose of error recovery, we treat rvalue refs like lvalue refs.
     BaseType = Ref->getPointeeType();
     Mode = 2;
-    DK = diag::ext_catch_incomplete_ref;
-    IncompleteCatchIsInvalid = false;
+    DK = diag::err_catch_incomplete_ref;
   }
   if (!Invalid && (Mode == 0 || !BaseType->isVoidType()) &&
-      !BaseType->isDependentType() && RequireCompleteType(Loc, BaseType, DK) &&
-      IncompleteCatchIsInvalid)
+      !BaseType->isDependentType() && RequireCompleteType(Loc, BaseType, DK))
     Invalid = true;
 
   if (!Invalid && !ExDeclType->isDependentType() &&

Modified: cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp Wed Jan 25 09:40:56 2012
@@ -1931,69 +1931,70 @@
   return true;
 }
 
-/// \brief Read the contents of the method pool for a given selector from
-/// external storage.
-///
-/// This routine should only be called once, when the method pool has no entry
-/// for this selector.
-Sema::GlobalMethodPool::iterator Sema::ReadMethodPool(Selector Sel) {
-  assert(ExternalSource && "We need an external AST source");
-  assert(MethodPool.find(Sel) == MethodPool.end() &&
-         "Selector data already loaded into the method pool");
-
-  // Read the method list from the external source.
-  GlobalMethods Methods = ExternalSource->ReadMethodPool(Sel);
-
-  return MethodPool.insert(std::make_pair(Sel, Methods)).first;
-}
-
-void Sema::AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl,
-                                 bool instance) {
-  GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
-  if (Pos == MethodPool.end()) {
-    if (ExternalSource)
-      Pos = ReadMethodPool(Method->getSelector());
-    else
-      Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
-                                             GlobalMethods())).first;
-  }
-  Method->setDefined(impl);
-  ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second;
-  if (Entry.Method == 0) {
-    // Haven't seen a method with this selector name yet - add it.
-    Entry.Method = Method;
-    Entry.Next = 0;
+void Sema::addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method) {
+  // If the list is empty, make it a singleton list.
+  if (List->Method == 0) {
+    List->Method = Method;
+    List->Next = 0;
     return;
   }
-
+  
   // We've seen a method with this name, see if we have already seen this type
   // signature.
-  for (ObjCMethodList *List = &Entry; List; List = List->Next) {
-    bool match = MatchTwoMethodDeclarations(Method, List->Method);
+  ObjCMethodList *Previous = List;
+  for (; List; Previous = List, List = List->Next) {
+    if (!MatchTwoMethodDeclarations(Method, List->Method))
+      continue;
+    
+    ObjCMethodDecl *PrevObjCMethod = List->Method;
 
-    if (match) {
-      ObjCMethodDecl *PrevObjCMethod = List->Method;
-      PrevObjCMethod->setDefined(impl);
-      // If a method is deprecated, push it in the global pool.
-      // This is used for better diagnostics.
-      if (Method->isDeprecated()) {
-        if (!PrevObjCMethod->isDeprecated())
-          List->Method = Method;
-      }
-      // If new method is unavailable, push it into global pool
-      // unless previous one is deprecated.
-      if (Method->isUnavailable()) {
-        if (PrevObjCMethod->getAvailability() < AR_Deprecated)
-          List->Method = Method;
-      }
-      return;
+    // Propagate the 'defined' bit.
+    if (Method->isDefined())
+      PrevObjCMethod->setDefined(true);
+    
+    // If a method is deprecated, push it in the global pool.
+    // This is used for better diagnostics.
+    if (Method->isDeprecated()) {
+      if (!PrevObjCMethod->isDeprecated())
+        List->Method = Method;
+    }
+    // If new method is unavailable, push it into global pool
+    // unless previous one is deprecated.
+    if (Method->isUnavailable()) {
+      if (PrevObjCMethod->getAvailability() < AR_Deprecated)
+        List->Method = Method;
     }
+    
+    return;
   }
-
+  
   // We have a new signature for an existing method - add it.
   // This is extremely rare. Only 1% of Cocoa selectors are "overloaded".
   ObjCMethodList *Mem = BumpAlloc.Allocate<ObjCMethodList>();
-  Entry.Next = new (Mem) ObjCMethodList(Method, Entry.Next);
+  Previous->Next = new (Mem) ObjCMethodList(Method, 0);
+}
+
+/// \brief Read the contents of the method pool for a given selector from
+/// external storage.
+void Sema::ReadMethodPool(Selector Sel) {
+  assert(ExternalSource && "We need an external AST source");
+  ExternalSource->ReadMethodPool(Sel);
+}
+
+void Sema::AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl,
+                                 bool instance) {
+  if (ExternalSource)
+    ReadMethodPool(Method->getSelector());
+  
+  GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
+  if (Pos == MethodPool.end())
+    Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
+                                           GlobalMethods())).first;
+  
+  Method->setDefined(impl);
+  
+  ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second;
+  addMethodToGlobalList(&Entry, Method);
 }
 
 /// Determines if this is an "acceptable" loose mismatch in the global
@@ -2018,13 +2019,12 @@
 ObjCMethodDecl *Sema::LookupMethodInGlobalPool(Selector Sel, SourceRange R,
                                                bool receiverIdOrClass,
                                                bool warn, bool instance) {
+  if (ExternalSource)
+    ReadMethodPool(Sel);
+    
   GlobalMethodPool::iterator Pos = MethodPool.find(Sel);
-  if (Pos == MethodPool.end()) {
-    if (ExternalSource)
-      Pos = ReadMethodPool(Sel);
-    else
-      return 0;
-  }
+  if (Pos == MethodPool.end())
+    return 0;
 
   ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
 
@@ -2484,7 +2484,11 @@
     Sema::GlobalMethodPool::iterator it = S.MethodPool.find(selector);
     if (it == S.MethodPool.end()) {
       if (!S.ExternalSource) return;
-      it = S.ReadMethodPool(selector);
+      S.ReadMethodPool(selector);
+      
+      it = S.MethodPool.find(selector);
+      if (it == S.MethodPool.end())
+        return;
     }
     ObjCMethodList &list =
       method->isInstanceMethod() ? it->second.first : it->second.second;

Modified: cfe/branches/tooling/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExpr.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExpr.cpp Wed Jan 25 09:40:56 2012
@@ -7252,10 +7252,9 @@
       ConvTy = Compatible;
 
     if (ConvTy == Compatible &&
-        getLangOptions().ObjCNonFragileABI &&
         LHSType->isObjCObjectType())
-      Diag(Loc, diag::err_assignment_requires_nonfragile_object)
-        << LHSType;
+        Diag(Loc, diag::err_objc_object_assignment)
+          << LHSType;
 
     // 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"

Modified: cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp Wed Jan 25 09:40:56 2012
@@ -20,6 +20,7 @@
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/TemplateDeduction.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/CharUnits.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
@@ -1104,6 +1105,21 @@
       PlaceArgs = &AllPlaceArgs[0];
   }
 
+  // Warn if the type is over-aligned and is being allocated by global operator
+  // new.
+  if (OperatorNew &&
+      (OperatorNew->isImplicit() ||
+       getSourceManager().isInSystemHeader(OperatorNew->getLocStart()))) {
+    if (unsigned Align = Context.getPreferredTypeAlign(AllocType.getTypePtr())){
+      unsigned SuitableAlign = Context.getTargetInfo().getSuitableAlign();
+      if (Align > SuitableAlign)
+        Diag(StartLoc, diag::warn_overaligned_type)
+            << AllocType
+            << unsigned(Align / Context.getCharWidth())
+            << unsigned(SuitableAlign / Context.getCharWidth());
+    }
+  }
+
   bool Init = ConstructorLParen.isValid();
   // --- Choosing a constructor ---
   CXXConstructorDecl *Constructor = 0;
@@ -2308,12 +2324,14 @@
     // Nothing to do.
     break;
 
-  case ICK_Lvalue_To_Rvalue:
+  case ICK_Lvalue_To_Rvalue: {
     assert(From->getObjectKind() != OK_ObjCProperty);
     FromType = FromType.getUnqualifiedType();
-    From = ImplicitCastExpr::Create(Context, FromType, CK_LValueToRValue,
-                                    From, 0, VK_RValue);
+    ExprResult FromRes = DefaultLvalueConversion(From);
+    assert(!FromRes.isInvalid() && "Can't perform deduced conversion?!");
+    From = FromRes.take();
     break;
+  }
 
   case ICK_Array_To_Pointer:
     FromType = Context.getArrayDecayedType(FromType);
@@ -3148,8 +3166,9 @@
     InitializationKind Kind(InitializationKind::CreateCopy(KeyLoc, 
                                                            SourceLocation()));
     
-    // Perform the initialization within a SFINAE trap at translation unit 
-    // scope.
+    // Perform the initialization in an unevaluated context within a SFINAE 
+    // trap at translation unit scope.
+    EnterExpressionEvaluationContext Unevaluated(Self, Sema::Unevaluated);
     Sema::SFINAETrap SFINAE(Self, /*AccessCheckingSFINAE=*/true);
     Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl());
     InitializationSequence Init(Self, To, Kind, &FromPtr, 1);
@@ -4341,12 +4360,21 @@
                        /*RPLoc*/ ExpectedLParenLoc);
 }
 
-static bool CheckArrow(Sema& S, QualType& ObjectType, Expr *Base, 
+static bool CheckArrow(Sema& S, QualType& ObjectType, Expr *&Base, 
                    tok::TokenKind& OpKind, SourceLocation OpLoc) {
+  if (Base->hasPlaceholderType()) {
+    ExprResult result = S.CheckPlaceholderExpr(Base);
+    if (result.isInvalid()) return true;
+    Base = result.take();
+  }
+  ObjectType = Base->getType();
+
   // C++ [expr.pseudo]p2:
   //   The left-hand side of the dot operator shall be of scalar type. The
   //   left-hand side of the arrow operator shall be of pointer to scalar type.
   //   This scalar type is the object type.
+  // Note that this is rather different from the normal handling for the
+  // arrow operator.
   if (OpKind == tok::arrow) {
     if (const PointerType *Ptr = ObjectType->getAs<PointerType>()) {
       ObjectType = Ptr->getPointeeType();
@@ -4376,7 +4404,7 @@
                                            bool HasTrailingLParen) {
   TypeSourceInfo *DestructedTypeInfo = Destructed.getTypeSourceInfo();
 
-  QualType ObjectType = Base->getType();
+  QualType ObjectType;
   if (CheckArrow(*this, ObjectType, Base, OpKind, OpLoc))
     return ExprError();
 
@@ -4481,7 +4509,7 @@
           SecondTypeName.getKind() == UnqualifiedId::IK_Identifier) &&
          "Invalid second type name in pseudo-destructor");
 
-  QualType ObjectType = Base->getType();
+  QualType ObjectType;
   if (CheckArrow(*this, ObjectType, Base, OpKind, OpLoc))
     return ExprError();
 
@@ -4609,8 +4637,7 @@
                                            SourceLocation TildeLoc, 
                                            const DeclSpec& DS,
                                            bool HasTrailingLParen) {
-  
-  QualType ObjectType = Base->getType();
+  QualType ObjectType;
   if (CheckArrow(*this, ObjectType, Base, OpKind, OpLoc))
     return ExprError();
 

Modified: cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp Wed Jan 25 09:40:56 2012
@@ -1510,7 +1510,7 @@
   // FIXME: When OldParm is a parameter pack and NewParm is not a parameter
   // pack, we actually have a set of instantiated locations. Maintain this set!
   if (OldParm->isParameterPack() && !NewParm->isParameterPack()) {
-    // Add the new parameter to 
+    // Add the new parameter to the instantiated parameter pack.
     CurrentInstantiationScope->InstantiatedLocalPackArg(OldParm, NewParm);
   } else {
     // Introduce an Old -> New mapping

Modified: cfe/branches/tooling/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/TreeTransform.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/TreeTransform.h (original)
+++ cfe/branches/tooling/lib/Sema/TreeTransform.h Wed Jan 25 09:40:56 2012
@@ -8125,8 +8125,10 @@
   if (getDerived().TransformFunctionTypeParams(E->getCaretLocation(),
                                                oldBlock->param_begin(),
                                                oldBlock->param_size(),
-                                               0, paramTypes, &params))
+                                               0, paramTypes, &params)) {
+    getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/0);
     return ExprError();
+  }
 
   const FunctionType *exprFunctionType = E->getFunctionType();
   QualType exprResultType = exprFunctionType->getResultType();
@@ -8147,6 +8149,7 @@
     getSema().Diag(E->getCaretLocation(), 
                    diag::err_object_cannot_be_passed_returned_by_value) 
       << 0 << blockScope->ReturnType;
+    getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/0);
     return ExprError();
   }
 
@@ -8171,8 +8174,10 @@
   
   // Transform the body
   StmtResult body = getDerived().TransformStmt(E->getBody());
-  if (body.isInvalid())
+  if (body.isInvalid()) {
+    getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/0);
     return ExprError();
+  }
 
 #ifndef NDEBUG
   // In builds with assertions, make sure that we captured everything we

Modified: cfe/branches/tooling/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReader.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReader.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReader.cpp Wed Jan 25 09:40:56 2012
@@ -510,8 +510,10 @@
     // For uninteresting identifiers, just build the IdentifierInfo
     // and associate it with the persistent ID.
     IdentifierInfo *II = KnownII;
-    if (!II)
+    if (!II) {
       II = &Reader.getIdentifierTable().getOwn(StringRef(k.first, k.second));
+      KnownII = II;
+    }
     Reader.SetIdentifierInfo(ID, II);
     II->setIsFromAST();
     Reader.markIdentifierUpToDate(II);    
@@ -538,8 +540,10 @@
   // Build the IdentifierInfo itself and link the identifier ID with
   // the new IdentifierInfo.
   IdentifierInfo *II = KnownII;
-  if (!II)
+  if (!II) {
     II = &Reader.getIdentifierTable().getOwn(StringRef(k.first, k.second));
+    KnownII = II;
+  }
   Reader.markIdentifierUpToDate(II);
   II->setIsFromAST();
 
@@ -1362,7 +1366,7 @@
       }
 
       // Finally, install the macro.
-      PP.setMacroInfo(II, MI);
+      PP.setMacroInfo(II, MI, /*LoadedFromAST=*/true);
 
       // Remember that we saw this macro last so that we add the tokens that
       // form its body to it.
@@ -1541,7 +1545,7 @@
 }
 
 void ASTReader::LoadMacroDefinition(
-                     llvm::DenseMap<IdentifierInfo *, uint64_t>::iterator Pos) {
+                    llvm::DenseMap<IdentifierInfo *, uint64_t>::iterator Pos) {
   assert(Pos != UnreadMacroRecordOffsets.end() && "Unknown macro definition");
   uint64_t Offset = Pos->second;
   UnreadMacroRecordOffsets.erase(Pos);
@@ -1579,9 +1583,12 @@
       if (!IdTable)
         return false;
       
+      ASTIdentifierLookupTrait Trait(IdTable->getInfoObj().getReader(),
+                                     M, This->Found);
+                                     
       std::pair<const char*, unsigned> Key(This->Name.begin(), 
                                            This->Name.size());
-      ASTIdentifierLookupTable::iterator Pos = IdTable->find(Key);
+      ASTIdentifierLookupTable::iterator Pos = IdTable->find(Key, &Trait);
       if (Pos == IdTable->end())
         return false;
       
@@ -5205,37 +5212,15 @@
 namespace clang { namespace serialization {
   class ReadMethodPoolVisitor {
     ASTReader &Reader;
-    Selector Sel;    
+    Selector Sel;
+    unsigned PriorGeneration;
     llvm::SmallVector<ObjCMethodDecl *, 4> InstanceMethods;
     llvm::SmallVector<ObjCMethodDecl *, 4> FactoryMethods;
 
-    /// \brief Build an ObjCMethodList from a vector of Objective-C method
-    /// declarations.
-    ObjCMethodList 
-    buildObjCMethodList(const SmallVectorImpl<ObjCMethodDecl *> &Vec) const
-    {
-      ObjCMethodList List;
-      ObjCMethodList *Prev = 0;
-      for (unsigned I = 0, N = Vec.size(); I != N; ++I) {
-        if (!List.Method) {
-          // This is the first method, which is the easy case.
-          List.Method = Vec[I];
-          Prev = &List;
-          continue;
-        }
-        
-        ObjCMethodList *Mem =
-          Reader.getSema()->BumpAlloc.Allocate<ObjCMethodList>();
-        Prev->Next = new (Mem) ObjCMethodList(Vec[I], 0);
-        Prev = Prev->Next;
-      }
-      
-      return List;
-    }
-    
   public:
-    ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel)
-      : Reader(Reader), Sel(Sel) { }
+    ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel, 
+                          unsigned PriorGeneration)
+      : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) { }
     
     static bool visit(ModuleFile &M, void *UserData) {
       ReadMethodPoolVisitor *This
@@ -5244,6 +5229,10 @@
       if (!M.SelectorLookupTable)
         return false;
       
+      // If we've already searched this module file, skip it now.
+      if (M.Generation <= This->PriorGeneration)
+        return true;
+
       ASTSelectorLookupTable *PoolTable
         = (ASTSelectorLookupTable*)M.SelectorLookupTable;
       ASTSelectorLookupTable::iterator Pos = PoolTable->find(This->Sel);
@@ -5266,28 +5255,50 @@
     }
     
     /// \brief Retrieve the instance methods found by this visitor.
-    ObjCMethodList getInstanceMethods() const { 
-      return buildObjCMethodList(InstanceMethods); 
+    ArrayRef<ObjCMethodDecl *> getInstanceMethods() const { 
+      return InstanceMethods; 
     }
 
     /// \brief Retrieve the instance methods found by this visitor.
-    ObjCMethodList getFactoryMethods() const { 
-      return buildObjCMethodList(FactoryMethods); 
+    ArrayRef<ObjCMethodDecl *> getFactoryMethods() const { 
+      return FactoryMethods;
     }
   };
 } } // end namespace clang::serialization
 
-std::pair<ObjCMethodList, ObjCMethodList>
-ASTReader::ReadMethodPool(Selector Sel) {
-  ReadMethodPoolVisitor Visitor(*this, Sel);
+/// \brief Add the given set of methods to the method list.
+static void addMethodsToPool(Sema &S, ArrayRef<ObjCMethodDecl *> Methods,
+                             ObjCMethodList &List) {
+  for (unsigned I = 0, N = Methods.size(); I != N; ++I) {
+    S.addMethodToGlobalList(&List, Methods[I]);
+  }
+}
+                             
+void ASTReader::ReadMethodPool(Selector Sel) {
+  // Get the selector generation and update it to the current generation.
+  unsigned &Generation = SelectorGeneration[Sel];
+  unsigned PriorGeneration = Generation;
+  Generation = CurrentGeneration;
+  
+  // Search for methods defined with this selector.
+  ReadMethodPoolVisitor Visitor(*this, Sel, PriorGeneration);
   ModuleMgr.visit(&ReadMethodPoolVisitor::visit, &Visitor);
-  std::pair<ObjCMethodList, ObjCMethodList> Result;
-  Result.first = Visitor.getInstanceMethods();
-  Result.second = Visitor.getFactoryMethods();
   
-  if (!Result.first.Method && !Result.second.Method)
+  if (Visitor.getInstanceMethods().empty() &&
+      Visitor.getFactoryMethods().empty()) {
     ++NumMethodPoolMisses;
-  return Result;
+    return;
+  }
+  
+  if (!getSema())
+    return;
+  
+  Sema &S = *getSema();
+  Sema::GlobalMethodPool::iterator Pos
+    = S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first;
+  
+  addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first);
+  addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
 }
 
 void ASTReader::ReadKnownNamespaces(

Modified: cfe/branches/tooling/lib/Serialization/ASTReaderInternals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReaderInternals.h?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReaderInternals.h (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReaderInternals.h Wed Jan 25 09:40:56 2012
@@ -129,6 +129,9 @@
   IdentifierInfo *ReadData(const internal_key_type& k,
                            const unsigned char* d,
                            unsigned DataLen);
+  
+  ASTReader &getReader() const { return Reader; }
+  
 };
   
 /// \brief The on-disk hash table used to contain information about

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp Wed Jan 25 09:40:56 2012
@@ -38,8 +38,9 @@
   void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
 
 private:
-  static const unsigned ReturnValueIndex = UINT_MAX;
-  static const unsigned InvalidArgIndex = UINT_MAX - 1;
+  static const unsigned InvalidArgIndex = UINT_MAX;
+  /// Denotes the return vale.
+  static const unsigned ReturnValueIndex = UINT_MAX - 1;
 
   mutable llvm::OwningPtr<BugType> BT;
   inline void initBugType() const {
@@ -60,18 +61,14 @@
   /// \brief Add taint sources on a post visit.
   void addSourcesPost(const CallExpr *CE, CheckerContext &C) const;
 
+  /// Check if the region the expression evaluates to is the standard input,
+  /// and thus, is tainted.
+  static bool isStdin(const Expr *E, CheckerContext &C);
+
   /// \brief Given a pointer argument, get the symbol of the value it contains
   /// (points to).
   static SymbolRef getPointedToSymbol(CheckerContext &C, const Expr *Arg);
 
-  static inline bool isTaintedOrPointsToTainted(const Expr *E,
-                                                const ProgramState *State,
-                                                CheckerContext &C) {
-    return (State->isTainted(E, C.getLocationContext()) ||
-            (E->getType().getTypePtr()->isPointerType() &&
-             State->isTainted(getPointedToSymbol(C, E))));
-  }
-
   /// Functions defining the attack surface.
   typedef const ProgramState *(GenericTaintChecker::*FnCheck)(const CallExpr *,
                                                        CheckerContext &C) const;
@@ -82,10 +79,6 @@
   /// Taint the scanned input if the file is tainted.
   const ProgramState *preFscanf(const CallExpr *CE, CheckerContext &C) const;
 
-  /// Check if the region the expression evaluates to is the standard input,
-  /// and thus, is tainted.
-  bool isStdin(const Expr *E, CheckerContext &C) const;
-
   /// Check for CWE-134: Uncontrolled Format String.
   static const char MsgUncontrolledFormatString[];
   bool checkUncontrolledFormatString(const CallExpr *CE,
@@ -162,6 +155,14 @@
                         DstArgs.end(), ArgNum) != DstArgs.end());
     }
 
+    static inline bool isTaintedOrPointsToTainted(const Expr *E,
+                                                  const ProgramState *State,
+                                                  CheckerContext &C) {
+      return (State->isTainted(E, C.getLocationContext()) || isStdin(E, C) ||
+              (E->getType().getTypePtr()->isPointerType() &&
+               State->isTainted(getPointedToSymbol(C, E))));
+    }
+
     /// \brief Pre-process a function which propagates taint according to the
     /// taint rule.
     const ProgramState *process(const CallExpr *CE, CheckerContext &C) const;
@@ -203,13 +204,29 @@
                                                      const FunctionDecl *FDecl,
                                                      StringRef Name,
                                                      CheckerContext &C) {
+  // TODO: Currently, we might loose precision here: we always mark a return
+  // value as tainted even if it's just a pointer, pointing to tainted data.
+
   // Check for exact name match for functions without builtin substitutes.
   TaintPropagationRule Rule = llvm::StringSwitch<TaintPropagationRule>(Name)
     .Case("atoi", TaintPropagationRule(0, ReturnValueIndex))
     .Case("atol", TaintPropagationRule(0, ReturnValueIndex))
     .Case("atoll", TaintPropagationRule(0, ReturnValueIndex))
+    .Case("getc", TaintPropagationRule(0, ReturnValueIndex))
+    .Case("fgetc", TaintPropagationRule(0, ReturnValueIndex))
+    .Case("getc_unlocked", TaintPropagationRule(0, ReturnValueIndex))
+    .Case("getw", TaintPropagationRule(0, ReturnValueIndex))
+    .Case("toupper", TaintPropagationRule(0, ReturnValueIndex))
+    .Case("tolower", TaintPropagationRule(0, ReturnValueIndex))
+    .Case("strchr", TaintPropagationRule(0, ReturnValueIndex))
+    .Case("strrchr", TaintPropagationRule(0, ReturnValueIndex))
     .Case("read", TaintPropagationRule(0, 2, 1, true))
     .Case("pread", TaintPropagationRule(InvalidArgIndex, 1, true))
+    .Case("gets", TaintPropagationRule(InvalidArgIndex, 0, true))
+    .Case("fgets", TaintPropagationRule(2, 0, true))
+    .Case("getline", TaintPropagationRule(2, 0))
+    .Case("getdelim", TaintPropagationRule(3, 0))
+    .Case("fgetln", TaintPropagationRule(0, ReturnValueIndex))
     .Default(TaintPropagationRule());
 
   if (!Rule.isNull())
@@ -317,6 +334,9 @@
   // arguments which should be tainted after the function returns. These are
   // stored in the state as TaintArgsOnPostVisit set.
   llvm::ImmutableSet<unsigned> TaintArgs = State->get<TaintArgsOnPostVisit>();
+  if (TaintArgs.isEmpty())
+    return false;
+
   for (llvm::ImmutableSet<unsigned>::iterator
          I = TaintArgs.begin(), E = TaintArgs.end(); I != E; ++I) {
     unsigned ArgNum  = *I;
@@ -356,10 +376,13 @@
     .Case("scanf", &GenericTaintChecker::postScanf)
     // TODO: Add support for vfscanf & family.
     .Case("getchar", &GenericTaintChecker::postRetTaint)
+    .Case("getchar_unlocked", &GenericTaintChecker::postRetTaint)
     .Case("getenv", &GenericTaintChecker::postRetTaint)
     .Case("fopen", &GenericTaintChecker::postRetTaint)
     .Case("fdopen", &GenericTaintChecker::postRetTaint)
     .Case("freopen", &GenericTaintChecker::postRetTaint)
+    .Case("getch", &GenericTaintChecker::postRetTaint)
+    .Case("wgetch", &GenericTaintChecker::postRetTaint)
     .Case("socket", &GenericTaintChecker::postSocket)
     .Default(0);
 
@@ -428,18 +451,14 @@
       for (unsigned int i = 0; i < CE->getNumArgs(); ++i) {
         if (isDestinationArgument(i))
           continue;
-        if ((IsTainted =
-               GenericTaintChecker::isTaintedOrPointsToTainted(CE->getArg(i),
-                                                               State, C)))
+        if ((IsTainted = isTaintedOrPointsToTainted(CE->getArg(i), State, C)))
           break;
       }
       break;
     }
 
     assert(ArgNum < CE->getNumArgs());
-    if ((IsTainted =
-           GenericTaintChecker::isTaintedOrPointsToTainted(CE->getArg(ArgNum),
-                                                           State, C)))
+    if ((IsTainted = isTaintedOrPointsToTainted(CE->getArg(ArgNum), State, C)))
       break;
   }
   if (!IsTainted)
@@ -541,8 +560,7 @@
   return C.getState()->addTaint(CE, C.getLocationContext());
 }
 
-bool GenericTaintChecker::isStdin(const Expr *E,
-                                  CheckerContext &C) const {
+bool GenericTaintChecker::isStdin(const Expr *E, CheckerContext &C) {
   const ProgramState *State = C.getState();
   SVal Val = State->getSVal(E, C.getLocationContext());
 
@@ -642,6 +660,9 @@
 bool GenericTaintChecker::checkSystemCall(const CallExpr *CE,
                                           StringRef Name,
                                           CheckerContext &C) const {
+  // TODO: It might make sense to run this check on demand. In some cases, 
+  // we should check if the environment has been cleansed here. We also might 
+  // need to know if the user was reset before these calls(seteuid).
   unsigned ArgNum = llvm::StringSwitch<unsigned>(Name)
     .Case("system", 0)
     .Case("popen", 0)
@@ -651,6 +672,8 @@
     .Case("execv", 0)
     .Case("execvp", 0)
     .Case("execvP", 0)
+    .Case("execve", 0)
+    .Case("dlopen", 0)
     .Default(UINT_MAX);
 
   if (ArgNum == UINT_MAX)

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExplodedGraph.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExplodedGraph.cpp Wed Jan 25 09:40:56 2012
@@ -15,6 +15,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/AST/Stmt.h"
+#include "clang/AST/ParentMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
@@ -47,6 +48,13 @@
 typedef std::vector<ExplodedNode*> NodeList;
 static inline NodeList*& getNodeList(void *&p) { return (NodeList*&) p; }
 
+static const unsigned CounterTop = 1000;
+
+ExplodedGraph::ExplodedGraph()
+  : NumNodes(0), recentlyAllocatedNodes(0),
+    freeNodes(0), reclaimNodes(false),
+    reclaimCounter(CounterTop) {}
+
 ExplodedGraph::~ExplodedGraph() {
   if (reclaimNodes) {
     delete getNodeList(recentlyAllocatedNodes);
@@ -61,6 +69,15 @@
 void ExplodedGraph::reclaimRecentlyAllocatedNodes() {
   if (!recentlyAllocatedNodes)
     return;
+
+  // Only periodically relcaim nodes so that we can build up a set of
+  // nodes that meet the reclamation criteria.  Freshly created nodes
+  // by definition have no successor, and thus cannot be reclaimed (see below).
+  assert(reclaimCounter > 0);
+  if (--reclaimCounter != 0)
+    return;
+  reclaimCounter = CounterTop;
+  
   NodeList &nl = *getNodeList(recentlyAllocatedNodes);
  
   // Reclaimn all nodes that match *all* the following criteria:
@@ -72,7 +89,7 @@
   // (5) The 'store' is the same as the predecessor.
   // (6) The 'GDM' is the same as the predecessor.
   // (7) The LocationContext is the same as the predecessor.
-  // (8) The PostStmt is for a non-CFGElement expression.
+  // (8) The PostStmt is for a non-consumed Stmt or Expr.
   
   for (NodeList::iterator i = nl.begin(), e = nl.end() ; i != e; ++i) {
     ExplodedNode *node = *i;
@@ -110,8 +127,11 @@
       continue;
 
     // Condition 8.
-    if (node->getCFG().isBlkExpr(ps.getStmt()))
-      continue;
+    if (const Expr *Ex = dyn_cast<Expr>(ps.getStmt())) {
+      ParentMap &PM = progPoint.getLocationContext()->getParentMap();
+      if (!PM.isConsumedExpr(Ex))
+        continue;
+    }
     
     // If we reach here, we can remove the node.  This means:
     // (a) changing the predecessors successor to the successor of this node

Modified: cfe/branches/tooling/test/Analysis/reference.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/reference.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/reference.cpp (original)
+++ cfe/branches/tooling/test/Analysis/reference.cpp Wed Jan 25 09:40:56 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-null-dereference %s
 // XFAIL
 
 typedef typeof(sizeof(int)) size_t;

Modified: cfe/branches/tooling/test/Analysis/taint-tester.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/taint-tester.c?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/taint-tester.c (original)
+++ cfe/branches/tooling/test/Analysis/taint-tester.c Wed Jan 25 09:40:56 2012
@@ -4,6 +4,7 @@
 
 int scanf(const char *restrict format, ...);
 int getchar(void);
+typedef __typeof(sizeof(int)) size_t;
 
 #define BUFSIZE 10
 int Buffer[BUFSIZE];
@@ -160,6 +161,26 @@
   int j = i; // expected-warning + {{tainted}}
 }
 
+int getw(FILE *);
+void getwTest() {
+  int i = getw(stdin); // expected-warning + {{tainted}}
+}
+
+typedef long ssize_t;
+ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+int  printf(const char * __restrict, ...);
+void free(void *ptr);
+void getlineTest(void) {
+  FILE *fp;
+  char *line = 0;
+  size_t len = 0;
+  ssize_t read;
+  while ((read = getline(&line, &len, stdin)) != -1) {
+    printf("%s", line); // expected-warning + {{tainted}}
+  }
+  free(line); // expected-warning + {{tainted}}
+}
+
 // Test propagation functions - the ones that propagate taint from arguments to
 // return value, ptr arguments.
 

Modified: cfe/branches/tooling/test/CodeGen/builtins-x86.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/builtins-x86.c?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/builtins-x86.c (original)
+++ cfe/branches/tooling/test/CodeGen/builtins-x86.c Wed Jan 25 09:40:56 2012
@@ -454,11 +454,8 @@
   tmp_V8f = __builtin_ia32_vbroadcastss256(tmp_fCp);
   tmp_V4d = __builtin_ia32_vbroadcastf128_pd256(tmp_V2dCp);
   tmp_V8f = __builtin_ia32_vbroadcastf128_ps256(tmp_V4fCp);
-  tmp_V4d = __builtin_ia32_loadupd256(tmp_dCp);
-  tmp_V8f = __builtin_ia32_loadups256(tmp_fCp);
   __builtin_ia32_storeupd256(tmp_dp, tmp_V4d);
   __builtin_ia32_storeups256(tmp_fp, tmp_V8f);
-  tmp_V32c = __builtin_ia32_loaddqu256(tmp_cCp);
   __builtin_ia32_storedqu256(tmp_cp, tmp_V32c);
   tmp_V32c = __builtin_ia32_lddqu256(tmp_cCp);
   __builtin_ia32_movntdq256(tmp_V4LLip, tmp_V4LLi);

Modified: cfe/branches/tooling/test/CodeGenCXX/conditional-gnu-ext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/conditional-gnu-ext.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/conditional-gnu-ext.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/conditional-gnu-ext.cpp Wed Jan 25 09:40:56 2012
@@ -140,3 +140,11 @@
   }
 
 }
+
+namespace test4 {
+  // Make sure this doesn't crash.
+  void f() {
+    const int a = 10, b = 20;
+    const int *c = &(a ?: b);
+  }
+}

Modified: cfe/branches/tooling/test/Driver/freebsd.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/freebsd.c?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/freebsd.c (original)
+++ cfe/branches/tooling/test/Driver/freebsd.c Wed Jan 25 09:40:56 2012
@@ -1,19 +1,20 @@
-// RUN: %clang -no-canonical-prefixes -ccc-clang-archs "" -target powerpc64-pc-freebsd8 %s -### 2> %t
+// RUN: %clang -no-canonical-prefixes --sysroot=%S/Inputs/basic_freebsd_tree -ccc-clang-archs "" -target powerpc64-pc-freebsd8 %s -### 2> %t
 // RUN: FileCheck --check-prefix=CHECK-PPC < %t %s
 //
 // CHECK-PPC: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8"
-// CHECK-PPC: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
+// CHECK-PPC: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-PPC: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
 
 
 // Check that -m32 properly adjusts the toolchain flags.
 //
-// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 -### %s 2> %t
+// RUN: %clang -no-canonical-prefixes --sysroot=%S/Inputs/basic_freebsd64_tree -target x86_64-pc-freebsd8 -m32 -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-LIB32 < %t %s
 //
 // CHECK-LIB32: clang{{.*}}" "-cc1" "-triple" "i386-pc-freebsd8"
 // CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd"
 //
-// RUN: %clang -target x86_64-pc-freebsd8 -m32 -print-search-dirs %s > %t
+// RUN: %clang --sysroot=%S/Inputs/basic_freebsd64_tree -target x86_64-pc-freebsd8 -m32 -print-search-dirs %s > %t
 // RUN: FileCheck --check-prefix=CHECK-LIB32PATHS < %t %s
 //
 // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32

Modified: cfe/branches/tooling/test/Index/TestClassDecl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/TestClassDecl.m?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/TestClassDecl.m (original)
+++ cfe/branches/tooling/test/Index/TestClassDecl.m Wed Jan 25 09:40:56 2012
@@ -16,7 +16,7 @@
 }
 
 // CHECK-scan: [1:1 - 8:1] Invalid Cursor => NoDeclFound
-// CHECK-scan: [8:1 - 8:8] UnexposedDecl=Foo:8:8
+// CHECK-scan: [8:1 - 8:8] ObjCInterfaceDecl=Foo:8:8
 // CHECK-scan: [8:8 - 8:11] ObjCClassRef=Foo:10:12
 // CHECK-scan: [8:11 - 10:1] Invalid Cursor => NoDeclFound
 // CHECK-scan: [10:1 - 11:5] ObjCInterfaceDecl=Foo:10:12

Modified: cfe/branches/tooling/test/Index/TestClassForwardDecl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/TestClassForwardDecl.m?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/TestClassForwardDecl.m (original)
+++ cfe/branches/tooling/test/Index/TestClassForwardDecl.m Wed Jan 25 09:40:56 2012
@@ -13,7 +13,7 @@
 }
 
 // CHECK-scan: [1:1 - 8:1] Invalid Cursor => NoDeclFound
-// CHECK-scan: [8:1 - 8:8] UnexposedDecl=Foo:8:8
+// CHECK-scan: [8:1 - 8:8] ObjCInterfaceDecl=Foo:8:8
 // CHECK-scan: [8:8 - 8:11] ObjCClassRef=Foo:8:8
 // CHECK-scan: [8:11 - 10:1] Invalid Cursor => NoDeclFound
 // CHECK-scan: [10:1 - 10:15] FunctionDecl=function:10:6 (Definition)

Modified: cfe/branches/tooling/test/Index/annotate-tokens.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/annotate-tokens.m?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/annotate-tokens.m (original)
+++ cfe/branches/tooling/test/Index/annotate-tokens.m Wed Jan 25 09:40:56 2012
@@ -452,8 +452,8 @@
 // CHECK: Punctuation: ")" [88:24 - 88:25] ObjCProtocolExpr=Proto:85:1
 // CHECK: Punctuation: ";" [88:25 - 88:26] CompoundStmt=
 // CHECK: Punctuation: "}" [89:1 - 89:2] CompoundStmt=
-// CHECK: Punctuation: "@" [93:1 - 93:2] UnexposedDecl=Rdar8595462_A:93:8
-// CHECK: Keyword: "class" [93:2 - 93:7] UnexposedDecl=Rdar8595462_A:93:8
+// CHECK: Punctuation: "@" [93:1 - 93:2] ObjCInterfaceDecl=Rdar8595462_A:93:8
+// CHECK: Keyword: "class" [93:2 - 93:7] ObjCInterfaceDecl=Rdar8595462_A:93:8
 // CHECK: Identifier: "Rdar8595462_A" [93:8 - 93:21] ObjCClassRef=Rdar8595462_A:93:8
 // CHECK: Punctuation: ";" [93:21 - 93:22]
 // CHECK: Punctuation: "@" [94:1 - 94:2] ObjCInterfaceDecl=Rdar8595462_B:94:12

Modified: cfe/branches/tooling/test/Index/file-refs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/file-refs.m?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/file-refs.m (original)
+++ cfe/branches/tooling/test/Index/file-refs.m Wed Jan 25 09:40:56 2012
@@ -43,8 +43,11 @@
 
 // RUN:  -file-refs-at=%s:7:18 \
 // CHECK:      ObjCImplementationDecl=Foo:7:17 (Definition)
-// CHECK-NEXT: UnexposedDecl=Foo:1:8 =[1:8 - 1:11]
+
+// FIXME: There should not be 2 for the same range.
+// CHECK-NEXT: ObjCInterfaceDecl=Foo:1:8 =[1:8 - 1:11]
 // CHECK-NEXT: ObjCClassRef=Foo:3:12 =[1:8 - 1:11]
+
 // CHECK-NEXT: ObjCInterfaceDecl=Foo:3:12 =[3:12 - 3:15]
 // CHECK-NEXT: ObjCImplementationDecl=Foo:7:17 (Definition) =[7:17 - 7:20]
 // CHECK-NEXT: ObjCClassRef=Foo:3:12 =[13:11 - 13:14]

Modified: cfe/branches/tooling/test/Index/properties-class-extensions.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/properties-class-extensions.m?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/properties-class-extensions.m (original)
+++ cfe/branches/tooling/test/Index/properties-class-extensions.m Wed Jan 25 09:40:56 2012
@@ -70,7 +70,7 @@
 // CHECK-NOT: properties-class-extensions.m:16:25: ObjCInstanceMethodDecl=bar:16:25 Extent=[16:25 - 16:28]
 // CHECK: properties-class-extensions.m:19:26: ObjCInstanceMethodDecl=setBar::19:26 Extent=[19:26 - 19:29]
 // CHECK: properties-class-extensions.m:19:26: ParmDecl=bar:19:26 (Definition) Extent=[19:26 - 19:29]
-// CHECK: properties-class-extensions.m:24:8: UnexposedDecl=Rdar8467189_Bar:24:8
+// CHECK: properties-class-extensions.m:24:8: ObjCInterfaceDecl=Rdar8467189_Bar:24:8 Extent=[24:1 - 24:23]
 // CHECK: properties-class-extensions.m:24:8: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[24:8 - 24:23]
 // CHECK: properties-class-extensions.m:25:11: ObjCProtocolDecl=Rdar8467189_FooProtocol:25:11 (Definition) Extent=[25:1 - 27:5]
 // CHECK: properties-class-extensions.m:26:39: ObjCPropertyDecl=Rdar8467189_Bar:26:39 Extent=[26:1 - 26:54]

Modified: cfe/branches/tooling/test/Modules/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Modules/Inputs/module.map?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Modules/Inputs/module.map (original)
+++ cfe/branches/tooling/test/Modules/Inputs/module.map Wed Jan 25 09:40:56 2012
@@ -75,3 +75,9 @@
   header "namespaces-right.h"
   export *
 }
+module MethodPoolA {
+  header "MethodPoolA.h"
+}
+module MethodPoolB {
+  header "MethodPoolB.h"
+}

Modified: cfe/branches/tooling/test/Sema/block-printf-attribute-1.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/block-printf-attribute-1.c?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/block-printf-attribute-1.c (original)
+++ cfe/branches/tooling/test/Sema/block-printf-attribute-1.c Wed Jan 25 09:40:56 2012
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
 
+#include <stdarg.h>
+
 int main() {
   void (^b) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 1, 3))) =   // expected-error {{format argument not a string type}}
     ^ __attribute__ ((__format__ (__printf__, 1, 3))) (int arg, const char * format, ...) {}; // expected-error {{format argument not a string type}}
@@ -9,3 +11,11 @@
   z(1, "%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
   z(1, "%s", "HELLO"); // no-warning
 }
+
+void multi_attr(va_list ap, int *x, long *y) {
+  // Handle block with multiple format attributes.
+  void (^vprintf_scanf) (const char *, va_list, const char *, ...) __attribute__((__format__(__printf__, 1, 0))) __attribute__((__format__(__scanf__, 3, 4))) =
+  ^ __attribute__((__format__(__printf__, 1, 0))) __attribute__((__format__(__scanf__, 3, 4))) (const char *str, va_list args, const char *fmt, ...) {};
+
+  vprintf_scanf("%", ap, "%d"); // expected-warning {{incomplete format specifier}}, expected-warning {{more '%' conversions than data arguments}}
+}

Modified: cfe/branches/tooling/test/Sema/format-strings-scanf.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/format-strings-scanf.c?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/format-strings-scanf.c (original)
+++ cfe/branches/tooling/test/Sema/format-strings-scanf.c Wed Jan 25 09:40:56 2012
@@ -103,3 +103,13 @@
   scanf("%m[abc]", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
 }
 
+void test_longlong(long long *x, unsigned long long *y) {
+  scanf("%Ld", y); // no-warning
+  scanf("%Lu", y); // no-warning
+  scanf("%Lx", y); // no-warning
+  scanf("%Ld", x); // no-warning
+  scanf("%Lu", x); // no-warning
+  scanf("%Lx", x); // no-warning
+  scanf("%Ls", "hello"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}
+}
+

Modified: cfe/branches/tooling/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/format-strings.c?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/format-strings.c (original)
+++ cfe/branches/tooling/test/Sema/format-strings.c Wed Jan 25 09:40:56 2012
@@ -469,3 +469,14 @@
   // when the original string is within the argument expression.
   printf(1 ? "yes %d" : "no %d"); // expected-warning 2{{more '%' conversions than data arguments}}
 }
+
+// PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx 
+void printf_longlong(long long x, unsigned long long y) {
+  printf("%Ld", y); // no-warning
+  printf("%Lu", y); // no-warning
+  printf("%Lx", y); // no-warning
+  printf("%Ld", x); // no-warning
+  printf("%Lu", x); // no-warning
+  printf("%Lx", x); // no-warning
+  printf("%Ls", "hello"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}
+}

Modified: cfe/branches/tooling/test/SemaCXX/exceptions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/exceptions.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/exceptions.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/exceptions.cpp Wed Jan 25 09:40:56 2012
@@ -12,8 +12,8 @@
   } catch(float i) {
   } catch(void v) { // expected-error {{cannot catch incomplete type 'void'}}
   } catch(A a) { // expected-error {{cannot catch incomplete type 'A'}}
-  } catch(A *a) { // expected-warning {{ISO C++ forbids catching a pointer to incomplete type 'A'}}
-  } catch(A &a) { // expected-warning {{ISO C++ forbids catching a reference to incomplete type 'A'}}
+  } catch(A *a) { // expected-error {{cannot catch pointer to incomplete type 'A'}}
+  } catch(A &a) { // expected-error {{cannot catch reference to incomplete type 'A'}}
   } catch(Abstract) { // expected-error {{variable type 'Abstract' is an abstract class}}
   } catch(...) {
     int j = i; // expected-error {{use of undeclared identifier 'i'}}

Modified: cfe/branches/tooling/test/SemaCXX/type-traits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/type-traits.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/type-traits.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/type-traits.cpp Wed Jan 25 09:40:56 2012
@@ -1543,6 +1543,12 @@
   { int arr[T(__is_convertible_to(X0<int>, X0<float>))]; }
 }
 
+namespace is_convertible_to_instantiate {
+  // Make sure we don't try to instantiate the constructor.
+  template<int x> class A { A(int) { int a[x]; } };
+  int x = __is_convertible_to(int, A<-1>);
+}
+
 void is_trivial()
 {
   { int arr[T(__is_trivial(int))]; }

Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 25 09:40:56 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-148800
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-148957

Modified: cfe/branches/tooling/test/SemaObjC/builtin_objc_lib_functions.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/builtin_objc_lib_functions.m?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/builtin_objc_lib_functions.m (original)
+++ cfe/branches/tooling/test/SemaObjC/builtin_objc_lib_functions.m Wed Jan 25 09:40:56 2012
@@ -20,10 +20,10 @@
 
 id f5(id val, id *dest) {
   return objc_assign_strongCast(val, dest); // expected-warning {{implicitly declaring C library function 'objc_assign_strongCast' with type 'id (id, id *)'}} \
-					    // expected-note {{please include the header </objc/objc-auto.h> or explicitly provide a declaration for 'objc_assign_strongCast'}}
+					    // expected-note {{please include the header <objc/objc-auto.h> or explicitly provide a declaration for 'objc_assign_strongCast'}}
 }
 
 int f6(Class exceptionClass, id exception) {
   return objc_exception_match(exceptionClass, exception); // expected-warning {{implicitly declaring C library function 'objc_exception_match' with type 'int (id, id)'}} \
-  							  // expected-note {{please include the header </objc/objc-exception.h> or explicitly provide a declaration for 'objc_exception_match'}}
+  							  // expected-note {{please include the header <objc/objc-exception.h> or explicitly provide a declaration for 'objc_exception_match'}}
 }

Modified: cfe/branches/tooling/test/SemaObjC/deref-interface.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/deref-interface.m?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/deref-interface.m (original)
+++ cfe/branches/tooling/test/SemaObjC/deref-interface.m Wed Jan 25 09:40:56 2012
@@ -6,7 +6,7 @@
 
 @implementation NSView
  - (id)initWithView:(id)realView {
-     *(NSView *)self = *(NSView *)realView;	// expected-error {{cannot assign to class object in non-fragile ABI}}
+     *(NSView *)self = *(NSView *)realView;	// expected-error {{cannot assign to class object}}
  }
 @end
 

Modified: cfe/branches/tooling/test/SemaObjC/format-strings-objc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/format-strings-objc.m?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/format-strings-objc.m (original)
+++ cfe/branches/tooling/test/SemaObjC/format-strings-objc.m Wed Jan 25 09:40:56 2012
@@ -13,6 +13,7 @@
 typedef unsigned int NSUInteger;
 @class NSString, Protocol;
 extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
 typedef struct _NSZone NSZone;
 @class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
 @protocol NSObject  - (BOOL)isEqual:(id)object; @end
@@ -82,3 +83,27 @@
   [Foo fooWithFormat:@"%@"]; // expected-warning {{more '%' conversions than data arguments}}
   [Foo fooWithCStringFormat:"%@"]; // expected-warning {{invalid conversion specifier '@'}}
 }
+
+// Warn about using BOOL with %@
+void rdar10743758(id x) {
+  NSLog(@"%@ %@", x, (BOOL) 1); // expected-warning {{format specifies type 'id' but the argument has type 'BOOL' (aka 'signed char')}}
+}
+
+NSString *test_literal_propagation(void) {
+  const char * const s1 = "constant string %s"; // expected-note {{format string is defined here}}
+  printf(s1); // expected-warning {{more '%' conversions than data arguments}}
+  const char * const s5 = "constant string %s"; // expected-note {{format string is defined here}}
+  const char * const s2 = s5;
+  printf(s2); // expected-warning {{more '%' conversions than data arguments}}
+
+  const char * const s3 = (const char *)0;
+  printf(s3); // expected-warning {{format string is not a string literal}}
+
+  NSString * const ns1 = @"constant string %s"; // expected-note {{format string is defined here}}
+  NSLog(ns1); // expected-warning {{more '%' conversions than data arguments}}
+  NSString * const ns5 = @"constant string %s"; // expected-note {{format string is defined here}}
+  NSString * const ns2 = ns5;
+  NSLog(ns2); // expected-warning {{more '%' conversions than data arguments}}
+  NSString * ns3 = ns1;
+  NSLog(ns3); // expected-warning {{format string is not a string literal}}}
+}

Modified: cfe/branches/tooling/test/SemaTemplate/alias-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaTemplate/alias-templates.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaTemplate/alias-templates.cpp (original)
+++ cfe/branches/tooling/test/SemaTemplate/alias-templates.cpp Wed Jan 25 09:40:56 2012
@@ -68,3 +68,36 @@
 
 itt::rebind<bool> btr;
 itt::rebind_thing<bool> btt(btr);
+
+namespace PR11848 {
+  template<typename T> using U = int;
+
+  template<typename T, typename ...Ts>
+  void f(U<T> i, U<Ts> ...is) { // expected-error {{type 'U<Ts>' (aka 'int') of function parameter pack does not contain any unexpanded parameter packs}}
+    return i + f<Ts...>(is...); // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
+  }
+
+  template<typename ...Ts>
+  struct S {
+    S(U<Ts>...ts); // expected-error {{does not contain any unexpanded parameter packs}}
+  };
+
+  template<typename T>
+  struct Hidden1 {
+    template<typename ...Ts>
+    Hidden1(typename T::template U<Ts> ...ts);
+  };
+
+  template<typename T, typename ...Ts>
+  struct Hidden2 {
+    Hidden2(typename T::template U<Ts> ...ts);
+  };
+
+  struct Hide {
+    template<typename T> using U = int;
+  };
+
+  // FIXME: This case crashes clang at the moment.
+  //Hidden1<Hide> h1;
+  Hidden2<Hide, double, char> h2(1, 2);
+}

Modified: cfe/branches/tooling/test/SemaTemplate/instantiate-function-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaTemplate/instantiate-function-1.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaTemplate/instantiate-function-1.cpp (original)
+++ cfe/branches/tooling/test/SemaTemplate/instantiate-function-1.cpp Wed Jan 25 09:40:56 2012
@@ -194,7 +194,7 @@
 template<typename T> struct TryCatch0 {
   void f() {
     try {
-    } catch (T t) { // expected-warning{{incomplete type}} \
+    } catch (T t) { // expected-error{{incomplete type}} \
                     // expected-error{{abstract class}}
     } catch (...) {
     }

Modified: cfe/branches/tooling/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CIndex.cpp?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CIndex.cpp Wed Jan 25 09:40:56 2012
@@ -3918,7 +3918,12 @@
       return MakeCXCursor(getCursorObjCSuperClassRef(C).first, tu);
 
     case CXCursor_ObjCProtocolRef: {
-      return MakeCXCursor(getCursorObjCProtocolRef(C).first, tu);
+      ObjCProtocolDecl *Prot = getCursorObjCProtocolRef(C).first;
+      if (ObjCProtocolDecl *Def = Prot->getDefinition())
+        return MakeCXCursor(Def, tu);
+
+      return MakeCXCursor(Prot, tu);
+    }
 
     case CXCursor_ObjCClassRef: {
       ObjCInterfaceDecl *Class = getCursorObjCClassRef(C).first;
@@ -3960,7 +3965,6 @@
     default:
       // We would prefer to enumerate all non-reference cursor kinds here.
       llvm_unreachable("Unhandled reference cursor kind");
-    }
   }
 }
 

Modified: cfe/branches/tooling/tools/scan-build/scan-build
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/scan-build/scan-build?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/tools/scan-build/scan-build (original)
+++ cfe/branches/tooling/tools/scan-build/scan-build Wed Jan 25 09:40:56 2012
@@ -961,7 +961,11 @@
 
  -plist         - By default the output of scan-build is a set of HTML files.
                   This option outputs the results as a set of .plist files.
-
+ 
+ -plist-html    - By default the output of scan-build is a set of HTML files.
+                  This option outputs the results as a set of HTML 
+                  and .plist files.
+ 
  --status-bugs  - By default, the exit status of $Prog is the same as the
                   executed build command.  Specifying this option causes the
                   exit status of $Prog to be 1 if it found potential bugs

Modified: cfe/branches/tooling/utils/analyzer/CmpRuns.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/analyzer/CmpRuns.py?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/utils/analyzer/CmpRuns.py (original)
+++ cfe/branches/tooling/utils/analyzer/CmpRuns.py Wed Jan 25 09:40:56 2012
@@ -65,18 +65,22 @@
         filename = self.report.run.getSourceName(self.report.files[loc['file']])
         line = loc['line']
         column = loc['col']
+        category = self.data['category']
+        description = self.data['description']
 
         # FIXME: Get a report number based on this key, to 'distinguish'
         # reports, or something.
         
-        return '%s:%d:%d' % (filename, line, column)
+        return '%s:%d:%d, %s: %s' % (filename, line, column, category, 
+                                   description)
 
     def getReportData(self):
         if self.htmlReport is None:
-            return "This diagnostic does not have any report data."
-
-        return open(os.path.join(self.report.run.path,
-                                 self.htmlReport), "rb").read() 
+            return " "
+        return os.path.join(self.report.run.path, self.htmlReport)
+        # We could also dump the report with:
+        # return open(os.path.join(self.report.run.path,
+        #                         self.htmlReport), "rb").read() 
 
 class AnalysisRun:
     def __init__(self, path, opts):

Modified: cfe/branches/tooling/utils/analyzer/SATestBuild.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/analyzer/SATestBuild.py?rev=148958&r1=148957&r2=148958&view=diff
==============================================================================
--- cfe/branches/tooling/utils/analyzer/SATestBuild.py (original)
+++ cfe/branches/tooling/utils/analyzer/SATestBuild.py Wed Jan 25 09:40:56 2012
@@ -132,7 +132,7 @@
     if not os.path.exists(BuildScriptPath):
         print "Error: build script is not defined: %s" % BuildScriptPath
         sys.exit(-1)       
-    SBOptions = "-plist -o " + SBOutputDir + " "
+    SBOptions = "-plist-html -o " + SBOutputDir + " "
     SBOptions += "-enable-checker " + Checkers + " "  
     try:
         SBCommandFile = open(BuildScriptPath, "r")





More information about the llvm-branch-commits mailing list