[llvm-branch-commits] [cfe-branch] r151671 - in /cfe/branches/tooling: ./ bindings/python/tests/cindex/ docs/ include/clang-c/ include/clang/AST/ include/clang/Analysis/Analyses/ include/clang/Analysis/Support/ include/clang/Basic/ include/clang/Driver/ include/clang/Frontend/ include/clang/Lex/ include/clang/Parse/ include/clang/Sema/ include/clang/Serialization/ include/clang/StaticAnalyzer/Core/BugReporter/ include/clang/StaticAnalyzer/Core/PathSensitive/ lib/ARCMigrate/ lib/AST/ lib/Analysis/ lib/Basic/ lib/CodeGen/ lib/D...

Manuel Klimek klimek at google.com
Tue Feb 28 15:49:27 PST 2012


Author: klimek
Date: Tue Feb 28 17:49:25 2012
New Revision: 151671

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

Added:
    cfe/branches/tooling/test/Analysis/malloc.m
      - copied unchanged from r151662, cfe/trunk/test/Analysis/malloc.m
    cfe/branches/tooling/test/Analysis/stats.c
      - copied unchanged from r151662, cfe/trunk/test/Analysis/stats.c
    cfe/branches/tooling/test/Analysis/system-header-simulator-objc.h
      - copied unchanged from r151662, cfe/trunk/test/Analysis/system-header-simulator-objc.h
    cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp
      - copied unchanged from r151662, cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp
    cfe/branches/tooling/test/CXX/expr/expr.ass/p9-cxx11.cpp
      - copied unchanged from r151662, cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp
    cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
      - copied unchanged from r151662, cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
    cfe/branches/tooling/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp
      - copied unchanged from r151662, cfe/trunk/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp
    cfe/branches/tooling/test/CXX/special/class.dtor/p5-0x.cpp
      - copied unchanged from r151662, cfe/trunk/test/CXX/special/class.dtor/p5-0x.cpp
    cfe/branches/tooling/test/CodeGen/decl-in-prototype.c
      - copied unchanged from r151662, cfe/trunk/test/CodeGen/decl-in-prototype.c
    cfe/branches/tooling/test/CodeGen/lifetime.c
      - copied unchanged from r151662, cfe/trunk/test/CodeGen/lifetime.c
    cfe/branches/tooling/test/CodeGen/ms-declspecs.c
      - copied unchanged from r151662, cfe/trunk/test/CodeGen/ms-declspecs.c
    cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
      - copied unchanged from r151662, cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
    cfe/branches/tooling/test/CodeGenCXX/forward-enum.cpp
      - copied unchanged from r151662, cfe/trunk/test/CodeGenCXX/forward-enum.cpp
    cfe/branches/tooling/test/CodeGenCXX/new-array-init-exceptions.cpp
      - copied unchanged from r151662, cfe/trunk/test/CodeGenCXX/new-array-init-exceptions.cpp
    cfe/branches/tooling/test/CodeGenCXX/new-array-init.cpp
      - copied unchanged from r151662, cfe/trunk/test/CodeGenCXX/new-array-init.cpp
    cfe/branches/tooling/test/CodeGenCXX/thiscall-struct-return.cpp
      - copied unchanged from r151662, cfe/trunk/test/CodeGenCXX/thiscall-struct-return.cpp
    cfe/branches/tooling/test/CodeGenObjC/auto-property-synthesize-protocol.m
      - copied unchanged from r151662, cfe/trunk/test/CodeGenObjC/auto-property-synthesize-protocol.m
    cfe/branches/tooling/test/CodeGenObjCXX/lambda-expressions.mm
      - copied unchanged from r151662, cfe/trunk/test/CodeGenObjCXX/lambda-expressions.mm
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/lib/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/lib/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/lib/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/lib/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/
    cfe/branches/tooling/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep
    cfe/branches/tooling/test/Driver/Inputs/prefixed_tools_tree/
      - copied from r151662, cfe/trunk/test/Driver/Inputs/prefixed_tools_tree/
    cfe/branches/tooling/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as
    cfe/branches/tooling/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld
      - copied unchanged from r151662, cfe/trunk/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld
    cfe/branches/tooling/test/Driver/prefixed-tools.c
      - copied unchanged from r151662, cfe/trunk/test/Driver/prefixed-tools.c
    cfe/branches/tooling/test/Index/targeted-cursor.m
      - copied unchanged from r151662, cfe/trunk/test/Index/targeted-cursor.m
    cfe/branches/tooling/test/Index/targeted-cursor.m.h
      - copied unchanged from r151662, cfe/trunk/test/Index/targeted-cursor.m.h
    cfe/branches/tooling/test/PCH/cxx11-constexpr.cpp
      - copied unchanged from r151662, cfe/trunk/test/PCH/cxx11-constexpr.cpp
    cfe/branches/tooling/test/PCH/cxx11-lambdas.mm
      - copied unchanged from r151662, cfe/trunk/test/PCH/cxx11-lambdas.mm
    cfe/branches/tooling/test/Parser/cxx0x-ambig.cpp
      - copied unchanged from r151662, cfe/trunk/test/Parser/cxx0x-ambig.cpp
    cfe/branches/tooling/test/Parser/cxx0x-condition.cpp
      - copied unchanged from r151662, cfe/trunk/test/Parser/cxx0x-condition.cpp
    cfe/branches/tooling/test/Rewriter/objc-modern-ivar-receiver-1.mm
      - copied unchanged from r151662, cfe/trunk/test/Rewriter/objc-modern-ivar-receiver-1.mm
    cfe/branches/tooling/test/Rewriter/rewrite-cast-ivar-modern-access.mm
      - copied unchanged from r151662, cfe/trunk/test/Rewriter/rewrite-cast-ivar-modern-access.mm
    cfe/branches/tooling/test/Rewriter/rewrite-modern-block-ivar-call.mm
      - copied unchanged from r151662, cfe/trunk/test/Rewriter/rewrite-modern-block-ivar-call.mm
    cfe/branches/tooling/test/Rewriter/rewrite-modern-ivar-use.mm
      - copied unchanged from r151662, cfe/trunk/test/Rewriter/rewrite-modern-ivar-use.mm
    cfe/branches/tooling/test/Rewriter/rewrite-modern-ivars-1.mm
      - copied unchanged from r151662, cfe/trunk/test/Rewriter/rewrite-modern-ivars-1.mm
    cfe/branches/tooling/test/Rewriter/rewrite-modern-nested-ivar.mm
      - copied unchanged from r151662, cfe/trunk/test/Rewriter/rewrite-modern-nested-ivar.mm
    cfe/branches/tooling/test/Rewriter/rewrite-modern-struct-ivar.mm
      - copied unchanged from r151662, cfe/trunk/test/Rewriter/rewrite-modern-struct-ivar.mm
    cfe/branches/tooling/test/Sema/decl-in-prototype.c
      - copied unchanged from r151662, cfe/trunk/test/Sema/decl-in-prototype.c
    cfe/branches/tooling/test/Sema/format-strings-non-standard.c
      - copied unchanged from r151662, cfe/trunk/test/Sema/format-strings-non-standard.c
    cfe/branches/tooling/test/Sema/many-logical-ops.c
      - copied unchanged from r151662, cfe/trunk/test/Sema/many-logical-ops.c
    cfe/branches/tooling/test/SemaObjC/NSString-type.m
      - copied unchanged from r151662, cfe/trunk/test/SemaObjC/NSString-type.m
    cfe/branches/tooling/test/SemaObjC/pragma-pack.m
      - copied unchanged from r151662, cfe/trunk/test/SemaObjC/pragma-pack.m
    cfe/branches/tooling/test/SemaObjCXX/NSString-type.mm
      - copied unchanged from r151662, cfe/trunk/test/SemaObjCXX/NSString-type.mm
Removed:
    cfe/branches/tooling/include/clang/Analysis/Support/SaveAndRestore.h
    cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp
    cfe/branches/tooling/test/Index/nested-macro-instantiations.cpp
    cfe/branches/tooling/test/PCH/cxx11-lambdas.cpp
Modified:
    cfe/branches/tooling/   (props changed)
    cfe/branches/tooling/CMakeLists.txt
    cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py
    cfe/branches/tooling/docs/LanguageExtensions.html
    cfe/branches/tooling/docs/ReleaseNotes.html
    cfe/branches/tooling/docs/UsersManual.html
    cfe/branches/tooling/include/clang-c/Index.h
    cfe/branches/tooling/include/clang/AST/ASTContext.h
    cfe/branches/tooling/include/clang/AST/ASTDiagnostic.h
    cfe/branches/tooling/include/clang/AST/Decl.h
    cfe/branches/tooling/include/clang/AST/DeclBase.h
    cfe/branches/tooling/include/clang/AST/DeclCXX.h
    cfe/branches/tooling/include/clang/AST/Expr.h
    cfe/branches/tooling/include/clang/AST/ExprCXX.h
    cfe/branches/tooling/include/clang/AST/ExprObjC.h
    cfe/branches/tooling/include/clang/AST/OperationKinds.h
    cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h
    cfe/branches/tooling/include/clang/AST/Stmt.h
    cfe/branches/tooling/include/clang/AST/Type.h
    cfe/branches/tooling/include/clang/Analysis/Analyses/FormatString.h
    cfe/branches/tooling/include/clang/Basic/Diagnostic.h
    cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/branches/tooling/include/clang/Basic/LLVM.h
    cfe/branches/tooling/include/clang/Basic/SourceLocation.h
    cfe/branches/tooling/include/clang/Basic/StmtNodes.td
    cfe/branches/tooling/include/clang/Basic/TokenKinds.def
    cfe/branches/tooling/include/clang/Basic/TypeTraits.h
    cfe/branches/tooling/include/clang/Driver/CC1Options.td
    cfe/branches/tooling/include/clang/Driver/Options.td
    cfe/branches/tooling/include/clang/Frontend/ASTUnit.h
    cfe/branches/tooling/include/clang/Frontend/AnalyzerOptions.h
    cfe/branches/tooling/include/clang/Frontend/PreprocessorOptions.h
    cfe/branches/tooling/include/clang/Lex/PreprocessingRecord.h
    cfe/branches/tooling/include/clang/Lex/Preprocessor.h
    cfe/branches/tooling/include/clang/Parse/Parser.h
    cfe/branches/tooling/include/clang/Sema/DeclSpec.h
    cfe/branches/tooling/include/clang/Sema/Initialization.h
    cfe/branches/tooling/include/clang/Sema/Overload.h
    cfe/branches/tooling/include/clang/Sema/Scope.h
    cfe/branches/tooling/include/clang/Sema/Sema.h
    cfe/branches/tooling/include/clang/Serialization/ASTBitCodes.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
    cfe/branches/tooling/lib/ARCMigrate/TransGCAttrs.cpp
    cfe/branches/tooling/lib/AST/ASTDiagnostic.cpp
    cfe/branches/tooling/lib/AST/ASTImporter.cpp
    cfe/branches/tooling/lib/AST/CXXInheritance.cpp
    cfe/branches/tooling/lib/AST/Decl.cpp
    cfe/branches/tooling/lib/AST/DeclBase.cpp
    cfe/branches/tooling/lib/AST/DeclCXX.cpp
    cfe/branches/tooling/lib/AST/DumpXML.cpp
    cfe/branches/tooling/lib/AST/Expr.cpp
    cfe/branches/tooling/lib/AST/ExprCXX.cpp
    cfe/branches/tooling/lib/AST/ExprClassification.cpp
    cfe/branches/tooling/lib/AST/ExprConstant.cpp
    cfe/branches/tooling/lib/AST/ItaniumMangle.cpp
    cfe/branches/tooling/lib/AST/StmtDumper.cpp
    cfe/branches/tooling/lib/AST/StmtPrinter.cpp
    cfe/branches/tooling/lib/AST/StmtProfile.cpp
    cfe/branches/tooling/lib/Analysis/AnalysisDeclContext.cpp
    cfe/branches/tooling/lib/Analysis/CFG.cpp
    cfe/branches/tooling/lib/Analysis/FormatString.cpp
    cfe/branches/tooling/lib/Analysis/UninitializedValues.cpp
    cfe/branches/tooling/lib/Basic/Diagnostic.cpp
    cfe/branches/tooling/lib/Basic/SourceLocation.cpp
    cfe/branches/tooling/lib/Basic/Targets.cpp
    cfe/branches/tooling/lib/CodeGen/BackendUtil.cpp
    cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp
    cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp
    cfe/branches/tooling/lib/CodeGen/CGClass.cpp
    cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
    cfe/branches/tooling/lib/CodeGen/CGExpr.cpp
    cfe/branches/tooling/lib/CodeGen/CGExprAgg.cpp
    cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp
    cfe/branches/tooling/lib/CodeGen/CGExprComplex.cpp
    cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp
    cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp
    cfe/branches/tooling/lib/CodeGen/CGObjC.cpp
    cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp
    cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp
    cfe/branches/tooling/lib/CodeGen/CGStmt.cpp
    cfe/branches/tooling/lib/CodeGen/CodeGenFunction.cpp
    cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h
    cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
    cfe/branches/tooling/lib/CodeGen/CodeGenModule.h
    cfe/branches/tooling/lib/CodeGen/CodeGenTypes.cpp
    cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp
    cfe/branches/tooling/lib/Driver/Driver.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/Frontend/ASTUnit.cpp
    cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp
    cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
    cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp
    cfe/branches/tooling/lib/Headers/tgmath.h
    cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp
    cfe/branches/tooling/lib/Lex/PreprocessingRecord.cpp
    cfe/branches/tooling/lib/Lex/Preprocessor.cpp
    cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp
    cfe/branches/tooling/lib/Parse/ParseDecl.cpp
    cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp
    cfe/branches/tooling/lib/Parse/ParseExpr.cpp
    cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp
    cfe/branches/tooling/lib/Parse/ParseObjc.cpp
    cfe/branches/tooling/lib/Parse/ParsePragma.cpp
    cfe/branches/tooling/lib/Parse/ParseStmt.cpp
    cfe/branches/tooling/lib/Parse/ParseTemplate.cpp
    cfe/branches/tooling/lib/Parse/ParseTentative.cpp
    cfe/branches/tooling/lib/Parse/Parser.cpp
    cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp
    cfe/branches/tooling/lib/Sema/AttributeList.cpp
    cfe/branches/tooling/lib/Sema/DeclSpec.cpp
    cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp
    cfe/branches/tooling/lib/Sema/JumpDiagnostics.cpp
    cfe/branches/tooling/lib/Sema/Scope.cpp
    cfe/branches/tooling/lib/Sema/Sema.cpp
    cfe/branches/tooling/lib/Sema/SemaCast.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/SemaExprMember.cpp
    cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp
    cfe/branches/tooling/lib/Sema/SemaInit.cpp
    cfe/branches/tooling/lib/Sema/SemaLambda.cpp
    cfe/branches/tooling/lib/Sema/SemaLookup.cpp
    cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp
    cfe/branches/tooling/lib/Sema/SemaOverload.cpp
    cfe/branches/tooling/lib/Sema/SemaPseudoObject.cpp
    cfe/branches/tooling/lib/Sema/SemaStmt.cpp
    cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
    cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp
    cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp
    cfe/branches/tooling/lib/Sema/SemaType.cpp
    cfe/branches/tooling/lib/Sema/TreeTransform.h
    cfe/branches/tooling/lib/Serialization/ASTReader.cpp
    cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp
    cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp
    cfe/branches/tooling/lib/Serialization/ASTWriter.cpp
    cfe/branches/tooling/lib/Serialization/ASTWriterDecl.cpp
    cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/Environment.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/MemRegion.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/Store.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
    cfe/branches/tooling/runtime/compiler-rt/Makefile
    cfe/branches/tooling/test/ARCMT/GC-no-arc-runtime.m
    cfe/branches/tooling/test/ARCMT/GC-no-arc-runtime.m.result
    cfe/branches/tooling/test/ARCMT/GC-no-finalize-removal.m
    cfe/branches/tooling/test/ARCMT/GC-no-finalize-removal.m.result
    cfe/branches/tooling/test/ARCMT/GC.m
    cfe/branches/tooling/test/ARCMT/GC.m.result
    cfe/branches/tooling/test/Analysis/inline-unique-reports.c
    cfe/branches/tooling/test/Analysis/keychainAPI.m
    cfe/branches/tooling/test/Analysis/malloc-interprocedural.c
    cfe/branches/tooling/test/Analysis/malloc.c
    cfe/branches/tooling/test/Analysis/malloc.mm
    cfe/branches/tooling/test/Analysis/method-arg-decay.m
    cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
    cfe/branches/tooling/test/Analysis/plist-output-alternate.m
    cfe/branches/tooling/test/Analysis/retain-release-gc-only.m
    cfe/branches/tooling/test/Analysis/retain-release-inline.m
    cfe/branches/tooling/test/Analysis/retain-release.m
    cfe/branches/tooling/test/Analysis/system-header-simulator.h
    cfe/branches/tooling/test/Analysis/taint-generic.c
    cfe/branches/tooling/test/CXX/class/class.union/p1.cpp
    cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp
    cfe/branches/tooling/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
    cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp
    cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp
    cfe/branches/tooling/test/CXX/special/class.ctor/p5-0x.cpp
    cfe/branches/tooling/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
    cfe/branches/tooling/test/CodeGen/complex-init-list.c
    cfe/branches/tooling/test/CodeGen/init.c
    cfe/branches/tooling/test/CodeGenCXX/blocks.cpp
    cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp
    cfe/branches/tooling/test/CodeGenCXX/constructor-init.cpp
    cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp
    cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
    cfe/branches/tooling/test/CodeGenCXX/debug-info-artificial-arg.cpp
    cfe/branches/tooling/test/CodeGenCXX/mangle-exprs.cpp
    cfe/branches/tooling/test/CodeGenCXX/pr9965.cpp
    cfe/branches/tooling/test/CodeGenCXX/visibility.cpp
    cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m
    cfe/branches/tooling/test/CodeGenObjC/arc.m
    cfe/branches/tooling/test/CodeGenObjCXX/debug-info.mm
    cfe/branches/tooling/test/Driver/darwin-as.c
    cfe/branches/tooling/test/Driver/debug-options.c
    cfe/branches/tooling/test/Driver/gcc-toolchain.cpp
    cfe/branches/tooling/test/Driver/linux-header-search.cpp
    cfe/branches/tooling/test/Driver/linux-ld.c
    cfe/branches/tooling/test/Index/annotate-tokens-cxx0x.cpp
    cfe/branches/tooling/test/Index/get-cursor.m
    cfe/branches/tooling/test/Index/index-refs.cpp
    cfe/branches/tooling/test/Lexer/has_extension.c
    cfe/branches/tooling/test/Lexer/has_feature_cxx0x.cpp
    cfe/branches/tooling/test/Misc/warning-flags.c
    cfe/branches/tooling/test/PCH/cxx-traits.cpp
    cfe/branches/tooling/test/PCH/cxx-traits.h
    cfe/branches/tooling/test/PCH/cxx0x-default-delete.cpp
    cfe/branches/tooling/test/PCH/objc_exprs.m
    cfe/branches/tooling/test/Parser/DelayedTemplateParsing.cpp
    cfe/branches/tooling/test/Parser/bracket-crash.cpp
    cfe/branches/tooling/test/Parser/cxx-condition.cpp
    cfe/branches/tooling/test/Preprocessor/feature_tests.c
    cfe/branches/tooling/test/Rewriter/func-in-impl.m
    cfe/branches/tooling/test/Rewriter/rewrite-ivar-use.m
    cfe/branches/tooling/test/Rewriter/rewrite-modern-class.mm
    cfe/branches/tooling/test/Rewriter/rewrite-nested-ivar.mm
    cfe/branches/tooling/test/Sema/MicrosoftCompatibility.c
    cfe/branches/tooling/test/Sema/MicrosoftExtensions.c
    cfe/branches/tooling/test/Sema/const-eval.c
    cfe/branches/tooling/test/Sema/format-strings-c90.c
    cfe/branches/tooling/test/Sema/format-strings.c
    cfe/branches/tooling/test/Sema/pragma-pack-2.c
    cfe/branches/tooling/test/SemaCXX/PR9461.cpp
    cfe/branches/tooling/test/SemaCXX/array-bounds.cpp
    cfe/branches/tooling/test/SemaCXX/constructor-initializer.cpp
    cfe/branches/tooling/test/SemaCXX/cxx0x-class.cpp
    cfe/branches/tooling/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
    cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-constructor.cpp
    cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-scalars.cpp
    cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
    cfe/branches/tooling/test/SemaCXX/cxx0x-nontrivial-union.cpp
    cfe/branches/tooling/test/SemaCXX/cxx0x-return-init-list.cpp
    cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp
    cfe/branches/tooling/test/SemaCXX/defaulted-private-dtor.cpp
    cfe/branches/tooling/test/SemaCXX/deleted-operator.cpp
    cfe/branches/tooling/test/SemaCXX/explicit.cpp
    cfe/branches/tooling/test/SemaCXX/format-strings.cpp
    cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp
    cfe/branches/tooling/test/SemaCXX/new-delete.cpp
    cfe/branches/tooling/test/SemaCXX/overload-call.cpp
    cfe/branches/tooling/test/SemaCXX/pragma-visibility.cpp
    cfe/branches/tooling/test/SemaCXX/type-traits.cpp
    cfe/branches/tooling/test/SemaCXX/typo-correction.cpp
    cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp
    cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp   (props changed)
    cfe/branches/tooling/test/SemaObjC/arc-peformselector.m
    cfe/branches/tooling/test/SemaObjC/arc-property.m
    cfe/branches/tooling/test/SemaObjC/arc-type-conversion.m
    cfe/branches/tooling/test/SemaObjC/arc.m
    cfe/branches/tooling/test/SemaObjC/category-1.m
    cfe/branches/tooling/test/SemaObjC/class-message-protocol-lookup.m
    cfe/branches/tooling/test/SemaObjC/compare-qualified-id.m
    cfe/branches/tooling/test/SemaObjC/incomplete-implementation.m
    cfe/branches/tooling/test/SemaObjC/method-attributes.m
    cfe/branches/tooling/test/SemaObjC/method-undef-category-warn-1.m
    cfe/branches/tooling/test/SemaObjC/method-undef-extension-warn-1.m
    cfe/branches/tooling/test/SemaObjC/protocol-implementing-class-methods.m
    cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m
    cfe/branches/tooling/test/SemaObjC/undef-protocol-methods-1.m
    cfe/branches/tooling/test/SemaObjC/warn-deprecated-implementations.m
    cfe/branches/tooling/tools/c-index-test/c-index-test.c
    cfe/branches/tooling/tools/libclang/CIndex.cpp
    cfe/branches/tooling/tools/libclang/CXCursor.cpp
    cfe/branches/tooling/tools/libclang/IndexBody.cpp
    cfe/branches/tooling/tools/libclang/IndexDecl.cpp
    cfe/branches/tooling/tools/libclang/Indexing.cpp
    cfe/branches/tooling/tools/libclang/IndexingContext.cpp
    cfe/branches/tooling/tools/libclang/IndexingContext.h
    cfe/branches/tooling/tools/libclang/libclang.exports
    cfe/branches/tooling/tools/scan-build/set-xcode-analyzer
    cfe/branches/tooling/www/analyzer/annotations.html
    cfe/branches/tooling/www/analyzer/latest_checker.html.incl
    cfe/branches/tooling/www/analyzer/release_notes.html
    cfe/branches/tooling/www/cxx_status.html

Propchange: cfe/branches/tooling/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 28 17:49:25 2012
@@ -1,3 +1,3 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:146581-151084
+/cfe/trunk:146581-151662
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/tooling/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/CMakeLists.txt?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/CMakeLists.txt (original)
+++ cfe/branches/tooling/CMakeLists.txt Tue Feb 28 17:49:25 2012
@@ -204,7 +204,8 @@
   endif(MSVC)
   install(TARGETS ${name}
     LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-    ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+    ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+    RUNTIME DESTINATION bin)
   set_target_properties(${name} PROPERTIES FOLDER "Clang libraries")
 endmacro(add_clang_library)
 

Modified: cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py Tue Feb 28 17:49:25 2012
@@ -36,6 +36,7 @@
 
     assert len(tu_nodes) == 3
 
+    assert tu_nodes[0] != tu_nodes[1]
     assert tu_nodes[0].kind == CursorKind.STRUCT_DECL
     assert tu_nodes[0].spelling == 's0'
     assert tu_nodes[0].is_definition() == True

Modified: cfe/branches/tooling/docs/LanguageExtensions.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/LanguageExtensions.html?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/docs/LanguageExtensions.html (original)
+++ cfe/branches/tooling/docs/LanguageExtensions.html Tue Feb 28 17:49:25 2012
@@ -228,6 +228,11 @@
 
 <p>The feature tag is described along with the language feature below.</p>
 
+<p>The feature name or extension name can also be specified with a preceding and
+following <code>__</code> (double underscore) to avoid interference from a macro
+with the same name. For instance, <code>__always_inline__</code> can be used
+instead of <code>always_inline</code>.</p>
+
 <!-- ======================================================================= -->
 <h3><a name="__has_attribute">__has_attribute</a></h3>
 <!-- ======================================================================= -->
@@ -706,8 +711,7 @@
 
 <p>Use <tt>__has_feature(cxx_generalized_initializers)</tt> to determine if
 support for generalized initializers (using braced lists and
-<tt>std::initializer_list</tt>) is enabled. Clang does not currently implement
-this feature.</p>
+<tt>std::initializer_list</tt>) is enabled.</p>
 
 <h4 id="cxx_implicit_moves">C++11 implicit move constructors/assignment operators</h4>
 
@@ -728,7 +732,7 @@
 
 <p>Use <tt>__has_feature(cxx_lambdas)</tt> or
 <tt>__has_extension(cxx_lambdas)</tt> to determine if support for lambdas
-is enabled. Clang does not currently implement this feature.</p>
+is enabled. </p>
 
 <h4 id="cxx_noexcept">C++11 noexcept</h4>
 
@@ -889,6 +893,8 @@
   <li><code>__is_literal(type)</code>: Determines whether the given type is a literal type</li>
   <li><code>__is_final</code>: Determines whether the given type is declared with a <code>final</code> class-virt-specifier.</li>
   <li><code>__underlying_type(type)</code>: Retrieves the underlying type for a given <code>enum</code> type. This trait is required to implement the C++11 standard library.</li>
+  <li><code>__is_trivially_assignable(totype, fromtype)</code>: Determines whether a value of type <tt>totype</tt> can be assigned to from a value of type <tt>fromtype</tt> such that no non-trivial functions are called as part of that assignment. This trait is required to implement the C++11 standard library.</li>
+  <li><code>__is_trivially_constructible(type, argtypes...)</code>: Determines whether a value of type <tt>type</tt> can be direct-initialized with arguments of types <tt>argtypes...</tt> such that no non-trivial functions are called as part of that initialization. This trait is required to implement the C++11 standard library.</li>
 </ul>
 
 <!-- ======================================================================= -->

Modified: cfe/branches/tooling/docs/ReleaseNotes.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/ReleaseNotes.html?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/docs/ReleaseNotes.html (original)
+++ cfe/branches/tooling/docs/ReleaseNotes.html Tue Feb 28 17:49:25 2012
@@ -121,10 +121,8 @@
 following are now considered to be of production quality:
 <ul>
   <li>Generalized constant expressions</li>
-  <!--
   <li>Lambda expressions</li>
   <li>Generalized initializers</li>
-  -->
 </ul>
 
 <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->

Modified: cfe/branches/tooling/docs/UsersManual.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/UsersManual.html?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/docs/UsersManual.html (original)
+++ cfe/branches/tooling/docs/UsersManual.html Tue Feb 28 17:49:25 2012
@@ -30,6 +30,8 @@
   <ul>
   <li><a href="#cl_diagnostics">Options to Control Error and Warning
       Messages</a></li>
+  <li><a href="#cl_crash_diagnostics">Options to Control Clang Crash
+      Diagnostics</a></li>
   </ul>
 </li>
 <li><a href="#general_features">Language and Target-Independent Features</a>
@@ -415,7 +417,6 @@
 
 </dl>
 
- 
 
 
 <!-- ===================================================== -->
@@ -509,6 +510,27 @@
 
 </dl>
 
+<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
+<h3 id="cl_crash_diagnostics">Options to Control Clang Crash Diagnostics</h3>
+<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
+
+<p>As unbelievable as it may sound, Clang does crash from time to time.  
+Generally, this only occurs to those living on the 
+<a href="http://llvm.org/releases/download.html#svn">bleeding edge</a>.  Clang
+goes to great lengths to assist you in filing a bug report.  Specifically, Clang
+generates preprocessed source file(s) and associated run script(s) upon a
+crash.  These files should be attached to a bug report to ease reproducibility
+of the failure.  Below are the command line options to control the crash
+diagnostics.
+</p>
+
+<p><b>-fno-crash-diagnostics</b>: Disable auto-generation of preprocessed 
+source files during a clang crash.</p>
+
+<p>The -fno-crash-diagnostics flag can be helpful for speeding the process of
+generating a delta reduced test case.</p>
+
+
 <!-- ======================================================================= -->
 <h2 id="general_features">Language and Target-Independent Features</h2>
 <!-- ======================================================================= -->

Modified: cfe/branches/tooling/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang-c/Index.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang-c/Index.h (original)
+++ cfe/branches/tooling/include/clang-c/Index.h Tue Feb 28 17:49:25 2012
@@ -993,28 +993,7 @@
    * Note: this is a *temporary* option that is available only while
    * we are testing C++ precompiled preamble support. It is deprecated.
    */
-  CXTranslationUnit_CXXChainedPCH = 0x20,
-  
-  /**
-   * \brief Used to indicate that the "detailed" preprocessing record,
-   * if requested, should also contain nested macro expansions.
-   *
-   * Nested macro expansions (i.e., macro expansions that occur
-   * inside another macro expansion) can, in some code bases, require
-   * a large amount of storage to due preprocessor metaprogramming. Moreover,
-   * its fairly rare that this information is useful for libclang clients.
-   */
-  CXTranslationUnit_NestedMacroExpansions = 0x40,
-
-  /**
-   * \brief Legacy name to indicate that the "detailed" preprocessing record,
-   * if requested, should contain nested macro expansions.
-   *
-   * \see CXTranslationUnit_NestedMacroExpansions for the current name for this
-   * value, and its semantics. This is just an alias.
-   */
-  CXTranslationUnit_NestedMacroInstantiations =
-    CXTranslationUnit_NestedMacroExpansions
+  CXTranslationUnit_CXXChainedPCH = 0x20
 };
 
 /**
@@ -4293,6 +4272,12 @@
 
 typedef struct {
   const CXIdxDeclInfo *declInfo;
+  const CXIdxEntityInfo *getter;
+  const CXIdxEntityInfo *setter;
+} CXIdxObjCPropertyDeclInfo;
+
+typedef struct {
+  const CXIdxDeclInfo *declInfo;
   const CXIdxBaseClassInfo *const *bases;
   unsigned numBases;
 } CXIdxCXXClassDeclInfo;
@@ -4408,6 +4393,9 @@
 CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
 clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
 
+CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
+clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
+
 CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
 clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
 

Modified: cfe/branches/tooling/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ASTContext.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ASTContext.h (original)
+++ cfe/branches/tooling/include/clang/AST/ASTContext.h Tue Feb 28 17:49:25 2012
@@ -218,6 +218,8 @@
 
   QualType ObjCConstantStringType;
   mutable RecordDecl *CFConstantStringTypeDecl;
+  
+  QualType ObjCNSStringType;
 
   /// \brief The typedef declaration for the Objective-C "instancetype" type.
   TypedefDecl *ObjCInstanceTypeDecl;
@@ -323,12 +325,6 @@
   typedef UsuallyTinyPtrVector<const CXXMethodDecl> CXXMethodVector;
   llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods;
 
-  /// \brief Mapping from lambda-to-block-pointer conversion functions to the
-  /// expression used to copy the lambda object.
-  llvm::DenseMap<const CXXConversionDecl *, Expr *> LambdaBlockPointerInits;
-  
-  friend class CXXConversionDecl;
-  
   /// \brief Mapping from each declaration context to its corresponding lambda 
   /// mangling context.
   llvm::DenseMap<const DeclContext *, LambdaMangleContext> LambdaMangleContexts;
@@ -950,6 +946,14 @@
     return ObjCConstantStringType;
   }
 
+  QualType getObjCNSStringType() const {
+    return ObjCNSStringType;
+  }
+  
+  void setObjCNSStringType(QualType T) {
+    ObjCNSStringType = T;
+  }
+  
   /// \brief Retrieve the type that 'id' has been defined to, which may be
   /// different from the built-in 'id' if 'id' has been typedef'd.
   QualType getObjCIdRedefinitionType() const {

Modified: cfe/branches/tooling/include/clang/AST/ASTDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ASTDiagnostic.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ASTDiagnostic.h (original)
+++ cfe/branches/tooling/include/clang/AST/ASTDiagnostic.h Tue Feb 28 17:49:25 2012
@@ -44,7 +44,7 @@
       unsigned NumPrevArgs,
       SmallVectorImpl<char> &Output,
       void *Cookie,
-      SmallVectorImpl<intptr_t> &QualTypeVals);
+      ArrayRef<intptr_t> QualTypeVals);
 }  // end namespace clang
 
 #endif

Modified: cfe/branches/tooling/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Decl.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Decl.h (original)
+++ cfe/branches/tooling/include/clang/AST/Decl.h Tue Feb 28 17:49:25 2012
@@ -251,6 +251,10 @@
       mergeLinkage(Other.linkage());
     }
 
+    // Merge the visibility V giving preference to explicit ones.
+    // This is used, for example, when merging the visibility of a class
+    // down to one of its members. If the member has no explicit visibility,
+    // the class visibility wins.
     void mergeVisibility(Visibility V, bool E = false) {
       // If one has explicit visibility and the other doesn't, keep the
       // explicit one.
@@ -262,14 +266,35 @@
       // If both are explicit or both are implicit, keep the minimum.
       setVisibility(minVisibility(visibility(), V), visibilityExplicit() || E);
     }
+    // Merge the visibility V, keeping the most restrictive one.
+    // This is used for cases like merging the visibility of a template
+    // argument to an instantiation. If we already have a hidden class,
+    // no argument should give it default visibility.
+    void mergeVisibilityWithMin(Visibility V, bool E = false) {
+      // Never increase the visibility
+      if (visibility() < V)
+        return;
+
+      // If this visibility is explicit, keep it.
+      if (visibilityExplicit() && !E)
+        return;
+      setVisibility(V, E);
+    }
     void mergeVisibility(LinkageInfo Other) {
       mergeVisibility(Other.visibility(), Other.visibilityExplicit());
     }
+    void mergeVisibilityWithMin(LinkageInfo Other) {
+      mergeVisibilityWithMin(Other.visibility(), Other.visibilityExplicit());
+    }
 
     void merge(LinkageInfo Other) {
       mergeLinkage(Other);
       mergeVisibility(Other);
     }
+    void mergeWithMin(LinkageInfo Other) {
+      mergeLinkage(Other);
+      mergeVisibilityWithMin(Other);
+    }
 
     friend LinkageInfo merge(LinkageInfo L, LinkageInfo R) {
       L.merge(R);
@@ -1406,6 +1431,11 @@
   /// no formals.
   ParmVarDecl **ParamInfo;
 
+  /// DeclsInPrototypeScope - Array of pointers to NamedDecls for
+  /// decls defined in the function prototype that are not parameters. E.g.
+  /// 'enum Y' in 'void f(enum Y {AA} x) {}'.
+  llvm::ArrayRef<NamedDecl*> DeclsInPrototypeScope;
+
   LazyDeclStmtPtr Body;
 
   // FIXME: This can be packed into the bitfields in Decl.
@@ -1771,6 +1801,11 @@
     setParams(getASTContext(), NewParamInfo);
   }
 
+  const llvm::ArrayRef<NamedDecl*> &getDeclsInPrototypeScope() const {
+    return DeclsInPrototypeScope;
+  }
+  void setDeclsInPrototypeScope(llvm::ArrayRef<NamedDecl *> NewDecls);
+
   /// getMinRequiredArguments - Returns the minimum number of arguments
   /// needed to call this function. This may be fewer than the number of
   /// function parameters, if some of the parameters have default

Modified: cfe/branches/tooling/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/DeclBase.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclBase.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclBase.h Tue Feb 28 17:49:25 2012
@@ -961,7 +961,7 @@
   ///
   /// \returns the first/last pair of declarations.
   static std::pair<Decl *, Decl *>
-  BuildDeclChain(const SmallVectorImpl<Decl*> &Decls, bool FieldsAlreadyLoaded);
+  BuildDeclChain(ArrayRef<Decl*> Decls, bool FieldsAlreadyLoaded);
 
    DeclContext(Decl::Kind K)
      : DeclKind(K), ExternalLexicalStorage(false),

Modified: cfe/branches/tooling/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/DeclCXX.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclCXX.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclCXX.h Tue Feb 28 17:49:25 2012
@@ -469,6 +469,10 @@
     ///   type (or array thereof), each such class has a trivial destructor.
     bool HasTrivialDestructor : 1;
 
+    /// HasIrrelevantDestructor - True when this class has a destructor with no
+    /// semantic effect.
+    bool HasIrrelevantDestructor : 1;
+
     /// HasNonLiteralTypeFieldsOrBases - True when this class contains at least
     /// one non-static data member or base class of non-literal or volatile
     /// type.
@@ -1145,9 +1149,9 @@
 
   // hasIrrelevantDestructor - Whether this class has a destructor which has no
   // semantic effect. Any such destructor will be trivial, public, defaulted
-  // and not deleted.
+  // and not deleted, and will call only irrelevant destructors.
   bool hasIrrelevantDestructor() const {
-    return hasTrivialDestructor() && !hasUserDeclaredDestructor();
+    return data().HasIrrelevantDestructor;
   }
 
   // hasNonLiteralTypeFieldsOrBases - Whether this class has a non-literal or
@@ -2261,15 +2265,6 @@
   /// a lambda closure type to a block pointer.
   bool isLambdaToBlockPointerConversion() const;
   
-  /// \brief For an implicit conversion function that converts a lambda
-  /// closure type to a block pointer, retrieve the expression used to
-  /// copy the closure object into the block.
-  Expr *getLambdaToBlockPointerCopyInit() const;
-  
-  /// \brief Set the copy-initialization expression to be used when converting
-  /// a lambda object to a block pointer.
-  void setLambdaToBlockPointerCopyInit(Expr *Init);
-  
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classof(const CXXConversionDecl *D) { return true; }

Modified: cfe/branches/tooling/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Expr.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Expr.h (original)
+++ cfe/branches/tooling/include/clang/AST/Expr.h Tue Feb 28 17:49:25 2012
@@ -512,6 +512,10 @@
   /// variable read.
   bool HasSideEffects(const ASTContext &Ctx) const;
 
+  /// \brief Determine whether this expression involves a call to any function
+  /// that is not trivial.
+  bool hasNonTrivialCall(ASTContext &Ctx);
+  
   /// EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded
   /// integer. This must be called on an expression that constant folds to an
   /// integer.
@@ -665,8 +669,7 @@
     return const_cast<Expr*>(this)->IgnoreParenNoopCasts(Ctx);
   }
 
-  static bool hasAnyTypeDependentArguments(Expr** Exprs, unsigned NumExprs);
-  static bool hasAnyValueDependentArguments(Expr** Exprs, unsigned NumExprs);
+  static bool hasAnyTypeDependentArguments(llvm::ArrayRef<Expr *> Exprs);
 
   static bool classof(const Stmt *T) {
     return T->getStmtClass() >= firstExprConstant &&
@@ -692,12 +695,15 @@
 
 public:
   OpaqueValueExpr(SourceLocation Loc, QualType T, ExprValueKind VK,
-                  ExprObjectKind OK = OK_Ordinary)
+                  ExprObjectKind OK = OK_Ordinary,
+                  Expr *SourceExpr = 0)
     : Expr(OpaqueValueExprClass, T, VK, OK,
-           T->isDependentType(), T->isDependentType(),
+           T->isDependentType(), 
+           T->isDependentType() || 
+           (SourceExpr && SourceExpr->isValueDependent()),
            T->isInstantiationDependentType(),
            false),
-      SourceExpr(0), Loc(Loc) {
+      SourceExpr(SourceExpr), Loc(Loc) {
   }
 
   /// Given an expression which invokes a copy constructor --- i.e.  a
@@ -731,7 +737,6 @@
   /// expression which binds the opaque value expression in the first
   /// place.
   Expr *getSourceExpr() const { return SourceExpr; }
-  void setSourceExpr(Expr *e) { SourceExpr = e; }
 
   static bool classof(const Stmt *T) {
     return T->getStmtClass() == OpaqueValueExprClass;
@@ -1080,11 +1085,11 @@
 /// the APFloat/APInt values will never get freed. APNumericStorage uses
 /// ASTContext's allocator for memory allocation.
 class APNumericStorage {
-  unsigned BitWidth;
   union {
     uint64_t VAL;    ///< Used to store the <= 64 bits integer value.
     uint64_t *pVal;  ///< Used to store the >64 bits integer value.
   };
+  unsigned BitWidth;
 
   bool hasAllocation() const { return llvm::APInt::getNumWords(BitWidth) > 1; }
 
@@ -1092,7 +1097,7 @@
   APNumericStorage& operator=(const APNumericStorage&); // do not implement
 
 protected:
-  APNumericStorage() : BitWidth(0), VAL(0) { }
+  APNumericStorage() : VAL(0), BitWidth(0) { }
 
   llvm::APInt getIntValue() const {
     unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
@@ -1104,13 +1109,13 @@
   void setIntValue(ASTContext &C, const llvm::APInt &Val);
 };
 
-class APIntStorage : public APNumericStorage {
+class APIntStorage : private APNumericStorage {
 public:
   llvm::APInt getValue() const { return getIntValue(); }
   void setValue(ASTContext &C, const llvm::APInt &Val) { setIntValue(C, Val); }
 };
 
-class APFloatStorage : public APNumericStorage {
+class APFloatStorage : private APNumericStorage {
 public:
   llvm::APFloat getValue(bool IsIEEE) const {
     return llvm::APFloat(getIntValue(), IsIEEE);
@@ -1120,8 +1125,7 @@
   }
 };
 
-class IntegerLiteral : public Expr {
-  APIntStorage Num;
+class IntegerLiteral : public Expr, public APIntStorage {
   SourceLocation Loc;
 
   /// \brief Construct an empty integer literal.
@@ -1151,13 +1155,11 @@
   /// \brief Returns a new empty integer literal.
   static IntegerLiteral *Create(ASTContext &C, EmptyShell Empty);
 
-  llvm::APInt getValue() const { return Num.getValue(); }
   SourceRange getSourceRange() const { return SourceRange(Loc); }
 
   /// \brief Retrieve the location of the literal.
   SourceLocation getLocation() const { return Loc; }
 
-  void setValue(ASTContext &C, const llvm::APInt &Val) { Num.setValue(C, Val); }
   void setLocation(SourceLocation Location) { Loc = Location; }
 
   static bool classof(const Stmt *T) {
@@ -1181,28 +1183,30 @@
 private:
   unsigned Value;
   SourceLocation Loc;
-  unsigned Kind : 2;
 public:
   // type should be IntTy
   CharacterLiteral(unsigned value, CharacterKind kind, QualType type,
                    SourceLocation l)
     : Expr(CharacterLiteralClass, type, VK_RValue, OK_Ordinary, false, false,
            false, false),
-      Value(value), Loc(l), Kind(kind) {
+      Value(value), Loc(l) {
+    CharacterLiteralBits.Kind = kind;
   }
 
   /// \brief Construct an empty character literal.
   CharacterLiteral(EmptyShell Empty) : Expr(CharacterLiteralClass, Empty) { }
 
   SourceLocation getLocation() const { return Loc; }
-  CharacterKind getKind() const { return static_cast<CharacterKind>(Kind); }
+  CharacterKind getKind() const {
+    return static_cast<CharacterKind>(CharacterLiteralBits.Kind);
+  }
 
   SourceRange getSourceRange() const { return SourceRange(Loc); }
 
   unsigned getValue() const { return Value; }
 
   void setLocation(SourceLocation Location) { Loc = Location; }
-  void setKind(CharacterKind kind) { Kind = kind; }
+  void setKind(CharacterKind kind) { CharacterLiteralBits.Kind = kind; }
   void setValue(unsigned Val) { Value = Val; }
 
   static bool classof(const Stmt *T) {
@@ -1214,41 +1218,41 @@
   child_range children() { return child_range(); }
 };
 
-class FloatingLiteral : public Expr {
-  APFloatStorage Num;
-  bool IsIEEE : 1; // Distinguishes between PPC128 and IEEE128.
-  bool IsExact : 1;
+class FloatingLiteral : public Expr, private APFloatStorage {
   SourceLocation Loc;
 
   FloatingLiteral(ASTContext &C, const llvm::APFloat &V, bool isexact,
                   QualType Type, SourceLocation L)
     : Expr(FloatingLiteralClass, Type, VK_RValue, OK_Ordinary, false, false,
-           false, false),
-      IsIEEE(&C.getTargetInfo().getLongDoubleFormat() ==
-             &llvm::APFloat::IEEEquad),
-      IsExact(isexact), Loc(L) {
+           false, false), Loc(L) {
+    FloatingLiteralBits.IsIEEE =
+      &C.getTargetInfo().getLongDoubleFormat() == &llvm::APFloat::IEEEquad;
+    FloatingLiteralBits.IsExact = isexact;
     setValue(C, V);
   }
 
   /// \brief Construct an empty floating-point literal.
   explicit FloatingLiteral(ASTContext &C, EmptyShell Empty)
-    : Expr(FloatingLiteralClass, Empty),
-      IsIEEE(&C.getTargetInfo().getLongDoubleFormat() ==
-             &llvm::APFloat::IEEEquad),
-      IsExact(false) { }
+    : Expr(FloatingLiteralClass, Empty) {
+    FloatingLiteralBits.IsIEEE =
+      &C.getTargetInfo().getLongDoubleFormat() == &llvm::APFloat::IEEEquad;
+    FloatingLiteralBits.IsExact = false;
+  }
 
 public:
   static FloatingLiteral *Create(ASTContext &C, const llvm::APFloat &V,
                                  bool isexact, QualType Type, SourceLocation L);
   static FloatingLiteral *Create(ASTContext &C, EmptyShell Empty);
 
-  llvm::APFloat getValue() const { return Num.getValue(IsIEEE); }
+  llvm::APFloat getValue() const {
+    return APFloatStorage::getValue(FloatingLiteralBits.IsIEEE);
+  }
   void setValue(ASTContext &C, const llvm::APFloat &Val) {
-    Num.setValue(C, Val);
+    APFloatStorage::setValue(C, Val);
   }
 
-  bool isExact() const { return IsExact; }
-  void setExact(bool E) { IsExact = E; }
+  bool isExact() const { return FloatingLiteralBits.IsExact; }
+  void setExact(bool E) { FloatingLiteralBits.IsExact = E; }
 
   /// getValueAsApproximateDouble - This returns the value as an inaccurate
   /// double.  Note that this may cause loss of precision, but is useful for
@@ -1335,10 +1339,10 @@
     const uint32_t *asUInt32;
   } StrData;
   unsigned Length;
-  unsigned CharByteWidth;
-  unsigned NumConcatenated;
+  unsigned CharByteWidth : 4;
   unsigned Kind : 3;
-  bool IsPascal : 1;
+  unsigned IsPascal : 1;
+  unsigned NumConcatenated;
   SourceLocation TokLocs[1];
 
   StringLiteral(QualType Ty) :
@@ -1822,8 +1826,6 @@
 /// expression operand.  Used for sizeof/alignof (C99 6.5.3.4) and
 /// vec_step (OpenCL 1.1 6.11.12).
 class UnaryExprOrTypeTraitExpr : public Expr {
-  unsigned Kind : 2;
-  bool isType : 1;    // true if operand is a type, false if an expression
   union {
     TypeSourceInfo *Ty;
     Stmt *Ex;
@@ -1840,7 +1842,9 @@
            TInfo->getType()->isDependentType(),
            TInfo->getType()->isInstantiationDependentType(),
            TInfo->getType()->containsUnexpandedParameterPack()),
-      Kind(ExprKind), isType(true), OpLoc(op), RParenLoc(rp) {
+      OpLoc(op), RParenLoc(rp) {
+    UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
+    UnaryExprOrTypeTraitExprBits.IsType = true;
     Argument.Ty = TInfo;
   }
 
@@ -1853,7 +1857,9 @@
            E->isTypeDependent(),
            E->isInstantiationDependent(),
            E->containsUnexpandedParameterPack()),
-      Kind(ExprKind), isType(false), OpLoc(op), RParenLoc(rp) {
+      OpLoc(op), RParenLoc(rp) {
+    UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
+    UnaryExprOrTypeTraitExprBits.IsType = false;
     Argument.Ex = E;
   }
 
@@ -1862,11 +1868,11 @@
     : Expr(UnaryExprOrTypeTraitExprClass, Empty) { }
 
   UnaryExprOrTypeTrait getKind() const {
-    return static_cast<UnaryExprOrTypeTrait>(Kind);
+    return static_cast<UnaryExprOrTypeTrait>(UnaryExprOrTypeTraitExprBits.Kind);
   }
-  void setKind(UnaryExprOrTypeTrait K) { Kind = K; }
+  void setKind(UnaryExprOrTypeTrait K) { UnaryExprOrTypeTraitExprBits.Kind = K;}
 
-  bool isArgumentType() const { return isType; }
+  bool isArgumentType() const { return UnaryExprOrTypeTraitExprBits.IsType; }
   QualType getArgumentType() const {
     return getArgumentTypeInfo()->getType();
   }
@@ -1882,10 +1888,13 @@
     return const_cast<UnaryExprOrTypeTraitExpr*>(this)->getArgumentExpr();
   }
 
-  void setArgument(Expr *E) { Argument.Ex = E; isType = false; }
+  void setArgument(Expr *E) {
+    Argument.Ex = E;
+    UnaryExprOrTypeTraitExprBits.IsType = false;
+  }
   void setArgument(TypeSourceInfo *TInfo) {
     Argument.Ty = TInfo;
-    isType = true;
+    UnaryExprOrTypeTraitExprBits.IsType = true;
   }
 
   /// Gets the argument type, or the type of the argument expression, whichever
@@ -2152,13 +2161,13 @@
   /// In X.F, this is the decl referenced by F.
   ValueDecl *MemberDecl;
 
-  /// MemberLoc - This is the location of the member name.
-  SourceLocation MemberLoc;
-
   /// MemberDNLoc - Provides source/type location info for the
   /// declaration name embedded in MemberDecl.
   DeclarationNameLoc MemberDNLoc;
 
+  /// MemberLoc - This is the location of the member name.
+  SourceLocation MemberLoc;
+
   /// IsArrow - True if this is "X->F", false if this is "X.F".
   bool IsArrow : 1;
 
@@ -2201,8 +2210,8 @@
            base->isValueDependent(),
            base->isInstantiationDependent(),
            base->containsUnexpandedParameterPack()),
-      Base(base), MemberDecl(memberdecl), MemberLoc(NameInfo.getLoc()),
-      MemberDNLoc(NameInfo.getInfo()), IsArrow(isarrow),
+      Base(base), MemberDecl(memberdecl), MemberDNLoc(NameInfo.getInfo()),
+      MemberLoc(NameInfo.getLoc()), IsArrow(isarrow),
       HasQualifierOrFoundDecl(false), HasTemplateKWAndArgsInfo(false),
       HadMultipleCandidates(false) {
     assert(memberdecl->getDeclName() == NameInfo.getName());
@@ -2219,7 +2228,7 @@
            base->isTypeDependent(), base->isValueDependent(),
            base->isInstantiationDependent(),
            base->containsUnexpandedParameterPack()),
-      Base(base), MemberDecl(memberdecl), MemberLoc(l), MemberDNLoc(),
+      Base(base), MemberDecl(memberdecl), MemberDNLoc(), MemberLoc(l),
       IsArrow(isarrow),
       HasQualifierOrFoundDecl(false), HasTemplateKWAndArgsInfo(false),
       HadMultipleCandidates(false) {}
@@ -2425,9 +2434,9 @@
 
   /// The type as written.  This can be an incomplete array type, in
   /// which case the actual expression type will be different.
-  TypeSourceInfo *TInfo;
+  /// The int part of the pair stores whether this expr is file scope.
+  llvm::PointerIntPair<TypeSourceInfo *, 1, bool> TInfoAndScope;
   Stmt *Init;
-  bool FileScope;
 public:
   CompoundLiteralExpr(SourceLocation lparenloc, TypeSourceInfo *tinfo,
                       QualType T, ExprValueKind VK, Expr *init, bool fileScope)
@@ -2437,7 +2446,7 @@
            (init->isInstantiationDependent() ||
             tinfo->getType()->isInstantiationDependentType()),
            init->containsUnexpandedParameterPack()),
-      LParenLoc(lparenloc), TInfo(tinfo), Init(init), FileScope(fileScope) {}
+      LParenLoc(lparenloc), TInfoAndScope(tinfo, fileScope), Init(init) {}
 
   /// \brief Construct an empty compound literal.
   explicit CompoundLiteralExpr(EmptyShell Empty)
@@ -2447,14 +2456,18 @@
   Expr *getInitializer() { return cast<Expr>(Init); }
   void setInitializer(Expr *E) { Init = E; }
 
-  bool isFileScope() const { return FileScope; }
-  void setFileScope(bool FS) { FileScope = FS; }
+  bool isFileScope() const { return TInfoAndScope.getInt(); }
+  void setFileScope(bool FS) { TInfoAndScope.setInt(FS); }
 
   SourceLocation getLParenLoc() const { return LParenLoc; }
   void setLParenLoc(SourceLocation L) { LParenLoc = L; }
 
-  TypeSourceInfo *getTypeSourceInfo() const { return TInfo; }
-  void setTypeSourceInfo(TypeSourceInfo* tinfo) { TInfo = tinfo; }
+  TypeSourceInfo *getTypeSourceInfo() const {
+    return TInfoAndScope.getPointer();
+  }
+  void setTypeSourceInfo(TypeSourceInfo *tinfo) {
+    TInfoAndScope.setPointer(tinfo);
+  }
 
   SourceRange getSourceRange() const {
     // FIXME: Init should never be null.
@@ -3059,8 +3072,7 @@
     SubExprs[COND] = cond;
     SubExprs[LHS] = lhs;
     SubExprs[RHS] = rhs;
-
-    OpaqueValue->setSourceExpr(common);
+    assert(OpaqueValue->getSourceExpr() == common && "Wrong opaque value");
   }
 
   /// \brief Build an empty conditional operator.
@@ -3663,15 +3675,15 @@
   /// The number of designators in this initializer expression.
   unsigned NumDesignators : 15;
 
-  /// \brief The designators in this designated initialization
-  /// expression.
-  Designator *Designators;
-
   /// The number of subexpressions of this initializer expression,
   /// which contains both the initializer and any additional
   /// expressions used by array and array-range designators.
   unsigned NumSubExprs : 16;
 
+  /// \brief The designators in this designated initialization
+  /// expression.
+  Designator *Designators;
+
 
   DesignatedInitExpr(ASTContext &C, QualType Ty, unsigned NumDesignators,
                      const Designator *Designators,
@@ -3681,7 +3693,7 @@
 
   explicit DesignatedInitExpr(unsigned NumSubExprs)
     : Expr(DesignatedInitExprClass, EmptyShell()),
-      NumDesignators(0), Designators(0), NumSubExprs(NumSubExprs) { }
+      NumDesignators(0), NumSubExprs(NumSubExprs), Designators(0) { }
 
 public:
   /// A field designator, e.g., ".x".
@@ -4215,9 +4227,8 @@
 public:
   BlockExpr(BlockDecl *BD, QualType ty)
     : Expr(BlockExprClass, ty, VK_RValue, OK_Ordinary,
-           ty->isDependentType(), false,
-           // FIXME: Check for instantiate-dependence in the statement?
-           ty->isInstantiationDependentType(),
+           ty->isDependentType(), ty->isDependentType(),
+           ty->isInstantiationDependentType() || BD->isDependentContext(),
            false),
       TheBlock(BD) {}
 

Modified: cfe/branches/tooling/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ExprCXX.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ExprCXX.h (original)
+++ cfe/branches/tooling/include/clang/AST/ExprCXX.h Tue Feb 28 17:49:25 2012
@@ -736,6 +736,9 @@
                               const CXXDestructorDecl *Destructor);
 
   const CXXDestructorDecl *getDestructor() const { return Destructor; }
+  void setDestructor(const CXXDestructorDecl *Dtor) {
+    Destructor = Dtor;
+  }
 };
 
 /// \brief Represents binding an expression to a temporary.
@@ -1361,19 +1364,6 @@
 /// CXXNewExpr - A new expression for memory allocation and constructor calls,
 /// e.g: "new CXXNewExpr(foo)".
 class CXXNewExpr : public Expr {
-  // Was the usage ::new, i.e. is the global new to be used?
-  bool GlobalNew : 1;
-  // Do we allocate an array? If so, the first SubExpr is the size expression.
-  bool Array : 1;
-  // If this is an array allocation, does the usual deallocation
-  // function for the allocated type want to know the allocated size?
-  bool UsualArrayDeleteWantsSize : 1;
-  // The number of placement new arguments.
-  unsigned NumPlacementArgs : 13;
-  // What kind of initializer do we have? Could be none, parens, or braces.
-  // In storage, we distinguish between "none, and no initializer expr", and
-  // "none, but an implicit initializer expr".
-  unsigned StoredInitializationStyle : 2;
   // Contains an optional array size expression, an optional initialization
   // expression, and any number of optional placement arguments, in that order.
   Stmt **SubExprs;
@@ -1395,6 +1385,20 @@
   /// \brief Source-range of a paren-delimited initializer.
   SourceRange DirectInitRange;
 
+  // Was the usage ::new, i.e. is the global new to be used?
+  bool GlobalNew : 1;
+  // Do we allocate an array? If so, the first SubExpr is the size expression.
+  bool Array : 1;
+  // If this is an array allocation, does the usual deallocation
+  // function for the allocated type want to know the allocated size?
+  bool UsualArrayDeleteWantsSize : 1;
+  // The number of placement new arguments.
+  unsigned NumPlacementArgs : 13;
+  // What kind of initializer do we have? Could be none, parens, or braces.
+  // In storage, we distinguish between "none, and no initializer expr", and
+  // "none, but an implicit initializer expr".
+  unsigned StoredInitializationStyle : 2;
+
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
 public:
@@ -1543,6 +1547,12 @@
 /// CXXDeleteExpr - A delete expression for memory deallocation and destructor
 /// calls, e.g. "delete[] pArray".
 class CXXDeleteExpr : public Expr {
+  // Points to the operator delete overload that is used. Could be a member.
+  FunctionDecl *OperatorDelete;
+  // The pointer expression to be deleted.
+  Stmt *Argument;
+  // Location of the expression.
+  SourceLocation Loc;
   // Is this a forced global delete, i.e. "::delete"?
   bool GlobalDelete : 1;
   // Is this the array form of delete, i.e. "delete[]"?
@@ -1554,12 +1564,6 @@
   // Does the usual deallocation function for the element type require
   // a size_t argument?
   bool UsualArrayDeleteWantsSize : 1;
-  // Points to the operator delete overload that is used. Could be a member.
-  FunctionDecl *OperatorDelete;
-  // The pointer expression to be deleted.
-  Stmt *Argument;
-  // Location of the expression.
-  SourceLocation Loc;
 public:
   CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
                 bool arrayFormAsWritten, bool usualArrayDeleteWantsSize,
@@ -1567,10 +1571,10 @@
     : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false,
            arg->isInstantiationDependent(),
            arg->containsUnexpandedParameterPack()),
+      OperatorDelete(operatorDelete), Argument(arg), Loc(loc),
       GlobalDelete(globalDelete),
       ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten),
-      UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize),
-      OperatorDelete(operatorDelete), Argument(arg), Loc(loc) { }
+      UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) { }
   explicit CXXDeleteExpr(EmptyShell Shell)
     : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { }
 
@@ -1923,6 +1927,102 @@
   friend class ASTStmtReader;
 };
 
+/// \brief A type trait used in the implementation of various C++11 and
+/// Library TR1 trait templates.
+///
+/// \code
+///   __is_trivially_constructible(vector<int>, int*, int*)
+/// \endcode
+class TypeTraitExpr : public Expr {
+  /// \brief The location of the type trait keyword.
+  SourceLocation Loc;
+  
+  /// \brief  The location of the closing parenthesis.
+  SourceLocation RParenLoc;
+  
+  // Note: The TypeSourceInfos for the arguments are allocated after the
+  // TypeTraitExpr.
+  
+  TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
+                ArrayRef<TypeSourceInfo *> Args,
+                SourceLocation RParenLoc,
+                bool Value);
+
+  TypeTraitExpr(EmptyShell Empty) : Expr(TypeTraitExprClass, Empty) { }
+
+  /// \brief Retrieve the argument types.
+  TypeSourceInfo **getTypeSourceInfos() {
+    return reinterpret_cast<TypeSourceInfo **>(this+1);
+  }
+  
+  /// \brief Retrieve the argument types.
+  TypeSourceInfo * const *getTypeSourceInfos() const {
+    return reinterpret_cast<TypeSourceInfo * const*>(this+1);
+  }
+  
+public:
+  /// \brief Create a new type trait expression.
+  static TypeTraitExpr *Create(ASTContext &C, QualType T, SourceLocation Loc, 
+                               TypeTrait Kind,
+                               ArrayRef<TypeSourceInfo *> Args,
+                               SourceLocation RParenLoc,
+                               bool Value);
+
+  static TypeTraitExpr *CreateDeserialized(ASTContext &C, unsigned NumArgs);
+  
+  /// \brief Determine which type trait this expression uses.
+  TypeTrait getTrait() const {
+    return static_cast<TypeTrait>(TypeTraitExprBits.Kind);
+  }
+
+  bool getValue() const { 
+    assert(!isValueDependent()); 
+    return TypeTraitExprBits.Value; 
+  }
+  
+  /// \brief Determine the number of arguments to this type trait.
+  unsigned getNumArgs() const { return TypeTraitExprBits.NumArgs; }
+  
+  /// \brief Retrieve the Ith argument.
+  TypeSourceInfo *getArg(unsigned I) const {
+    assert(I < getNumArgs() && "Argument out-of-range");
+    return getArgs()[I];
+  }
+  
+  /// \brief Retrieve the argument types.
+  ArrayRef<TypeSourceInfo *> getArgs() const { 
+    return ArrayRef<TypeSourceInfo *>(getTypeSourceInfos(), getNumArgs());
+  }
+  
+  typedef TypeSourceInfo **arg_iterator;
+  arg_iterator arg_begin() { 
+    return getTypeSourceInfos(); 
+  }
+  arg_iterator arg_end() { 
+    return getTypeSourceInfos() + getNumArgs(); 
+  }
+
+  typedef TypeSourceInfo const * const *arg_const_iterator;
+  arg_const_iterator arg_begin() const { return getTypeSourceInfos(); }
+  arg_const_iterator arg_end() const { 
+    return getTypeSourceInfos() + getNumArgs(); 
+  }
+
+  SourceRange getSourceRange() const { return SourceRange(Loc, RParenLoc); }
+  
+  static bool classof(const Stmt *T) {
+    return T->getStmtClass() == TypeTraitExprClass;
+  }
+  static bool classof(const TypeTraitExpr *) { return true; }
+  
+  // Iterators
+  child_range children() { return child_range(); }
+  
+  friend class ASTStmtReader;
+  friend class ASTStmtWriter;
+
+};
+  
 /// ArrayTypeTraitExpr - An Embarcadero array type trait, as used in the
 /// implementation of __array_rank and __array_extent.
 /// Example:
@@ -2050,6 +2150,12 @@
 /// \brief A reference to an overloaded function set, either an
 /// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
 class OverloadExpr : public Expr {
+  /// The common name of these declarations.
+  DeclarationNameInfo NameInfo;
+
+  /// \brief The nested-name-specifier that qualifies the name, if any.
+  NestedNameSpecifierLoc QualifierLoc;
+
   /// The results.  These are undesugared, which is to say, they may
   /// include UsingShadowDecls.  Access is relative to the naming
   /// class.
@@ -2057,12 +2163,6 @@
   DeclAccessPair *Results;
   unsigned NumResults;
 
-  /// The common name of these declarations.
-  DeclarationNameInfo NameInfo;
-
-  /// \brief The nested-name-specifier that qualifies the name, if any.
-  NestedNameSpecifierLoc QualifierLoc;
-
 protected:
   /// \brief Whether the name includes info for explicit template
   /// keyword and arguments.
@@ -2087,8 +2187,8 @@
                bool KnownContainsUnexpandedParameterPack);
 
   OverloadExpr(StmtClass K, EmptyShell Empty)
-    : Expr(K, Empty), Results(0), NumResults(0),
-      QualifierLoc(), HasTemplateKWAndArgsInfo(false) { }
+    : Expr(K, Empty), QualifierLoc(), Results(0), NumResults(0),
+      HasTemplateKWAndArgsInfo(false) { }
 
   void initializeResults(ASTContext &C,
                          UnresolvedSetIterator Begin,
@@ -3427,7 +3527,7 @@
 class MaterializeTemporaryExpr : public Expr {
   /// \brief The temporary-generating expression whose value will be
   /// materialized.
- Stmt *Temporary;
+  Stmt *Temporary;
 
   friend class ASTStmtReader;
   friend class ASTStmtWriter;

Modified: cfe/branches/tooling/include/clang/AST/ExprObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ExprObjC.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ExprObjC.h (original)
+++ cfe/branches/tooling/include/clang/AST/ExprObjC.h Tue Feb 28 17:49:25 2012
@@ -176,9 +176,9 @@
 
 /// ObjCIvarRefExpr - A reference to an ObjC instance variable.
 class ObjCIvarRefExpr : public Expr {
-  class ObjCIvarDecl *D;
-  SourceLocation Loc;
+  ObjCIvarDecl *D;
   Stmt *Base;
+  SourceLocation Loc;
   bool IsArrow:1;      // True if this is "X->F", false if this is "X.F".
   bool IsFreeIvar:1;   // True if ivar reference has no base (self assumed).
 
@@ -190,7 +190,7 @@
          /*TypeDependent=*/false, base->isValueDependent(), 
          base->isInstantiationDependent(),
          base->containsUnexpandedParameterPack()), 
-    D(d), Loc(l), Base(base), IsArrow(arrow), IsFreeIvar(freeIvar) {}
+    D(d), Base(base), Loc(l), IsArrow(arrow), IsFreeIvar(freeIvar) {}
 
   explicit ObjCIvarRefExpr(EmptyShell Empty)
     : Expr(ObjCIvarRefExprClass, Empty) {}

Modified: cfe/branches/tooling/include/clang/AST/OperationKinds.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/OperationKinds.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/OperationKinds.h (original)
+++ cfe/branches/tooling/include/clang/AST/OperationKinds.h Tue Feb 28 17:49:25 2012
@@ -281,7 +281,14 @@
   /// \brief Converts from _Atomic(T) to T.
   CK_AtomicToNonAtomic,
   /// \brief Converts from T to _Atomic(T).
-  CK_NonAtomicToAtomic
+  CK_NonAtomicToAtomic,
+  
+  /// \brief Causes a block literal to by copied to the heap and then 
+  /// autoreleased.
+  ///
+  /// This particular cast kind is used for the conversion from a C++11
+  /// lambda expression to a block pointer.
+  CK_CopyAndAutoreleaseBlockObject
 };
 
 #define CK_Invalid ((CastKind) -1)

Modified: cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h Tue Feb 28 17:49:25 2012
@@ -1946,6 +1946,11 @@
     TRY_TO(TraverseTypeLoc(S->getRhsTypeSourceInfo()->getTypeLoc()));
   })
 
+DEF_TRAVERSE_STMT(TypeTraitExpr, {
+  for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
+    TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
+})
+
 DEF_TRAVERSE_STMT(ArrayTypeTraitExpr, {
     TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
   })

Modified: cfe/branches/tooling/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Stmt.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Stmt.h (original)
+++ cfe/branches/tooling/include/clang/AST/Stmt.h Tue Feb 28 17:49:25 2012
@@ -159,6 +159,29 @@
   };
   enum { NumExprBits = 16 };
 
+  class CharacterLiteralBitfields {
+    friend class CharacterLiteral;
+    unsigned : NumExprBits;
+
+    unsigned Kind : 2;
+  };
+
+  class FloatingLiteralBitfields {
+    friend class FloatingLiteral;
+    unsigned : NumExprBits;
+
+    unsigned IsIEEE : 1; // Distinguishes between PPC128 and IEEE128.
+    unsigned IsExact : 1;
+  };
+
+  class UnaryExprOrTypeTraitExprBitfields {
+    friend class UnaryExprOrTypeTraitExpr;
+    unsigned : NumExprBits;
+
+    unsigned Kind : 2;
+    unsigned IsType : 1; // true if operand is a type, false if an expression.
+  };
+
   class DeclRefExprBitfields {
     friend class DeclRefExpr;
     friend class ASTStmtReader; // deserialization
@@ -227,6 +250,24 @@
     unsigned InitializesStdInitializerList : 1;
   };
 
+  class TypeTraitExprBitfields {
+    friend class TypeTraitExpr;
+    friend class ASTStmtReader;
+    friend class ASTStmtWriter;
+    
+    unsigned : NumExprBits;
+    
+    /// \brief The kind of type trait, which is a value of a TypeTrait enumerator.
+    unsigned Kind : 8;
+    
+    /// \brief If this expression is not value-dependent, this indicates whether
+    /// the trait evaluated true or false.
+    unsigned Value : 1;
+
+    /// \brief The number of arguments to this type trait.
+    unsigned NumArgs : 32 - 8 - 1 - NumExprBits;
+  };
+  
   union {
     // FIXME: this is wasteful on 64-bit platforms.
     void *Aligner;
@@ -234,6 +275,9 @@
     StmtBitfields StmtBits;
     CompoundStmtBitfields CompoundStmtBits;
     ExprBitfields ExprBits;
+    CharacterLiteralBitfields CharacterLiteralBits;
+    FloatingLiteralBitfields FloatingLiteralBits;
+    UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits;
     DeclRefExprBitfields DeclRefExprBits;
     CastExprBitfields CastExprBits;
     CallExprBitfields CallExprBits;
@@ -241,9 +285,11 @@
     PseudoObjectExprBitfields PseudoObjectExprBits;
     ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits;
     InitListExprBitfields InitListExprBits;
+    TypeTraitExprBitfields TypeTraitExprBits;
   };
 
   friend class ASTStmtReader;
+  friend class ASTStmtWriter;
 
 public:
   // Only allow allocation of Stmts using the allocator in ASTContext
@@ -307,8 +353,8 @@
   /// dump - This does a local dump of the specified AST fragment.  It dumps the
   /// specified node and a few nodes underneath it, but not the whole subtree.
   /// This is useful in a debugger.
-  void dump() const;
-  void dump(SourceManager &SM) const;
+  LLVM_ATTRIBUTE_USED void dump() const;
+  LLVM_ATTRIBUTE_USED void dump(SourceManager &SM) const;
   void dump(raw_ostream &OS, SourceManager &SM) const;
 
   /// dumpAll - This does a dump of the specified AST fragment and all subtrees.

Modified: cfe/branches/tooling/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Type.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Type.h (original)
+++ cfe/branches/tooling/include/clang/AST/Type.h Tue Feb 28 17:49:25 2012
@@ -2698,15 +2698,15 @@
   /// ExtProtoInfo - Extra information about a function prototype.
   struct ExtProtoInfo {
     ExtProtoInfo() :
-      Variadic(false), HasTrailingReturn(false), ExceptionSpecType(EST_None),
-      TypeQuals(0), RefQualifier(RQ_None), NumExceptions(0), Exceptions(0),
-      NoexceptExpr(0), ConsumedArguments(0) {}
+      Variadic(false), HasTrailingReturn(false), TypeQuals(0),
+      ExceptionSpecType(EST_None), RefQualifier(RQ_None),
+      NumExceptions(0), Exceptions(0), NoexceptExpr(0), ConsumedArguments(0) {}
 
     FunctionType::ExtInfo ExtInfo;
-    bool Variadic;
-    bool HasTrailingReturn;
-    ExceptionSpecificationType ExceptionSpecType;
+    bool Variadic : 1;
+    bool HasTrailingReturn : 1;
     unsigned char TypeQuals;
+    ExceptionSpecificationType ExceptionSpecType;
     RefQualifierKind RefQualifier;
     unsigned NumExceptions;
     const QualType *Exceptions;

Modified: cfe/branches/tooling/include/clang/Analysis/Analyses/FormatString.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Analysis/Analyses/FormatString.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Analysis/Analyses/FormatString.h (original)
+++ cfe/branches/tooling/include/clang/Analysis/Analyses/FormatString.h Tue Feb 28 17:49:25 2012
@@ -348,6 +348,12 @@
   bool usesPositionalArg() const { return UsesPositionalArg; }
 
   bool hasValidLengthModifier() const;
+
+  bool hasStandardLengthModifier() const;
+
+  bool hasStandardConversionSpecifier(const LangOptions &LangOpt) const;
+
+  bool hasStandardLengthConversionCombination() const;
 };
 
 } // end analyze_format_string namespace

Removed: cfe/branches/tooling/include/clang/Analysis/Support/SaveAndRestore.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Analysis/Support/SaveAndRestore.h?rev=151670&view=auto
==============================================================================
--- cfe/branches/tooling/include/clang/Analysis/Support/SaveAndRestore.h (original)
+++ cfe/branches/tooling/include/clang/Analysis/Support/SaveAndRestore.h (removed)
@@ -1,47 +0,0 @@
-//===-- SaveAndRestore.h - Utility  -------------------------------*- C++ -*-=//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file provides utility classes that uses RAII to save and restore
-//  values.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_ANALYSIS_SAVERESTORE
-#define LLVM_CLANG_ANALYSIS_SAVERESTORE
-
-namespace clang {
-
-// SaveAndRestore - A utility class that uses RAII to save and restore
-//  the value of a variable.
-template<typename T>
-struct SaveAndRestore {
-  SaveAndRestore(T& x) : X(x), old_value(x) {}
-  SaveAndRestore(T& x, const T &new_value) : X(x), old_value(x) {
-    X = new_value;
-  }
-  ~SaveAndRestore() { X = old_value; }
-  T get() { return old_value; }
-private:
-  T& X;
-  T old_value;
-};
-
-// SaveOr - Similar to SaveAndRestore.  Operates only on bools; the old
-//  value of a variable is saved, and during the dstor the old value is
-//  or'ed with the new value.
-struct SaveOr {
-  SaveOr(bool& x) : X(x), old_value(x) { x = false; }
-  ~SaveOr() { X |= old_value; }
-private:
-  bool& X;
-  const bool old_value;
-};
-
-}
-#endif

Modified: cfe/branches/tooling/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/Diagnostic.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/Diagnostic.h (original)
+++ cfe/branches/tooling/include/clang/Basic/Diagnostic.h Tue Feb 28 17:49:25 2012
@@ -289,7 +289,7 @@
       unsigned NumPrevArgs,
       SmallVectorImpl<char> &Output,
       void *Cookie,
-      SmallVectorImpl<intptr_t> &QualTypeVals);
+      ArrayRef<intptr_t> QualTypeVals);
   void *ArgToStringCookie;
   ArgToStringFnTy ArgToStringFn;
 

Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td Tue Feb 28 17:49:25 2012
@@ -107,6 +107,11 @@
   "see all)">;
 def note_constexpr_call_here : Note<"in call to '%0'">;
 
+// FIXME: See EvalInfo::IntExprEvaluatorDepth.
+def err_intexpr_depth_limit_exceeded : Error<
+  "integer expression evaluation exceeded maximum sub-expression depth">,
+  DefaultFatal; // avoid emitting it multiple times for the same parent expr.
+
 // inline asm related.
 let CategoryName = "Inline Assembly Issue" in {
   def err_asm_invalid_escape : Error<

Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td Tue Feb 28 17:49:25 2012
@@ -105,6 +105,9 @@
 def warn_drv_unused_argument : Warning<
   "argument unused during compilation: '%0'">,
   InGroup<DiagGroup<"unused-command-line-argument">>;
+def warn_drv_empty_joined_argument : Warning<
+  "joined argument expects addition arg: '%0'">,
+  InGroup<DiagGroup<"unused-command-line-argument">>;
 def warn_drv_not_using_clang_cpp : Warning<
   "not using the clang preprocessor due to user override">;
 def warn_drv_not_using_clang_cxx : Warning<

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=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td Tue Feb 28 17:49:25 2012
@@ -244,6 +244,7 @@
 def VexingParse : DiagGroup<"vexing-parse">;
 def VLA : DiagGroup<"vla">;
 def VolatileRegisterVar : DiagGroup<"volatile-register-var">;
+def Visibility : DiagGroup<"visibility">;
 
 // GCC calls -Wdeprecated-writable-strings -Wwrite-strings.
 def GCCWriteStrings : DiagGroup<"write-strings" , [DeprecatedWritableStr]>;
@@ -290,6 +291,7 @@
 // Format settings.
 def FormatInvalidSpecifier : DiagGroup<"format-invalid-specifier">;
 def FormatSecurity : DiagGroup<"format-security">;
+def FormatNonStandard : DiagGroup<"format-non-standard">;
 def FormatY2K : DiagGroup<"format-y2k">;
 def Format : DiagGroup<"format",
                        [FormatExtraArgs, FormatZeroLength, NonNull,

Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td Tue Feb 28 17:49:25 2012
@@ -223,10 +223,8 @@
 def warn_cxx98_compat_inline_namespace : Warning<
   "inline namespaces are incompatible with C++98">,
   InGroup<CXX98Compat>, DefaultIgnore;
-def err_generalized_initializer_lists : Error<
-  "generalized initializer lists are a C++11 extension unsupported in Clang">;
 def ext_generalized_initializer_lists : ExtWarn<
-  "generalized initializer lists are a C++11 extension unsupported in Clang">,
+  "generalized initializer lists are a C++11 extension">,
   InGroup<CXX11>;
 def warn_cxx98_compat_generalized_initializer_lists : Warning<
   "generalized initializer lists are incompatible with C++98">,
@@ -256,6 +254,9 @@
   "C requires a comma prior to the ellipsis in a variadic function type">;
 def err_unexpected_typedef_ident : Error<
   "unexpected type name %0: expected identifier">;
+def warn_cxx98_compat_decltype : Warning<
+  "'decltype' type specifier is incompatible with C++98">,
+  InGroup<CXX98Compat>, DefaultIgnore;
 def err_unexpected_scope_on_base_decltype : Error<
   "unexpected namespace scope prior to decltype">;
 def err_expected_class_name : Error<"expected class name">;
@@ -381,8 +382,10 @@
   "function definition does not declare parameters">;
 def err_expected_lparen_after_type : Error<
   "expected '(' for function-style cast or type construction">;
-def err_expected_equal_after_declarator : Error<
-  "expected '=' after declarator">;
+def err_expected_init_in_condition : Error<
+  "variable declaration in condition must have an initializer">;
+def err_expected_init_in_condition_lparen : Error<
+  "variable declaration in condition cannot have a parenthesized initializer">;
 def warn_parens_disambiguated_as_function_decl : Warning<
   "parentheses were disambiguated as a function declarator">,
   InGroup<VexingParse>;

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=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td Tue Feb 28 17:49:25 2012
@@ -132,7 +132,11 @@
 def warn_unused_exception_param : Warning<"unused exception parameter %0">,
   InGroup<UnusedExceptionParameter>, DefaultIgnore;
 def warn_decl_in_param_list : Warning<
-  "declaration of %0 will not be visible outside of this function">;
+  "declaration of %0 will not be visible outside of this function">,
+  InGroup<Visibility>;
+def warn_redefinition_in_param_list : Warning<
+  "redefinition of %0 will not be visible outside of this function">,
+  InGroup<Visibility>;
 def warn_empty_parens_are_function_decl : Warning<
   "empty parentheses interpreted as a function declaration">,
   InGroup<VexingParse>;
@@ -538,7 +542,7 @@
   "multiple methods named %0 found">, InGroup<StrictSelector>, DefaultIgnore;
 def warn_accessor_property_type_mismatch : Warning<
   "type of property %0 does not match type of accessor %1">;
-def note_method_declared_at : Note<"method declared here">;
+def note_method_declared_at : Note<"method %0 declared here">;
 def err_setter_type_void : Error<"type of setter must be void">;
 def err_duplicate_method_decl : Error<"duplicate declaration of method %0">;
 def warn_duplicate_method_decl : 
@@ -679,7 +683,7 @@
 def warn_unimplemented_selector:  Warning<
   "unimplemented selector %0">, InGroup<Selector>, DefaultIgnore;
 def warn_unimplemented_protocol_method : Warning<
-  "method in protocol not implemented">, InGroup<Protocol>;
+  "method %0 in protocol not implemented">, InGroup<Protocol>;
 
 // C++ declarations
 def err_static_assert_expression_is_not_constant : Error<
@@ -1176,9 +1180,6 @@
   InGroup<CXX98CompatBindToTemporaryCopy>, DefaultIgnore;
 
 // C++11 decltype
-def warn_cxx98_compat_decltype : Warning<
-  "'decltype' type specifier is incompatible with C++98">,
-  InGroup<CXX98Compat>, DefaultIgnore;
 def err_decltype_in_declarator : Error<
     "'decltype' cannot be used to name a declaration">;
     
@@ -3625,6 +3626,8 @@
   "comparison of distinct pointer types (%0 and %1)">;
 def ext_typecheck_cond_incompatible_operands : ExtWarn<
   "incompatible operand types (%0 and %1)">;
+def err_cond_voidptr_arc : Error <
+  "operands to conditional of types %0 and %1 are incompatible in ARC mode">;
 def err_typecheck_comparison_of_distinct_pointers : Error<
   "comparison of distinct pointer types (%0 and %1)">;
 def ext_typecheck_comparison_of_distinct_pointers_nonstandard : ExtWarn<
@@ -3671,6 +3674,9 @@
 
 def err_invalid_non_static_member_use : Error<
   "invalid use of nonstatic data member %0">;
+def warn_cxx98_compat_non_static_member_use : Warning<
+  "use of non-static data member %0 in an unevaluated context is "
+  "incompatible with C++98">, InGroup<CXX98Compat>, DefaultIgnore;
 def err_invalid_incomplete_type_use : Error<
   "invalid use of incomplete type %0">;
 def err_builtin_func_cast_more_than_one_arg : Error<
@@ -4438,6 +4444,10 @@
 
 def err_incomplete_type_used_in_type_trait_expr : Error<
   "incomplete type %0 used in type trait expression">;
+def err_type_trait_arity : Error<
+  "type trait requires %0%select{| or more}1 argument%select{|s}2; have "
+  "%3 argument%s3">;
+  
 def err_dimension_expr_not_constant_integer : Error<
   "dimension expression does not evaluate to a constant unsigned int">;
 def err_expected_ident_or_lparen : Error<"expected identifier or '('">;
@@ -4847,6 +4857,11 @@
 def warn_format_nonsensical_length: Warning<
   "length modifier '%0' results in undefined behavior or no effect with '%1' conversion specifier">,
   InGroup<Format>;
+def warn_format_non_standard: ExtWarn<
+  "'%0' is a non-standard %1">, InGroup<FormatNonStandard>, DefaultIgnore;
+def warn_format_non_standard_conversion_spec: ExtWarn<
+  "using the length modifier '%0' with the conversion specifier '%1' is non-standard">,
+  InGroup<FormatNonStandard>, DefaultIgnore;
 def warn_printf_ignored_flag: Warning<
   "flag '%0' is ignored when flag '%1' is present">,
   InGroup<Format>;
@@ -5052,6 +5067,9 @@
   DefaultError, InGroup<ReturnType>;
 def ext_return_has_void_expr : Extension<
   "void %select{function|method}1 %0 should not return void expression">;
+def err_return_init_list : Error<
+  "%select{void function|void method|constructor|destructor}1 %0 "
+  "must not return a value">;
 def warn_noreturn_function_has_return_expr : Warning<
   "function %0 declared 'noreturn' should not return">,
   InGroup<DiagGroup<"invalid-noreturn">>;

Modified: cfe/branches/tooling/include/clang/Basic/LLVM.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/LLVM.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/LLVM.h (original)
+++ cfe/branches/tooling/include/clang/Basic/LLVM.h Tue Feb 28 17:49:25 2012
@@ -29,6 +29,9 @@
   template<typename T, unsigned N> class SmallVector;
   template<typename T> class SmallVectorImpl;
 
+  template<typename T>
+  struct SaveAndRestore;
+
   // Reference counting.
   template <typename T> class IntrusiveRefCntPtr;
   template <typename T> struct IntrusiveRefCntPtrInfo;
@@ -56,6 +59,7 @@
   using llvm::SmallString;
   using llvm::SmallVector;
   using llvm::SmallVectorImpl;
+  using llvm::SaveAndRestore;
 
   // Reference counting.
   using llvm::IntrusiveRefCntPtr;

Modified: cfe/branches/tooling/include/clang/Basic/SourceLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/SourceLocation.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/SourceLocation.h (original)
+++ cfe/branches/tooling/include/clang/Basic/SourceLocation.h Tue Feb 28 17:49:25 2012
@@ -325,7 +325,7 @@
 
   /// Prints information about this FullSourceLoc to stderr. Useful for
   ///  debugging.
-  LLVM_ATTRIBUTE_USED void dump() const { SourceLocation::dump(*SrcMgr); }
+  LLVM_ATTRIBUTE_USED void dump() const;
 
   friend inline bool
   operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS) {

Modified: cfe/branches/tooling/include/clang/Basic/StmtNodes.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/StmtNodes.td?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/StmtNodes.td (original)
+++ cfe/branches/tooling/include/clang/Basic/StmtNodes.td Tue Feb 28 17:49:25 2012
@@ -107,6 +107,7 @@
 def CXXNewExpr : DStmt<Expr>;
 def CXXDeleteExpr : DStmt<Expr>;
 def CXXPseudoDestructorExpr : DStmt<Expr>;
+def TypeTraitExpr : DStmt<Expr>;
 def UnaryTypeTraitExpr : DStmt<Expr>;
 def BinaryTypeTraitExpr : DStmt<Expr>;
 def ArrayTypeTraitExpr : DStmt<Expr>;

Modified: cfe/branches/tooling/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/TokenKinds.def?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/TokenKinds.def (original)
+++ cfe/branches/tooling/include/clang/Basic/TokenKinds.def Tue Feb 28 17:49:25 2012
@@ -365,7 +365,9 @@
 KEYWORD(__is_union                  , KEYCXX)
 
 // Clang-only C++ Type Traits
+KEYWORD(__is_trivially_constructible, KEYCXX)
 KEYWORD(__is_trivially_copyable     , KEYCXX)
+KEYWORD(__is_trivially_assignable   , KEYCXX)
 KEYWORD(__underlying_type           , KEYCXX)
 
 // Embarcadero Expression Traits
@@ -573,6 +575,11 @@
 // handles them.
 ANNOTATION(pragma_vis)
 
+// Annotation for #pragma pack...
+// The lexer produces these so that they only take effect when the parser
+// handles them.
+ANNOTATION(pragma_pack)
+
 #undef ANNOTATION
 #undef TESTING_KEYWORD
 #undef OBJC2_AT_KEYWORD

Modified: cfe/branches/tooling/include/clang/Basic/TypeTraits.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/TypeTraits.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/TypeTraits.h (original)
+++ cfe/branches/tooling/include/clang/Basic/TypeTraits.h Tue Feb 28 17:49:25 2012
@@ -68,7 +68,8 @@
     BTT_IsConvertible,
     BTT_IsConvertibleTo,
     BTT_IsSame,
-    BTT_TypeCompatible
+    BTT_TypeCompatible,
+    BTT_IsTriviallyAssignable
   };
 
   /// ArrayTypeTrait - Names for the array type traits.
@@ -83,6 +84,12 @@
     UETT_AlignOf,
     UETT_VecStep
   };
+  
+  /// \brief Names for type traits that operate specifically on types.
+  enum TypeTrait {
+    TT_IsTriviallyConstructible
+  };
+  
 }
 
 #endif

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=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/CC1Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/CC1Options.td Tue Feb 28 17:49:25 2012
@@ -86,6 +86,8 @@
   HelpText<"The maximum number of nodes the analyzer can generate (150000 default, 0 = no limit)">;
 def analyzer_max_loop : Separate<"-analyzer-max-loop">,
   HelpText<"The maximum number of times the analyzer will go through a loop">;
+def analyzer_stats : Flag<"-analyzer-stats">,
+  HelpText<"Print internal analyzer statistics.">;
 
 def analyzer_checker : Separate<"-analyzer-checker">,
   HelpText<"Choose analyzer checkers to enable">;

Modified: cfe/branches/tooling/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/Options.td?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/Options.td Tue Feb 28 17:49:25 2012
@@ -292,6 +292,7 @@
 def fconstexpr_depth_EQ : Joined<"-fconstexpr-depth=">, Group<f_Group>;
 def fconstexpr_backtrace_limit_EQ : Joined<"-fconstexpr-backtrace-limit=">,
                                     Group<f_Group>;
+def fno_crash_diagnostics : Flag<"-fno-crash-diagnostics">, Group<f_clang_Group>, Flags<[NoArgumentUnused]>;
 def fcreate_profile : Flag<"-fcreate-profile">, Group<f_Group>;
 def fcxx_exceptions: Flag<"-fcxx-exceptions">, Group<f_Group>;
 def fcxx_modules : Flag <"-fcxx-modules">, Group<f_Group>, Flags<[NoForward]>;
@@ -544,9 +545,11 @@
 def fdata_sections : Flag <"-fdata-sections">, Group<f_Group>;
 def f : Joined<"-f">, Group<f_Group>;
 def g0 : Flag<"-g0">, Group<g_Group>;
+def g2 : Flag<"-g2">, Group<g_Group>;
 def g3 : Flag<"-g3">, Group<g_Group>;
 def gdwarf2 : Flag<"-gdwarf-2">, Group<g_Group>;
 def gfull : Flag<"-gfull">, Group<g_Group>;
+def ggdb : Flag<"-ggdb">, Group<g_Group>;
 def gstabs : Flag<"-gstabs">, Group<g_Group>;
 def gstabsplus : Flag<"-gstabs+">, Group<g_Group>;
 def gstabs1 : Flag<"-gstabs1">, Group<g_Group>;

Modified: cfe/branches/tooling/include/clang/Frontend/ASTUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/ASTUnit.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/ASTUnit.h Tue Feb 28 17:49:25 2012
@@ -258,10 +258,6 @@
   
   /// \brief Whether we should be caching code-completion results.
   bool ShouldCacheCodeCompletionResults;
-  
-  /// \brief Whether we want to include nested macro expansions in the
-  /// detailed preprocessing record.
-  bool NestedMacroExpansions;
  
   /// \brief The language options used when we load an AST file.
   LangOptions ASTFileLangOpts;
@@ -707,8 +703,7 @@
                                              bool CaptureDiagnostics = false,
                                              bool PrecompilePreamble = false,
                                       TranslationUnitKind TUKind = TU_Complete,
-                                       bool CacheCodeCompletionResults = false,
-                                       bool NestedMacroExpansions = true);
+                                       bool CacheCodeCompletionResults = false);
 
   /// LoadFromCommandLine - Create an ASTUnit from a vector of command line
   /// arguments, which must specify exactly one source file.
@@ -735,8 +730,7 @@
                                       bool RemappedFilesKeepOriginalName = true,
                                       bool PrecompilePreamble = false,
                                       TranslationUnitKind TUKind = TU_Complete,
-                                      bool CacheCodeCompletionResults = false,
-                                      bool NestedMacroExpansions = true);
+                                      bool CacheCodeCompletionResults = false);
   
   /// \brief Reparse the source files using the same command-line options that
   /// were originally used to produce this translation unit.

Modified: cfe/branches/tooling/include/clang/Frontend/AnalyzerOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/AnalyzerOptions.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/AnalyzerOptions.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/AnalyzerOptions.h Tue Feb 28 17:49:25 2012
@@ -84,6 +84,7 @@
   unsigned CFGAddImplicitDtors : 1;
   unsigned CFGAddInitializers : 1;
   unsigned EagerlyTrimEGraph : 1;
+  unsigned PrintStats : 1;
 
 public:
   AnalyzerOptions() {
@@ -104,6 +105,7 @@
     CFGAddImplicitDtors = 0;
     CFGAddInitializers = 0;
     EagerlyTrimEGraph = 0;
+    PrintStats = 0;
   }
 };
 

Modified: cfe/branches/tooling/include/clang/Frontend/PreprocessorOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/PreprocessorOptions.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/PreprocessorOptions.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/PreprocessorOptions.h Tue Feb 28 17:49:25 2012
@@ -50,10 +50,6 @@
                                /// record of all macro definitions and
                                /// expansions.
   
-  /// \brief Whether the detailed preprocessing record includes nested macro 
-  /// expansions.
-  unsigned DetailedRecordIncludesNestedMacroExpansions : 1;
-  
   /// The implicit PCH included at the start of the translation unit, or empty.
   std::string ImplicitPCHInclude;
 
@@ -162,7 +158,6 @@
   
 public:
   PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
-                          DetailedRecordIncludesNestedMacroExpansions(false),
                           DisablePCHValidation(false), DisableStatCache(false),
                           DumpDeserializedPCHDecls(false),
                           PrecompiledPreambleBytes(0, true),

Modified: cfe/branches/tooling/include/clang/Lex/PreprocessingRecord.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/PreprocessingRecord.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/PreprocessingRecord.h (original)
+++ cfe/branches/tooling/include/clang/Lex/PreprocessingRecord.h Tue Feb 28 17:49:25 2012
@@ -284,10 +284,6 @@
   /// expanded, etc.
   class PreprocessingRecord : public PPCallbacks {
     SourceManager &SourceMgr;
-
-    /// \brief Whether we should include nested macro expansions in
-    /// the preprocessing record.
-    bool IncludeNestedMacroExpansions;
     
     /// \brief Allocator used to store preprocessing objects.
     llvm::BumpPtrAllocator BumpAlloc;
@@ -353,7 +349,7 @@
     
   public:
     /// \brief Construct a new preprocessing record.
-    PreprocessingRecord(SourceManager &SM, bool IncludeNestedMacroExpansions);
+    explicit PreprocessingRecord(SourceManager &SM);
     
     /// \brief Allocate memory in the preprocessing record.
     void *Allocate(unsigned Size, unsigned Align = 8) {

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=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/Preprocessor.h (original)
+++ cfe/branches/tooling/include/clang/Lex/Preprocessor.h Tue Feb 28 17:49:25 2012
@@ -512,7 +512,7 @@
 
   /// \brief Create a new preprocessing record, which will keep track of
   /// all macro expansions, macro definitions, etc.
-  void createPreprocessingRecord(bool IncludeNestedMacroExpansions);
+  void createPreprocessingRecord();
 
   /// EnterMainSourceFile - Enter the specified FileID as the main source file,
   /// which implicitly adds the builtin defines etc.

Modified: cfe/branches/tooling/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Parse/Parser.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Parse/Parser.h (original)
+++ cfe/branches/tooling/include/clang/Parse/Parser.h Tue Feb 28 17:49:25 2012
@@ -410,6 +410,10 @@
   /// #pragma GCC visibility...
   void HandlePragmaVisibility();
 
+  /// \brief Handle the annotation token produced for
+  /// #pragma pack...
+  void HandlePragmaPack();
+
   /// GetLookAheadToken - This peeks ahead N tokens and returns that token
   /// without consuming any tokens.  LookAhead(0) returns 'Tok', LookAhead(1)
   /// returns the token after Tok, etc.
@@ -1288,7 +1292,7 @@
   };
 
   ExprResult ParseExpression(TypeCastState isTypeCast = NotTypeCast);
-  ExprResult ParseConstantExpression();
+  ExprResult ParseConstantExpression(TypeCastState isTypeCast = NotTypeCast);
   // Expr that doesn't include commas.
   ExprResult ParseAssignmentExpression(TypeCastState isTypeCast = NotTypeCast);
 
@@ -1332,8 +1336,7 @@
                            SmallVectorImpl<SourceLocation> &CommaLocs,
                            void (Sema::*Completer)(Scope *S,
                                                    Expr *Data,
-                                                   Expr **Args,
-                                                   unsigned NumArgs) = 0,
+                                             llvm::ArrayRef<Expr *> Args) = 0,
                            Expr *Data = 0);
 
   /// ParenParseOption - Control what ParseParenExpression will parse.
@@ -1828,9 +1831,11 @@
   /// declaration specifier, TPResult::False() if it is not,
   /// TPResult::Ambiguous() if it could be either a decl-specifier or a
   /// function-style cast, and TPResult::Error() if a parsing error was
-  /// encountered.
+  /// encountered. If it could be a braced C++11 function-style cast, returns
+  /// BracedCastResult.
   /// Doesn't consume tokens.
-  TPResult isCXXDeclarationSpecifier();
+  TPResult
+  isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False());
 
   // "Tentative parsing" functions, used for disambiguation. If a parsing error
   // is encountered they will return TPResult::Error().
@@ -2164,7 +2169,8 @@
   // GNU G++: Type Traits [Type-Traits.html in the GCC manual]
   ExprResult ParseUnaryTypeTrait();
   ExprResult ParseBinaryTypeTrait();
-
+  ExprResult ParseTypeTrait();
+  
   //===--------------------------------------------------------------------===//
   // Embarcadero: Arary and Expression Traits
   ExprResult ParseArrayTypeTrait();

Modified: cfe/branches/tooling/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/DeclSpec.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/DeclSpec.h (original)
+++ cfe/branches/tooling/include/clang/Sema/DeclSpec.h Tue Feb 28 17:49:25 2012
@@ -1645,9 +1645,14 @@
     case ForContext:
       return true;
 
+    case ConditionContext:
+      // This may not be followed by a direct initializer, but it can't be a
+      // function declaration either, and we'd prefer to perform a tentative
+      // parse in order to produce the right diagnostic.
+      return true;
+
     case KNRTypeListContext:
     case MemberContext:
-    case ConditionContext:
     case PrototypeContext:
     case ObjCParameterContext:
     case ObjCResultContext:

Modified: cfe/branches/tooling/include/clang/Sema/Initialization.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Initialization.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Initialization.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Initialization.h Tue Feb 28 17:49:25 2012
@@ -365,17 +365,18 @@
 public:
   /// \brief The kind of initialization being performed.
   enum InitKind {
-    IK_Direct,     ///< Direct initialization
-    IK_DirectList, ///< Direct list-initialization
-    IK_Copy,       ///< Copy initialization
-    IK_Default,    ///< Default initialization
-    IK_Value       ///< Value initialization
+    IK_Direct,       ///< Direct initialization
+    IK_DirectList,   ///< Direct list-initialization
+    IK_Copy,         ///< Copy initialization
+    IK_Default,      ///< Default initialization
+    IK_Value         ///< Value initialization
   };
   
 private:
   /// \brief The context of the initialization.
   enum InitContext {
     IC_Normal,         ///< Normal context
+    IC_ExplicitConvs,  ///< Normal context, but allows explicit conversion funcs
     IC_Implicit,       ///< Implicit context (value initialization)
     IC_StaticCast,     ///< Static cast context
     IC_CStyleCast,     ///< C-style cast context
@@ -442,8 +443,11 @@
 
   /// \brief Create a copy initialization.
   static InitializationKind CreateCopy(SourceLocation InitLoc,
-                                       SourceLocation EqualLoc) {
-    return InitializationKind(IK_Copy, IC_Normal, InitLoc, EqualLoc, EqualLoc);
+                                       SourceLocation EqualLoc,
+                                       bool AllowExplicitConvs = false) {
+    return InitializationKind(IK_Copy, 
+                              AllowExplicitConvs? IC_ExplicitConvs : IC_Normal,
+                              InitLoc, EqualLoc, EqualLoc);
   }
   
   /// \brief Create a default initialization.
@@ -511,6 +515,12 @@
   ///        constructors.
   bool AllowExplicit() const { return !isCopyInit(); }
 
+  /// \brief Retrieve whether this initialization allows the use of explicit
+  /// conversion functions.
+  bool allowExplicitConversionFunctions() const {
+    return !isCopyInit() || Context == IC_ExplicitConvs;
+  }
+  
   /// \brief Retrieve the source range containing the locations of the open
   /// and closing parentheses for value and direct initializations.
   SourceRange getParenRange() const {

Modified: cfe/branches/tooling/include/clang/Sema/Overload.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Overload.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Overload.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Overload.h Tue Feb 28 17:49:25 2012
@@ -401,11 +401,15 @@
     };
 
     /// ConversionKind - The kind of implicit conversion sequence.
-    unsigned ConversionKind : 31;
+    unsigned ConversionKind : 30;
 
     /// \brief Whether the argument is an initializer list.
     bool ListInitializationSequence : 1;
 
+    /// \brief Whether the target is really a std::initializer_list, and the
+    /// sequence only represents the worst element conversion.
+    bool StdInitializerListElement : 1;
+
     void setKind(Kind K) {
       destruct();
       ConversionKind = K;
@@ -435,13 +439,16 @@
     };
 
     ImplicitConversionSequence() 
-      : ConversionKind(Uninitialized), ListInitializationSequence(false) {}
+      : ConversionKind(Uninitialized), ListInitializationSequence(false),
+        StdInitializerListElement(false)
+    {}
     ~ImplicitConversionSequence() {
       destruct();
     }
     ImplicitConversionSequence(const ImplicitConversionSequence &Other)
       : ConversionKind(Other.ConversionKind), 
-        ListInitializationSequence(Other.ListInitializationSequence)
+        ListInitializationSequence(Other.ListInitializationSequence),
+        StdInitializerListElement(Other.StdInitializerListElement)
     {
       switch (ConversionKind) {
       case Uninitialized: break;
@@ -536,6 +543,16 @@
       ListInitializationSequence = true;
     }
 
+    /// \brief Whether the target is really a std::initializer_list, and the
+    /// sequence only represents the worst element conversion.
+    bool isStdInitializerListElement() const {
+      return StdInitializerListElement;
+    }
+
+    void setStdInitializerListElement(bool V = true) {
+      StdInitializerListElement = V;
+    }
+
     // The result of a comparison between implicit conversion
     // sequences. Use Sema::CompareImplicitConversionSequences to
     // actually perform the comparison.
@@ -780,7 +797,7 @@
 
     void NoteCandidates(Sema &S,
                         OverloadCandidateDisplayKind OCD,
-                        Expr **Args, unsigned NumArgs,
+                        llvm::ArrayRef<Expr *> Args,
                         const char *Opc = 0,
                         SourceLocation Loc = SourceLocation());
   };

Modified: cfe/branches/tooling/include/clang/Sema/Scope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Scope.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Scope.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Scope.h Tue Feb 28 17:49:25 2012
@@ -297,6 +297,10 @@
   /// \brief Determine whether this scope is a C++ 'try' block.
   bool isTryScope() const { return getFlags() & Scope::TryScope; }
 
+  /// containedInPrototypeScope - Return true if this or a parent scope
+  /// is a FunctionPrototypeScope.
+  bool containedInPrototypeScope() const;
+
   typedef UsingDirectivesTy::iterator udir_iterator;
   typedef UsingDirectivesTy::const_iterator const_udir_iterator;
 

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=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Sema.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Sema.h Tue Feb 28 17:49:25 2012
@@ -59,6 +59,7 @@
   class BlockDecl;
   class CXXBasePath;
   class CXXBasePaths;
+  class CXXBindTemporaryExpr;
   typedef SmallVector<CXXBaseSpecifier*, 4> CXXCastPath;
   class CXXConstructorDecl;
   class CXXConversionDecl;
@@ -562,6 +563,9 @@
     /// \brief Whether the enclosing context needed a cleanup.
     bool ParentNeedsCleanups;
 
+    /// \brief Whether we are in a decltype expression.
+    bool IsDecltype;
+
     /// \brief The number of active cleanup objects when we entered
     /// this expression evaluation context.
     unsigned NumCleanupObjects;
@@ -583,13 +587,22 @@
     /// This mangling information is allocated lazily, since most contexts
     /// do not have lambda expressions.
     LambdaMangleContext *LambdaMangle;
+
+    /// \brief If we are processing a decltype type, a set of call expressions
+    /// for which we have deferred checking the completeness of the return type.
+    llvm::SmallVector<CallExpr*, 8> DelayedDecltypeCalls;
+
+    /// \brief If we are processing a decltype type, a set of temporary binding
+    /// expressions for which we have deferred checking the destructor.
+    llvm::SmallVector<CXXBindTemporaryExpr*, 8> DelayedDecltypeBinds;
     
     ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context,
                                       unsigned NumCleanupObjects,
                                       bool ParentNeedsCleanups,
-                                      Decl *LambdaContextDecl)
+                                      Decl *LambdaContextDecl,
+                                      bool IsDecltype)
       : Context(Context), ParentNeedsCleanups(ParentNeedsCleanups),
-        NumCleanupObjects(NumCleanupObjects), 
+        IsDecltype(IsDecltype), NumCleanupObjects(NumCleanupObjects),
         LambdaContextDecl(LambdaContextDecl), LambdaMangle() { }
     
     ~ExpressionEvaluationContextRecord() {
@@ -889,6 +902,13 @@
   // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
   //
 
+  /// List of decls defined in a function prototype. This contains EnumConstants
+  /// that incorrectly end up in translation unit scope because there is no
+  /// function to pin them on. ActOnFunctionDeclarator reads this list and patches
+  /// them into the FunctionDecl.
+  std::vector<NamedDecl*> DeclsInPrototypeScope;
+  bool InFunctionDeclarator;
+
   DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = 0);
 
   void DiagnoseUseOfUnimplementedSelectors();
@@ -1035,6 +1055,7 @@
   // Returns true if the variable declaration is a redeclaration
   bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
   void CheckCompleteVariableDeclaration(VarDecl *var);
+  void ActOnStartFunctionDeclarator();
   NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
                                      TypeSourceInfo *TInfo,
                                      LookupResult &Previous,
@@ -1445,7 +1466,8 @@
   ExprResult PerformCopyInitialization(const InitializedEntity &Entity,
                                        SourceLocation EqualLoc,
                                        ExprResult Init,
-                                       bool TopLevelOfInitList = false);
+                                       bool TopLevelOfInitList = false,
+                                       bool AllowExplicit = false);
   ExprResult PerformObjectArgumentInitialization(Expr *From,
                                                  NestedNameSpecifier *Qualifier,
                                                  NamedDecl *FoundDecl,
@@ -1486,12 +1508,13 @@
 
   void AddOverloadCandidate(FunctionDecl *Function,
                             DeclAccessPair FoundDecl,
-                            Expr **Args, unsigned NumArgs,
+                            llvm::ArrayRef<Expr *> Args,
                             OverloadCandidateSet& CandidateSet,
                             bool SuppressUserConversions = false,
-                            bool PartialOverloading = false);
+                            bool PartialOverloading = false,
+                            bool AllowExplicit = false);
   void AddFunctionCandidates(const UnresolvedSetImpl &Functions,
-                             Expr **Args, unsigned NumArgs,
+                             llvm::ArrayRef<Expr *> Args,
                              OverloadCandidateSet& CandidateSet,
                              bool SuppressUserConversions = false);
   void AddMethodCandidate(DeclAccessPair FoundDecl,
@@ -1504,7 +1527,7 @@
                           DeclAccessPair FoundDecl,
                           CXXRecordDecl *ActingContext, QualType ObjectType,
                           Expr::Classification ObjectClassification,
-                          Expr **Args, unsigned NumArgs,
+                          llvm::ArrayRef<Expr *> Args,
                           OverloadCandidateSet& CandidateSet,
                           bool SuppressUserConversions = false);
   void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
@@ -1513,13 +1536,13 @@
                                  TemplateArgumentListInfo *ExplicitTemplateArgs,
                                   QualType ObjectType,
                                   Expr::Classification ObjectClassification,
-                                  Expr **Args, unsigned NumArgs,
+                                  llvm::ArrayRef<Expr *> Args,
                                   OverloadCandidateSet& CandidateSet,
                                   bool SuppressUserConversions = false);
   void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
                                     DeclAccessPair FoundDecl,
                                  TemplateArgumentListInfo *ExplicitTemplateArgs,
-                                    Expr **Args, unsigned NumArgs,
+                                    llvm::ArrayRef<Expr *> Args,
                                     OverloadCandidateSet& CandidateSet,
                                     bool SuppressUserConversions = false);
   void AddConversionCandidate(CXXConversionDecl *Conversion,
@@ -1536,7 +1559,7 @@
                              DeclAccessPair FoundDecl,
                              CXXRecordDecl *ActingContext,
                              const FunctionProtoType *Proto,
-                             Expr *Object, Expr **Args, unsigned NumArgs,
+                             Expr *Object, llvm::ArrayRef<Expr*> Args,
                              OverloadCandidateSet& CandidateSet);
   void AddMemberOperatorCandidates(OverloadedOperatorKind Op,
                                    SourceLocation OpLoc,
@@ -1553,8 +1576,8 @@
                                     Expr **Args, unsigned NumArgs,
                                     OverloadCandidateSet& CandidateSet);
   void AddArgumentDependentLookupCandidates(DeclarationName Name,
-                                            bool Operator,
-                                            Expr **Args, unsigned NumArgs,
+                                            bool Operator, SourceLocation Loc,
+                                            llvm::ArrayRef<Expr *> Args,
                                 TemplateArgumentListInfo *ExplicitTemplateArgs,
                                             OverloadCandidateSet& CandidateSet,
                                             bool PartialOverloading = false,
@@ -1603,7 +1626,7 @@
                                             FunctionDecl *Fn);
 
   void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
-                                   Expr **Args, unsigned NumArgs,
+                                   llvm::ArrayRef<Expr *> Args,
                                    OverloadCandidateSet &CandidateSet,
                                    bool PartialOverloading = false);
 
@@ -1799,7 +1822,8 @@
   CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class);
 
   void ArgumentDependentLookup(DeclarationName Name, bool Operator,
-                               Expr **Args, unsigned NumArgs,
+                               SourceLocation Loc,
+                               llvm::ArrayRef<Expr *> Args,
                                ADLResult &Functions,
                                bool StdNamespaceIsAssociated = false);
 
@@ -1818,7 +1842,7 @@
                              bool EnteringContext = false,
                              const ObjCObjectPointerType *OPT = 0);
 
-  void FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
+  void FindAssociatedClassesAndNamespaces(llvm::ArrayRef<Expr *> Args,
                                    AssociatedNamespaceSet &AssociatedNamespaces,
                                    AssociatedClassSet &AssociatedClasses);
 
@@ -2315,7 +2339,8 @@
                              Expr **Args, unsigned NumArgs);
 
   void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-                                       Decl *LambdaContextDecl = 0);
+                                       Decl *LambdaContextDecl = 0,
+                                       bool IsDecltype = false);
 
   void PopExpressionEvaluationContext();
 
@@ -2427,7 +2452,7 @@
   bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
                            CorrectionCandidateCallback &CCC,
                            TemplateArgumentListInfo *ExplicitTemplateArgs = 0,
-                           Expr **Args = 0, unsigned NumArgs = 0);
+                       llvm::ArrayRef<Expr *> Args = llvm::ArrayRef<Expr *>());
 
   ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S,
                                 IdentifierInfo *II,
@@ -3114,7 +3139,8 @@
   bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
                                MultiExprArg ArgsPtr,
                                SourceLocation Loc,
-                               ASTOwningVector<Expr*> &ConvertedArgs);
+                               ASTOwningVector<Expr*> &ConvertedArgs,
+                               bool AllowExplicit = false);
 
   ParsedType getDestructorName(SourceLocation TildeLoc,
                                IdentifierInfo &II, SourceLocation NameLoc,
@@ -3303,6 +3329,14 @@
                                   TypeSourceInfo *RhsT,
                                   SourceLocation RParen);
 
+  /// \brief Parsed one of the type trait support pseudo-functions.
+  ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
+                            ArrayRef<ParsedType> Args,
+                            SourceLocation RParenLoc);
+  ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
+                            ArrayRef<TypeSourceInfo *> Args,
+                            SourceLocation RParenLoc);
+  
   /// ActOnArrayTypeTrait - Parsed one of the bianry type trait support
   /// pseudo-functions.
   ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT,
@@ -3446,6 +3480,8 @@
                                    bool EnteringContext,
                                    CXXScopeSpec &SS);
 
+  ExprResult ActOnDecltypeExpression(Expr *E);
+
   bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS,
                                            const DeclSpec &DS, 
                                            SourceLocation ColonColonLoc);
@@ -4480,7 +4516,7 @@
   /// \param Unexpanded the set of unexpanded parameter packs.
   void DiagnoseUnexpandedParameterPacks(SourceLocation Loc,
                                         UnexpandedParameterPackContext UPPC,
-                    const SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
+                                  ArrayRef<UnexpandedParameterPack> Unexpanded);
 
   /// \brief If the given type contains an unexpanded parameter pack,
   /// diagnose the error.
@@ -4807,7 +4843,7 @@
   TemplateDeductionResult
   DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
                           TemplateArgumentListInfo *ExplicitTemplateArgs,
-                          Expr **Args, unsigned NumArgs,
+                          llvm::ArrayRef<Expr *> Args,
                           FunctionDecl *&Specialization,
                           sema::TemplateDeductionInfo &Info);
 
@@ -5461,6 +5497,9 @@
                                          IdentifierInfo *CatName,
                                          SourceLocation CatLoc);
 
+  DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl,
+                                               ArrayRef<Decl *> Decls);
+
   DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
                                      IdentifierInfo **IdentList,
                                      SourceLocation *IdentLocs,
@@ -5884,7 +5923,8 @@
                               unsigned FirstProtoArg,
                               Expr **Args, unsigned NumArgs,
                               SmallVector<Expr *, 8> &AllArgs,
-                              VariadicCallType CallType = VariadicDoesNotApply);
+                              VariadicCallType CallType = VariadicDoesNotApply,
+                              bool AllowExplicit = false);
 
   // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
   // will warn if the resulting type is not a POD type.
@@ -6356,7 +6396,7 @@
   void CodeCompleteTag(Scope *S, unsigned TagSpec);
   void CodeCompleteTypeQualifiers(DeclSpec &DS);
   void CodeCompleteCase(Scope *S);
-  void CodeCompleteCall(Scope *S, Expr *Fn, Expr **Args, unsigned NumArgs);
+  void CodeCompleteCall(Scope *S, Expr *Fn, llvm::ArrayRef<Expr *> Args);
   void CodeCompleteInitializer(Scope *S, Decl *D);
   void CodeCompleteReturn(Scope *S);
   void CodeCompleteAfterIf(Scope *S);
@@ -6572,9 +6612,11 @@
 public:
   EnterExpressionEvaluationContext(Sema &Actions,
                                    Sema::ExpressionEvaluationContext NewContext,
-                                   Decl *LambdaContextDecl = 0)
+                                   Decl *LambdaContextDecl = 0,
+                                   bool IsDecltype = false)
     : Actions(Actions) {
-    Actions.PushExpressionEvaluationContext(NewContext, LambdaContextDecl);
+    Actions.PushExpressionEvaluationContext(NewContext, LambdaContextDecl,
+                                            IsDecltype);
   }
 
   ~EnterExpressionEvaluationContext() {

Modified: cfe/branches/tooling/include/clang/Serialization/ASTBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Serialization/ASTBitCodes.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/branches/tooling/include/clang/Serialization/ASTBitCodes.h Tue Feb 28 17:49:25 2012
@@ -1156,6 +1156,7 @@
       EXPR_OPAQUE_VALUE,          // OpaqueValueExpr
       EXPR_BINARY_CONDITIONAL_OPERATOR,  // BinaryConditionalOperator
       EXPR_BINARY_TYPE_TRAIT,     // BinaryTypeTraitExpr
+      EXPR_TYPE_TRAIT,            // TypeTraitExpr
       EXPR_ARRAY_TYPE_TRAIT,      // ArrayTypeTraitIntExpr
       
       EXPR_PACK_EXPANSION,        // PackExpansionExpr

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Tue Feb 28 17:49:25 2012
@@ -71,6 +71,7 @@
   std::string ShortDescription;
   std::string Description;
   PathDiagnosticLocation Location;
+  PathDiagnosticLocation UniqueingLocation;
   const ExplodedNode *ErrorNode;
   SmallVector<SourceRange, 4> Ranges;
   ExtraTextList ExtraText;
@@ -95,6 +96,18 @@
     : BT(bt), Description(desc), Location(l), ErrorNode(0),
       Callbacks(F.getEmptyList()) {}
 
+  /// \brief Create a BugReport with a custom uniqueing location.
+  ///
+  /// The reports that have the same report location, description, bug type, and
+  /// ranges are uniqued - only one of the equivalent reports will be presented
+  /// to the user. This method allows to rest the location which should be used
+  /// for uniquing reports. For example, memory leaks checker, could set this to
+  /// the allocation site, rather then the location where the bug is reported.
+  BugReport(BugType& bt, StringRef desc, const ExplodedNode *errornode,
+            PathDiagnosticLocation LocationToUnique)
+    : BT(bt), Description(desc), UniqueingLocation(LocationToUnique),
+      ErrorNode(errornode), Callbacks(F.getEmptyList()) {}
+
   virtual ~BugReport();
 
   const BugType& getBugType() const { return BT; }

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h Tue Feb 28 17:49:25 2012
@@ -170,23 +170,6 @@
                     llvm::raw_ostream &Out,
                     BugReporterContext &BRC);
 };
-
-class CallEnterExitBRVisitor : public BugReporterVisitor {
-  const bool showTopLevelCall;
-public:
-  void Profile(llvm::FoldingSetNodeID &ID) const {
-    static int x = 0;
-    ID.AddPointer(&x);
-  }
-  
-  CallEnterExitBRVisitor(bool showTopLevel)
-    : showTopLevelCall(showTopLevel) {}
-  
-  PathDiagnosticPiece *VisitNode(const ExplodedNode *N,
-                                 const ExplodedNode *PrevN,
-                                 BugReporterContext &BRC,
-                                 BugReport &BR);
-};
   
 namespace bugreporter {
 

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h Tue Feb 28 17:49:25 2012
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_PATH_DIAGNOSTIC_H
 
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Analysis/ProgramPoint.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/PointerUnion.h"
@@ -262,7 +263,7 @@
 
 class PathDiagnosticPiece : public RefCountedBaseVPTR {
 public:
-  enum Kind { ControlFlow, Event, Macro, CallEnter, CallExit };
+  enum Kind { ControlFlow, Event, Macro, Call };
   enum DisplayHint { Above, Below };
 
 private:
@@ -364,31 +365,55 @@
     return P->getKind() == Event;
   }
 };
+
+class PathDiagnosticCallPiece : public PathDiagnosticPiece {
+  PathDiagnosticCallPiece(const Decl *callerD,
+                          const PathDiagnosticLocation &callReturnPos)
+    : PathDiagnosticPiece(Call), Caller(callerD),
+      Callee(0), callReturn(callReturnPos) {}
+
+  PathDiagnosticCallPiece(PathPieces &oldPath)
+    : PathDiagnosticPiece(Call), Caller(0), Callee(0), path(oldPath) {}
   
-class PathDiagnosticCallEnterPiece : public PathDiagnosticSpotPiece {
+  const Decl *Caller;
+  const Decl *Callee;
 public:
-  PathDiagnosticCallEnterPiece(const PathDiagnosticLocation &pos,
-                              StringRef s)
-    : PathDiagnosticSpotPiece(pos, s, CallEnter, false) {}
+  PathDiagnosticLocation callEnter;
+  PathDiagnosticLocation callReturn;  
+  PathPieces path;
   
-  ~PathDiagnosticCallEnterPiece();
+  virtual ~PathDiagnosticCallPiece();
   
-  static inline bool classof(const PathDiagnosticPiece *P) {
-    return P->getKind() == CallEnter;
-  }  
-};
+  const Decl *getCaller() const { return Caller; }
+  
+  const Decl *getCallee() const { return Callee; }
+  void setCallee(const CallEnter &CE, const SourceManager &SM);
+  
+  virtual PathDiagnosticLocation getLocation() const {
+    return callEnter;
+  }
+  
+  IntrusiveRefCntPtr<PathDiagnosticEventPiece> getCallEnterEvent() const;
+  IntrusiveRefCntPtr<PathDiagnosticEventPiece> getCallExitEvent() const;
 
-class PathDiagnosticCallExitPiece : public PathDiagnosticSpotPiece {
-public:
-  PathDiagnosticCallExitPiece(const PathDiagnosticLocation &pos,
-                             StringRef s)
-  : PathDiagnosticSpotPiece(pos, s, CallExit, false) {}
+  virtual void flattenLocations() {
+    callEnter.flatten();
+    callReturn.flatten();
+    for (PathPieces::iterator I = path.begin(), 
+         E = path.end(); I != E; ++I) (*I)->flattenLocations();
+  }
   
-  ~PathDiagnosticCallExitPiece();
+  static PathDiagnosticCallPiece *construct(const ExplodedNode *N,
+                                            const CallExit &CE,
+                                            const SourceManager &SM);
+  
+  static PathDiagnosticCallPiece *construct(PathPieces &pieces);
   
+  virtual void Profile(llvm::FoldingSetNodeID &ID) const;
+
   static inline bool classof(const PathDiagnosticPiece *P) {
-    return P->getKind() == CallExit;
-  }  
+    return P->getKind() == Call;
+  }
 };
 
 class PathDiagnosticControlFlowPiece : public PathDiagnosticPiece {
@@ -479,8 +504,29 @@
   std::string Desc;
   std::string Category;
   std::deque<std::string> OtherDesc;
+  PathPieces pathImpl;
+  llvm::SmallVector<PathPieces *, 3> pathStack;
 public:
-  PathPieces path;
+  const PathPieces &path;
+
+  /// Return the path currently used by builders for constructing the 
+  /// PathDiagnostic.
+  PathPieces &getActivePath() {
+    if (pathStack.empty())
+      return pathImpl;
+    return *pathStack.back();
+  }
+  
+  /// Return a mutable version of 'path'.
+  PathPieces &getMutablePieces() {
+    return pathImpl;
+  }
+    
+  /// Return the unrolled size of the path.
+  unsigned full_size();
+
+  void pushActivePath(PathPieces *p) { pathStack.push_back(p); }
+  void popActivePath() { if (!pathStack.empty()) pathStack.pop_back(); }
 
   PathDiagnostic();
   PathDiagnostic(StringRef bugtype, StringRef desc,
@@ -498,14 +544,10 @@
   meta_iterator meta_end() const { return OtherDesc.end(); }
   void addMeta(StringRef s) { OtherDesc.push_back(s); }
 
-  PathDiagnosticLocation getLocation() const {
-    assert(path.size() > 0 &&
-           "getLocation() requires a non-empty PathDiagnostic.");
-    return (*path.rbegin())->getLocation();
-  }
+  PathDiagnosticLocation getLocation() const;
 
   void flattenLocations() {
-    for (PathPieces::iterator I = path.begin(), E = path.end(); 
+    for (PathPieces::iterator I = pathImpl.begin(), E = pathImpl.end(); 
          I != E; ++I) (*I)->flattenLocations();
   }
   

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Tue Feb 28 17:49:25 2012
@@ -18,6 +18,7 @@
 
 #include "clang/AST/CharUnits.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/ExprObjC.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -94,6 +95,7 @@
     CompoundLiteralRegionKind = BEG_TYPED_VALUE_REGIONS,
     CXXThisRegionKind,
     StringRegionKind,
+    ObjCStringRegionKind,
     ElementRegionKind,
     // Decl Regions.
     BEG_DECL_REGIONS,
@@ -694,6 +696,40 @@
     return R->getKind() == StringRegionKind;
   }
 };
+  
+/// The region associated with an ObjCStringLiteral.
+class ObjCStringRegion : public TypedValueRegion {
+  friend class MemRegionManager;
+  const ObjCStringLiteral* Str;
+protected:
+  
+  ObjCStringRegion(const ObjCStringLiteral* str, const MemRegion* sreg)
+  : TypedValueRegion(sreg, ObjCStringRegionKind), Str(str) {}
+  
+  static void ProfileRegion(llvm::FoldingSetNodeID& ID,
+                            const ObjCStringLiteral* Str,
+                            const MemRegion* superRegion);
+  
+public:
+  
+  const ObjCStringLiteral* getObjCStringLiteral() const { return Str; }
+  
+  QualType getValueType() const {
+    return Str->getType();
+  }
+  
+  bool isBoundable() const { return false; }
+  
+  void Profile(llvm::FoldingSetNodeID& ID) const {
+    ProfileRegion(ID, Str, superRegion);
+  }
+  
+  void dumpToStream(raw_ostream &os) const;
+  
+  static bool classof(const MemRegion* R) {
+    return R->getKind() == ObjCStringRegionKind;
+  }
+};
 
 /// CompoundLiteralRegion - A memory region representing a compound literal.
 ///   Compound literals are essentially temporaries that are stack allocated
@@ -1067,7 +1103,9 @@
   /// getSymbolicRegion - Retrieve or create a "symbolic" memory region.
   const SymbolicRegion* getSymbolicRegion(SymbolRef sym);
 
-  const StringRegion* getStringRegion(const StringLiteral* Str);
+  const StringRegion *getStringRegion(const StringLiteral* Str);
+
+  const ObjCStringRegion *getObjCStringRegion(const ObjCStringLiteral *Str);
 
   /// getVarRegion - Retrieve or create the memory region associated with
   ///  a specified VarDecl and LocationContext.

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h Tue Feb 28 17:49:25 2012
@@ -230,9 +230,6 @@
   /// Get the lvalue for a variable reference.
   Loc getLValue(const VarDecl *D, const LocationContext *LC) const;
 
-  /// Get the lvalue for a StringLiteral.
-  Loc getLValue(const StringLiteral *literal) const;
-
   Loc getLValue(const CompoundLiteralExpr *literal, 
                 const LocationContext *LC) const;
 
@@ -636,10 +633,6 @@
   return getStateManager().StoreMgr->getLValueVar(VD, LC);
 }
 
-inline Loc ProgramState::getLValue(const StringLiteral *literal) const {
-  return getStateManager().StoreMgr->getLValueString(literal);
-}
-
 inline Loc ProgramState::getLValue(const CompoundLiteralExpr *literal,
                                const LocationContext *LC) const {
   return getStateManager().StoreMgr->getLValueCompoundLiteral(literal, LC);

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h Tue Feb 28 17:49:25 2012
@@ -94,10 +94,6 @@
     return svalBuilder.makeLoc(MRMgr.getVarRegion(VD, LC));
   }
 
-  virtual Loc getLValueString(const StringLiteral* S) {
-    return svalBuilder.makeLoc(MRMgr.getStringRegion(S));
-  }
-
   Loc getLValueCompoundLiteral(const CompoundLiteralExpr *CL,
                                const LocationContext *LC) {
     return loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL, LC));

Modified: cfe/branches/tooling/lib/ARCMigrate/TransGCAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransGCAttrs.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransGCAttrs.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransGCAttrs.cpp Tue Feb 28 17:49:25 2012
@@ -11,7 +11,7 @@
 #include "Internals.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/TinyPtrVector.h"
@@ -183,30 +183,6 @@
 
 } // anonymous namespace
 
-static void clearRedundantStrongs(MigrationContext &MigrateCtx) {
-  TransformActions &TA = MigrateCtx.Pass.TA;
-
-  for (unsigned i = 0, e = MigrateCtx.GCAttrs.size(); i != e; ++i) {
-    MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs[i];
-    if (Attr.Kind == MigrationContext::GCAttrOccurrence::Strong &&
-        Attr.FullyMigratable && Attr.Dcl) {
-      TypeSourceInfo *TInfo = 0;
-      if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(Attr.Dcl))
-        TInfo = DD->getTypeSourceInfo();
-      else if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(Attr.Dcl))
-        TInfo = PD->getTypeSourceInfo();
-      if (!TInfo)
-        continue;
-
-      if (TInfo->getType().getObjCLifetime() == Qualifiers::OCL_Strong) {
-        Transaction Trans(TA);
-        TA.remove(Attr.Loc);
-        MigrateCtx.RemovedAttrSet.insert(Attr.Loc.getRawEncoding());
-      }
-    }
-  }
-}
-
 static void errorForGCAttrsOnNonObjC(MigrationContext &MigrateCtx) {
   TransformActions &TA = MigrateCtx.Pass.TA;
 
@@ -354,7 +330,6 @@
   GCAttrsCollector(MigrateCtx, AllProps).TraverseDecl(
                                   MigrateCtx.Pass.Ctx.getTranslationUnitDecl());
 
-  clearRedundantStrongs(MigrateCtx);
   errorForGCAttrsOnNonObjC(MigrateCtx);
   checkAllProps(MigrateCtx, AllProps);
   checkWeakGCAttrs(MigrateCtx);

Modified: cfe/branches/tooling/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTDiagnostic.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTDiagnostic.cpp Tue Feb 28 17:49:25 2012
@@ -154,17 +154,16 @@
 ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty,
                               const DiagnosticsEngine::ArgumentValue *PrevArgs,
                               unsigned NumPrevArgs,
-                              SmallVectorImpl<intptr_t> &QualTypeVals) {
+                              ArrayRef<intptr_t> QualTypeVals) {
   // FIXME: Playing with std::string is really slow.
   bool ForceAKA = false;
   QualType CanTy = Ty.getCanonicalType();
   std::string S = Ty.getAsString(Context.getPrintingPolicy());
   std::string CanS = CanTy.getAsString(Context.getPrintingPolicy());
 
-  for (SmallVectorImpl<intptr_t>::iterator I = QualTypeVals.begin(),
-       E = QualTypeVals.end(); I != E; ++I) {
+  for (unsigned I = 0, E = QualTypeVals.size(); I != E; ++I) {
     QualType CompareTy =
-        QualType::getFromOpaquePtr(reinterpret_cast<void*>(*I));
+        QualType::getFromOpaquePtr(reinterpret_cast<void*>(QualTypeVals[I]));
     if (CompareTy == Ty)
       continue;  // Same types
     QualType CompareCanTy = CompareTy.getCanonicalType();
@@ -235,7 +234,7 @@
     unsigned NumPrevArgs,
     SmallVectorImpl<char> &Output,
     void *Cookie,
-    SmallVectorImpl<intptr_t> &QualTypeVals) {
+    ArrayRef<intptr_t> QualTypeVals) {
   ASTContext &Context = *static_cast<ASTContext*>(Cookie);
   
   std::string S;

Modified: cfe/branches/tooling/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTImporter.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTImporter.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTImporter.cpp Tue Feb 28 17:49:25 2012
@@ -1849,16 +1849,29 @@
     ToData.HasProtectedFields = FromData.HasProtectedFields;
     ToData.HasPublicFields = FromData.HasPublicFields;
     ToData.HasMutableFields = FromData.HasMutableFields;
+    ToData.HasOnlyCMembers = FromData.HasOnlyCMembers;
     ToData.HasTrivialDefaultConstructor = FromData.HasTrivialDefaultConstructor;
     ToData.HasConstexprNonCopyMoveConstructor
       = FromData.HasConstexprNonCopyMoveConstructor;
+    ToData.DefaultedDefaultConstructorIsConstexpr
+      = FromData.DefaultedDefaultConstructorIsConstexpr;
+    ToData.DefaultedCopyConstructorIsConstexpr
+      = FromData.DefaultedCopyConstructorIsConstexpr;
+    ToData.DefaultedMoveConstructorIsConstexpr
+      = FromData.DefaultedMoveConstructorIsConstexpr;
+    ToData.HasConstexprDefaultConstructor
+      = FromData.HasConstexprDefaultConstructor;
+    ToData.HasConstexprCopyConstructor = FromData.HasConstexprCopyConstructor;
+    ToData.HasConstexprMoveConstructor = FromData.HasConstexprMoveConstructor;
     ToData.HasTrivialCopyConstructor = FromData.HasTrivialCopyConstructor;
     ToData.HasTrivialMoveConstructor = FromData.HasTrivialMoveConstructor;
     ToData.HasTrivialCopyAssignment = FromData.HasTrivialCopyAssignment;
     ToData.HasTrivialMoveAssignment = FromData.HasTrivialMoveAssignment;
     ToData.HasTrivialDestructor = FromData.HasTrivialDestructor;
+    ToData.HasIrrelevantDestructor = FromData.HasIrrelevantDestructor;
     ToData.HasNonLiteralTypeFieldsOrBases
       = FromData.HasNonLiteralTypeFieldsOrBases;
+    // ComputedVisibleConversions not imported.
     ToData.UserProvidedDefaultConstructor
       = FromData.UserProvidedDefaultConstructor;
     ToData.DeclaredDefaultConstructor = FromData.DeclaredDefaultConstructor;
@@ -1870,7 +1883,8 @@
     ToData.FailedImplicitMoveConstructor
       = FromData.FailedImplicitMoveConstructor;
     ToData.FailedImplicitMoveAssignment = FromData.FailedImplicitMoveAssignment;
-    
+    ToData.IsLambda = FromData.IsLambda;
+
     SmallVector<CXXBaseSpecifier *, 4> Bases;
     for (CXXRecordDecl::base_class_iterator 
                   Base1 = FromCXX->bases_begin(),

Modified: cfe/branches/tooling/lib/AST/CXXInheritance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/CXXInheritance.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/CXXInheritance.cpp (original)
+++ cfe/branches/tooling/lib/AST/CXXInheritance.cpp Tue Feb 28 17:49:25 2012
@@ -23,12 +23,15 @@
 void CXXBasePaths::ComputeDeclsFound() {
   assert(NumDeclsFound == 0 && !DeclsFound &&
          "Already computed the set of declarations");
-  
-  std::set<NamedDecl *> Decls;
-  for (CXXBasePaths::paths_iterator Path = begin(), PathEnd = end();
-       Path != PathEnd; ++Path)
-    Decls.insert(*Path->Decls.first);
-  
+
+  SmallVector<NamedDecl *, 8> Decls;
+  for (paths_iterator Path = begin(), PathEnd = end(); Path != PathEnd; ++Path)
+    Decls.push_back(*Path->Decls.first);
+
+  // Eliminate duplicated decls.
+  llvm::array_pod_sort(Decls.begin(), Decls.end());
+  Decls.erase(std::unique(Decls.begin(), Decls.end()), Decls.end());
+
   NumDeclsFound = Decls.size();
   DeclsFound = new NamedDecl * [NumDeclsFound];
   std::copy(Decls.begin(), Decls.end(), DeclsFound);

Modified: cfe/branches/tooling/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Decl.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Decl.cpp (original)
+++ cfe/branches/tooling/lib/AST/Decl.cpp Tue Feb 28 17:49:25 2012
@@ -176,9 +176,9 @@
       break;
 
     case TemplateArgument::Pack:
-      LV.merge(getLVForTemplateArgumentList(Args[I].pack_begin(),
-                                            Args[I].pack_size(),
-                                            F));
+      LV.mergeWithMin(getLVForTemplateArgumentList(Args[I].pack_begin(),
+                                                   Args[I].pack_size(),
+                                                   F));
       break;
     }
   }
@@ -279,6 +279,7 @@
   //   scope and no storage-class specifier, its linkage is
   //   external.
   LinkageInfo LV;
+  LV.mergeVisibility(Context.getLangOptions().getVisibilityMode());
 
   if (F.ConsiderVisibilityAttributes) {
     if (llvm::Optional<Visibility> Vis = D->getExplicitVisibility()) {
@@ -413,7 +414,7 @@
         LV.merge(getLVForDecl(specInfo->getTemplate(),
                               F.onlyTemplateVisibility()));
         const TemplateArgumentList &templateArgs = *specInfo->TemplateArguments;
-        LV.merge(getLVForTemplateArgumentList(templateArgs, F));
+        LV.mergeWithMin(getLVForTemplateArgumentList(templateArgs, F));
       }
     }
 
@@ -439,7 +440,7 @@
 
         // The arguments at which the template was instantiated.
         const TemplateArgumentList &TemplateArgs = spec->getTemplateArgs();
-        LV.merge(getLVForTemplateArgumentList(TemplateArgs, F));
+        LV.mergeWithMin(getLVForTemplateArgumentList(TemplateArgs, F));
       }
     }
 
@@ -482,11 +483,6 @@
   if (LV.linkage() != ExternalLinkage)
     return LinkageInfo(LV.linkage(), DefaultVisibility, false);
 
-  // If we didn't end up with hidden visibility, consider attributes
-  // and -fvisibility.
-  if (F.ConsiderGlobalVisibility)
-    LV.mergeVisibility(Context.getLangOptions().getVisibilityMode());
-
   return LV;
 }
 
@@ -503,6 +499,7 @@
     return LinkageInfo::none();
 
   LinkageInfo LV;
+  LV.mergeVisibility(D->getASTContext().getLangOptions().getVisibilityMode());
 
   // The flags we're going to use to compute the class's visibility.
   LVFlags ClassF = F;
@@ -544,7 +541,8 @@
     if (FunctionTemplateSpecializationInfo *spec
            = MD->getTemplateSpecializationInfo()) {
       if (shouldConsiderTemplateLV(MD, spec)) {
-        LV.merge(getLVForTemplateArgumentList(*spec->TemplateArguments, F));
+        LV.mergeWithMin(getLVForTemplateArgumentList(*spec->TemplateArguments,
+                                                     F));
         if (F.ConsiderTemplateParameterTypes)
           LV.merge(getLVForTemplateParameterList(
                               spec->getTemplate()->getTemplateParameters()));
@@ -583,7 +581,8 @@
       if (shouldConsiderTemplateLV(spec)) {
         // Merge template argument/parameter information for member
         // class template specializations.
-        LV.merge(getLVForTemplateArgumentList(spec->getTemplateArgs(), F));
+        LV.mergeWithMin(getLVForTemplateArgumentList(spec->getTemplateArgs(),
+                                                     F));
       if (F.ConsiderTemplateParameterTypes)
         LV.merge(getLVForTemplateParameterList(
                     spec->getSpecializedTemplate()->getTemplateParameters()));
@@ -601,13 +600,6 @@
       LV.mergeVisibility(TypeLV.visibility(), TypeLV.visibilityExplicit());
   }
 
-  F.ConsiderGlobalVisibility &= !LV.visibilityExplicit();
-
-  // Apply -fvisibility if desired.
-  if (F.ConsiderGlobalVisibility && LV.visibility() != HiddenVisibility) {
-    LV.mergeVisibility(D->getASTContext().getLangOptions().getVisibilityMode());
-  }
-
   return LV;
 }
 
@@ -697,6 +689,12 @@
           = fn->getTemplateSpecializationInfo())
       return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl());
 
+    // If the function is a member of a specialization of a class template
+    // and the corresponding decl has explicit visibility, use that.
+    FunctionDecl *InstantiatedFrom = fn->getInstantiatedFromMemberFunction();
+    if (InstantiatedFrom)
+      return getVisibilityOf(InstantiatedFrom);
+
     return llvm::Optional<Visibility>();
   }
 
@@ -711,6 +709,14 @@
         = dyn_cast<ClassTemplateSpecializationDecl>(this))
     return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl());
 
+  // If this is a member class of a specialization of a class template
+  // and the corresponding decl has explicit visibility, use that.
+  if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(this)) {
+    CXXRecordDecl *InstantiatedFrom = RD->getInstantiatedFromMemberClass();
+    if (InstantiatedFrom)
+      return getVisibilityOf(InstantiatedFrom);
+  }
+
   return llvm::Optional<Visibility>();
 }
 
@@ -1841,6 +1847,16 @@
   }
 }
 
+void FunctionDecl::setDeclsInPrototypeScope(llvm::ArrayRef<NamedDecl *> NewDecls) {
+  assert(DeclsInPrototypeScope.empty() && "Already has prototype decls!");
+
+  if (!NewDecls.empty()) {
+    NamedDecl **A = new (getASTContext()) NamedDecl*[NewDecls.size()];
+    std::copy(NewDecls.begin(), NewDecls.end(), A);
+    DeclsInPrototypeScope = llvm::ArrayRef<NamedDecl*>(A, NewDecls.size());
+  }
+}
+
 /// getMinRequiredArguments - Returns the minimum number of arguments
 /// needed to call this function. This may be fewer than the number of
 /// function parameters, if some of the parameters have default

Modified: cfe/branches/tooling/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DeclBase.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DeclBase.cpp (original)
+++ cfe/branches/tooling/lib/AST/DeclBase.cpp Tue Feb 28 17:49:25 2012
@@ -872,7 +872,7 @@
 }
 
 std::pair<Decl *, Decl *>
-DeclContext::BuildDeclChain(const SmallVectorImpl<Decl*> &Decls,
+DeclContext::BuildDeclChain(ArrayRef<Decl*> Decls,
                             bool FieldsAlreadyLoaded) {
   // Build up a chain of declarations via the Decl::NextInContextAndBits field.
   Decl *FirstNewDecl = 0;

Modified: cfe/branches/tooling/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DeclCXX.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/AST/DeclCXX.cpp Tue Feb 28 17:49:25 2012
@@ -52,6 +52,7 @@
     HasConstexprMoveConstructor(false), HasTrivialCopyConstructor(true),
     HasTrivialMoveConstructor(true), HasTrivialCopyAssignment(true),
     HasTrivialMoveAssignment(true), HasTrivialDestructor(true),
+    HasIrrelevantDestructor(true),
     HasNonLiteralTypeFieldsOrBases(false), ComputedVisibleConversions(false),
     UserProvidedDefaultConstructor(false), DeclaredDefaultConstructor(false),
     DeclaredCopyConstructor(false), DeclaredMoveConstructor(false),
@@ -284,7 +285,10 @@
     //   have trivial destructors.
     if (!BaseClassDecl->hasTrivialDestructor())
       data().HasTrivialDestructor = false;
-    
+
+    if (!BaseClassDecl->hasIrrelevantDestructor())
+      data().HasIrrelevantDestructor = false;
+
     // A class has an Objective-C object member if... or any of its bases
     // has an Objective-C object member.
     if (BaseClassDecl->hasObjectMember())
@@ -648,7 +652,8 @@
   if (CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D)) {
     data().DeclaredDestructor = true;
     data().UserDeclaredDestructor = true;
-    
+    data().HasIrrelevantDestructor = false;
+
     // C++ [class]p4: 
     //   A POD-struct is an aggregate class that has [...] no user-defined 
     //   destructor.
@@ -865,6 +870,8 @@
 
         if (!FieldRec->hasTrivialDestructor())
           data().HasTrivialDestructor = false;
+        if (!FieldRec->hasIrrelevantDestructor())
+          data().HasIrrelevantDestructor = false;
         if (FieldRec->hasObjectMember())
           setHasObjectMember(true);
 
@@ -1248,6 +1255,7 @@
     Data.HasTrivialCopyConstructor = false;
     Data.HasTrivialCopyAssignment = false;
     Data.HasTrivialDestructor = false;
+    Data.HasIrrelevantDestructor = false;
   }
   
   // If the class may be abstract (but hasn't been marked as such), check for
@@ -1770,16 +1778,6 @@
          getConversionType()->isBlockPointerType();
 }
 
-Expr *CXXConversionDecl::getLambdaToBlockPointerCopyInit() const {
-  assert(isLambdaToBlockPointerConversion());
-  return getASTContext().LambdaBlockPointerInits[this];
-}
-
-void CXXConversionDecl::setLambdaToBlockPointerCopyInit(Expr *Init) {
-  assert(isLambdaToBlockPointerConversion());
-  getASTContext().LambdaBlockPointerInits[this] = Init;
-}
-
 void LinkageSpecDecl::anchor() { }
 
 LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C,

Modified: cfe/branches/tooling/lib/AST/DumpXML.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DumpXML.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DumpXML.cpp (original)
+++ cfe/branches/tooling/lib/AST/DumpXML.cpp Tue Feb 28 17:49:25 2012
@@ -497,6 +497,10 @@
     for (FunctionDecl::param_iterator
            I = D->param_begin(), E = D->param_end(); I != E; ++I)
       dispatch(*I);
+    for (llvm::ArrayRef<NamedDecl*>::iterator
+           I = D->getDeclsInPrototypeScope().begin(), E = D->getDeclsInPrototypeScope().end();
+         I != E; ++I)
+      dispatch(*I);
     if (D->doesThisDeclarationHaveABody())
       dispatch(D->getBody());
   }

Modified: cfe/branches/tooling/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Expr.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Expr.cpp (original)
+++ cfe/branches/tooling/lib/AST/Expr.cpp Tue Feb 28 17:49:25 2012
@@ -18,6 +18,7 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/EvaluatedExprVisitor.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Lex/LiteralSupport.h"
@@ -1076,6 +1077,11 @@
            !getSubExpr()->getType()->isBlockPointerType());
     goto CheckNoBasePath;
 
+  case CK_CopyAndAutoreleaseBlockObject:
+    assert(getType()->isBlockPointerType());
+    assert(getSubExpr()->getType()->isBlockPointerType());
+    goto CheckNoBasePath;
+      
   // These should not have an inheritance path.
   case CK_Dynamic:
   case CK_ToUnion:
@@ -1231,6 +1237,8 @@
     return "AtomicToNonAtomic";
   case CK_NonAtomicToAtomic:
     return "NonAtomicToAtomic";
+  case CK_CopyAndAutoreleaseBlockObject:
+    return "CopyAndAutoreleaseBlockObject";
   }
 
   llvm_unreachable("Unhandled cast kind!");
@@ -2161,6 +2169,7 @@
   case AddrLabelExprClass:
   case ArrayTypeTraitExprClass:
   case BinaryTypeTraitExprClass:
+  case TypeTraitExprClass:
   case CXXBoolLiteralExprClass:
   case CXXNoexceptExprClass:
   case CXXNullPtrLiteralExprClass:
@@ -2519,24 +2528,14 @@
 
 /// hasAnyTypeDependentArguments - Determines if any of the expressions
 /// in Exprs is type-dependent.
-bool Expr::hasAnyTypeDependentArguments(Expr** Exprs, unsigned NumExprs) {
-  for (unsigned I = 0; I < NumExprs; ++I)
+bool Expr::hasAnyTypeDependentArguments(llvm::ArrayRef<Expr *> Exprs) {
+  for (unsigned I = 0; I < Exprs.size(); ++I)
     if (Exprs[I]->isTypeDependent())
       return true;
 
   return false;
 }
 
-/// hasAnyValueDependentArguments - Determines if any of the expressions
-/// in Exprs is value-dependent.
-bool Expr::hasAnyValueDependentArguments(Expr** Exprs, unsigned NumExprs) {
-  for (unsigned I = 0; I < NumExprs; ++I)
-    if (Exprs[I]->isValueDependent())
-      return true;
-
-  return false;
-}
-
 bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef) const {
   // This function is attempting whether an expression is an initializer
   // which can be evaluated at compile-time.  isEvaluatable handles most
@@ -2657,6 +2656,60 @@
   return isEvaluatable(Ctx);
 }
 
+namespace {
+  /// \brief Look for a call to a non-trivial function within an expression.
+  class NonTrivialCallFinder : public EvaluatedExprVisitor<NonTrivialCallFinder>
+  {
+    typedef EvaluatedExprVisitor<NonTrivialCallFinder> Inherited;
+    
+    bool NonTrivial;
+    
+  public:
+    explicit NonTrivialCallFinder(ASTContext &Context) 
+      : Inherited(Context), NonTrivial(false) { }
+    
+    bool hasNonTrivialCall() const { return NonTrivial; }
+    
+    void VisitCallExpr(CallExpr *E) {
+      if (CXXMethodDecl *Method
+          = dyn_cast_or_null<CXXMethodDecl>(E->getCalleeDecl())) {
+        if (Method->isTrivial()) {
+          // Recurse to children of the call.
+          Inherited::VisitStmt(E);
+          return;
+        }
+      }
+      
+      NonTrivial = true;
+    }
+    
+    void VisitCXXConstructExpr(CXXConstructExpr *E) {
+      if (E->getConstructor()->isTrivial()) {
+        // Recurse to children of the call.
+        Inherited::VisitStmt(E);
+        return;
+      }
+      
+      NonTrivial = true;
+    }
+    
+    void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
+      if (E->getTemporary()->getDestructor()->isTrivial()) {
+        Inherited::VisitStmt(E);
+        return;
+      }
+      
+      NonTrivial = true;
+    }
+  };
+}
+
+bool Expr::hasNonTrivialCall(ASTContext &Ctx) {
+  NonTrivialCallFinder Finder(Ctx);
+  Finder.Visit(this);
+  return Finder.hasNonTrivialCall();  
+}
+
 /// isNullPointerConstant - C99 6.3.2.3p3 - Return whether this is a null 
 /// pointer constant or not, as well as the specific kind of constant detected.
 /// Null pointer constants can be integer constant expressions with the

Modified: cfe/branches/tooling/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ExprCXX.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/AST/ExprCXX.cpp Tue Feb 28 17:49:25 2012
@@ -57,10 +57,10 @@
          ty->isDependentType(), ty->isDependentType(),
          ty->isInstantiationDependentType(),
          ty->containsUnexpandedParameterPack()),
-    GlobalNew(globalNew), UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize),
     SubExprs(0), OperatorNew(operatorNew), OperatorDelete(operatorDelete),
     AllocatedTypeInfo(allocatedTypeInfo), TypeIdParens(typeIdParens),
-    StartLoc(startLoc), DirectInitRange(directInitRange) {
+    StartLoc(startLoc), DirectInitRange(directInitRange),
+    GlobalNew(globalNew), UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) {
   assert((initializer != 0 || initializationStyle == NoInit) &&
          "Only NoInit can have no initializer.");
   StoredInitializationStyle = initializer ? initializationStyle + 1 : 0;
@@ -199,7 +199,6 @@
   return SourceRange(Base->getLocStart(), End);
 }
 
-
 // UnresolvedLookupExpr
 UnresolvedLookupExpr *
 UnresolvedLookupExpr::Create(ASTContext &C, 
@@ -257,8 +256,8 @@
           (QualifierLoc && 
            QualifierLoc.getNestedNameSpecifier()
                                       ->containsUnexpandedParameterPack()))),
-    Results(0), NumResults(End - Begin), NameInfo(NameInfo),
-    QualifierLoc(QualifierLoc),
+    NameInfo(NameInfo), QualifierLoc(QualifierLoc),
+    Results(0), NumResults(End - Begin),
     HasTemplateKWAndArgsInfo(TemplateArgs != 0 || TemplateKWLoc.isValid())
 {
   NumResults = End - Begin;
@@ -1262,4 +1261,51 @@
   return TemplateArgument(Arguments, NumArguments);
 }
 
+TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
+                             ArrayRef<TypeSourceInfo *> Args,
+                             SourceLocation RParenLoc,
+                             bool Value)
+  : Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary,
+         /*TypeDependent=*/false,
+         /*ValueDependent=*/false,
+         /*InstantiationDependent=*/false,
+         /*ContainsUnexpandedParameterPack=*/false),
+    Loc(Loc), RParenLoc(RParenLoc)
+{
+  TypeTraitExprBits.Kind = Kind;
+  TypeTraitExprBits.Value = Value;
+  TypeTraitExprBits.NumArgs = Args.size();
+
+  TypeSourceInfo **ToArgs = getTypeSourceInfos();
+  
+  for (unsigned I = 0, N = Args.size(); I != N; ++I) {
+    if (Args[I]->getType()->isDependentType())
+      setValueDependent(true);
+    if (Args[I]->getType()->isInstantiationDependentType())
+      setInstantiationDependent(true);
+    if (Args[I]->getType()->containsUnexpandedParameterPack())
+      setContainsUnexpandedParameterPack(true);
+    
+    ToArgs[I] = Args[I];
+  }
+}
+
+TypeTraitExpr *TypeTraitExpr::Create(ASTContext &C, QualType T, 
+                                     SourceLocation Loc, 
+                                     TypeTrait Kind,
+                                     ArrayRef<TypeSourceInfo *> Args,
+                                     SourceLocation RParenLoc,
+                                     bool Value) {
+  unsigned Size = sizeof(TypeTraitExpr) + sizeof(TypeSourceInfo*) * Args.size();
+  void *Mem = C.Allocate(Size);
+  return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
+}
+
+TypeTraitExpr *TypeTraitExpr::CreateDeserialized(ASTContext &C,
+                                                 unsigned NumArgs) {
+  unsigned Size = sizeof(TypeTraitExpr) + sizeof(TypeSourceInfo*) * NumArgs;
+  void *Mem = C.Allocate(Size);
+  return new (Mem) TypeTraitExpr(EmptyShell());
+}
+
 void ArrayTypeTraitExpr::anchor() { }

Modified: cfe/branches/tooling/lib/AST/ExprClassification.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ExprClassification.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ExprClassification.cpp (original)
+++ cfe/branches/tooling/lib/AST/ExprClassification.cpp Tue Feb 28 17:49:25 2012
@@ -151,6 +151,7 @@
   case Expr::CXXScalarValueInitExprClass:
   case Expr::UnaryTypeTraitExprClass:
   case Expr::BinaryTypeTraitExprClass:
+  case Expr::TypeTraitExprClass:
   case Expr::ArrayTypeTraitExprClass:
   case Expr::ExpressionTraitExprClass:
   case Expr::ObjCSelectorExprClass:

Modified: cfe/branches/tooling/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ExprConstant.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ExprConstant.cpp (original)
+++ cfe/branches/tooling/lib/AST/ExprConstant.cpp Tue Feb 28 17:49:25 2012
@@ -44,6 +44,7 @@
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include <cstring>
 #include <functional>
 
@@ -445,13 +446,18 @@
     /// are suppressed.
     bool CheckingPotentialConstantExpression;
 
+    /// \brief Stack depth of IntExprEvaluator.
+    /// We check this against a maximum value to avoid stack overflow, see
+    /// test case in test/Sema/many-logical-ops.c.
+    // FIXME: This is a hack; handle properly unlimited logical ops.
+    unsigned IntExprEvaluatorDepth;
 
     EvalInfo(const ASTContext &C, Expr::EvalStatus &S)
       : Ctx(const_cast<ASTContext&>(C)), EvalStatus(S), CurrentCall(0),
         CallStackDepth(0), NextCallIndex(1),
         BottomFrame(*this, SourceLocation(), 0, 0, 0),
         EvaluatingDecl(0), EvaluatingDeclValue(0), HasActiveDiagnostic(false),
-        CheckingPotentialConstantExpression(false) {}
+        CheckingPotentialConstantExpression(false), IntExprEvaluatorDepth(0) {}
 
     const CCValue *getOpaqueValue(const OpaqueValueExpr *e) const {
       MapTy::const_iterator i = OpaqueValues.find(e);
@@ -538,8 +544,10 @@
                                  = diag::note_invalid_subexpr_in_const_expr,
                                unsigned ExtraNotes = 0) {
       // Don't override a previous diagnostic.
-      if (!EvalStatus.Diag || !EvalStatus.Diag->empty())
+      if (!EvalStatus.Diag || !EvalStatus.Diag->empty()) {
+        HasActiveDiagnostic = false;
         return OptionalDiagnostic();
+      }
       return Diag(Loc, DiagId, ExtraNotes);
     }
 
@@ -2223,8 +2231,8 @@
   // essential for unions, where the operations performed by the constructor
   // cannot be represented by ctor-initializers.
   if (Definition->isDefaulted() &&
-      ((Definition->isCopyConstructor() && RD->hasTrivialCopyConstructor()) ||
-       (Definition->isMoveConstructor() && RD->hasTrivialMoveConstructor()))) {
+      ((Definition->isCopyConstructor() && Definition->isTrivial()) ||
+       (Definition->isMoveConstructor() && Definition->isTrivial()))) {
     LValue RHS;
     RHS.setFrom(ArgValues[0]);
     CCValue Value;
@@ -4065,6 +4073,20 @@
 
   bool ZeroInitialization(const Expr *E) { return Success(0, E); }
 
+  // FIXME: See EvalInfo::IntExprEvaluatorDepth.
+  bool Visit(const Expr *E) {
+    SaveAndRestore<unsigned> Depth(Info.IntExprEvaluatorDepth,
+                                   Info.IntExprEvaluatorDepth+1);
+    const unsigned MaxDepth = 512;
+    if (Depth.get() > MaxDepth) {
+      Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
+                                       diag::err_intexpr_depth_limit_exceeded);
+      return false;
+    }
+
+    return ExprEvaluatorBaseTy::Visit(E);
+  }
+
   //===--------------------------------------------------------------------===//
   //                            Visitor Methods
   //===--------------------------------------------------------------------===//
@@ -4117,6 +4139,10 @@
     return Success(E->getValue(), E);
   }
 
+  bool VisitTypeTraitExpr(const TypeTraitExpr *E) {
+    return Success(E->getValue(), E);
+  }
+
   bool VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E) {
     return Success(E->getValue(), E);
   }
@@ -5207,6 +5233,7 @@
   case CK_ARCConsumeObject:
   case CK_ARCReclaimReturnedObject:
   case CK_ARCExtendBlockObject:
+  case CK_CopyAndAutoreleaseBlockObject:
     return Error(E);
 
   case CK_UserDefinedConversion:
@@ -5682,6 +5709,7 @@
   case CK_ARCConsumeObject:
   case CK_ARCReclaimReturnedObject:
   case CK_ARCExtendBlockObject:
+  case CK_CopyAndAutoreleaseBlockObject:
     llvm_unreachable("invalid cast kind for complex value");
 
   case CK_LValueToRValue:
@@ -6356,6 +6384,7 @@
   case Expr::CXXScalarValueInitExprClass:
   case Expr::UnaryTypeTraitExprClass:
   case Expr::BinaryTypeTraitExprClass:
+  case Expr::TypeTraitExprClass:
   case Expr::ArrayTypeTraitExprClass:
   case Expr::ExpressionTraitExprClass:
   case Expr::CXXNoexceptExprClass:
@@ -6370,12 +6399,12 @@
       return CheckEvalInICE(E, Ctx);
     return ICEDiag(2, E->getLocStart());
   }
-  case Expr::DeclRefExprClass:
+  case Expr::DeclRefExprClass: {
     if (isa<EnumConstantDecl>(cast<DeclRefExpr>(E)->getDecl()))
       return NoDiag();
-    if (Ctx.getLangOptions().CPlusPlus && IsConstNonVolatile(E->getType())) {
-      const NamedDecl *D = cast<DeclRefExpr>(E)->getDecl();
-
+    const ValueDecl *D = dyn_cast<ValueDecl>(cast<DeclRefExpr>(E)->getDecl());
+    if (Ctx.getLangOptions().CPlusPlus &&
+        D && IsConstNonVolatile(D->getType())) {
       // Parameter variables are never constants.  Without this check,
       // getAnyInitializer() can find a default argument, which leads
       // to chaos.
@@ -6399,6 +6428,7 @@
       }
     }
     return ICEDiag(2, E->getLocStart());
+  }
   case Expr::UnaryOperatorClass: {
     const UnaryOperator *Exp = cast<UnaryOperator>(E);
     switch (Exp->getOpcode()) {

Modified: cfe/branches/tooling/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ItaniumMangle.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/branches/tooling/lib/AST/ItaniumMangle.cpp Tue Feb 28 17:49:25 2012
@@ -2356,7 +2356,6 @@
   case Expr::CXXThisExprClass:
   case Expr::DesignatedInitExprClass:
   case Expr::ImplicitValueInitExprClass:
-  case Expr::InitListExprClass:
   case Expr::ParenListExprClass:
   case Expr::LambdaExprClass:
     llvm_unreachable("unexpected statement kind");
@@ -2383,6 +2382,7 @@
   case Expr::StmtExprClass:
   case Expr::UnaryTypeTraitExprClass:
   case Expr::BinaryTypeTraitExprClass:
+  case Expr::TypeTraitExprClass:
   case Expr::ArrayTypeTraitExprClass:
   case Expr::ExpressionTraitExprClass:
   case Expr::VAArgExprClass:
@@ -2417,6 +2417,16 @@
   case Expr::OpaqueValueExprClass:
     llvm_unreachable("cannot mangle opaque value; mangling wrong thing?");
 
+  case Expr::InitListExprClass: {
+    // Proposal by Jason Merrill, 2012-01-03
+    Out << "il";
+    const InitListExpr *InitList = cast<InitListExpr>(E);
+    for (unsigned i = 0, e = InitList->getNumInits(); i != e; ++i)
+      mangleExpression(InitList->getInit(i));
+    Out << "E";
+    break;
+  }
+
   case Expr::CXXDefaultArgExprClass:
     mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
     break;
@@ -2453,7 +2463,6 @@
   }
 
   case Expr::CXXNewExprClass: {
-    // Proposal from David Vandervoorde, 2010.06.30
     const CXXNewExpr *New = cast<CXXNewExpr>(E);
     if (New->isGlobalNew()) Out << "gs";
     Out << (New->isArray() ? "na" : "nw");
@@ -2463,8 +2472,11 @@
     Out << '_';
     mangleType(New->getAllocatedType());
     if (New->hasInitializer()) {
-      // FIXME: Does this mean "parenthesized initializer"?
-      Out << "pi";
+      // Proposal by Jason Merrill, 2012-01-03
+      if (New->getInitializationStyle() == CXXNewExpr::ListInit)
+        Out << "il";
+      else
+        Out << "pi";
       const Expr *Init = New->getInitializer();
       if (const CXXConstructExpr *CCE = dyn_cast<CXXConstructExpr>(Init)) {
         // Directly inline the initializers.
@@ -2475,6 +2487,12 @@
       } else if (const ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
         for (unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
           mangleExpression(PLE->getExpr(i));
+      } else if (New->getInitializationStyle() == CXXNewExpr::ListInit &&
+                 isa<InitListExpr>(Init)) {
+        // Only take InitListExprs apart for list-initialization.
+        const InitListExpr *InitList = cast<InitListExpr>(Init);
+        for (unsigned i = 0, e = InitList->getNumInits(); i != e; ++i)
+          mangleExpression(InitList->getInit(i));
       } else
         mangleExpression(Init);
     }
@@ -2540,7 +2558,11 @@
     const CXXConstructExpr *CE = cast<CXXConstructExpr>(E);
     unsigned N = CE->getNumArgs();
 
-    Out << "cv";
+    // Proposal by Jason Merrill, 2012-01-03
+    if (CE->isListInitialization())
+      Out << "tl";
+    else
+      Out << "cv";
     mangleType(CE->getType());
     if (N != 1) Out << '_';
     for (unsigned I = 0; I != N; ++I) mangleExpression(CE->getArg(I));

Modified: cfe/branches/tooling/lib/AST/StmtDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/StmtDumper.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/StmtDumper.cpp (original)
+++ cfe/branches/tooling/lib/AST/StmtDumper.cpp Tue Feb 28 17:49:25 2012
@@ -516,7 +516,8 @@
     OS << "(capture ";
     if (i->isByRef()) OS << "byref ";
     if (i->isNested()) OS << "nested ";
-    DumpDeclRef(i->getVariable());
+    if (i->getVariable())
+      DumpDeclRef(i->getVariable());
     if (i->hasCopyExpr()) DumpSubTree(i->getCopyExpr());
     OS << ")";
   }

Modified: cfe/branches/tooling/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/StmtPrinter.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/StmtPrinter.cpp (original)
+++ cfe/branches/tooling/lib/AST/StmtPrinter.cpp Tue Feb 28 17:49:25 2012
@@ -1545,15 +1545,23 @@
 
 static const char *getTypeTraitName(BinaryTypeTrait BTT) {
   switch (BTT) {
-  case BTT_IsBaseOf:         return "__is_base_of";
-  case BTT_IsConvertible:    return "__is_convertible";
-  case BTT_IsSame:           return "__is_same";
-  case BTT_TypeCompatible:   return "__builtin_types_compatible_p";
-  case BTT_IsConvertibleTo:  return "__is_convertible_to";
+  case BTT_IsBaseOf:              return "__is_base_of";
+  case BTT_IsConvertible:         return "__is_convertible";
+  case BTT_IsSame:                return "__is_same";
+  case BTT_TypeCompatible:        return "__builtin_types_compatible_p";
+  case BTT_IsConvertibleTo:       return "__is_convertible_to";
+  case BTT_IsTriviallyAssignable: return "__is_trivially_assignable";
   }
   llvm_unreachable("Binary type trait not covered by switch");
 }
 
+static const char *getTypeTraitName(TypeTrait TT) {
+  switch (TT) {
+  case clang::TT_IsTriviallyConstructible:return "__is_trivially_constructible";
+  }
+  llvm_unreachable("Type trait not covered by switch");
+}
+
 static const char *getTypeTraitName(ArrayTypeTrait ATT) {
   switch (ATT) {
   case ATT_ArrayRank:        return "__array_rank";
@@ -1581,6 +1589,16 @@
      << E->getRhsType().getAsString(Policy) << ")";
 }
 
+void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
+  OS << getTypeTraitName(E->getTrait()) << "(";
+  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
+    if (I > 0)
+      OS << ", ";
+    OS << E->getArg(I)->getType().getAsString(Policy);
+  }
+  OS << ")";
+}
+
 void StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
   OS << getTypeTraitName(E->getTrait()) << "("
      << E->getQueriedType().getAsString(Policy) << ")";

Modified: cfe/branches/tooling/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/StmtProfile.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/StmtProfile.cpp (original)
+++ cfe/branches/tooling/lib/AST/StmtProfile.cpp Tue Feb 28 17:49:25 2012
@@ -868,6 +868,14 @@
   VisitType(S->getRhsType());
 }
 
+void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
+  VisitExpr(S);
+  ID.AddInteger(S->getTrait());
+  ID.AddInteger(S->getNumArgs());
+  for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
+    VisitType(S->getArg(I)->getType());
+}
+
 void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
   VisitExpr(S);
   ID.AddInteger(S->getTrait());

Modified: cfe/branches/tooling/lib/Analysis/AnalysisDeclContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/AnalysisDeclContext.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/AnalysisDeclContext.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/AnalysisDeclContext.cpp Tue Feb 28 17:49:25 2012
@@ -24,7 +24,7 @@
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/CFGStmtMap.h"
 #include "clang/Analysis/Support/BumpVector.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/ErrorHandling.h"
 

Modified: cfe/branches/tooling/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/CFG.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/CFG.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/CFG.cpp Tue Feb 28 17:49:25 2012
@@ -12,7 +12,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtVisitor.h"

Modified: cfe/branches/tooling/lib/Analysis/FormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/FormatString.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/FormatString.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/FormatString.cpp Tue Feb 28 17:49:25 2012
@@ -602,3 +602,74 @@
   }
   llvm_unreachable("Invalid LengthModifier Kind!");
 }
+
+bool FormatSpecifier::hasStandardLengthModifier() const {
+  switch (LM.getKind()) {
+    case LengthModifier::None:
+    case LengthModifier::AsChar:
+    case LengthModifier::AsShort:
+    case LengthModifier::AsLong:
+    case LengthModifier::AsLongLong:
+    case LengthModifier::AsIntMax:
+    case LengthModifier::AsSizeT:
+    case LengthModifier::AsPtrDiff:
+    case LengthModifier::AsLongDouble:
+      return true;
+    case LengthModifier::AsAllocate:
+    case LengthModifier::AsMAllocate:
+    case LengthModifier::AsQuad:
+      return false;
+  }
+  llvm_unreachable("Invalid LengthModifier Kind!");
+}
+
+bool FormatSpecifier::hasStandardConversionSpecifier(const LangOptions &LangOpt) const {
+  switch (CS.getKind()) {
+    case ConversionSpecifier::cArg:
+    case ConversionSpecifier::dArg:
+    case ConversionSpecifier::iArg:
+    case ConversionSpecifier::oArg:
+    case ConversionSpecifier::uArg:
+    case ConversionSpecifier::xArg:
+    case ConversionSpecifier::XArg:
+    case ConversionSpecifier::fArg:
+    case ConversionSpecifier::FArg:
+    case ConversionSpecifier::eArg:
+    case ConversionSpecifier::EArg:
+    case ConversionSpecifier::gArg:
+    case ConversionSpecifier::GArg:
+    case ConversionSpecifier::aArg:
+    case ConversionSpecifier::AArg:
+    case ConversionSpecifier::sArg:
+    case ConversionSpecifier::pArg:
+    case ConversionSpecifier::nArg:
+    case ConversionSpecifier::ObjCObjArg:
+    case ConversionSpecifier::ScanListArg:
+    case ConversionSpecifier::PercentArg:
+      return true;
+    case ConversionSpecifier::CArg:
+    case ConversionSpecifier::SArg:
+      return LangOpt.ObjC1 || LangOpt.ObjC2;
+    case ConversionSpecifier::InvalidSpecifier:
+    case ConversionSpecifier::PrintErrno:
+      return false;
+  }
+  llvm_unreachable("Invalid ConversionSpecifier Kind!");
+}
+
+bool FormatSpecifier::hasStandardLengthConversionCombination() const {
+  if (LM.getKind() == LengthModifier::AsLongDouble) {
+    switch(CS.getKind()) {
+        case ConversionSpecifier::dArg:
+        case ConversionSpecifier::iArg:
+        case ConversionSpecifier::oArg:
+        case ConversionSpecifier::uArg:
+        case ConversionSpecifier::xArg:
+        case ConversionSpecifier::XArg:
+          return false;
+        default:
+          return true;
+    }
+  }
+  return true;
+}

Modified: cfe/branches/tooling/lib/Analysis/UninitializedValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/UninitializedValues.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/UninitializedValues.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/UninitializedValues.cpp Tue Feb 28 17:49:25 2012
@@ -21,7 +21,7 @@
 #include "clang/Analysis/AnalysisContext.h"
 #include "clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h"
 #include "clang/Analysis/Analyses/UninitializedValues.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 
 using namespace clang;
 

Modified: cfe/branches/tooling/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/Diagnostic.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/Diagnostic.cpp (original)
+++ cfe/branches/tooling/lib/Basic/Diagnostic.cpp Tue Feb 28 17:49:25 2012
@@ -27,7 +27,7 @@
                                unsigned NumPrevArgs,
                                SmallVectorImpl<char> &Output,
                                void *Cookie,
-                               SmallVectorImpl<intptr_t> &QualTypeVals) {
+                               ArrayRef<intptr_t> QualTypeVals) {
   const char *Str = "<can't format argument>";
   Output.append(Str, Str+strlen(Str));
 }

Modified: cfe/branches/tooling/lib/Basic/SourceLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/SourceLocation.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/SourceLocation.cpp (original)
+++ cfe/branches/tooling/lib/Basic/SourceLocation.cpp Tue Feb 28 17:49:25 2012
@@ -115,6 +115,10 @@
   return SrcMgr->isBeforeInTranslationUnit(*this, Loc);
 }
 
+void FullSourceLoc::dump() const {
+  SourceLocation::dump(*SrcMgr);
+}
+
 const char *FullSourceLoc::getCharacterData(bool *Invalid) const {
   assert(isValid());
   return SrcMgr->getCharacterData(*this, Invalid);

Modified: cfe/branches/tooling/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/Targets.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/Targets.cpp (original)
+++ cfe/branches/tooling/lib/Basic/Targets.cpp Tue Feb 28 17:49:25 2012
@@ -490,10 +490,20 @@
     Builder.defineMacro("__ELF__");
     Builder.defineMacro("__svr4__");
     Builder.defineMacro("__SVR4");
-    Builder.defineMacro("_XOPEN_SOURCE", "500");
+    // Solaris headers require _XOPEN_SOURCE to be set to 600 for C99 and
+    // newer, but to 500 for everything else.  feature_test.h has a check to
+    // ensure that you are not using C99 with an old version of X/Open or C89
+    // with a new version.  
+    if (Opts.C99 || Opts.C11)
+      Builder.defineMacro("_XOPEN_SOURCE", "600");
+    else
+      Builder.defineMacro("_XOPEN_SOURCE", "500");
+    if (Opts.CPlusPlus0x)
+      Builder.defineMacro("__C99FEATURES__");
     Builder.defineMacro("_LARGEFILE_SOURCE");
     Builder.defineMacro("_LARGEFILE64_SOURCE");
     Builder.defineMacro("__EXTENSIONS__");
+    Builder.defineMacro("_REENTRANT");
   }
 public:
   SolarisTargetInfo(const std::string& triple)

Modified: cfe/branches/tooling/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/BackendUtil.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/BackendUtil.cpp Tue Feb 28 17:49:25 2012
@@ -184,7 +184,11 @@
   }
   case CodeGenOptions::OnlyAlwaysInlining:
     // Respect always_inline.
-    PMBuilder.Inliner = createAlwaysInlinerPass();
+    if (OptLevel == 0)
+      // Do not insert lifetime intrinsics at -O0.
+      PMBuilder.Inliner = createAlwaysInlinerPass(false);
+    else
+      PMBuilder.Inliner = createAlwaysInlinerPass();
     break;
   }
 

Modified: cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp Tue Feb 28 17:49:25 2012
@@ -624,7 +624,8 @@
   // Using the computed layout, generate the actual block function.
   llvm::Constant *blockFn
     = CodeGenFunction(CGM).GenerateBlockFunction(CurGD, blockInfo,
-                                                 CurFuncDecl, LocalDeclMap);
+                                                 CurFuncDecl, LocalDeclMap,
+                                                 InLambdaConversionToBlock);
   blockFn = llvm::ConstantExpr::getBitCast(blockFn, VoidPtrTy);
 
   // If there is nothing to capture, we can emit this as a global block.
@@ -699,6 +700,11 @@
       src = Builder.CreateStructGEP(LoadBlockStruct(),
                                     enclosingCapture.getIndex(),
                                     "block.capture.addr");
+    } else if (InLambdaConversionToBlock) {
+      // The lambda capture in a lambda's conversion-to-block-pointer is
+      // special; we know its argument is an lvalue we can simply emit.
+      CXXConstructExpr *CE = cast<CXXConstructExpr>(ci->getCopyExpr());
+      src = EmitLValue(CE->getArg(0)).getAddress();
     } else {
       // This is a [[type]]*.
       src = LocalDeclMap[variable];
@@ -921,7 +927,8 @@
     llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap;
     blockFn = CodeGenFunction(*this).GenerateBlockFunction(GlobalDecl(),
                                                            blockInfo,
-                                                           0, LocalDeclMap);
+                                                           0, LocalDeclMap,
+                                                           false);
   }
   blockFn = llvm::ConstantExpr::getBitCast(blockFn, VoidPtrTy);
 
@@ -975,7 +982,8 @@
 CodeGenFunction::GenerateBlockFunction(GlobalDecl GD,
                                        const CGBlockInfo &blockInfo,
                                        const Decl *outerFnDecl,
-                                       const DeclMapTy &ldm) {
+                                       const DeclMapTy &ldm,
+                                       bool IsLambdaConversionToBlock) {
   const BlockDecl *blockDecl = blockInfo.getBlockDecl();
 
   // Check if we should generate debug info for this block function.
@@ -1092,7 +1100,10 @@
   llvm::BasicBlock::iterator entry_ptr = Builder.GetInsertPoint();
   --entry_ptr;
 
-  EmitStmt(blockDecl->getBody());
+  if (IsLambdaConversionToBlock)
+    EmitLambdaBlockInvokeBody();
+  else
+    EmitStmt(blockDecl->getBody());
 
   // Remember where we were...
   llvm::BasicBlock *resume = Builder.GetInsertBlock();

Modified: cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp Tue Feb 28 17:49:25 2012
@@ -2019,7 +2019,7 @@
 }
 
 llvm::Value *CodeGenFunction::
-BuildVector(const SmallVectorImpl<llvm::Value*> &Ops) {
+BuildVector(ArrayRef<llvm::Value*> Ops) {
   assert((Ops.size() & (Ops.size() - 1)) == 0 &&
          "Not a power-of-two sized vector!");
   bool AllConstants = true;

Modified: cfe/branches/tooling/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGClass.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGClass.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGClass.cpp Tue Feb 28 17:49:25 2012
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "CGBlocks.h"
 #include "CGDebugInfo.h"
 #include "CodeGenFunction.h"
 #include "clang/AST/CXXInheritance.h"
@@ -248,9 +249,9 @@
   }
   
   // Apply the offset.
-  Value = Builder.CreatePtrToInt(Value, NonVirtualOffset->getType());
-  Value = Builder.CreateSub(Value, NonVirtualOffset);
-  Value = Builder.CreateIntToPtr(Value, DerivedPtrTy);
+  Value = Builder.CreateBitCast(Value, Int8PtrTy);
+  Value = Builder.CreateGEP(Value, Builder.CreateNeg(NonVirtualOffset),
+                            "sub.ptr");
 
   // Just cast.
   Value = Builder.CreateBitCast(Value, DerivedPtrTy);
@@ -1061,6 +1062,10 @@
     QualType::DestructionKind dtorKind = type.isDestructedType();
     if (!dtorKind) continue;
 
+    // Anonymous union members do not have their destructors called.
+    const RecordType *RT = type->getAsUnionType();
+    if (RT && RT->getDecl()->isAnonymousStructOrUnion()) continue;
+
     CleanupKind cleanupKind = getCleanupKind(dtorKind);
     EHStack.pushCleanup<DestroyField>(cleanupKind, field,
                                       getDestroyer(dtorKind),
@@ -1726,33 +1731,17 @@
   return CGM.GetAddrOfFunction(MD, fnType);
 }
 
-void CodeGenFunction::EmitLambdaToBlockPointerBody(FunctionArgList &Args) {
-  CGM.ErrorUnsupported(CurFuncDecl, "lambda conversion to block");
-}
-
-void CodeGenFunction::EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD) {
-  const CXXRecordDecl *Lambda = MD->getParent();
+void CodeGenFunction::EmitForwardingCallToLambda(const CXXRecordDecl *Lambda,
+                                                 CallArgList &CallArgs) {
+  // Lookup the call operator
   DeclarationName Name
     = getContext().DeclarationNames.getCXXOperatorName(OO_Call);
   DeclContext::lookup_const_result Calls = Lambda->lookup(Name);
   CXXMethodDecl *CallOperator = cast<CXXMethodDecl>(*Calls.first++);
-  const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
+  const FunctionProtoType *FPT =
+      CallOperator->getType()->getAs<FunctionProtoType>();
   QualType ResultType = FPT->getResultType();
 
-  // Start building arguments for forwarding call
-  CallArgList CallArgs;
-
-  QualType ThisType = getContext().getPointerType(getContext().getRecordType(Lambda));
-  llvm::Value *ThisPtr = llvm::UndefValue::get(getTypes().ConvertType(ThisType));
-  CallArgs.add(RValue::get(ThisPtr), ThisType);
-
-  // Add the rest of the parameters.
-  for (FunctionDecl::param_const_iterator I = MD->param_begin(),
-       E = MD->param_end(); I != E; ++I) {
-    ParmVarDecl *param = *I;
-    EmitDelegateCallArg(CallArgs, param);
-  }
-
   // Get the address of the call operator.
   GlobalDecl GD(CallOperator);
   const CGFunctionInfo &CalleeFnInfo =
@@ -1776,11 +1765,67 @@
     EmitReturnOfRValue(RV, ResultType);
 }
 
+void CodeGenFunction::EmitLambdaBlockInvokeBody() {
+  const BlockDecl *BD = BlockInfo->getBlockDecl();
+  const VarDecl *variable = BD->capture_begin()->getVariable();
+  const CXXRecordDecl *Lambda = variable->getType()->getAsCXXRecordDecl();
+
+  // Start building arguments for forwarding call
+  CallArgList CallArgs;
+
+  QualType ThisType = getContext().getPointerType(getContext().getRecordType(Lambda));
+  llvm::Value *ThisPtr = GetAddrOfBlockDecl(variable, false);
+  CallArgs.add(RValue::get(ThisPtr), ThisType);
+
+  // Add the rest of the parameters.
+  for (BlockDecl::param_const_iterator I = BD->param_begin(),
+       E = BD->param_end(); I != E; ++I) {
+    ParmVarDecl *param = *I;
+    EmitDelegateCallArg(CallArgs, param);
+  }
+
+  EmitForwardingCallToLambda(Lambda, CallArgs);
+}
+
+void CodeGenFunction::EmitLambdaToBlockPointerBody(FunctionArgList &Args) {
+  if (cast<CXXMethodDecl>(CurFuncDecl)->isVariadic()) {
+    // FIXME: Making this work correctly is nasty because it requires either
+    // cloning the body of the call operator or making the call operator forward.
+    CGM.ErrorUnsupported(CurFuncDecl, "lambda conversion to variadic function");
+    return;
+  }
+
+  InLambdaConversionToBlock = true;
+  EmitFunctionBody(Args);
+  InLambdaConversionToBlock = false;
+}
+
+void CodeGenFunction::EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD) {
+  const CXXRecordDecl *Lambda = MD->getParent();
+
+  // Start building arguments for forwarding call
+  CallArgList CallArgs;
+
+  QualType ThisType = getContext().getPointerType(getContext().getRecordType(Lambda));
+  llvm::Value *ThisPtr = llvm::UndefValue::get(getTypes().ConvertType(ThisType));
+  CallArgs.add(RValue::get(ThisPtr), ThisType);
+
+  // Add the rest of the parameters.
+  for (FunctionDecl::param_const_iterator I = MD->param_begin(),
+       E = MD->param_end(); I != E; ++I) {
+    ParmVarDecl *param = *I;
+    EmitDelegateCallArg(CallArgs, param);
+  }
+
+  EmitForwardingCallToLambda(Lambda, CallArgs);
+}
+
 void CodeGenFunction::EmitLambdaStaticInvokeFunction(const CXXMethodDecl *MD) {
   if (MD->isVariadic()) {
     // FIXME: Making this work correctly is nasty because it requires either
     // cloning the body of the call operator or making the call operator forward.
     CGM.ErrorUnsupported(MD, "lambda conversion to variadic function");
+    return;
   }
 
   EmitLambdaDelegatingInvokeBody(MD);

Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp Tue Feb 28 17:49:25 2012
@@ -345,6 +345,7 @@
     //  Class isa;
     // } *id;
 
+    // TODO: Cache these two types to avoid duplicates.
     llvm::DIType OCTy =
       DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
                                  "objc_class", getOrCreateMainFile(),
@@ -1243,9 +1244,9 @@
                               Line, Size, Align, Flags,
                               llvm::DIArray(), RuntimeLang);
   
-  // Otherwise, insert it into the TypeCache so that recursive uses will find
-  // it.
-  TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl;
+  // Otherwise, insert it into the CompletedTypeCache so that recursive uses
+  // will find it and we're emitting the complete type.
+  CompletedTypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl;
   // Push the struct on region stack.
   llvm::MDNode *MN = RealDecl;
   llvm::TrackingVH<llvm::MDNode> FwdDeclNode = MN;

Modified: cfe/branches/tooling/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExpr.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExpr.cpp Tue Feb 28 17:49:25 2012
@@ -2096,7 +2096,8 @@
   case CK_ARCProduceObject:
   case CK_ARCConsumeObject:
   case CK_ARCReclaimReturnedObject:
-  case CK_ARCExtendBlockObject: {
+  case CK_ARCExtendBlockObject: 
+  case CK_CopyAndAutoreleaseBlockObject: {
     // These casts only produce lvalues when we're binding a reference to a 
     // temporary realized from a (converted) pure rvalue. Emit the expression
     // as a value, copy it into a temporary, and return an lvalue referring to

Modified: cfe/branches/tooling/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprAgg.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprAgg.cpp Tue Feb 28 17:49:25 2012
@@ -324,6 +324,7 @@
   RecordDecl::field_iterator field = record->field_begin();
   if (field == record->field_end()) {
     CGF.ErrorUnsupported(initList, "weird std::initializer_list");
+    return;
   }
 
   QualType elementPtr = ctx.getPointerType(element.withConst());
@@ -331,6 +332,7 @@
   // Start pointer.
   if (!ctx.hasSameType(field->getType(), elementPtr)) {
     CGF.ErrorUnsupported(initList, "weird std::initializer_list");
+    return;
   }
   LValue start = CGF.EmitLValueForFieldInitialization(destPtr, *field, 0);
   llvm::Value *arrayStart = Builder.CreateStructGEP(alloc, 0, "arraystart");
@@ -339,6 +341,7 @@
 
   if (field == record->field_end()) {
     CGF.ErrorUnsupported(initList, "weird std::initializer_list");
+    return;
   }
   LValue endOrLength = CGF.EmitLValueForFieldInitialization(destPtr, *field, 0);
   if (ctx.hasSameType(field->getType(), elementPtr)) {
@@ -350,6 +353,7 @@
     CGF.EmitStoreThroughLValue(RValue::get(Builder.getInt(size)), endOrLength);
   } else {
     CGF.ErrorUnsupported(initList, "weird std::initializer_list");
+    return;
   }
 
   if (!Dest.isExternallyDestructed())
@@ -614,6 +618,7 @@
   case CK_ARCConsumeObject:
   case CK_ARCReclaimReturnedObject:
   case CK_ARCExtendBlockObject:
+  case CK_CopyAndAutoreleaseBlockObject:
     llvm_unreachable("cast kind invalid for aggregate types");
   }
 }
@@ -852,9 +857,16 @@
     return;
   
   if (!CGF.hasAggregateLLVMType(type)) {
-    // For non-aggregates, we can store zero
+    // For non-aggregates, we can store zero.
     llvm::Value *null = llvm::Constant::getNullValue(CGF.ConvertType(type));
-    CGF.EmitStoreThroughLValue(RValue::get(null), lv);
+    // Note that the following is not equivalent to
+    // EmitStoreThroughBitfieldLValue for ARC types.
+    if (lv.isBitField()) {
+      CGF.EmitStoreThroughBitfieldLValue(RValue::get(null), lv);
+    } else {
+      assert(lv.isSimple());
+      CGF.EmitStoreOfScalar(null, lv, /* isInitialization */ true);
+    }
   } else {
     // There's a potential optimization opportunity in combining
     // memsets; that would be easy for arrays, but relatively
@@ -899,10 +911,8 @@
       }
     }
 
-    QualType elementType = E->getType().getCanonicalType();
-    elementType = CGF.getContext().getQualifiedType(
-                    cast<ArrayType>(elementType)->getElementType(),
-                    elementType.getQualifiers() + Dest.getQualifiers());
+    QualType elementType =
+        CGF.getContext().getAsArrayType(E->getType())->getElementType();
 
     llvm::PointerType *APType =
       cast<llvm::PointerType>(DestPtr->getType());

Modified: cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp Tue Feb 28 17:49:25 2012
@@ -508,6 +508,7 @@
 
 static llvm::Value *EmitCXXNewAllocSize(CodeGenFunction &CGF,
                                         const CXXNewExpr *e,
+                                        unsigned minElements,
                                         llvm::Value *&numElements,
                                         llvm::Value *&sizeWithoutCookie) {
   QualType type = e->getAllocatedType();
@@ -581,6 +582,11 @@
     // Okay, compute a count at the right width.
     llvm::APInt adjustedCount = count.zextOrTrunc(sizeWidth);
 
+    // If there is a brace-initializer, we cannot allocate fewer elements than
+    // there are initializers. If we do, that's treated like an overflow.
+    if (adjustedCount.ult(minElements))
+      hasAnyOverflow = true;
+
     // Scale numElements by that.  This might overflow, but we don't
     // care because it only overflows if allocationSize does, too, and
     // if that overflows then we shouldn't use this.
@@ -612,14 +618,16 @@
 
   // Otherwise, we might need to use the overflow intrinsics.
   } else {
-    // There are up to four conditions we need to test for:
+    // There are up to five conditions we need to test for:
     // 1) if isSigned, we need to check whether numElements is negative;
     // 2) if numElementsWidth > sizeWidth, we need to check whether
     //   numElements is larger than something representable in size_t;
-    // 3) we need to compute
+    // 3) if minElements > 0, we need to check whether numElements is smaller
+    //    than that.
+    // 4) we need to compute
     //      sizeWithoutCookie := numElements * typeSizeMultiplier
     //    and check whether it overflows; and
-    // 4) if we need a cookie, we need to compute
+    // 5) if we need a cookie, we need to compute
     //      size := sizeWithoutCookie + cookieSize
     //    and check whether it overflows.
 
@@ -646,10 +654,11 @@
       // If there's a non-1 type size multiplier, then we can do the
       // signedness check at the same time as we do the multiply
       // because a negative number times anything will cause an
-      // unsigned overflow.  Otherwise, we have to do it here.
+      // unsigned overflow.  Otherwise, we have to do it here. But at least
+      // in this case, we can subsume the >= minElements check.
       if (typeSizeMultiplier == 1)
         hasOverflow = CGF.Builder.CreateICmpSLT(numElements,
-                                      llvm::ConstantInt::get(CGF.SizeTy, 0));
+                              llvm::ConstantInt::get(CGF.SizeTy, minElements));
 
     // Otherwise, zext up to size_t if necessary.
     } else if (numElementsWidth < sizeWidth) {
@@ -658,6 +667,21 @@
 
     assert(numElements->getType() == CGF.SizeTy);
 
+    if (minElements) {
+      // Don't allow allocation of fewer elements than we have initializers.
+      if (!hasOverflow) {
+        hasOverflow = CGF.Builder.CreateICmpULT(numElements,
+                              llvm::ConstantInt::get(CGF.SizeTy, minElements));
+      } else if (numElementsWidth > sizeWidth) {
+        // The other existing overflow subsumes this check.
+        // We do an unsigned comparison, since any signed value < -1 is
+        // taken care of either above or below.
+        hasOverflow = CGF.Builder.CreateOr(hasOverflow,
+                          CGF.Builder.CreateICmpULT(numElements,
+                              llvm::ConstantInt::get(CGF.SizeTy, minElements)));
+      }
+    }
+
     size = numElements;
 
     // Multiply by the type size if necessary.  This multiplier
@@ -741,11 +765,8 @@
   return size;
 }
 
-static void StoreAnyExprIntoOneUnit(CodeGenFunction &CGF, const CXXNewExpr *E,
-                                    llvm::Value *NewPtr) {
-
-  const Expr *Init = E->getInitializer();
-  QualType AllocType = E->getAllocatedType();
+static void StoreAnyExprIntoOneUnit(CodeGenFunction &CGF, const Expr *Init,
+                                    QualType AllocType, llvm::Value *NewPtr) {
 
   CharUnits Alignment = CGF.getContext().getTypeAlignInChars(AllocType);
   if (!CGF.hasAggregateLLVMType(AllocType))
@@ -775,26 +796,64 @@
   if (!E->hasInitializer())
     return; // We have a POD type.
 
-  // Check if the number of elements is constant.
-  bool checkZero = true;
-  if (llvm::ConstantInt *constNum = dyn_cast<llvm::ConstantInt>(numElements)) {
-    // If it's constant zero, skip the whole loop.
-    if (constNum->isZero()) return;
-
-    checkZero = false;
-  }
-
+  llvm::Value *explicitPtr = beginPtr;
   // Find the end of the array, hoisted out of the loop.
   llvm::Value *endPtr =
     Builder.CreateInBoundsGEP(beginPtr, numElements, "array.end");
 
+  unsigned initializerElements = 0;
+
+  const Expr *Init = E->getInitializer();
+  llvm::AllocaInst *endOfInit = 0;
+  QualType::DestructionKind dtorKind = elementType.isDestructedType();
+  EHScopeStack::stable_iterator cleanup;
+  llvm::Instruction *cleanupDominator = 0;
+  // If the initializer is an initializer list, first do the explicit elements.
+  if (const InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
+    initializerElements = ILE->getNumInits();
+
+    // Enter a partial-destruction cleanup if necessary.
+    if (needsEHCleanup(dtorKind)) {
+      // In principle we could tell the cleanup where we are more
+      // directly, but the control flow can get so varied here that it
+      // would actually be quite complex.  Therefore we go through an
+      // alloca.
+      endOfInit = CreateTempAlloca(beginPtr->getType(), "array.endOfInit");
+      cleanupDominator = Builder.CreateStore(beginPtr, endOfInit);
+      pushIrregularPartialArrayCleanup(beginPtr, endOfInit, elementType,
+                                       getDestroyer(dtorKind));
+      cleanup = EHStack.stable_begin();
+    }
+
+    for (unsigned i = 0, e = ILE->getNumInits(); i != e; ++i) {
+      // Tell the cleanup that it needs to destroy up to this
+      // element.  TODO: some of these stores can be trivially
+      // observed to be unnecessary.
+      if (endOfInit) Builder.CreateStore(explicitPtr, endOfInit);
+      StoreAnyExprIntoOneUnit(*this, ILE->getInit(i), elementType, explicitPtr);
+      explicitPtr =Builder.CreateConstGEP1_32(explicitPtr, 1, "array.exp.next");
+    }
+
+    // The remaining elements are filled with the array filler expression.
+    Init = ILE->getArrayFiller();
+  }
+
   // Create the continuation block.
   llvm::BasicBlock *contBB = createBasicBlock("new.loop.end");
 
-  // If we need to check for zero, do so now.
-  if (checkZero) {
+  // If the number of elements isn't constant, we have to now check if there is
+  // anything left to initialize.
+  if (llvm::ConstantInt *constNum = dyn_cast<llvm::ConstantInt>(numElements)) {
+    // If all elements have already been initialized, skip the whole loop.
+    if (constNum->getZExtValue() <= initializerElements) {
+      // If there was a cleanup, deactivate it.
+      if (cleanupDominator)
+        DeactivateCleanupBlock(cleanup, cleanupDominator);;
+      return;
+    }
+  } else {
     llvm::BasicBlock *nonEmptyBB = createBasicBlock("new.loop.nonempty");
-    llvm::Value *isEmpty = Builder.CreateICmpEQ(beginPtr, endPtr,
+    llvm::Value *isEmpty = Builder.CreateICmpEQ(explicitPtr, endPtr,
                                                 "array.isempty");
     Builder.CreateCondBr(isEmpty, contBB, nonEmptyBB);
     EmitBlock(nonEmptyBB);
@@ -808,14 +867,14 @@
 
   // Set up the current-element phi.
   llvm::PHINode *curPtr =
-    Builder.CreatePHI(beginPtr->getType(), 2, "array.cur");
-  curPtr->addIncoming(beginPtr, entryBB);
+    Builder.CreatePHI(explicitPtr->getType(), 2, "array.cur");
+  curPtr->addIncoming(explicitPtr, entryBB);
+
+  // Store the new cleanup position for irregular cleanups.
+  if (endOfInit) Builder.CreateStore(curPtr, endOfInit);
 
   // Enter a partial-destruction cleanup if necessary.
-  QualType::DestructionKind dtorKind = elementType.isDestructedType();
-  EHScopeStack::stable_iterator cleanup;
-  llvm::Instruction *cleanupDominator = 0;
-  if (needsEHCleanup(dtorKind)) {
+  if (!cleanupDominator && needsEHCleanup(dtorKind)) {
     pushRegularPartialArrayCleanup(beginPtr, curPtr, elementType,
                                    getDestroyer(dtorKind));
     cleanup = EHStack.stable_begin();
@@ -823,7 +882,7 @@
   }
 
   // Emit the initializer into this element.
-  StoreAnyExprIntoOneUnit(*this, E, curPtr);
+  StoreAnyExprIntoOneUnit(*this, Init, E->getAllocatedType(), curPtr);
 
   // Leave the cleanup if we entered one.
   if (cleanupDominator) {
@@ -861,7 +920,7 @@
     if (const CXXConstructExpr *CCE = dyn_cast_or_null<CXXConstructExpr>(Init)){
       CXXConstructorDecl *Ctor = CCE->getConstructor();
       bool RequiresZeroInitialization = false;
-      if (Ctor->getParent()->hasTrivialDefaultConstructor()) {
+      if (Ctor->isTrivial()) {
         // If new expression did not specify value-initialization, then there
         // is no initialization.
         if (!CCE->requiresZeroInitialization() || Ctor->getParent()->isEmpty())
@@ -895,7 +954,7 @@
   if (!Init)
     return;
 
-  StoreAnyExprIntoOneUnit(CGF, E, NewPtr);
+  StoreAnyExprIntoOneUnit(CGF, Init, E->getAllocatedType(), NewPtr);
 }
 
 namespace {
@@ -1069,10 +1128,18 @@
   // The allocation size is the first argument.
   QualType sizeType = getContext().getSizeType();
 
+  // If there is a brace-initializer, cannot allocate fewer elements than inits.
+  unsigned minElements = 0;
+  if (E->isArray() && E->hasInitializer()) {
+    if (const InitListExpr *ILE = dyn_cast<InitListExpr>(E->getInitializer()))
+      minElements = ILE->getNumInits();
+  }
+
   llvm::Value *numElements = 0;
   llvm::Value *allocSizeWithoutCookie = 0;
   llvm::Value *allocSize =
-    EmitCXXNewAllocSize(*this, E, numElements, allocSizeWithoutCookie);
+    EmitCXXNewAllocSize(*this, E, minElements, numElements,
+                        allocSizeWithoutCookie);
   
   allocatorArgs.add(RValue::get(allocSize), sizeType);
 

Modified: cfe/branches/tooling/lib/CodeGen/CGExprComplex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprComplex.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprComplex.cpp Tue Feb 28 17:49:25 2012
@@ -261,6 +261,10 @@
 
   ComplexPairTy VisitInitListExpr(InitListExpr *E);
 
+  ComplexPairTy VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
+    return EmitLoadOfLValue(E);
+  }
+
   ComplexPairTy VisitVAArgExpr(VAArgExpr *E);
 
   ComplexPairTy VisitAtomicExpr(AtomicExpr *E) {
@@ -413,6 +417,7 @@
   case CK_ARCConsumeObject:
   case CK_ARCReclaimReturnedObject:
   case CK_ARCExtendBlockObject:
+  case CK_CopyAndAutoreleaseBlockObject:
     llvm_unreachable("invalid cast kind for complex value");
 
   case CK_FloatingRealToComplex:

Modified: cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp Tue Feb 28 17:49:25 2012
@@ -53,9 +53,14 @@
     NextFieldOffsetInChars(CharUnits::Zero()),
     LLVMStructAlignment(CharUnits::One()) { }
 
+  void AppendVTablePointer(BaseSubobject Base, llvm::Constant *VTable,
+                           const CXXRecordDecl *VTableClass);
+
   void AppendField(const FieldDecl *Field, uint64_t FieldOffset,
                    llvm::Constant *InitExpr);
 
+  void AppendBytes(CharUnits FieldOffsetInChars, llvm::Constant *InitCst);
+
   void AppendBitField(const FieldDecl *Field, uint64_t FieldOffset,
                       llvm::ConstantInt *InitExpr);
 
@@ -66,7 +71,9 @@
   void ConvertStructToPacked();
 
   bool Build(InitListExpr *ILE);
-  void Build(const APValue &Val, QualType ValTy);
+  void Build(const APValue &Val, const RecordDecl *RD, bool IsPrimaryBase,
+             llvm::Constant *VTable, const CXXRecordDecl *VTableClass,
+             CharUnits BaseOffset);
   llvm::Constant *Finalize(QualType Ty);
 
   CharUnits getAlignment(const llvm::Constant *C) const {
@@ -81,14 +88,36 @@
   }
 };
 
+void ConstStructBuilder::AppendVTablePointer(BaseSubobject Base,
+                                             llvm::Constant *VTable,
+                                             const CXXRecordDecl *VTableClass) {
+  // Find the appropriate vtable within the vtable group.
+  uint64_t AddressPoint =
+    CGM.getVTableContext().getVTableLayout(VTableClass).getAddressPoint(Base);
+  llvm::Value *Indices[] = {
+    llvm::ConstantInt::get(CGM.Int64Ty, 0),
+    llvm::ConstantInt::get(CGM.Int64Ty, AddressPoint)
+  };
+  llvm::Constant *VTableAddressPoint =
+    llvm::ConstantExpr::getInBoundsGetElementPtr(VTable, Indices);
+
+  // Add the vtable at the start of the object.
+  AppendBytes(CharUnits::Zero(), VTableAddressPoint);
+}
+
 void ConstStructBuilder::
 AppendField(const FieldDecl *Field, uint64_t FieldOffset,
             llvm::Constant *InitCst) {
-
   const ASTContext &Context = CGM.getContext();
 
   CharUnits FieldOffsetInChars = Context.toCharUnitsFromBits(FieldOffset);
 
+  AppendBytes(FieldOffsetInChars, InitCst);
+}
+
+void ConstStructBuilder::
+AppendBytes(CharUnits FieldOffsetInChars, llvm::Constant *InitCst) {
+
   assert(NextFieldOffsetInChars <= FieldOffsetInChars
          && "Field offset mismatch!");
 
@@ -340,7 +369,7 @@
                             
 bool ConstStructBuilder::Build(InitListExpr *ILE) {
   if (ILE->initializesStdInitializerList()) {
-    CGM.ErrorUnsupported(ILE, "global std::initializer_list");
+    //CGM.ErrorUnsupported(ILE, "global std::initializer_list");
     return false;
   }
 
@@ -399,23 +428,56 @@
   return true;
 }
 
-void ConstStructBuilder::Build(const APValue &Val, QualType ValTy) {
-  RecordDecl *RD = ValTy->getAs<RecordType>()->getDecl();
+namespace {
+struct BaseInfo {
+  BaseInfo(const CXXRecordDecl *Decl, CharUnits Offset, unsigned Index)
+    : Decl(Decl), Offset(Offset), Index(Index) {
+  }
+
+  const CXXRecordDecl *Decl;
+  CharUnits Offset;
+  unsigned Index;
+
+  bool operator<(const BaseInfo &O) const { return Offset < O.Offset; }
+};
+}
+
+void ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD,
+                               bool IsPrimaryBase, llvm::Constant *VTable,
+                               const CXXRecordDecl *VTableClass,
+                               CharUnits Offset) {
   const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
 
-  if (CXXRecordDecl *CD = dyn_cast<CXXRecordDecl>(RD)) {
+  if (const CXXRecordDecl *CD = dyn_cast<CXXRecordDecl>(RD)) {
+    // Add a vtable pointer, if we need one and it hasn't already been added.
+    if (CD->isDynamicClass() && !IsPrimaryBase)
+      AppendVTablePointer(BaseSubobject(CD, Offset), VTable, VTableClass);
+
+    // Accumulate and sort bases, in order to visit them in address order, which
+    // may not be the same as declaration order.
+    llvm::SmallVector<BaseInfo, 8> Bases;
+    Bases.reserve(CD->getNumBases());
     unsigned BaseNo = 0;
-    for (CXXRecordDecl::base_class_iterator Base = CD->bases_begin(),
+    for (CXXRecordDecl::base_class_const_iterator Base = CD->bases_begin(),
          BaseEnd = CD->bases_end(); Base != BaseEnd; ++Base, ++BaseNo) {
-      // Build the base class subobject at the appropriately-offset location
-      // within this object.
+      assert(!Base->isVirtual() && "should not have virtual bases here");
       const CXXRecordDecl *BD = Base->getType()->getAsCXXRecordDecl();
       CharUnits BaseOffset = Layout.getBaseClassOffset(BD);
-      NextFieldOffsetInChars -= BaseOffset;
+      Bases.push_back(BaseInfo(BD, BaseOffset, BaseNo));
+    }
+    std::stable_sort(Bases.begin(), Bases.end());
 
-      Build(Val.getStructBase(BaseNo), Base->getType());
+    for (unsigned I = 0, N = Bases.size(); I != N; ++I) {
+      BaseInfo &Base = Bases[I];
+      // Build the base class subobject at the appropriately-offset location
+      // within this object.
+      NextFieldOffsetInChars -= Base.Offset;
+
+      bool IsPrimaryBase = Layout.getPrimaryBase() == Base.Decl;
+      Build(Val.getStructBase(Base.Index), Base.Decl, IsPrimaryBase,
+            VTable, VTableClass, Offset + Base.Offset);
 
-      NextFieldOffsetInChars += BaseOffset;
+      NextFieldOffsetInChars += Base.Offset;
     }
   }
 
@@ -532,7 +594,15 @@
                                                 const APValue &Val,
                                                 QualType ValTy) {
   ConstStructBuilder Builder(CGM, CGF);
-  Builder.Build(Val, ValTy);
+
+  const RecordDecl *RD = ValTy->castAs<RecordType>()->getDecl();
+  const CXXRecordDecl *CD = dyn_cast<CXXRecordDecl>(RD);
+  llvm::Constant *VTable = 0;
+  if (CD && CD->isDynamicClass())
+    VTable = CGM.getVTables().GetAddrOfVTable(CD);
+
+  Builder.Build(Val, RD, false, VTable, CD, CharUnits::Zero());
+
   return Builder.Finalize(ValTy);
 }
 
@@ -636,6 +706,7 @@
     case CK_ARCConsumeObject:
     case CK_ARCReclaimReturnedObject:
     case CK_ARCExtendBlockObject:
+    case CK_CopyAndAutoreleaseBlockObject:
       return 0;
 
     // These don't need to be handled here because Evaluate knows how to

Modified: cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp Tue Feb 28 17:49:25 2012
@@ -1148,6 +1148,9 @@
   case CK_ARCExtendBlockObject:
     return CGF.EmitARCExtendBlockObject(E);
 
+  case CK_CopyAndAutoreleaseBlockObject:
+    return CGF.EmitBlockCopyAndAutorelease(Visit(E), E->getType());
+      
   case CK_FloatingRealToComplex:
   case CK_FloatingComplexCast:
   case CK_IntegralRealToComplex:

Modified: cfe/branches/tooling/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjC.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjC.cpp Tue Feb 28 17:49:25 2012
@@ -2774,5 +2774,30 @@
   return HelperFn;
 }
 
+llvm::Value *
+CodeGenFunction::EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty) {
+  // Get selectors for retain/autorelease.
+  IdentifierInfo *RetainID = &getContext().Idents.get("retain");
+  Selector RetainSelector =
+      getContext().Selectors.getNullarySelector(RetainID);
+  IdentifierInfo *AutoreleaseID = &getContext().Idents.get("autorelease");
+  Selector AutoreleaseSelector =
+      getContext().Selectors.getNullarySelector(AutoreleaseID);
+
+  // Emit calls to retain/autorelease.
+  CGObjCRuntime &Runtime = CGM.getObjCRuntime();
+  llvm::Value *Val = Block;
+  RValue Result;
+  Result = Runtime.GenerateMessageSend(*this, ReturnValueSlot(),
+                                       Ty, RetainSelector,
+                                       Val, CallArgList(), 0, 0);
+  Val = Result.getScalarVal();
+  Result = Runtime.GenerateMessageSend(*this, ReturnValueSlot(),
+                                       Ty, AutoreleaseSelector,
+                                       Val, CallArgList(), 0, 0);
+  Val = Result.getScalarVal();
+  return Val;
+}
+
 
 CGObjCRuntime::~CGObjCRuntime() {}

Modified: cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp Tue Feb 28 17:49:25 2012
@@ -337,10 +337,9 @@
   /// containing a size and an array of structures containing instance variable
   /// metadata.  This is used purely for introspection in the fragile ABI.  In
   /// the non-fragile ABI, it's used for instance variable fixup.
-  llvm::Constant *GenerateIvarList(
-      const SmallVectorImpl<llvm::Constant *>  &IvarNames,
-      const SmallVectorImpl<llvm::Constant *>  &IvarTypes,
-      const SmallVectorImpl<llvm::Constant *>  &IvarOffsets);
+  llvm::Constant *GenerateIvarList(ArrayRef<llvm::Constant *> IvarNames,
+                                   ArrayRef<llvm::Constant *> IvarTypes,
+                                   ArrayRef<llvm::Constant *> IvarOffsets);
   /// Generates a method list structure.  This is a structure containing a size
   /// and an array of structures containing method metadata.
   ///
@@ -348,8 +347,8 @@
   /// pointer allowing them to be chained together in a linked list.
   llvm::Constant *GenerateMethodList(const StringRef &ClassName,
       const StringRef &CategoryName,
-      const SmallVectorImpl<Selector>  &MethodSels,
-      const SmallVectorImpl<llvm::Constant *>  &MethodTypes,
+      ArrayRef<Selector> MethodSels,
+      ArrayRef<llvm::Constant *> MethodTypes,
       bool isClassMethodList);
   /// Emits an empty protocol.  This is used for @protocol() where no protocol
   /// is found.  The runtime will (hopefully) fix up the pointer to refer to the
@@ -362,8 +361,7 @@
         SmallVectorImpl<llvm::Constant*> &InstanceMethodTypes);
   /// Generates a list of referenced protocols.  Classes, categories, and
   /// protocols all use this structure.
-  llvm::Constant *GenerateProtocolList(
-      const SmallVectorImpl<std::string> &Protocols);
+  llvm::Constant *GenerateProtocolList(ArrayRef<std::string> Protocols);
   /// To ensure that all protocols are seen by the runtime, we add a category on
   /// a class defined in the runtime, declaring no methods, but adopting the
   /// protocols.  This is a horribly ugly hack, but it allows us to collect all
@@ -388,8 +386,8 @@
   /// Generates a method list.  This is used by protocols to define the required
   /// and optional methods.
   llvm::Constant *GenerateProtocolMethodList(
-      const SmallVectorImpl<llvm::Constant *>  &MethodNames,
-      const SmallVectorImpl<llvm::Constant *>  &MethodTypes);
+      ArrayRef<llvm::Constant *> MethodNames,
+      ArrayRef<llvm::Constant *> MethodTypes);
   /// Returns a selector with the specified type encoding.  An empty string is
   /// used to return an untyped selector (with the types field set to NULL).
   llvm::Value *GetSelector(CGBuilderTy &Builder, Selector Sel,
@@ -428,7 +426,7 @@
   /// significant bit being assumed to come first in the bitfield.  Therefore,
   /// a bitfield with the 64th bit set will be (int64_t)&{ 2, [0, 1<<31] },
   /// while a bitfield / with the 63rd bit set will be 1<<64.
-  llvm::Constant *MakeBitField(llvm::SmallVectorImpl<bool> &bits);
+  llvm::Constant *MakeBitField(ArrayRef<bool> bits);
 public:
   CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
       unsigned protocolClassVersion);
@@ -1257,11 +1255,12 @@
 
 /// Generates a MethodList.  Used in construction of a objc_class and
 /// objc_category structures.
-llvm::Constant *CGObjCGNU::GenerateMethodList(const StringRef &ClassName,
-                                              const StringRef &CategoryName,
-    const SmallVectorImpl<Selector> &MethodSels,
-    const SmallVectorImpl<llvm::Constant *> &MethodTypes,
-    bool isClassMethodList) {
+llvm::Constant *CGObjCGNU::
+GenerateMethodList(const StringRef &ClassName,
+                   const StringRef &CategoryName,
+                   ArrayRef<Selector> MethodSels,
+                   ArrayRef<llvm::Constant *> MethodTypes,
+                   bool isClassMethodList) {
   if (MethodSels.empty())
     return NULLPtr;
   // Get the method structure type.
@@ -1314,10 +1313,10 @@
 }
 
 /// Generates an IvarList.  Used in construction of a objc_class.
-llvm::Constant *CGObjCGNU::GenerateIvarList(
-    const SmallVectorImpl<llvm::Constant *>  &IvarNames,
-    const SmallVectorImpl<llvm::Constant *>  &IvarTypes,
-    const SmallVectorImpl<llvm::Constant *>  &IvarOffsets) {
+llvm::Constant *CGObjCGNU::
+GenerateIvarList(ArrayRef<llvm::Constant *> IvarNames,
+                 ArrayRef<llvm::Constant *> IvarTypes,
+                 ArrayRef<llvm::Constant *> IvarOffsets) {
   if (IvarNames.size() == 0)
     return NULLPtr;
   // Get the method structure type.
@@ -1444,9 +1443,9 @@
   return Class;
 }
 
-llvm::Constant *CGObjCGNU::GenerateProtocolMethodList(
-    const SmallVectorImpl<llvm::Constant *>  &MethodNames,
-    const SmallVectorImpl<llvm::Constant *>  &MethodTypes) {
+llvm::Constant *CGObjCGNU::
+GenerateProtocolMethodList(ArrayRef<llvm::Constant *> MethodNames,
+                           ArrayRef<llvm::Constant *> MethodTypes) {
   // Get the method structure type.
   llvm::StructType *ObjCMethodDescTy = llvm::StructType::get(
     PtrToInt8Ty, // Really a selector, but the runtime does the casting for us.
@@ -1473,8 +1472,7 @@
 }
 
 // Create the protocol list structure used in classes, categories and so on
-llvm::Constant *CGObjCGNU::GenerateProtocolList(
-    const SmallVectorImpl<std::string> &Protocols) {
+llvm::Constant *CGObjCGNU::GenerateProtocolList(ArrayRef<std::string>Protocols){
   llvm::ArrayType *ProtocolArrayTy = llvm::ArrayType::get(PtrToInt8Ty,
       Protocols.size());
   llvm::StructType *ProtocolListTy = llvm::StructType::get(
@@ -1771,7 +1769,7 @@
 /// significant bit being assumed to come first in the bitfield.  Therefore, a
 /// bitfield with the 64th bit set will be (int64_t)&{ 2, [0, 1<<31] }, while a
 /// bitfield / with the 63rd bit set will be 1<<64.
-llvm::Constant *CGObjCGNU::MakeBitField(llvm::SmallVectorImpl<bool> &bits) {
+llvm::Constant *CGObjCGNU::MakeBitField(ArrayRef<bool> bits) {
   int bitCount = bits.size();
   int ptrBits =
         (TheModule.getPointerSize() == llvm::Module::Pointer32) ? 32 : 64;

Modified: cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp Tue Feb 28 17:49:25 2012
@@ -831,7 +831,7 @@
   void BuildAggrIvarLayout(const ObjCImplementationDecl *OI,
                            const llvm::StructLayout *Layout,
                            const RecordDecl *RD,
-                           const SmallVectorImpl<const FieldDecl*> &RecFields,
+                           ArrayRef<const FieldDecl*> RecFields,
                            unsigned int BytePos, bool ForStrongLayout,
                            bool &HasUnion);
 
@@ -1080,7 +1080,7 @@
 
   virtual void GenerateClass(const ObjCImplementationDecl *ClassDecl);
 
-  virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) {};
+  virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) {}
 
   virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
                                            const ObjCProtocolDecl *PD);
@@ -1335,7 +1335,7 @@
 
   virtual void GenerateClass(const ObjCImplementationDecl *ClassDecl);
 
-  virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) {};
+  virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) {}
 
   virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
                                            const ObjCProtocolDecl *PD);
@@ -2561,14 +2561,14 @@
 
 /*
   struct objc_ivar {
-  char *ivar_name;
-  char *ivar_type;
-  int ivar_offset;
+    char *ivar_name;
+    char *ivar_type;
+    int ivar_offset;
   };
 
   struct objc_ivar_list {
-  int ivar_count;
-  struct objc_ivar list[count];
+    int ivar_count;
+    struct objc_ivar list[count];
   };
 */
 llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID,
@@ -3768,7 +3768,7 @@
 void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI,
                              const llvm::StructLayout *Layout,
                              const RecordDecl *RD,
-                             const SmallVectorImpl<const FieldDecl*> &RecFields,
+                             ArrayRef<const FieldDecl*> RecFields,
                              unsigned int BytePos, bool ForStrongLayout,
                              bool &HasUnion) {
   bool IsUnion = (RD && RD->isUnion());

Modified: cfe/branches/tooling/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGStmt.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGStmt.cpp Tue Feb 28 17:49:25 2012
@@ -191,20 +191,13 @@
   PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),S.getLBracLoc(),
                              "LLVM IR generation of compound statement ('{}')");
 
-  CGDebugInfo *DI = getDebugInfo();
-  if (DI)
-    DI->EmitLexicalBlockStart(Builder, S.getLBracLoc());
-
-  // Keep track of the current cleanup stack depth.
-  RunCleanupsScope Scope(*this);
+  // Keep track of the current cleanup stack depth, including debug scopes.
+  LexicalScope Scope(*this, S.getSourceRange());
 
   for (CompoundStmt::const_body_iterator I = S.body_begin(),
        E = S.body_end()-GetLast; I != E; ++I)
     EmitStmt(*I);
 
-  if (DI)
-    DI->EmitLexicalBlockEnd(Builder, S.getRBracLoc());
-
   RValue RV;
   if (!GetLast)
     RV = RValue::get(0);

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenFunction.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenFunction.cpp Tue Feb 28 17:49:25 2012
@@ -32,7 +32,8 @@
     Target(CGM.getContext().getTargetInfo()),
     Builder(cgm.getModule().getContext()),
     AutoreleaseResult(false), BlockInfo(0), BlockPointer(0),
-    LambdaThisCaptureField(0), NormalCleanupDest(0), NextCleanupDestIndex(1),
+    LambdaThisCaptureField(0), InLambdaConversionToBlock(false),
+    NormalCleanupDest(0), NextCleanupDestIndex(1),
     FirstBlockInfo(0), EHResumeBlock(0), ExceptionSlot(0), EHSelectorSlot(0),
     DebugInfo(0), DisableDebugInfo(false), DidCallStackSave(false),
     IndirectBranch(0), SwitchInsn(0), CaseRangeBlock(0), UnreachableBlock(0),

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h Tue Feb 28 17:49:25 2012
@@ -601,6 +601,7 @@
 
   llvm::DenseMap<const VarDecl *, FieldDecl *> LambdaCaptureFields;
   FieldDecl *LambdaThisCaptureField;
+  bool InLambdaConversionToBlock;
 
   /// \brief A mapping from NRVO variables to the flags used to indicate
   /// when the NRVO has been applied to this variable.
@@ -1335,7 +1336,8 @@
   llvm::Function *GenerateBlockFunction(GlobalDecl GD,
                                         const CGBlockInfo &Info,
                                         const Decl *OuterFuncDecl,
-                                        const DeclMapTy &ldm);
+                                        const DeclMapTy &ldm,
+                                        bool IsLambdaConversionToBlock);
 
   llvm::Constant *GenerateCopyHelperFunction(const CGBlockInfo &blockInfo);
   llvm::Constant *GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo);
@@ -1343,6 +1345,7 @@
                                              const ObjCPropertyImplDecl *PID);
   llvm::Constant *GenerateObjCAtomicGetterCopyHelperFunction(
                                              const ObjCPropertyImplDecl *PID);
+  llvm::Value *EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty);
 
   void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags);
 
@@ -1376,7 +1379,10 @@
   void EmitDestructorBody(FunctionArgList &Args);
   void EmitFunctionBody(FunctionArgList &Args);
 
+  void EmitForwardingCallToLambda(const CXXRecordDecl *Lambda,
+                                  CallArgList &CallArgs);
   void EmitLambdaToBlockPointerBody(FunctionArgList &Args);
+  void EmitLambdaBlockInvokeBody();
   void EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD);
   void EmitLambdaStaticInvokeFunction(const CXXMethodDecl *MD);
 
@@ -2226,7 +2232,7 @@
   llvm::Value *EmitNeonShiftVector(llvm::Value *V, llvm::Type *Ty,
                                    bool negateForRightShift);
 
-  llvm::Value *BuildVector(const SmallVectorImpl<llvm::Value*> &Ops);
+  llvm::Value *BuildVector(ArrayRef<llvm::Value*> Ops);
   llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
   llvm::Value *EmitHexagonBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
   llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp Tue Feb 28 17:49:25 2012
@@ -39,6 +39,7 @@
 #include "llvm/Module.h"
 #include "llvm/Intrinsics.h"
 #include "llvm/LLVMContext.h"
+#include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Target/Mangler.h"
 #include "llvm/Target/TargetData.h"
@@ -1359,6 +1360,123 @@
       TheTargetData.getTypeStoreSizeInBits(Ty));
 }
 
+llvm::Constant *
+CodeGenModule::MaybeEmitGlobalStdInitializerListInitializer(const VarDecl *D,
+                                                       const Expr *rawInit) {
+  ArrayRef<ExprWithCleanups::CleanupObject> cleanups;
+  if (const ExprWithCleanups *withCleanups =
+          dyn_cast<ExprWithCleanups>(rawInit)) {
+    cleanups = withCleanups->getObjects();
+    rawInit = withCleanups->getSubExpr();
+  }
+
+  const InitListExpr *init = dyn_cast<InitListExpr>(rawInit);
+  if (!init || !init->initializesStdInitializerList() ||
+      init->getNumInits() == 0)
+    return 0;
+
+  ASTContext &ctx = getContext();
+  unsigned numInits = init->getNumInits();
+  // FIXME: This check is here because we would otherwise silently miscompile
+  // nested global std::initializer_lists. Better would be to have a real
+  // implementation.
+  for (unsigned i = 0; i < numInits; ++i) {
+    const InitListExpr *inner = dyn_cast<InitListExpr>(init->getInit(i));
+    if (inner && inner->initializesStdInitializerList()) {
+      ErrorUnsupported(inner, "nested global std::initializer_list");
+      return 0;
+    }
+  }
+
+  // Synthesize a fake VarDecl for the array and initialize that.
+  QualType elementType = init->getInit(0)->getType();
+  llvm::APInt numElements(ctx.getTypeSize(ctx.getSizeType()), numInits);
+  QualType arrayType = ctx.getConstantArrayType(elementType, numElements,
+                                                ArrayType::Normal, 0);
+
+  IdentifierInfo *name = &ctx.Idents.get(D->getNameAsString() + "__initlist");
+  TypeSourceInfo *sourceInfo = ctx.getTrivialTypeSourceInfo(
+                                              arrayType, D->getLocation());
+  VarDecl *backingArray = VarDecl::Create(ctx, const_cast<DeclContext*>(
+                                                          D->getDeclContext()),
+                                          D->getLocStart(), D->getLocation(),
+                                          name, arrayType, sourceInfo,
+                                          SC_Static, SC_Static);
+
+  // Now clone the InitListExpr to initialize the array instead.
+  // Incredible hack: we want to use the existing InitListExpr here, so we need
+  // to tell it that it no longer initializes a std::initializer_list.
+  Expr *arrayInit = new (ctx) InitListExpr(ctx, init->getLBraceLoc(),
+                                    const_cast<InitListExpr*>(init)->getInits(),
+                                                   init->getNumInits(),
+                                                   init->getRBraceLoc());
+  arrayInit->setType(arrayType);
+
+  if (!cleanups.empty())
+    arrayInit = ExprWithCleanups::Create(ctx, arrayInit, cleanups);
+
+  backingArray->setInit(arrayInit);
+
+  // Emit the definition of the array.
+  EmitGlobalVarDefinition(backingArray);
+
+  // Inspect the initializer list to validate it and determine its type.
+  // FIXME: doing this every time is probably inefficient; caching would be nice
+  RecordDecl *record = init->getType()->castAs<RecordType>()->getDecl();
+  RecordDecl::field_iterator field = record->field_begin();
+  if (field == record->field_end()) {
+    ErrorUnsupported(D, "weird std::initializer_list");
+    return 0;
+  }
+  QualType elementPtr = ctx.getPointerType(elementType.withConst());
+  // Start pointer.
+  if (!ctx.hasSameType(field->getType(), elementPtr)) {
+    ErrorUnsupported(D, "weird std::initializer_list");
+    return 0;
+  }
+  ++field;
+  if (field == record->field_end()) {
+    ErrorUnsupported(D, "weird std::initializer_list");
+    return 0;
+  }
+  bool isStartEnd = false;
+  if (ctx.hasSameType(field->getType(), elementPtr)) {
+    // End pointer.
+    isStartEnd = true;
+  } else if(!ctx.hasSameType(field->getType(), ctx.getSizeType())) {
+    ErrorUnsupported(D, "weird std::initializer_list");
+    return 0;
+  }
+
+  // Now build an APValue representing the std::initializer_list.
+  APValue initListValue(APValue::UninitStruct(), 0, 2);
+  APValue &startField = initListValue.getStructField(0);
+  APValue::LValuePathEntry startOffsetPathEntry;
+  startOffsetPathEntry.ArrayIndex = 0;
+  startField = APValue(APValue::LValueBase(backingArray),
+                       CharUnits::fromQuantity(0),
+                       llvm::makeArrayRef(startOffsetPathEntry),
+                       /*IsOnePastTheEnd=*/false, 0);
+
+  if (isStartEnd) {
+    APValue &endField = initListValue.getStructField(1);
+    APValue::LValuePathEntry endOffsetPathEntry;
+    endOffsetPathEntry.ArrayIndex = numInits;
+    endField = APValue(APValue::LValueBase(backingArray),
+                       ctx.getTypeSizeInChars(elementType) * numInits,
+                       llvm::makeArrayRef(endOffsetPathEntry),
+                       /*IsOnePastTheEnd=*/true, 0);
+  } else {
+    APValue &sizeField = initListValue.getStructField(1);
+    sizeField = APValue(llvm::APSInt(numElements));
+  }
+
+  // Emit the constant for the initializer_list.
+  llvm::Constant *llvmInit = EmitConstantValue(initListValue, D->getType());
+  assert(llvmInit && "failed to initialize as constant");
+  return llvmInit;
+}
+
 void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
   llvm::Constant *Init = 0;
   QualType ASTTy = D->getType();
@@ -1368,7 +1486,7 @@
 
   const VarDecl *InitDecl;
   const Expr *InitExpr = D->getAnyInitializer(InitDecl);
-  
+
   if (!InitExpr) {
     // This is a tentative definition; tentative definitions are
     // implicitly initialized with { 0 }.
@@ -1382,7 +1500,15 @@
     assert(!ASTTy->isIncompleteType() && "Unexpected incomplete type");
     Init = EmitNullConstant(D->getType());
   } else {
-    Init = EmitConstantInit(*InitDecl);
+    // If this is a std::initializer_list, emit the special initializer.
+    Init = MaybeEmitGlobalStdInitializerListInitializer(D, InitExpr);
+    // An empty init list will perform zero-initialization, which happens
+    // to be exactly what we want.
+    // FIXME: It does so in a global constructor, which is *not* what we
+    // want.
+
+    if (!Init)
+      Init = EmitConstantInit(*InitDecl);
     if (!Init) {
       QualType T = InitExpr->getType();
       if (D->getType()->isReferenceType())

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.h Tue Feb 28 17:49:25 2012
@@ -55,6 +55,7 @@
   class Decl;
   class Expr;
   class Stmt;
+  class InitListExpr;
   class StringLiteral;
   class NamedDecl;
   class ValueDecl;
@@ -877,6 +878,8 @@
 
   void EmitGlobalFunctionDefinition(GlobalDecl GD);
   void EmitGlobalVarDefinition(const VarDecl *D);
+  llvm::Constant *MaybeEmitGlobalStdInitializerListInitializer(const VarDecl *D,
+                                                              const Expr *init);
   void EmitAliasDefinition(GlobalDecl GD);
   void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
   void EmitObjCIvarInitializations(ObjCImplementationDecl *D);

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenTypes.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenTypes.cpp Tue Feb 28 17:49:25 2012
@@ -195,11 +195,9 @@
   // If this isn't a tagged type, we can convert it!
   const TagType *TT = Ty->getAs<TagType>();
   if (TT == 0) return true;
-  
-  
-  // If it's a tagged type used by-value, but is just a forward decl, we can't
-  // convert it.  Note that getDefinition()==0 is not the same as !isDefinition.
-  if (TT->getDecl()->getDefinition() == 0)
+    
+  // Incomplete types cannot be converted.
+  if (TT->isIncompleteType())
     return false;
   
   // If this is an enum, then it is always safe to convert.

Modified: cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp Tue Feb 28 17:49:25 2012
@@ -424,7 +424,8 @@
     return (Size == 8 || Size == 16 || Size == 32 || Size == 64);
   }
 
-  static bool shouldReturnTypeInRegister(QualType Ty, ASTContext &Context);
+  static bool shouldReturnTypeInRegister(QualType Ty, ASTContext &Context, 
+                                          unsigned callingConvention);
 
   /// getIndirectResult - Give a source type \arg Ty, return a suitable result
   /// such that the argument will be passed in memory.
@@ -435,11 +436,13 @@
 
 public:
 
-  ABIArgInfo classifyReturnType(QualType RetTy) const;
+  ABIArgInfo classifyReturnType(QualType RetTy, 
+                                unsigned callingConvention) const;
   ABIArgInfo classifyArgumentType(QualType RetTy) const;
 
   virtual void computeInfo(CGFunctionInfo &FI) const {
-    FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+    FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), 
+                                            FI.getCallingConvention());
     for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
          it != ie; ++it)
       it->info = classifyArgumentType(it->type);
@@ -485,7 +488,8 @@
 /// shouldReturnTypeInRegister - Determine if the given type should be
 /// passed in a register (for the Darwin ABI).
 bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty,
-                                               ASTContext &Context) {
+                                               ASTContext &Context,
+                                               unsigned callingConvention) {
   uint64_t Size = Context.getTypeSize(Ty);
 
   // Type must be register sized.
@@ -510,7 +514,8 @@
 
   // Arrays are treated like records.
   if (const ConstantArrayType *AT = Context.getAsConstantArrayType(Ty))
-    return shouldReturnTypeInRegister(AT->getElementType(), Context);
+    return shouldReturnTypeInRegister(AT->getElementType(), Context,
+                                      callingConvention);
 
   // Otherwise, it must be a record type.
   const RecordType *RT = Ty->getAs<RecordType>();
@@ -518,6 +523,13 @@
 
   // FIXME: Traverse bases here too.
 
+  // For thiscall conventions, structures will never be returned in
+  // a register.  This is for compatibility with the MSVC ABI
+  if (callingConvention == llvm::CallingConv::X86_ThisCall && 
+      RT->isStructureType()) {
+    return false;
+  }
+
   // Structure types are passed in register if all fields would be
   // passed in a register.
   for (RecordDecl::field_iterator i = RT->getDecl()->field_begin(),
@@ -529,14 +541,15 @@
       continue;
 
     // Check fields recursively.
-    if (!shouldReturnTypeInRegister(FD->getType(), Context))
+    if (!shouldReturnTypeInRegister(FD->getType(), Context, 
+                                    callingConvention))
       return false;
   }
-
   return true;
 }
 
-ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy) const {
+ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy, 
+                                            unsigned callingConvention) const {
   if (RetTy->isVoidType())
     return ABIArgInfo::getIgnore();
 
@@ -583,7 +596,8 @@
 
     // Small structures which are register sized are generally returned
     // in a register.
-    if (X86_32ABIInfo::shouldReturnTypeInRegister(RetTy, getContext())) {
+    if (X86_32ABIInfo::shouldReturnTypeInRegister(RetTy, getContext(), 
+                                                  callingConvention)) {
       uint64_t Size = getContext().getTypeSize(RetTy);
 
       // As a special-case, if the struct is a "single-element" struct, and

Modified: cfe/branches/tooling/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Driver.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Driver.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Driver.cpp Tue Feb 28 17:49:25 2012
@@ -113,6 +113,12 @@
       Diag(clang::diag::err_drv_unsupported_opt) << A->getAsString(*Args);
       continue;
     }
+
+    // Warn about -mcpu= without an argument.
+    if (A->getOption().matches(options::OPT_mcpu_EQ) && 
+        A->containsValue("")) {
+      Diag(clang::diag::warn_drv_empty_joined_argument) << A->getAsString(*Args);
+    }
   }
 
   return Args;
@@ -304,6 +310,10 @@
       Cur = Split.second;
     }
   }
+  // FIXME: DefaultTargetTriple is used by the target-prefixed calls to as/ld
+  // and getToolChain is const.
+  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),
@@ -363,6 +373,9 @@
 // diagnostic information to a bug report.
 void Driver::generateCompilationDiagnostics(Compilation &C,
                                             const Command *FailingCommand) {
+  if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
+    return;
+
   Diag(clang::diag::note_drv_command_failed_diag_msg)
     << "Please submit a bug report to " BUG_REPORT_URL " and include command"
     " line arguments and all diagnostic information.";
@@ -1504,6 +1517,7 @@
 
 std::string Driver::GetProgramPath(const char *Name, const ToolChain &TC,
                                    bool WantFile) const {
+  // FIXME: Needs a better variable than DefaultTargetTriple
   std::string TargetSpecificExecutable(DefaultTargetTriple + "-" + Name);
   // Respect a limited subset of the '-Bprefix' functionality in GCC by
   // attempting to use this prefix when lokup up program paths.
@@ -1574,6 +1588,7 @@
 static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple,
                                         const ArgList &Args,
                                         StringRef DarwinArchName) {
+  // FIXME: Already done in Compilation *Driver::BuildCompilation
   if (const Arg *A = Args.getLastArg(options::OPT_target))
     DefaultTargetTriple = A->getValue(Args);
 

Modified: cfe/branches/tooling/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChains.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChains.cpp (original)
+++ cfe/branches/tooling/lib/Driver/ToolChains.cpp Tue Feb 28 17:49:25 2012
@@ -1219,6 +1219,7 @@
   };
   static const char *const PPC64LibDirs[] = { "/lib64", "/lib" };
   static const char *const PPC64Triples[] = {
+    "powerpc64-linux-gnu",
     "powerpc64-unknown-linux-gnu",
     "powerpc64-suse-linux",
     "ppc64-redhat-linux"
@@ -1962,6 +1963,14 @@
     if (llvm::sys::fs::exists(SysRoot + "/lib/mipsel-linux-gnu"))
       return "mipsel-linux-gnu";
     return TargetTriple.str();
+  case llvm::Triple::ppc:
+    if (llvm::sys::fs::exists(SysRoot + "/lib/powerpc-linux-gnu"))
+      return "powerpc-linux-gnu";
+    return TargetTriple.str();
+  case llvm::Triple::ppc64:
+    if (llvm::sys::fs::exists(SysRoot + "/lib/powerpc64-linux-gnu"))
+      return "powerpc64-linux-gnu";
+    return TargetTriple.str();
   }
 }
 
@@ -2171,6 +2180,12 @@
   const StringRef MIPSELMultiarchIncludeDirs[] = {
     "/usr/include/mipsel-linux-gnu"
   };
+  const StringRef PPCMultiarchIncludeDirs[] = {
+    "/usr/include/powerpc-linux-gnu"
+  };
+  const StringRef PPC64MultiarchIncludeDirs[] = {
+    "/usr/include/powerpc64-linux-gnu"
+  };
   ArrayRef<StringRef> MultiarchIncludeDirs;
   if (getTriple().getArch() == llvm::Triple::x86_64) {
     MultiarchIncludeDirs = X86_64MultiarchIncludeDirs;
@@ -2182,6 +2197,10 @@
     MultiarchIncludeDirs = MIPSMultiarchIncludeDirs;
   } else if (getTriple().getArch() == llvm::Triple::mipsel) {
     MultiarchIncludeDirs = MIPSELMultiarchIncludeDirs;
+  } else if (getTriple().getArch() == llvm::Triple::ppc) {
+    MultiarchIncludeDirs = PPCMultiarchIncludeDirs;
+  } else if (getTriple().getArch() == llvm::Triple::ppc64) {
+    MultiarchIncludeDirs = PPC64MultiarchIncludeDirs;
   }
   for (ArrayRef<StringRef>::iterator I = MultiarchIncludeDirs.begin(),
                                      E = MultiarchIncludeDirs.end();

Modified: cfe/branches/tooling/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChains.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChains.h (original)
+++ cfe/branches/tooling/lib/Driver/ToolChains.h Tue Feb 28 17:49:25 2012
@@ -329,9 +329,8 @@
 #ifdef DISABLE_DEFAULT_INTEGRATED_ASSEMBLER
     return false;
 #else
-    // Default integrated assembler to on for x86.
-    return (getTriple().getArch() == llvm::Triple::x86 ||
-            getTriple().getArch() == llvm::Triple::x86_64);
+    // Default integrated assembler to on for Darwin.
+    return true;
 #endif
   }
   virtual bool IsStrictAliasingDefault() const {

Modified: cfe/branches/tooling/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Tools.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Tools.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Tools.cpp Tue Feb 28 17:49:25 2012
@@ -2079,7 +2079,6 @@
     !Args.hasFlag(options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
                   getToolChain().getTriple().getOS() != llvm::Triple::Cygwin &&
                   getToolChain().getTriple().getOS() != llvm::Triple::MinGW32 &&
-                  getToolChain().getTriple().getOS() != llvm::Triple::Solaris &&
                   getToolChain().getTriple().getArch() !=
                   llvm::Triple::hexagon))
     CmdArgs.push_back("-fno-use-cxa-atexit");
@@ -4249,9 +4248,13 @@
     if (!Args.hasArg(options::OPT_shared)) {
       CmdArgs.push_back(Args.MakeArgString(LibPath + "crt1.o"));
       CmdArgs.push_back(Args.MakeArgString(LibPath + "crti.o"));
+      CmdArgs.push_back(Args.MakeArgString(LibPath + "values-Xa.o"));
       CmdArgs.push_back(Args.MakeArgString(GCCLibPath + "crtbegin.o"));
     } else {
+      CmdArgs.push_back(Args.MakeArgString(LibPath + "cxa_finalize.o"));
       CmdArgs.push_back(Args.MakeArgString(LibPath + "crti.o"));
+      CmdArgs.push_back(Args.MakeArgString(LibPath + "values-Xa.o"));
+      CmdArgs.push_back(Args.MakeArgString(GCCLibPath + "crtbegin.o"));
     }
   }
 
@@ -4260,22 +4263,25 @@
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
   Args.AddAllArgs(CmdArgs, options::OPT_e);
+  Args.AddAllArgs(CmdArgs, options::OPT_r);
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  if (getToolChain().getDriver().CCCIsCXX)
+    getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nodefaultlibs)) {
-    CmdArgs.push_back("-lgcc");
     CmdArgs.push_back("-lgcc_s");
-    if (!Args.hasArg(options::OPT_shared))
+    if (!Args.hasArg(options::OPT_shared)) {
+      CmdArgs.push_back("-lgcc");
       CmdArgs.push_back("-lc");
-
+      CmdArgs.push_back("-lm");
+    }
   }
 
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nostartfiles)) {
-    if (!Args.hasArg(options::OPT_shared))
-      CmdArgs.push_back(Args.MakeArgString(GCCLibPath + "crtend.o"));
+    CmdArgs.push_back(Args.MakeArgString(GCCLibPath + "crtend.o"));
   }
   CmdArgs.push_back(Args.MakeArgString(LibPath + "crtn.o"));
 

Modified: cfe/branches/tooling/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/ASTUnit.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/ASTUnit.cpp Tue Feb 28 17:49:25 2012
@@ -220,7 +220,6 @@
     PreambleRebuildCounter(0), SavedMainFileBuffer(0), PreambleBuffer(0),
     NumWarningsInPreamble(0),
     ShouldCacheCodeCompletionResults(false),
-    NestedMacroExpansions(true),
     CompletionCacheTopLevelHashValue(0),
     PreambleTopLevelHashValue(0),
     CurrentTopLevelHashValue(0),
@@ -1093,8 +1092,6 @@
   // If the main file has been overridden due to the use of a preamble,
   // make that override happen and introduce the preamble.
   PreprocessorOptions &PreprocessorOpts = Clang->getPreprocessorOpts();
-  PreprocessorOpts.DetailedRecordIncludesNestedMacroExpansions
-    = NestedMacroExpansions;
   if (OverrideMainBuffer) {
     PreprocessorOpts.addRemappedFile(OriginalSourceFile, OverrideMainBuffer);
     PreprocessorOpts.PrecompiledPreambleBytes.first = Preamble.size();
@@ -1832,8 +1829,7 @@
                                              bool CaptureDiagnostics,
                                              bool PrecompilePreamble,
                                              TranslationUnitKind TUKind,
-                                             bool CacheCodeCompletionResults,
-                                             bool NestedMacroExpansions) {  
+                                             bool CacheCodeCompletionResults) {  
   // Create the AST unit.
   OwningPtr<ASTUnit> AST;
   AST.reset(new ASTUnit(false));
@@ -1844,7 +1840,6 @@
   AST->TUKind = TUKind;
   AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
   AST->Invocation = CI;
-  AST->NestedMacroExpansions = NestedMacroExpansions;
   
   // Recover resources if we crash before exiting this method.
   llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit>
@@ -1867,8 +1862,7 @@
                                       bool RemappedFilesKeepOriginalName,
                                       bool PrecompilePreamble,
                                       TranslationUnitKind TUKind,
-                                      bool CacheCodeCompletionResults,
-                                      bool NestedMacroExpansions) {
+                                      bool CacheCodeCompletionResults) {
   if (!Diags.getPtr()) {
     // No diagnostics engine was provided, so create our own diagnostics object
     // with the default options.
@@ -1926,7 +1920,6 @@
   AST->StoredDiagnostics.swap(StoredDiagnostics);
   AST->Invocation = CI;
   CI = 0; // Zero out now to ease cleanup during crash recovery.
-  AST->NestedMacroExpansions = NestedMacroExpansions;
   
   // Recover resources if we crash before exiting this method.
   llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit>

Modified: cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp Tue Feb 28 17:49:25 2012
@@ -257,8 +257,7 @@
   }
 
   if (PPOpts.DetailedRecord)
-    PP->createPreprocessingRecord(
-                                  PPOpts.DetailedRecordIncludesNestedMacroExpansions);
+    PP->createPreprocessingRecord();
 
   InitializePreprocessor(*PP, PPOpts, getHeaderSearchOpts(), getFrontendOpts());
 

Modified: cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp Tue Feb 28 17:49:25 2012
@@ -1043,6 +1043,7 @@
   Opts.MaxLoop = Args.getLastArgIntValue(OPT_analyzer_max_loop, 4, Diags);
   Opts.EagerlyTrimEGraph = !Args.hasArg(OPT_analyzer_no_eagerly_trim_egraph);
   Opts.InlineCall = Args.hasArg(OPT_analyzer_inline_call);
+  Opts.PrintStats = Args.hasArg(OPT_analyzer_stats);
 
   Opts.CheckersControlList.clear();
   for (arg_iterator it = Args.filtered_begin(OPT_analyzer_checker,

Modified: cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp Tue Feb 28 17:49:25 2012
@@ -417,13 +417,6 @@
   case llvm::Triple::Solaris:
     AddGnuCPlusPlusIncludePaths("/usr/gcc/4.5/include/c++/4.5.2/",
                                 "i386-pc-solaris2.11", "", "", triple);
-    AddGnuCPlusPlusIncludePaths(
-        "/usr/gcc/4.5/lib/gcc/i386-pc-solaris2.11/4.5.2/include",
-        "", "", "", triple);
-    AddGnuCPlusPlusIncludePaths(
-        "/usr/gcc/4.5/lib/gcc/i386-pc-solaris2.11/4.5.2/include-fixed",
-        "", "", "", triple);
-
     // Solaris - Fall though..
   case llvm::Triple::AuroraUX:
     // AuroraUX

Modified: cfe/branches/tooling/lib/Headers/tgmath.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Headers/tgmath.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Headers/tgmath.h (original)
+++ cfe/branches/tooling/lib/Headers/tgmath.h Tue Feb 28 17:49:25 2012
@@ -540,15 +540,15 @@
     _TG_ATTRS
     __tg_fabs(long double __x) {return fabsl(__x);}
 
-static float _Complex
+static float
     _TG_ATTRS
     __tg_fabs(float _Complex __x) {return cabsf(__x);}
 
-static double _Complex
+static double
     _TG_ATTRS
     __tg_fabs(double _Complex __x) {return cabs(__x);}
 
-static long double _Complex
+static long double
     _TG_ATTRS
     __tg_fabs(long double _Complex __x) {return cabsl(__x);}
 
@@ -976,6 +976,23 @@
 #undef log2
 #define log2(__x) __tg_log2(__tg_promote1((__x))(__x))
 
+// logb
+
+static float
+    _TG_ATTRS
+    __tg_logb(float __x) {return logbf(__x);}
+
+static double
+    _TG_ATTRS
+    __tg_logb(double __x) {return logb(__x);}
+
+static long double
+    _TG_ATTRS
+    __tg_logb(long double __x) {return logbl(__x);}
+
+#undef logb
+#define logb(__x) __tg_logb(__tg_promote1((__x))(__x))
+
 // lrint
 
 static long

Modified: cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp Tue Feb 28 17:49:25 2012
@@ -589,8 +589,13 @@
 /// specified by the identifier as a standard language feature.
 static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
   const LangOptions &LangOpts = PP.getLangOptions();
+  StringRef Feature = II->getName();
 
-  return llvm::StringSwitch<bool>(II->getName())
+  // Normalize the feature name, __foo__ becomes foo.
+  if (Feature.startswith("__") && Feature.endswith("__") && Feature.size() >= 4)
+    Feature = Feature.substr(2, Feature.size() - 4);
+
+  return llvm::StringSwitch<bool>(Feature)
            .Case("address_sanitizer", LangOpts.AddressSanitizer)
            .Case("attribute_analyzer_noreturn", true)
            .Case("attribute_availability", true)
@@ -645,11 +650,11 @@
            .Case("cxx_delegating_constructors", LangOpts.CPlusPlus0x)
            .Case("cxx_deleted_functions", LangOpts.CPlusPlus0x)
            .Case("cxx_explicit_conversions", LangOpts.CPlusPlus0x)
-         //.Case("cxx_generalized_initializers", LangOpts.CPlusPlus0x)
+           .Case("cxx_generalized_initializers", LangOpts.CPlusPlus0x)
            .Case("cxx_implicit_moves", LangOpts.CPlusPlus0x)
          //.Case("cxx_inheriting_constructors", false)
            .Case("cxx_inline_namespaces", LangOpts.CPlusPlus0x)
-         //.Case("cxx_lambdas", false)
+           .Case("cxx_lambdas", LangOpts.CPlusPlus0x)
            .Case("cxx_nonstatic_member_init", LangOpts.CPlusPlus0x)
            .Case("cxx_noexcept", LangOpts.CPlusPlus0x)
            .Case("cxx_nullptr", LangOpts.CPlusPlus0x)
@@ -700,6 +705,8 @@
                                                             != tok::identifier)
            .Case("is_polymorphic", LangOpts.CPlusPlus)
            .Case("is_trivial", LangOpts.CPlusPlus)
+           .Case("is_trivially_assignable", LangOpts.CPlusPlus)
+           .Case("is_trivially_constructible", LangOpts.CPlusPlus)
            .Case("is_trivially_copyable", LangOpts.CPlusPlus)
            .Case("is_union", LangOpts.CPlusPlus)
            .Case("modules", LangOpts.Modules)
@@ -722,10 +729,16 @@
     return false;
 
   const LangOptions &LangOpts = PP.getLangOptions();
+  StringRef Extension = II->getName();
+
+  // Normalize the extension name, __foo__ becomes foo.
+  if (Extension.startswith("__") && Extension.endswith("__") &&
+      Extension.size() >= 4)
+    Extension = Extension.substr(2, Extension.size() - 4);
 
   // Because we inherit the feature list from HasFeature, this string switch
   // must be less restrictive than HasFeature's.
-  return llvm::StringSwitch<bool>(II->getName())
+  return llvm::StringSwitch<bool>(Extension)
            // C11 features supported by other languages as extensions.
            .Case("c_alignas", true)
            .Case("c_atomic", true)

Modified: cfe/branches/tooling/lib/Lex/PreprocessingRecord.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PreprocessingRecord.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PreprocessingRecord.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PreprocessingRecord.cpp Tue Feb 28 17:49:25 2012
@@ -37,10 +37,8 @@
   this->FileName = StringRef(Memory, FileName.size());
 }
 
-PreprocessingRecord::PreprocessingRecord(SourceManager &SM,
-                                         bool IncludeNestedMacroExpansions)
-  : SourceMgr(SM), IncludeNestedMacroExpansions(IncludeNestedMacroExpansions),
-    ExternalSource(0)
+PreprocessingRecord::PreprocessingRecord(SourceManager &SM)
+  : SourceMgr(SM), ExternalSource(0)
 {
 }
 
@@ -331,7 +329,8 @@
 
 void PreprocessingRecord::MacroExpands(const Token &Id, const MacroInfo* MI,
                                        SourceRange Range) {
-  if (!IncludeNestedMacroExpansions && Id.getLocation().isMacroID())
+  // We don't record nested macro expansions.
+  if (Id.getLocation().isMacroID())
     return;
 
   if (MI->isBuiltinMacro())

Modified: cfe/branches/tooling/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Preprocessor.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Preprocessor.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Preprocessor.cpp Tue Feb 28 17:49:25 2012
@@ -654,12 +654,10 @@
 
 CodeCompletionHandler::~CodeCompletionHandler() { }
 
-void Preprocessor::createPreprocessingRecord(
-                                      bool IncludeNestedMacroExpansions) {
+void Preprocessor::createPreprocessingRecord() {
   if (Record)
     return;
   
-  Record = new PreprocessingRecord(getSourceManager(),
-                                   IncludeNestedMacroExpansions);
+  Record = new PreprocessingRecord(getSourceManager());
   addPPCallbacks(Record);
 }

Modified: cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp Tue Feb 28 17:49:25 2012
@@ -145,16 +145,14 @@
   // function body.
   if (ConsumeAndStoreFunctionPrologue(Toks)) {
     // We didn't find the left-brace we expected after the
-    // constructor initializer.
-    if (Tok.is(tok::semi)) {
-      // We found a semicolon; complain, consume the semicolon, and
-      // don't try to parse this method later.
-      Diag(Tok.getLocation(), diag::err_expected_lbrace);
-      ConsumeAnyToken();
-      delete getCurrentClass().LateParsedDeclarations.back();
-      getCurrentClass().LateParsedDeclarations.pop_back();
-      return FnD;
-    }
+    // constructor initializer; we already printed an error, and it's likely
+    // impossible to recover, so don't try to parse this method later.
+    // If we stopped at a semicolon, consume it to avoid an extra warning.
+     if (Tok.is(tok::semi))
+      ConsumeToken();
+    delete getCurrentClass().LateParsedDeclarations.back();
+    getCurrentClass().LateParsedDeclarations.pop_back();
+    return FnD;
   } else {
     // Consume everything up to (and including) the matching right brace.
     ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
@@ -606,6 +604,7 @@
     Toks.push_back(Tok);
     ConsumeToken();
   }
+  bool ReadInitializer = false;
   if (Tok.is(tok::colon)) {
     // Initializers can contain braces too.
     Toks.push_back(Tok);
@@ -613,37 +612,52 @@
 
     while (Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) {
       if (Tok.is(tok::eof) || Tok.is(tok::semi))
-        return true;
+        return Diag(Tok.getLocation(), diag::err_expected_lbrace);
 
       // Grab the identifier.
       if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
                                 /*StopAtSemi=*/true,
                                 /*ConsumeFinalToken=*/false))
-        return true;
+        return Diag(Tok.getLocation(), diag::err_expected_lparen);
 
       tok::TokenKind kind = Tok.getKind();
       Toks.push_back(Tok);
-      if (kind == tok::l_paren)
+      bool IsLParen = (kind == tok::l_paren);
+      SourceLocation LOpen = Tok.getLocation();
+
+      if (IsLParen) {
         ConsumeParen();
-      else {
+      } else {
         assert(kind == tok::l_brace && "Must be left paren or brace here.");
         ConsumeBrace();
         // In C++03, this has to be the start of the function body, which
-        // means the initializer is malformed.
+        // means the initializer is malformed; we'll diagnose it later.
         if (!getLang().CPlusPlus0x)
           return false;
       }
 
       // Grab the initializer
-      if (!ConsumeAndStoreUntil(kind == tok::l_paren ? tok::r_paren :
-                                                       tok::r_brace,
-                                Toks, /*StopAtSemi=*/true))
+      if (!ConsumeAndStoreUntil(IsLParen ? tok::r_paren : tok::r_brace,
+                                Toks, /*StopAtSemi=*/true)) {
+        Diag(Tok, IsLParen ? diag::err_expected_rparen :
+                             diag::err_expected_rbrace);
+        Diag(LOpen, diag::note_matching) << (IsLParen ? "(" : "{");
         return true;
+      }
+
+      // Grab pack ellipsis, if present
+      if (Tok.is(tok::ellipsis)) {
+        Toks.push_back(Tok);
+        ConsumeToken();
+      }
 
       // Grab the separating comma, if any.
       if (Tok.is(tok::comma)) {
         Toks.push_back(Tok);
         ConsumeToken();
+      } else if (Tok.isNot(tok::l_brace)) {
+        ReadInitializer = true;
+        break;
       }
     }
   }
@@ -651,11 +665,14 @@
   // Grab any remaining garbage to be diagnosed later. We stop when we reach a
   // brace: an opening one is the function body, while a closing one probably
   // means we've reached the end of the class.
-  if (!ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
-                            /*StopAtSemi=*/true, /*ConsumeFinalToken=*/false))
-    return true;
-  if(Tok.isNot(tok::l_brace))
-    return true;
+  ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
+                       /*StopAtSemi=*/true,
+                       /*ConsumeFinalToken=*/false);
+  if (Tok.isNot(tok::l_brace)) {
+    if (ReadInitializer)
+      return Diag(Tok.getLocation(), diag::err_expected_lbrace_or_comma);
+    return Diag(Tok.getLocation(), diag::err_expected_lbrace);
+  }
 
   Toks.push_back(Tok);
   ConsumeBrace();

Modified: cfe/branches/tooling/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseDecl.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseDecl.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseDecl.cpp Tue Feb 28 17:49:25 2012
@@ -3000,9 +3000,15 @@
 
         // Consume the ':'.
         ConsumeToken();
-      
-        if ((getLang().CPlusPlus && 
-             isCXXDeclarationSpecifier() != TPResult::True()) ||
+
+        // If we see a type specifier followed by an open-brace, we have an
+        // ambiguity between an underlying type and a C++11 braced
+        // function-style cast. Resolve this by always treating it as an
+        // underlying type.
+        // FIXME: The standard is not entirely clear on how to disambiguate in
+        // this case.
+        if ((getLang().CPlusPlus &&
+             isCXXDeclarationSpecifier(TPResult::True()) != TPResult::True()) ||
             (!getLang().CPlusPlus && !isDeclarationSpecifier(true))) {
           // We'll parse this as a bitfield later.
           PossibleBitfield = true;
@@ -4220,6 +4226,8 @@
   ExprResult NoexceptExpr;
   ParsedType TrailingReturnType;
   
+  Actions.ActOnStartFunctionDeclarator();
+
   SourceLocation EndLoc;
   if (isFunctionDeclaratorIdentifierList()) {
     if (RequiresArg)

Modified: cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp Tue Feb 28 17:49:25 2012
@@ -653,6 +653,9 @@
       return EndLoc;
     }
   } else {
+    if (Tok.getIdentifierInfo()->isStr("decltype"))
+      Diag(Tok, diag::warn_cxx98_compat_decltype);
+
     ConsumeToken();
 
     BalancedDelimiterTracker T(*this, tok::l_paren);
@@ -667,13 +670,13 @@
 
     // C++0x [dcl.type.simple]p4:
     //   The operand of the decltype specifier is an unevaluated operand.
-    EnterExpressionEvaluationContext Unevaluated(Actions,
-                                                 Sema::Unevaluated);
+    EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated,
+                                                 0, /*IsDecltype=*/true);
     Result = ParseExpression();
     if (Result.isInvalid()) {
-      SkipUntil(tok::r_paren, true, true);
+      SkipUntil(tok::r_paren);
       DS.SetTypeSpecError();
-      return Tok.is(tok::eof) ? Tok.getLocation() : ConsumeParen();
+      return StartLoc;
     }
 
     // Match the ')'
@@ -685,6 +688,12 @@
       return T.getCloseLocation();
     }
 
+    Result = Actions.ActOnDecltypeExpression(Result.take());
+    if (Result.isInvalid()) {
+      DS.SetTypeSpecError();
+      return T.getCloseLocation();
+    }
+
     EndLoc = T.getCloseLocation();
   }
 
@@ -2006,7 +2015,7 @@
       if (Init.isInvalid())
         SkipUntil(tok::comma, true, true);
       else if (ThisDecl)
-        Actions.AddInitializerToDecl(ThisDecl, Init.get(), false,
+        Actions.AddInitializerToDecl(ThisDecl, Init.get(), EqualLoc.isInvalid(),
                                    DS.getTypeSpecType() == DeclSpec::TST_auto);      
     } else if (ThisDecl && DS.getStorageClassSpec() == DeclSpec::SCS_static) {
       // No initializer.
@@ -2081,15 +2090,15 @@
 ///
 ///   pure-specifier:
 ///     '= 0'
-///  
+///
 ///   brace-or-equal-initializer:
 ///     '=' initializer-expression
-///     braced-init-list                       [TODO]
-///  
+///     braced-init-list
+///
 ///   initializer-clause:
 ///     assignment-expression
-///     braced-init-list                       [TODO]
-///  
+///     braced-init-list
+///
 ///   defaulted/deleted function-definition:                                                                                                                                                                                               
 ///     '=' 'default'
 ///     '=' 'delete'
@@ -2131,9 +2140,8 @@
       return ExprResult();
     }
 
-    return ParseInitializer();
-  } else
-    return ExprError(Diag(Tok, diag::err_generalized_initializer_lists));
+  }
+  return ParseInitializer();
 }
 
 /// ParseCXXMemberSpecification - Parse the class definition.
@@ -2246,6 +2254,16 @@
         continue;
       }
 
+      if (Tok.is(tok::annot_pragma_vis)) {
+        HandlePragmaVisibility();
+        continue;
+      }
+
+      if (Tok.is(tok::annot_pragma_pack)) {
+        HandlePragmaPack();
+        continue;
+      }
+
       AccessSpecifier AS = getAccessSpecifierIfPresent();
       if (AS != AS_none) {
         // Current token is a C++ access specifier.

Modified: cfe/branches/tooling/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseExpr.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseExpr.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseExpr.cpp Tue Feb 28 17:49:25 2012
@@ -249,7 +249,7 @@
 }
 
 
-ExprResult Parser::ParseConstantExpression() {
+ExprResult Parser::ParseConstantExpression(TypeCastState isTypeCast) {
   // C++03 [basic.def.odr]p2:
   //   An expression is potentially evaluated unless it appears where an
   //   integral constant expression is required (see 5.19) [...].
@@ -257,7 +257,7 @@
   EnterExpressionEvaluationContext Unevaluated(Actions,
                                                Sema::ConstantEvaluated);
 
-  ExprResult LHS(ParseCastExpression(false));
+  ExprResult LHS(ParseCastExpression(false, false, isTypeCast));
   return ParseRHSOfBinaryExpression(LHS, prec::Conditional);
 }
 
@@ -351,12 +351,23 @@
     // be a throw-expression, which is not a valid cast-expression.
     // Therefore we need some special-casing here.
     // Also note that the third operand of the conditional operator is
-    // an assignment-expression in C++.
+    // an assignment-expression in C++, and in C++11, we can have a
+    // braced-init-list on the RHS of an assignment.
     ExprResult RHS;
-    if (getLang().CPlusPlus && NextTokPrec <= prec::Conditional)
+    if (getLang().CPlusPlus0x && MinPrec == prec::Assignment &&
+        Tok.is(tok::l_brace)) {
+      Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
+      RHS = ParseBraceInitializer();
+      if (LHS.isInvalid() || RHS.isInvalid())
+        return ExprError();
+      // A braced-init-list can never be followed by more operators.
+      return Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
+                                OpToken.getKind(), LHS.take(), RHS.take());
+    } else if (getLang().CPlusPlus && NextTokPrec <= prec::Conditional) {
       RHS = ParseAssignmentExpression();
-    else
+    } else {
       RHS = ParseCastExpression(false);
+    }
 
     if (RHS.isInvalid())
       LHS = ExprError();
@@ -1140,8 +1151,12 @@
   case tok::kw___is_same:
   case tok::kw___is_convertible:
   case tok::kw___is_convertible_to:
+  case tok::kw___is_trivially_assignable:
     return ParseBinaryTypeTrait();
 
+  case tok::kw___is_trivially_constructible:
+    return ParseTypeTrait();
+      
   case tok::kw___array_rank:
   case tok::kw___array_extent:
     return ParseArrayTypeTrait();
@@ -1328,7 +1343,8 @@
       CommaLocsTy CommaLocs;
       
       if (Tok.is(tok::code_completion)) {
-        Actions.CodeCompleteCall(getCurScope(), LHS.get(), 0, 0);
+        Actions.CodeCompleteCall(getCurScope(), LHS.get(),
+                                 llvm::ArrayRef<Expr *>());
         cutOffParsing();
         return ExprError();
       }
@@ -2207,13 +2223,12 @@
                             SmallVectorImpl<SourceLocation> &CommaLocs,
                                  void (Sema::*Completer)(Scope *S, 
                                                            Expr *Data,
-                                                           Expr **Args,
-                                                           unsigned NumArgs),
+                                                   llvm::ArrayRef<Expr *> Args),
                                  Expr *Data) {
   while (1) {
     if (Tok.is(tok::code_completion)) {
       if (Completer)
-        (Actions.*Completer)(getCurScope(), Data, Exprs.data(), Exprs.size());
+        (Actions.*Completer)(getCurScope(), Data, Exprs);
       else
         Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Expression);
       cutOffParsing();

Modified: cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp Tue Feb 28 17:49:25 2012
@@ -870,8 +870,10 @@
 
   // FIXME: Rename BlockScope -> ClosureScope if we decide to continue using
   // it.
-  ParseScope BodyScope(this, Scope::BlockScope | Scope::FnScope |
-                             Scope::DeclScope);
+  unsigned ScopeFlags = Scope::BlockScope | Scope::FnScope | Scope::DeclScope;
+  if (getCurScope()->getFlags() & Scope::ThisScope)
+    ScopeFlags |= Scope::ThisScope;
+  ParseScope BodyScope(this, ScopeFlags);
 
   Actions.ActOnStartOfLambdaDefinition(Intro, D, getCurScope());
 
@@ -1269,6 +1271,8 @@
 ///       condition:
 ///         expression
 ///         type-specifier-seq declarator '=' assignment-expression
+/// [C++11] type-specifier-seq declarator '=' initializer-clause
+/// [C++11] type-specifier-seq declarator braced-init-list
 /// [GNU]   type-specifier-seq declarator simple-asm-expr[opt] attributes[opt]
 ///             '=' assignment-expression
 ///
@@ -1340,17 +1344,34 @@
 
   // '=' assignment-expression
   // If a '==' or '+=' is found, suggest a fixit to '='.
-  if (isTokenEqualOrEqualTypo()) {
+  bool CopyInitialization = isTokenEqualOrEqualTypo();
+  if (CopyInitialization)
     ConsumeToken();
-    ExprResult AssignExpr(ParseAssignmentExpression());
-    if (!AssignExpr.isInvalid()) 
-      Actions.AddInitializerToDecl(DeclOut, AssignExpr.take(), false,
-                                   DS.getTypeSpecType() == DeclSpec::TST_auto);
+
+  ExprResult InitExpr = ExprError();
+  if (getLang().CPlusPlus0x && Tok.is(tok::l_brace)) {
+    Diag(Tok.getLocation(),
+         diag::warn_cxx98_compat_generalized_initializer_lists);
+    InitExpr = ParseBraceInitializer();
+  } else if (CopyInitialization) {
+    InitExpr = ParseAssignmentExpression();
+  } else if (Tok.is(tok::l_paren)) {
+    // This was probably an attempt to initialize the variable.
+    SourceLocation LParen = ConsumeParen(), RParen = LParen;
+    if (SkipUntil(tok::r_paren, true, /*DontConsume=*/true))
+      RParen = ConsumeParen();
+    Diag(DeclOut ? DeclOut->getLocation() : LParen,
+         diag::err_expected_init_in_condition_lparen)
+      << SourceRange(LParen, RParen);
   } else {
-    // FIXME: C++0x allows a braced-init-list
-    Diag(Tok, diag::err_expected_equal_after_declarator);
+    Diag(DeclOut ? DeclOut->getLocation() : Tok.getLocation(),
+         diag::err_expected_init_in_condition);
   }
-  
+
+  if (!InitExpr.isInvalid())
+    Actions.AddInitializerToDecl(DeclOut, InitExpr.take(), !CopyInitialization,
+                                 DS.getTypeSpecType() == DeclSpec::TST_auto);
+
   // FIXME: Build a reference to this declaration? Convert it to bool?
   // (This is currently handled by Sema).
 
@@ -2433,6 +2454,15 @@
   case tok::kw___is_same:                    return BTT_IsSame;
   case tok::kw___builtin_types_compatible_p: return BTT_TypeCompatible;
   case tok::kw___is_convertible_to:          return BTT_IsConvertibleTo;
+  case tok::kw___is_trivially_assignable:    return BTT_IsTriviallyAssignable;
+  }
+}
+
+static TypeTrait TypeTraitFromTokKind(tok::TokenKind kind) {
+  switch (kind) {
+  default: llvm_unreachable("Not a known type trait");
+  case tok::kw___is_trivially_constructible: 
+    return TT_IsTriviallyConstructible;
   }
 }
 
@@ -2518,6 +2548,58 @@
                                       T.getCloseLocation());
 }
 
+/// \brief Parse the built-in type-trait pseudo-functions that allow 
+/// implementation of the TR1/C++11 type traits templates.
+///
+///       primary-expression:
+///          type-trait '(' type-id-seq ')'
+///
+///       type-id-seq:
+///          type-id ...[opt] type-id-seq[opt]
+///
+ExprResult Parser::ParseTypeTrait() {
+  TypeTrait Kind = TypeTraitFromTokKind(Tok.getKind());
+  SourceLocation Loc = ConsumeToken();
+  
+  BalancedDelimiterTracker Parens(*this, tok::l_paren);
+  if (Parens.expectAndConsume(diag::err_expected_lparen))
+    return ExprError();
+
+  llvm::SmallVector<ParsedType, 2> Args;
+  do {
+    // Parse the next type.
+    TypeResult Ty = ParseTypeName();
+    if (Ty.isInvalid()) {
+      Parens.skipToEnd();
+      return ExprError();
+    }
+
+    // Parse the ellipsis, if present.
+    if (Tok.is(tok::ellipsis)) {
+      Ty = Actions.ActOnPackExpansion(Ty.get(), ConsumeToken());
+      if (Ty.isInvalid()) {
+        Parens.skipToEnd();
+        return ExprError();
+      }
+    }
+    
+    // Add this type to the list of arguments.
+    Args.push_back(Ty.get());
+    
+    if (Tok.is(tok::comma)) {
+      ConsumeToken();
+      continue;
+    }
+    
+    break;
+  } while (true);
+  
+  if (Parens.consumeClose())
+    return ExprError();
+  
+  return Actions.ActOnTypeTrait(Kind, Loc, Args, Parens.getCloseLocation());
+}
+
 /// ParseArrayTypeTrait - Parse the built-in array type-trait
 /// pseudo-functions.
 ///

Modified: cfe/branches/tooling/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseObjc.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseObjc.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseObjc.cpp Tue Feb 28 17:49:25 2012
@@ -1532,9 +1532,7 @@
     }
   }
 
-  DeclsInGroup.push_back(ObjCImpDecl);
-  return Actions.BuildDeclaratorGroup(
-           DeclsInGroup.data(), DeclsInGroup.size(), false);
+  return Actions.ActOnFinishObjCImplementation(ObjCImpDecl, DeclsInGroup);
 }
 
 Parser::DeclGroupPtrTy

Modified: cfe/branches/tooling/lib/Parse/ParsePragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParsePragma.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParsePragma.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParsePragma.cpp Tue Feb 28 17:49:25 2012
@@ -37,6 +37,24 @@
   Actions.ActOnPragmaVisibility(VisType, VisLoc);
 }
 
+struct PragmaPackInfo {
+  Sema::PragmaPackKind Kind;
+  IdentifierInfo *Name;
+  Expr *Alignment;
+  SourceLocation LParenLoc;
+  SourceLocation RParenLoc;
+};
+
+void Parser::HandlePragmaPack() {
+  assert(Tok.is(tok::annot_pragma_pack));
+  PragmaPackInfo *Info =
+    static_cast<PragmaPackInfo *>(Tok.getAnnotationValue());
+  SourceLocation PragmaLoc = ConsumeToken();
+  Actions.ActOnPragmaPack(Info->Kind, Info->Name, Info->Alignment, PragmaLoc,
+                          Info->LParenLoc, Info->RParenLoc);
+  delete Info;
+}
+
 // #pragma GCC visibility comes in two variants:
 //   'push' '(' [visibility] ')'
 //   'pop'
@@ -196,8 +214,20 @@
     return;
   }
 
-  Actions.ActOnPragmaPack(Kind, Name, Alignment.release(), PackLoc,
-                          LParenLoc, RParenLoc);
+  PragmaPackInfo *Info = new PragmaPackInfo;
+  Info->Kind = Kind;
+  Info->Name = Name;
+  Info->Alignment = Alignment.release();
+  Info->LParenLoc = LParenLoc;
+  Info->RParenLoc = RParenLoc;
+
+  Token *Toks = new Token[1];
+  Toks[0].startToken();
+  Toks[0].setKind(tok::annot_pragma_pack);
+  Toks[0].setLocation(PackLoc);
+  Toks[0].setAnnotationValue(static_cast<void*>(Info));
+  PP.EnterTokenStream(Toks, 1, /*DisableMacroExpansion=*/true,
+                      /*OwnsTokens=*/true);
 }
 
 // #pragma ms_struct on

Modified: cfe/branches/tooling/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseStmt.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseStmt.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseStmt.cpp Tue Feb 28 17:49:25 2012
@@ -280,6 +280,14 @@
 
   case tok::kw___try:
     return ParseSEHTryBlock(attrs);
+
+  case tok::annot_pragma_vis:
+    HandlePragmaVisibility();
+    return StmtEmpty();
+
+  case tok::annot_pragma_pack:
+    HandlePragmaPack();
+    return StmtEmpty();
   }
 
   // If we reached this code, the statement must end in a semicolon.
@@ -1597,9 +1605,6 @@
       return StmtError();
     }
 
-    // FIXME: This is a hack to allow something like C++0x's generalized
-    // initializer lists, but only enough of this feature to allow Clang to
-    // parse libstdc++ 4.5's headers.
     if (Tok.is(tok::l_brace) && getLang().CPlusPlus) {
       R = ParseInitializer();
       if (R.isUsable())

Modified: cfe/branches/tooling/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseTemplate.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseTemplate.cpp Tue Feb 28 17:49:25 2012
@@ -1037,7 +1037,7 @@
   
   // Parse a non-type template argument. 
   SourceLocation Loc = Tok.getLocation();
-  ExprResult ExprArg = ParseConstantExpression();
+  ExprResult ExprArg = ParseConstantExpression(MaybeTypeCast);
   if (ExprArg.isInvalid() || !ExprArg.get())
     return ParsedTemplateArgument();
 
@@ -1157,109 +1157,113 @@
 
   llvm_unreachable("Late templated function without associated lexed tokens");
 }
-
-/// \brief Late parse a C++ function template in Microsoft mode.
-void Parser::ParseLateTemplatedFuncDef(LateParsedTemplatedFunction &LMT) {
-  if(!LMT.D)
-     return;
-
-  // If this is a member template, introduce the template parameter scope.
-  ParseScope TemplateScope(this, Scope::TemplateParamScope);
-
-  // Get the FunctionDecl.
-  FunctionDecl *FD = 0;
-  if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(LMT.D))
-    FD = FunTmpl->getTemplatedDecl();
-  else
-    FD = cast<FunctionDecl>(LMT.D);
-  
-  // Reinject the template parameters.
-  SmallVector<ParseScope*, 4> TemplateParamScopeStack;
-  DeclaratorDecl* Declarator = dyn_cast<DeclaratorDecl>(FD);
-  if (Declarator && Declarator->getNumTemplateParameterLists() != 0) {
-    Actions.ActOnReenterDeclaratorTemplateScope(getCurScope(), Declarator);
-    Actions.ActOnReenterTemplateScope(getCurScope(), LMT.D);
-  } else {
-    Actions.ActOnReenterTemplateScope(getCurScope(), LMT.D);
-
-    // Get the list of DeclContext to reenter.
-    SmallVector<DeclContext*, 4> DeclContextToReenter;
-    DeclContext *DD = FD->getLexicalParent();
-    while (DD && DD->isRecord()) {
-      DeclContextToReenter.push_back(DD);
-      DD = DD->getLexicalParent();
-    }
-
-    // Reenter template scopes from outmost to innermost.
-    SmallVector<DeclContext*, 4>::reverse_iterator II =
-    DeclContextToReenter.rbegin();
-    for (; II != DeclContextToReenter.rend(); ++II) {
-      if (ClassTemplatePartialSpecializationDecl* MD =
-                dyn_cast_or_null<ClassTemplatePartialSpecializationDecl>(*II)) {
-       TemplateParamScopeStack.push_back(new ParseScope(this,
-                                                   Scope::TemplateParamScope));
-        Actions.ActOnReenterTemplateScope(getCurScope(), MD);
-      } else if (CXXRecordDecl* MD = dyn_cast_or_null<CXXRecordDecl>(*II)) {
-        TemplateParamScopeStack.push_back(new ParseScope(this,
-                                                    Scope::TemplateParamScope,
-                                       MD->getDescribedClassTemplate() != 0 ));
-        Actions.ActOnReenterTemplateScope(getCurScope(),
-                                          MD->getDescribedClassTemplate());
-      }
-    }
-  }
-  assert(!LMT.Toks.empty() && "Empty body!");
-
-  // Append the current token at the end of the new token stream so that it
-  // doesn't get lost.
-  LMT.Toks.push_back(Tok);
-  PP.EnterTokenStream(LMT.Toks.data(), LMT.Toks.size(), true, false);
-
-  // Consume the previously pushed token.
-  ConsumeAnyToken();
-  assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try))
-         && "Inline method not starting with '{', ':' or 'try'");
-
-  // Parse the method body. Function body parsing code is similar enough
-  // to be re-used for method bodies as well.
-  ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope);
-
-  // Recreate the DeclContext.
-  Sema::ContextRAII SavedContext(Actions, Actions.getContainingDC(FD));
-
-  if (FunctionTemplateDecl *FunctionTemplate
-        = dyn_cast_or_null<FunctionTemplateDecl>(LMT.D))
-    Actions.ActOnStartOfFunctionDef(getCurScope(),
-                                   FunctionTemplate->getTemplatedDecl());
-  if (FunctionDecl *Function = dyn_cast_or_null<FunctionDecl>(LMT.D))
-    Actions.ActOnStartOfFunctionDef(getCurScope(), Function);
-  
-
-  if (Tok.is(tok::kw_try)) {
-    ParseFunctionTryBlock(LMT.D, FnScope);
-  } else {
-    if (Tok.is(tok::colon))
-      ParseConstructorInitializer(LMT.D);
-    else
-      Actions.ActOnDefaultCtorInitializers(LMT.D);
-
-    if (Tok.is(tok::l_brace)) {
-      ParseFunctionStatementBody(LMT.D, FnScope);
-      Actions.MarkAsLateParsedTemplate(FD, false);
-    } else
-      Actions.ActOnFinishFunctionBody(LMT.D, 0);
-  }
-
-  // Exit scopes.
+
+/// \brief Late parse a C++ function template in Microsoft mode.
+void Parser::ParseLateTemplatedFuncDef(LateParsedTemplatedFunction &LMT) {
+  if(!LMT.D)
+     return;
+
+  // Get the FunctionDecl.
+  FunctionDecl *FD = 0;
+  if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(LMT.D))
+    FD = FunTmpl->getTemplatedDecl();
+  else
+    FD = cast<FunctionDecl>(LMT.D);
+  
+  // To restore the context after late parsing.
+  Sema::ContextRAII GlobalSavedContext(Actions, Actions.CurContext);
+
+  SmallVector<ParseScope*, 4> TemplateParamScopeStack;
+  DeclaratorDecl* Declarator = dyn_cast<DeclaratorDecl>(FD);
+  if (Declarator && Declarator->getNumTemplateParameterLists() != 0) {
+    TemplateParamScopeStack.push_back(new ParseScope(this, Scope::TemplateParamScope));
+    Actions.ActOnReenterDeclaratorTemplateScope(getCurScope(), Declarator);
+    Actions.ActOnReenterTemplateScope(getCurScope(), LMT.D);
+  } else {
+    // Get the list of DeclContext to reenter.
+    SmallVector<DeclContext*, 4> DeclContextToReenter;
+    DeclContext *DD = FD->getLexicalParent();
+    while (DD && !DD->isTranslationUnit()) {
+      DeclContextToReenter.push_back(DD);
+      DD = DD->getLexicalParent();
+    }
+
+    // Reenter template scopes from outmost to innermost.
+    SmallVector<DeclContext*, 4>::reverse_iterator II =
+    DeclContextToReenter.rbegin();
+    for (; II != DeclContextToReenter.rend(); ++II) {
+      if (ClassTemplatePartialSpecializationDecl* MD =
+                dyn_cast_or_null<ClassTemplatePartialSpecializationDecl>(*II)) {
+        TemplateParamScopeStack.push_back(new ParseScope(this,
+                                                   Scope::TemplateParamScope));
+        Actions.ActOnReenterTemplateScope(getCurScope(), MD);
+      } else if (CXXRecordDecl* MD = dyn_cast_or_null<CXXRecordDecl>(*II)) {
+        TemplateParamScopeStack.push_back(new ParseScope(this,
+                                                    Scope::TemplateParamScope,
+                                       MD->getDescribedClassTemplate() != 0 ));
+        Actions.ActOnReenterTemplateScope(getCurScope(),
+                                          MD->getDescribedClassTemplate());
+      }
+      TemplateParamScopeStack.push_back(new ParseScope(this, Scope::DeclScope));
+      Actions.PushDeclContext(Actions.getCurScope(), *II);
+    }
+    TemplateParamScopeStack.push_back(new ParseScope(this,
+                                      Scope::TemplateParamScope));
+    Actions.ActOnReenterTemplateScope(getCurScope(), LMT.D);
+  }
+
+  assert(!LMT.Toks.empty() && "Empty body!");
+
+  // Append the current token at the end of the new token stream so that it
+  // doesn't get lost.
+  LMT.Toks.push_back(Tok);
+  PP.EnterTokenStream(LMT.Toks.data(), LMT.Toks.size(), true, false);
+
+  // Consume the previously pushed token.
+  ConsumeAnyToken();
+  assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try))
+         && "Inline method not starting with '{', ':' or 'try'");
+
+  // Parse the method body. Function body parsing code is similar enough
+  // to be re-used for method bodies as well.
+  ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope);
+
+  // Recreate the containing function DeclContext.
+  Sema::ContextRAII FunctionSavedContext(Actions, Actions.getContainingDC(FD));
+
+  if (FunctionTemplateDecl *FunctionTemplate
+        = dyn_cast_or_null<FunctionTemplateDecl>(LMT.D))
+    Actions.ActOnStartOfFunctionDef(getCurScope(),
+                                   FunctionTemplate->getTemplatedDecl());
+  if (FunctionDecl *Function = dyn_cast_or_null<FunctionDecl>(LMT.D))
+    Actions.ActOnStartOfFunctionDef(getCurScope(), Function);
+  
+
+  if (Tok.is(tok::kw_try)) {
+    ParseFunctionTryBlock(LMT.D, FnScope);
+  } else {
+    if (Tok.is(tok::colon))
+      ParseConstructorInitializer(LMT.D);
+    else
+      Actions.ActOnDefaultCtorInitializers(LMT.D);
+
+    if (Tok.is(tok::l_brace)) {
+      ParseFunctionStatementBody(LMT.D, FnScope);
+      Actions.MarkAsLateParsedTemplate(FD, false);
+    } else
+      Actions.ActOnFinishFunctionBody(LMT.D, 0);
+  }
+
+  // Exit scopes.
   FnScope.Exit();
-  SmallVector<ParseScope*, 4>::reverse_iterator I =
-   TemplateParamScopeStack.rbegin();
-  for (; I != TemplateParamScopeStack.rend(); ++I)
-    delete *I;
-
-  DeclGroupPtrTy grp = Actions.ConvertDeclToDeclGroup(LMT.D);
-  if (grp)
-    Actions.getASTConsumer().HandleTopLevelDecl(grp.get());
+  SmallVector<ParseScope*, 4>::reverse_iterator I =
+   TemplateParamScopeStack.rbegin();
+  for (; I != TemplateParamScopeStack.rend(); ++I)
+    delete *I;
+
+  DeclGroupPtrTy grp = Actions.ConvertDeclToDeclGroup(LMT.D);
+  if (grp)
+    Actions.getASTConsumer().HandleTopLevelDecl(grp.get());
 }
 
 /// \brief Lex a delayed template function for late parsing.

Modified: cfe/branches/tooling/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseTentative.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseTentative.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseTentative.cpp Tue Feb 28 17:49:25 2012
@@ -233,6 +233,8 @@
 ///       condition:
 ///         expression
 ///         type-specifier-seq declarator '=' assignment-expression
+/// [C++11] type-specifier-seq declarator '=' initializer-clause
+/// [C++11] type-specifier-seq declarator braced-init-list
 /// [GNU]   type-specifier-seq declarator simple-asm-expr[opt] attributes[opt]
 ///             '=' assignment-expression
 ///
@@ -274,6 +276,8 @@
     if (Tok.is(tok::equal)  ||
         Tok.is(tok::kw_asm) || Tok.is(tok::kw___attribute))
       TPR = TPResult::True();
+    else if (getLang().CPlusPlus0x && Tok.is(tok::l_brace))
+      TPR = TPResult::True();
     else
       TPR = TPResult::False();
   }
@@ -685,6 +689,8 @@
   case tok::kw___is_pod:
   case tok::kw___is_polymorphic:
   case tok::kw___is_trivial:
+  case tok::kw___is_trivially_assignable:
+  case tok::kw___is_trivially_constructible:
   case tok::kw___is_trivially_copyable:
   case tok::kw___is_union:
   case tok::kw___uuidof:
@@ -834,7 +840,8 @@
 ///           'volatile'
 /// [GNU]     restrict
 ///
-Parser::TPResult Parser::isCXXDeclarationSpecifier() {
+Parser::TPResult
+Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult) {
   switch (Tok.getKind()) {
   case tok::identifier:   // foo::bar
     // Check for need to substitute AltiVec __vector keyword
@@ -849,7 +856,7 @@
       return TPResult::Error();
     if (Tok.is(tok::identifier))
       return TPResult::False();
-    return isCXXDeclarationSpecifier();
+    return isCXXDeclarationSpecifier(BracedCastResult);
 
   case tok::coloncolon: {    // ::foo::bar
     const Token &Next = NextToken();
@@ -863,7 +870,7 @@
     // recurse to handle whatever we get.
     if (TryAnnotateTypeOrScopeToken())
       return TPResult::Error();
-    return isCXXDeclarationSpecifier();
+    return isCXXDeclarationSpecifier(BracedCastResult);
 
     // decl-specifier:
     //   storage-class-specifier
@@ -965,7 +972,7 @@
           bool isIdentifier = Tok.is(tok::identifier);
           TPResult TPR = TPResult::False();
           if (!isIdentifier)
-            TPR = isCXXDeclarationSpecifier();
+            TPR = isCXXDeclarationSpecifier(BracedCastResult);
           PA.Revert();
 
           if (isIdentifier ||
@@ -1005,6 +1012,7 @@
       
       TPResult TPR = TryParseProtocolQualifiers();
       bool isFollowedByParen = Tok.is(tok::l_paren);
+      bool isFollowedByBrace = Tok.is(tok::l_brace);
       
       PA.Revert();
       
@@ -1013,6 +1021,9 @@
       
       if (isFollowedByParen)
         return TPResult::Ambiguous();
+
+      if (getLang().CPlusPlus0x && isFollowedByBrace)
+        return BracedCastResult;
       
       return TPResult::True();
     }
@@ -1036,6 +1047,15 @@
     if (NextToken().is(tok::l_paren))
       return TPResult::Ambiguous();
 
+    // This is a function-style cast in all cases we disambiguate other than
+    // one:
+    //   struct S {
+    //     enum E : int { a = 4 }; // enum
+    //     enum E : int { 4 };     // bit-field
+    //   };
+    if (getLang().CPlusPlus0x && NextToken().is(tok::l_brace))
+      return BracedCastResult;
+
     if (isStartOfObjCClassMessageMissingOpenBracket())
       return TPResult::False();
       
@@ -1050,6 +1070,7 @@
 
     TPResult TPR = TryParseTypeofSpecifier();
     bool isFollowedByParen = Tok.is(tok::l_paren);
+    bool isFollowedByBrace = Tok.is(tok::l_brace);
 
     PA.Revert();
 
@@ -1059,6 +1080,9 @@
     if (isFollowedByParen)
       return TPResult::Ambiguous();
 
+    if (getLang().CPlusPlus0x && isFollowedByBrace)
+      return BracedCastResult;
+
     return TPResult::True();
   }
 
@@ -1219,6 +1243,8 @@
     MaybeParseMicrosoftAttributes(attrs);
 
     // decl-specifier-seq
+    // A parameter-declaration's initializer must be preceded by an '=', so
+    // decl-specifier-seq '{' is not a parameter in C++11.
     TPResult TPR = TryParseDeclarationSpecifier();
     if (TPR != TPResult::Ambiguous())
       return TPR;

Modified: cfe/branches/tooling/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/Parser.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/Parser.cpp (original)
+++ cfe/branches/tooling/lib/Parse/Parser.cpp Tue Feb 28 17:49:25 2012
@@ -549,6 +549,9 @@
   case tok::annot_pragma_vis:
     HandlePragmaVisibility();
     return DeclGroupPtrTy();
+  case tok::annot_pragma_pack:
+    HandlePragmaPack();
+    return DeclGroupPtrTy();
   case tok::semi:
     Diag(Tok, getLang().CPlusPlus0x ?
          diag::warn_cxx98_compat_top_level_semi : diag::ext_top_level_semi)

Modified: cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp Tue Feb 28 17:49:25 2012
@@ -108,6 +108,7 @@
     llvm::SmallPtrSet<ObjCInterfaceDecl*, 8> ObjCSynthesizedStructs;
     llvm::SmallPtrSet<ObjCProtocolDecl*, 8> ObjCSynthesizedProtocols;
     llvm::SmallPtrSet<ObjCInterfaceDecl*, 8> ObjCWrittenInterfaces;
+    llvm::SmallPtrSet<TagDecl*, 8> TagsDefinedInIvarDecls;
     SmallVector<ObjCInterfaceDecl*, 32> ObjCInterfacesSeen;
     SmallVector<Stmt *, 32> Stmts;
     SmallVector<int, 8> ObjCBcLabelNo;
@@ -133,7 +134,9 @@
     llvm::SmallPtrSet<VarDecl *, 8> ImportedLocalExternalDecls;
     
     llvm::DenseMap<BlockExpr *, std::string> RewrittenBlockExprs;
-
+    llvm::DenseMap<ObjCInterfaceDecl *, 
+                    llvm::SmallPtrSet<ObjCIvarDecl *, 8> > ReferencedIvars;
+    
     // This maps an original source AST to it's rewritten form. This allows
     // us to avoid rewriting the same node twice (which is very uncommon).
     // This is needed to support some of the exotic property rewriting.
@@ -171,7 +174,7 @@
             break;
           } else {
             // Keep track of all interface declarations seen.
-            ObjCInterfacesSeen.push_back(Class->getCanonicalDecl());
+            ObjCInterfacesSeen.push_back(Class);
             break;
           }
         }
@@ -331,6 +334,11 @@
     void RewriteObjCInternalStruct(ObjCInterfaceDecl *CDecl,
                                       std::string &Result);
     
+    void RewriteObjCFieldDecl(FieldDecl *fieldDecl, std::string &Result);
+    
+    void RewriteIvarOffsetSymbols(ObjCInterfaceDecl *CDecl,
+                                  std::string &Result);
+    
     virtual void Initialize(ASTContext &context);
     
     // Misc. AST transformation routines. Somtimes they end up calling
@@ -1231,6 +1239,9 @@
     ResultStr += "typedef struct objc_object ";
     ResultStr += ClassDecl->getNameAsString();
     ResultStr += ";\n#endif\n";
+    
+    RewriteIvarOffsetSymbols(ClassDecl, ResultStr);
+    
     RewriteObjCInternalStruct(ClassDecl, ResultStr);
     // Mark this typedef as having been written into its c++ equivalent.
     ObjCWrittenInterfaces.insert(ClassDecl->getCanonicalDecl());
@@ -3157,6 +3168,78 @@
   return false;
 }
 
+/// RewriteObjCFieldDecl - This routine rewrites a field into the buffer.
+/// It handles elaborated types, as well as enum types in the process.
+void RewriteModernObjC::RewriteObjCFieldDecl(FieldDecl *fieldDecl, 
+                                             std::string &Result) {
+  QualType Type = fieldDecl->getType();
+  std::string Name = fieldDecl->getNameAsString();
+
+  if (Type->isRecordType()) {
+    RecordDecl *RD = Type->getAs<RecordType>()->getDecl();
+    if (RD->isCompleteDefinition()) {
+      if (RD->isStruct())
+        Result += "\n\tstruct ";
+      else if (RD->isUnion())
+        Result += "\n\tunion ";
+      else
+        assert(false && "class not allowed as an ivar type");
+  
+      Result += RD->getName();
+      if (TagsDefinedInIvarDecls.count(RD)) {
+        // This struct is already defined. Do not write its definition again.
+        Result += " "; Result += Name; Result += ";\n";
+        return;
+      }
+      TagsDefinedInIvarDecls.insert(RD);
+      Result += " {\n";
+      for (RecordDecl::field_iterator i = RD->field_begin(), 
+          e = RD->field_end(); i != e; ++i) {
+        FieldDecl *FD = *i;
+        RewriteObjCFieldDecl(FD, Result);
+      }
+      Result += "\t} "; 
+      Result += Name; Result += ";\n";
+      return;
+    }
+  }
+  else if (Type->isEnumeralType()) {
+    EnumDecl *ED = Type->getAs<EnumType>()->getDecl();
+    if (ED->isCompleteDefinition()) {
+      Result += "\n\tenum ";
+      Result += ED->getName();
+      if (TagsDefinedInIvarDecls.count(ED)) {
+        // This enum is already defined. Do not write its definition again.
+        Result += " "; Result += Name; Result += ";\n";
+        return;
+      }
+      TagsDefinedInIvarDecls.insert(ED);
+      
+      Result += " {\n";
+      for (EnumDecl::enumerator_iterator EC = ED->enumerator_begin(),
+           ECEnd = ED->enumerator_end(); EC != ECEnd; ++EC) {
+        Result += "\t"; Result += EC->getName(); Result += " = ";
+        llvm::APSInt Val = EC->getInitVal();
+        Result += Val.toString(10);
+        Result += ",\n";
+      }
+      Result += "\t} "; 
+      Result += Name; Result += ";\n";
+      return;
+    }
+  }
+  
+  Result += "\t";
+  convertObjCTypeToCStyleType(Type);
+  
+  Type.getAsStringInternal(Name, Context->getPrintingPolicy());
+  Result += Name;
+  if (fieldDecl->isBitField()) {
+    Result += " : "; Result += utostr(fieldDecl->getBitWidthValue(*Context));
+  }
+  Result += ";\n";
+}
+
 /// RewriteObjCInternalStruct - Rewrite one internal struct corresponding to
 /// an objective-c class with ivars.
 void RewriteModernObjC::RewriteObjCInternalStruct(ObjCInterfaceDecl *CDecl,
@@ -3197,22 +3280,10 @@
     Result += "_IMPL "; Result += RCDecl->getNameAsString();
     Result += "_IVARS;\n";
   }
-  
-  for (unsigned i = 0, e = IVars.size(); i < e; i++) {
-    ObjCIvarDecl *IvarDecl = IVars[i];
-    QualType Type = IvarDecl->getType();
-    std::string Name = IvarDecl->getNameAsString();
+  TagsDefinedInIvarDecls.clear();
+  for (unsigned i = 0, e = IVars.size(); i < e; i++)
+    RewriteObjCFieldDecl(IVars[i], Result);
 
-    Result += "\t";
-    convertObjCTypeToCStyleType(Type);
-    
-    Type.getAsStringInternal(Name, Context->getPrintingPolicy());
-    Result += Name;
-    if (IvarDecl->isBitField()) {
-      Result += " : "; Result += utostr(IvarDecl->getBitWidthValue(*Context));
-    }
-    Result += ";\n";
-  }
   Result += "};\n";
   endBuf += Lexer::MeasureTokenLength(LocEnd, *SM, LangOpts);
   ReplaceText(LocStart, endBuf-startBuf, Result);
@@ -3221,6 +3292,24 @@
     llvm_unreachable("struct already synthesize- RewriteObjCInternalStruct");
 }
 
+/// RewriteIvarOffsetSymbols - Rewrite ivar offset symbols of those ivars which
+/// have been referenced in an ivar access expression.
+void RewriteModernObjC::RewriteIvarOffsetSymbols(ObjCInterfaceDecl *CDecl,
+                                                  std::string &Result) {
+  // write out ivar offset symbols which have been referenced in an ivar
+  // access expression.
+  llvm::SmallPtrSet<ObjCIvarDecl *, 8> Ivars = ReferencedIvars[CDecl];
+  if (Ivars.empty())
+    return;
+  for (llvm::SmallPtrSet<ObjCIvarDecl *, 8>::iterator i = Ivars.begin(),
+       e = Ivars.end(); i != e; i++) {
+    ObjCIvarDecl *IvarDecl = (*i);
+    Result += "\nextern unsigned long OBJC_IVAR_$_";
+    Result += CDecl->getName(); Result += "_";
+    Result += IvarDecl->getName(); Result += ";";
+  }
+}
+
 //===----------------------------------------------------------------------===//
 // Meta Data Emission
 //===----------------------------------------------------------------------===//
@@ -3230,16 +3319,6 @@
 /// and emits meta-data.
 
 void RewriteModernObjC::RewriteImplementations() {
-  
-  for (unsigned i = 0, e = ObjCInterfacesSeen.size(); i < e; i++) {
-    ObjCInterfaceDecl *CDecl = ObjCInterfacesSeen[i];
-    // Write struct declaration for the class matching its ivar declarations.
-    // Note that for modern abi, this is postponed until the end of TU
-    // because class extensions and the implementation might declare their own
-    // private ivars.
-    RewriteInterfaceDecl(CDecl);
-  }
-  
   int ClsDefCount = ClassImplementation.size();
   int CatDefCount = CategoryImplementation.size();
 
@@ -5022,6 +5101,15 @@
     RewriteObjCProtocolMetaData(*I, Preamble);
 
   InsertText(SM->getLocForStartOfFile(MainFileID), Preamble, false);
+  for (unsigned i = 0, e = ObjCInterfacesSeen.size(); i < e; i++) {
+    ObjCInterfaceDecl *CDecl = ObjCInterfacesSeen[i];
+    // Write struct declaration for the class matching its ivar declarations.
+    // Note that for modern abi, this is postponed until the end of TU
+    // because class extensions and the implementation might declare their own
+    // private ivars.
+    RewriteInterfaceDecl(CDecl);
+  }
+  
   if (ClassImplementation.size() || CategoryImplementation.size())
     RewriteImplementations();
 
@@ -6408,7 +6496,7 @@
   ObjCIvarDecl *D = IV->getDecl();
   
   Expr *Replacement = IV;
-  if (CurMethodDef) {
+  
     if (BaseExpr->getType()->isObjCObjectPointerType()) {
       const ObjCInterfaceType *iFaceDecl =
       dyn_cast<ObjCInterfaceType>(BaseExpr->getType()->getPointeeType());
@@ -6419,70 +6507,50 @@
                                                    clsDeclared);
       assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class");
       
-      // Synthesize an explicit cast to gain access to the ivar.
-      std::string RecName = clsDeclared->getIdentifier()->getName();
-      RecName += "_IMPL";
-      IdentifierInfo *II = &Context->Idents.get(RecName);
-      RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
-                                          SourceLocation(), SourceLocation(),
-                                          II);
-      assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
-      QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
-      CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT,
-                                                    CK_BitCast,
-                                                    IV->getBase());
-      // Don't forget the parens to enforce the proper binding.
-      ParenExpr *PE = new (Context) ParenExpr(OldRange.getBegin(),
-                                              OldRange.getEnd(),
-                                              castExpr);
-      if (IV->isFreeIvar() &&
-          declaresSameEntity(CurMethodDef->getClassInterface(), iFaceDecl->getDecl())) {
-        MemberExpr *ME = new (Context) MemberExpr(PE, true, D,
-                                                  IV->getLocation(),
-                                                  D->getType(),
-                                                  VK_LValue, OK_Ordinary);
-        Replacement = ME;
-      } else {
-        IV->setBase(PE);
-      }
-    }
-  } else { // we are outside a method.
-    assert(!IV->isFreeIvar() && "Cannot have a free standing ivar outside a method");
-    
-    // Explicit ivar refs need to have a cast inserted.
-    // FIXME: consider sharing some of this code with the code above.
-    if (BaseExpr->getType()->isObjCObjectPointerType()) {
-      const ObjCInterfaceType *iFaceDecl =
-      dyn_cast<ObjCInterfaceType>(BaseExpr->getType()->getPointeeType());
-      // lookup which class implements the instance variable.
-      ObjCInterfaceDecl *clsDeclared = 0;
-      iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(),
-                                                   clsDeclared);
-      assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class");
+      // Build name of symbol holding ivar offset.
+      std::string IvarOffsetName = "OBJC_IVAR_$_";
+      IvarOffsetName += clsDeclared->getIdentifier()->getName();
+      IvarOffsetName += "_";
+      IvarOffsetName += D->getName();
+      ReferencedIvars[clsDeclared].insert(D);
       
-      // Synthesize an explicit cast to gain access to the ivar.
-      std::string RecName = clsDeclared->getIdentifier()->getName();
-      RecName += "_IMPL";
-      IdentifierInfo *II = &Context->Idents.get(RecName);
-      RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
-                                          SourceLocation(), SourceLocation(),
-                                          II);
-      assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
-      QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
-      CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT,
+      // cast offset to "char *".
+      CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, 
+                                                    Context->getPointerType(Context->CharTy),
                                                     CK_BitCast,
-                                                    IV->getBase());
+                                                    BaseExpr);
+      VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
+                                       SourceLocation(), &Context->Idents.get(IvarOffsetName),
+                                       Context->UnsignedLongTy, 0, SC_Extern, SC_None);
+      DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, Context->UnsignedLongTy, VK_LValue,
+                                                   SourceLocation());
+      BinaryOperator *addExpr = 
+        new (Context) BinaryOperator(castExpr, DRE, BO_Add, 
+                                     Context->getPointerType(Context->CharTy),
+                                     VK_RValue, OK_Ordinary, SourceLocation());
       // Don't forget the parens to enforce the proper binding.
-      ParenExpr *PE = new (Context) ParenExpr(IV->getBase()->getLocStart(),
-                                              IV->getBase()->getLocEnd(), castExpr);
-      // Cannot delete IV->getBase(), since PE points to it.
-      // Replace the old base with the cast. This is important when doing
-      // embedded rewrites. For example, [newInv->_container addObject:0].
-      IV->setBase(PE);
+      ParenExpr *PE = new (Context) ParenExpr(SourceLocation(),
+                                              SourceLocation(),
+                                              addExpr);
+      QualType IvarT = D->getType();
+      convertBlockPointerToFunctionPointer(IvarT);
+      QualType castT = Context->getPointerType(IvarT);
+      
+      castExpr = NoTypeInfoCStyleCastExpr(Context, 
+                                          castT,
+                                          CK_BitCast,
+                                          PE);
+      Expr *Exp = new (Context) UnaryOperator(castExpr, UO_Deref, castT,
+                                              VK_LValue, OK_Ordinary,
+                                              SourceLocation());
+      PE = new (Context) ParenExpr(OldRange.getBegin(),
+                                   OldRange.getEnd(),
+                                   Exp);
+
+      Replacement = PE;
     }
-  }
   
-  ReplaceStmtWithRange(IV, Replacement, OldRange);
-  return Replacement;  
+    ReplaceStmtWithRange(IV, Replacement, OldRange);
+    return Replacement;  
 }
 

Modified: cfe/branches/tooling/lib/Sema/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/AttributeList.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/AttributeList.cpp (original)
+++ cfe/branches/tooling/lib/Sema/AttributeList.cpp Tue Feb 28 17:49:25 2012
@@ -101,7 +101,8 @@
   StringRef AttrName = Name->getName();
 
   // Normalize the attribute name, __foo__ becomes foo.
-  if (AttrName.startswith("__") && AttrName.endswith("__"))
+  if (AttrName.startswith("__") && AttrName.endswith("__") &&
+      AttrName.size() >= 4)
     AttrName = AttrName.substr(2, AttrName.size() - 4);
 
   return llvm::StringSwitch<AttributeList::Kind>(AttrName)

Modified: cfe/branches/tooling/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/DeclSpec.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/DeclSpec.cpp (original)
+++ cfe/branches/tooling/lib/Sema/DeclSpec.cpp Tue Feb 28 17:49:25 2012
@@ -898,8 +898,6 @@
   if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32)
     Diag(D, TSTLoc, diag::warn_cxx98_compat_unicode_type)
       << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t");
-  if (TypeSpecType == TST_decltype)
-    Diag(D, TSTLoc, diag::warn_cxx98_compat_decltype);
   if (Constexpr_specified)
     Diag(D, ConstexprLoc, diag::warn_cxx98_compat_constexpr);
 

Modified: cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp Tue Feb 28 17:49:25 2012
@@ -113,7 +113,7 @@
                              bool ExplicitInstantiationOrSpecialization) const {
   Ctx = Ctx->getRedeclContext();
 
-  if (Ctx->isFunctionOrMethod()) {
+  if (Ctx->isFunctionOrMethod() || S->isFunctionPrototypeScope()) {
     // Ignore the scopes associated within transparent declaration contexts.
     while (S->getEntity() &&
            ((DeclContext *)S->getEntity())->isTransparentContext())

Modified: cfe/branches/tooling/lib/Sema/JumpDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/JumpDiagnostics.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/JumpDiagnostics.cpp (original)
+++ cfe/branches/tooling/lib/Sema/JumpDiagnostics.cpp Tue Feb 28 17:49:25 2012
@@ -74,7 +74,7 @@
   
   void VerifyJumps();
   void VerifyIndirectJumps();
-  void NoteJumpIntoScopes(const SmallVectorImpl<unsigned> &ToScopes);
+  void NoteJumpIntoScopes(ArrayRef<unsigned> ToScopes);
   void DiagnoseIndirectJump(IndirectGotoStmt *IG, unsigned IGScope,
                             LabelDecl *Target, unsigned TargetScope);
   void CheckJump(Stmt *From, Stmt *To, SourceLocation DiagLoc,
@@ -669,8 +669,7 @@
 }
 
 /// Produce note diagnostics for a jump into a protected scope.
-void JumpScopeChecker::NoteJumpIntoScopes(
-                                    const SmallVectorImpl<unsigned> &ToScopes) {
+void JumpScopeChecker::NoteJumpIntoScopes(ArrayRef<unsigned> ToScopes) {
   assert(!ToScopes.empty());
   for (unsigned I = 0, E = ToScopes.size(); I != E; ++I)
     if (Scopes[ToScopes[I]].InDiag)

Modified: cfe/branches/tooling/lib/Sema/Scope.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/Scope.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/Scope.cpp (original)
+++ cfe/branches/tooling/lib/Sema/Scope.cpp Tue Feb 28 17:49:25 2012
@@ -59,3 +59,13 @@
   Entity = 0;
   ErrorTrap.reset();
 }
+
+bool Scope::containedInPrototypeScope() const {
+  const Scope *S = this;
+  while (S) {
+    if (S->isFunctionPrototypeScope())
+      return true;
+    S = S->getParent();
+  }
+  return false;
+}

Modified: cfe/branches/tooling/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/Sema.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/Sema.cpp (original)
+++ cfe/branches/tooling/lib/Sema/Sema.cpp Tue Feb 28 17:49:25 2012
@@ -94,7 +94,7 @@
     ObjCShouldCallSuperDealloc(false),
     ObjCShouldCallSuperFinalize(false),
     TUKind(TUKind),
-    NumSFINAEErrors(0), SuppressAccessChecking(false), 
+    NumSFINAEErrors(0), InFunctionDeclarator(false), SuppressAccessChecking(false), 
     AccessCheckingSFINAE(false), InNonInstantiationSFINAEContext(false),
     NonInstantiationEntries(0), ArgumentPackSubstitutionIndex(-1),
     CurrentInstantiationScope(0), TyposCorrected(0),
@@ -111,7 +111,8 @@
                                        &Context);
 
   ExprEvalContexts.push_back(
-        ExpressionEvaluationContextRecord(PotentiallyEvaluated, 0, false, 0));
+        ExpressionEvaluationContextRecord(PotentiallyEvaluated, 0,
+                                          false, 0, false));
 
   FunctionScopes.push_back(new FunctionScopeInfo(Diags));
 }

Modified: cfe/branches/tooling/lib/Sema/SemaCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaCast.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaCast.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaCast.cpp Tue Feb 28 17:49:25 2012
@@ -369,7 +369,7 @@
     << CT << srcType << destType
     << range << src->getSourceRange();
 
-  candidates.NoteCandidates(S, howManyCandidates, &src, 1);
+  candidates.NoteCandidates(S, howManyCandidates, src);
 
   return true;
 }

Modified: cfe/branches/tooling/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaChecking.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaChecking.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaChecking.cpp Tue Feb 28 17:49:25 2012
@@ -1663,7 +1663,20 @@
 
   void HandleIncompleteSpecifier(const char *startSpecifier,
                                  unsigned specifierLen);
-    
+
+  void HandleNonStandardLengthModifier(
+      const analyze_format_string::LengthModifier &LM,
+      const char *startSpecifier, unsigned specifierLen);
+
+  void HandleNonStandardConversionSpecifier(
+      const analyze_format_string::ConversionSpecifier &CS,
+      const char *startSpecifier, unsigned specifierLen);
+
+  void HandleNonStandardConversionSpecification(
+      const analyze_format_string::LengthModifier &LM,
+      const analyze_format_string::ConversionSpecifier &CS,
+      const char *startSpecifier, unsigned specifierLen);
+
   virtual void HandleInvalidPosition(const char *startSpecifier,
                                      unsigned specifierLen,
                                      analyze_format_string::PositionContext p);
@@ -1739,6 +1752,37 @@
                        getSpecifierRange(startSpecifier, specifierLen));
 }
 
+void CheckFormatHandler::HandleNonStandardLengthModifier(
+    const analyze_format_string::LengthModifier &LM,
+    const char *startSpecifier, unsigned specifierLen) {
+  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard) << LM.toString()
+                       << "length modifier",
+                       getLocationOfByte(LM.getStart()),
+                       /*IsStringLocation*/true,
+                       getSpecifierRange(startSpecifier, specifierLen));
+}
+
+void CheckFormatHandler::HandleNonStandardConversionSpecifier(
+    const analyze_format_string::ConversionSpecifier &CS,
+    const char *startSpecifier, unsigned specifierLen) {
+  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard) << CS.toString()
+                       << "conversion specifier",
+                       getLocationOfByte(CS.getStart()),
+                       /*IsStringLocation*/true,
+                       getSpecifierRange(startSpecifier, specifierLen));
+}
+
+void CheckFormatHandler::HandleNonStandardConversionSpecification(
+    const analyze_format_string::LengthModifier &LM,
+    const analyze_format_string::ConversionSpecifier &CS,
+    const char *startSpecifier, unsigned specifierLen) {
+  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_conversion_spec)
+                       << LM.toString() << CS.toString(),
+                       getLocationOfByte(LM.getStart()),
+                       /*IsStringLocation*/true,
+                       getSpecifierRange(startSpecifier, specifierLen));
+}
+
 void
 CheckFormatHandler::HandleInvalidPosition(const char *startPos, unsigned posLen,
                                      analyze_format_string::PositionContext p) {
@@ -2157,6 +2201,13 @@
                          FixItHint::CreateRemoval(
                            getSpecifierRange(LM.getStart(),
                                              LM.getLength())));
+  if (!FS.hasStandardLengthModifier())
+    HandleNonStandardLengthModifier(LM, startSpecifier, specifierLen);
+  if (!FS.hasStandardConversionSpecifier(S.getLangOptions()))
+    HandleNonStandardConversionSpecifier(CS, startSpecifier, specifierLen);
+  if (!FS.hasStandardLengthConversionCombination())
+    HandleNonStandardConversionSpecification(LM, CS, startSpecifier,
+                                             specifierLen);
 
   // Are we using '%n'?
   if (CS.getKind() == ConversionSpecifier::nArg) {
@@ -2343,6 +2394,14 @@
                          FixItHint::CreateRemoval(R));
   }
 
+  if (!FS.hasStandardLengthModifier())
+    HandleNonStandardLengthModifier(LM, startSpecifier, specifierLen);
+  if (!FS.hasStandardConversionSpecifier(S.getLangOptions()))
+    HandleNonStandardConversionSpecifier(CS, startSpecifier, specifierLen);
+  if (!FS.hasStandardLengthConversionCombination())
+    HandleNonStandardConversionSpecification(LM, CS, startSpecifier,
+                                             specifierLen);
+
   // The remaining checks depend on the data arguments.
   if (HasVAListArg)
     return true;
@@ -2996,37 +3055,31 @@
   case Stmt::ImplicitCastExprClass:
   case Stmt::CStyleCastExprClass:
   case Stmt::CXXFunctionalCastExprClass:
-  case Stmt::ObjCBridgedCastExprClass: {
-    Expr* SubExpr = cast<CastExpr>(E)->getSubExpr();
-    QualType T = SubExpr->getType();
-
-    if (SubExpr->getType()->isPointerType() ||
-        SubExpr->getType()->isBlockPointerType() ||
-        SubExpr->getType()->isObjCQualifiedIdType())
-      return EvalAddr(SubExpr, refVars);
-    else if (T->isArrayType())
-      return EvalVal(SubExpr, refVars);
-    else
-      return 0;
-  }
-
-  // C++ casts.  For dynamic casts, static casts, and const casts, we
-  // are always converting from a pointer-to-pointer, so we just blow
-  // through the cast.  In the case the dynamic cast doesn't fail (and
-  // return NULL), we take the conservative route and report cases
-  // where we return the address of a stack variable.  For Reinterpre
-  // FIXME: The comment about is wrong; we're not always converting
-  // from pointer to pointer. I'm guessing that this code should also
-  // handle references to objects.
+  case Stmt::ObjCBridgedCastExprClass:
   case Stmt::CXXStaticCastExprClass:
   case Stmt::CXXDynamicCastExprClass:
   case Stmt::CXXConstCastExprClass:
   case Stmt::CXXReinterpretCastExprClass: {
-      Expr *S = cast<CXXNamedCastExpr>(E)->getSubExpr();
-      if (S->getType()->isPointerType() || S->getType()->isBlockPointerType())
-        return EvalAddr(S, refVars);
-      else
-        return NULL;
+    Expr* SubExpr = cast<CastExpr>(E)->getSubExpr();
+    switch (cast<CastExpr>(E)->getCastKind()) {
+    case CK_BitCast:
+    case CK_LValueToRValue:
+    case CK_NoOp:
+    case CK_BaseToDerived:
+    case CK_DerivedToBase:
+    case CK_UncheckedDerivedToBase:
+    case CK_Dynamic:
+    case CK_CPointerToObjCPointerCast:
+    case CK_BlockPointerToObjCPointerCast:
+    case CK_AnyPointerToBlockPointerCast:
+      return EvalAddr(SubExpr, refVars);
+
+    case CK_ArrayToPointerDecay:
+      return EvalVal(SubExpr, refVars);
+
+    default:
+      return 0;
+    }
   }
 
   case Stmt::MaterializeTemporaryExprClass:
@@ -4387,7 +4440,7 @@
 void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
                             const ArraySubscriptExpr *ASE,
                             bool AllowOnePastEnd, bool IndexNegated) {
-  IndexExpr = IndexExpr->IgnoreParenCasts();
+  IndexExpr = IndexExpr->IgnoreParenImpCasts();
   if (IndexExpr->isValueDependent())
     return;
 
@@ -4433,15 +4486,15 @@
     }
 
     if (size.getBitWidth() > index.getBitWidth())
-      index = index.sext(size.getBitWidth());
+      index = index.zext(size.getBitWidth());
     else if (size.getBitWidth() < index.getBitWidth())
-      size = size.sext(index.getBitWidth());
+      size = size.zext(index.getBitWidth());
 
     // For array subscripting the index must be less than size, but for pointer
     // arithmetic also allow the index (offset) to be equal to size since
     // computing the next address after the end of the array is legal and
     // commonly done e.g. in C++ iterators and range-based for loops.
-    if (AllowOnePastEnd ? index.sle(size) : index.slt(size))
+    if (AllowOnePastEnd ? index.ule(size) : index.ult(size))
       return;
 
     // Also don't warn for arrays of size 1 which are members of some
@@ -4969,4 +5022,3 @@
     Diag(NBody->getSemiLoc(), diag::note_empty_body_on_separate_line);
   }
 }
-

Modified: cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp Tue Feb 28 17:49:25 2012
@@ -3707,19 +3707,19 @@
   };
 }
 
-static bool anyNullArguments(Expr **Args, unsigned NumArgs) {
-  if (NumArgs && !Args)
+static bool anyNullArguments(llvm::ArrayRef<Expr*> Args) {
+  if (Args.size() && !Args.data())
     return true;
-  
-  for (unsigned I = 0; I != NumArgs; ++I)
+
+  for (unsigned I = 0; I != Args.size(); ++I)
     if (!Args[I])
       return true;
-  
+
   return false;
 }
 
 void Sema::CodeCompleteCall(Scope *S, Expr *FnIn,
-                            Expr **ArgsIn, unsigned NumArgs) {
+                            llvm::ArrayRef<Expr *> Args) {
   if (!CodeCompleter)
     return;
 
@@ -3729,11 +3729,10 @@
   // e.g., by merging the two kinds of results.
 
   Expr *Fn = (Expr *)FnIn;
-  Expr **Args = (Expr **)ArgsIn;
 
   // Ignore type-dependent call expressions entirely.
-  if (!Fn || Fn->isTypeDependent() || anyNullArguments(Args, NumArgs) ||
-      Expr::hasAnyTypeDependentArguments(Args, NumArgs)) {
+  if (!Fn || Fn->isTypeDependent() || anyNullArguments(Args) ||
+      Expr::hasAnyTypeDependentArguments(Args)) {
     CodeCompleteOrdinaryName(S, PCC_Expression);
     return;
   }
@@ -3751,7 +3750,7 @@
 
   Expr *NakedFn = Fn->IgnoreParenCasts();
   if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
-    AddOverloadedCallCandidates(ULE, Args, NumArgs, CandidateSet,
+    AddOverloadedCallCandidates(ULE, Args, CandidateSet,
                                 /*PartialOverloading=*/ true);
   else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {
     FunctionDecl *FDecl = dyn_cast<FunctionDecl>(DRE->getDecl());
@@ -3761,9 +3760,8 @@
         Results.push_back(ResultCandidate(FDecl));
       else
         // FIXME: access?
-        AddOverloadCandidate(FDecl, DeclAccessPair::make(FDecl, AS_none),
-                             Args, NumArgs, CandidateSet,
-                             false, /*PartialOverloading*/true);
+        AddOverloadCandidate(FDecl, DeclAccessPair::make(FDecl, AS_none), Args,
+                             CandidateSet, false, /*PartialOverloading*/true);
     }
   }
   
@@ -3786,12 +3784,12 @@
     for (unsigned I = 0, N = Results.size(); I != N; ++I) {
       if (const FunctionType *FType = Results[I].getFunctionType())
         if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FType))
-          if (NumArgs < Proto->getNumArgs()) {
+          if (Args.size() < Proto->getNumArgs()) {
             if (ParamType.isNull())
-              ParamType = Proto->getArgType(NumArgs);
+              ParamType = Proto->getArgType(Args.size());
             else if (!Context.hasSameUnqualifiedType(
                                             ParamType.getNonReferenceType(),
-                           Proto->getArgType(NumArgs).getNonReferenceType())) {
+                       Proto->getArgType(Args.size()).getNonReferenceType())) {
               ParamType = QualType();
               break;
             }
@@ -3812,8 +3810,8 @@
     
     if (const FunctionProtoType *Proto
                                   = FunctionType->getAs<FunctionProtoType>()) {
-      if (NumArgs < Proto->getNumArgs())
-        ParamType = Proto->getArgType(NumArgs);
+      if (Args.size() < Proto->getNumArgs())
+        ParamType = Proto->getArgType(Args.size());
     }
   }
 
@@ -3823,7 +3821,7 @@
     CodeCompleteExpression(S, ParamType);
   
   if (!Results.empty())
-    CodeCompleter->ProcessOverloadCandidates(*this, NumArgs, Results.data(), 
+    CodeCompleter->ProcessOverloadCandidates(*this, Args.size(), Results.data(),
                                              Results.size());
 }
 

Modified: cfe/branches/tooling/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDecl.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDecl.cpp Tue Feb 28 17:49:25 2012
@@ -1249,6 +1249,10 @@
   }
 }
 
+void Sema::ActOnStartFunctionDeclarator() {
+  InFunctionDeclarator = true;
+}
+
 /// \brief Look for an Objective-C class in the translation unit.
 ///
 /// \param Id The name of the Objective-C class we're looking for. If
@@ -4810,6 +4814,8 @@
 
   assert(R.getTypePtr()->isFunctionType());
 
+  InFunctionDeclarator = false;
+
   // TODO: consider using NameInfo for diagnostic.
   DeclarationNameInfo NameInfo = GetNameForDeclarator(D);
   DeclarationName Name = NameInfo.getName();
@@ -5241,6 +5247,15 @@
   // Finally, we know we have the right number of parameters, install them.
   NewFD->setParams(Params);
 
+  // Find all anonymous symbols defined during the declaration of this function
+  // and add to NewFD. This lets us track decls such 'enum Y' in:
+  //
+  //   void f(enum Y {AA} x) {}
+  //
+  // which would otherwise incorrectly end up in the translation unit scope.
+  NewFD->setDeclsInPrototypeScope(DeclsInPrototypeScope);
+  DeclsInPrototypeScope.clear();
+
   // Process the non-inheritable attributes on this declaration.
   ProcessDeclAttributes(S, NewFD, D,
                         /*NonInheritable=*/true, /*Inheritable=*/false);
@@ -6226,10 +6241,8 @@
   // completed by the initializer. For example:
   //   int ary[] = { 1, 3, 5 };
   // "ary" transitions from an IncompleteArrayType to a ConstantArrayType.
-  if (!VDecl->isInvalidDecl() && (DclT != SavT)) {
+  if (!VDecl->isInvalidDecl() && (DclT != SavT))
     VDecl->setType(DclT);
-    Init->setType(DclT.getNonReferenceType());
-  }
 
   // Check any implicit conversions within the expression.
   CheckImplicitConversions(Init, VDecl->getLocation());
@@ -7227,6 +7240,43 @@
     }
   }
 
+  // If we had any tags defined in the function prototype,
+  // introduce them into the function scope.
+  if (FnBodyScope) {
+    for (llvm::ArrayRef<NamedDecl*>::iterator I = FD->getDeclsInPrototypeScope().begin(),
+           E = FD->getDeclsInPrototypeScope().end(); I != E; ++I) {
+      NamedDecl *D = *I;
+
+      // Some of these decls (like enums) may have been pinned to the translation unit
+      // for lack of a real context earlier. If so, remove from the translation unit
+      // and reattach to the current context.
+      if (D->getLexicalDeclContext() == Context.getTranslationUnitDecl()) {
+        // Is the decl actually in the context?
+        for (DeclContext::decl_iterator DI = Context.getTranslationUnitDecl()->decls_begin(),
+               DE = Context.getTranslationUnitDecl()->decls_end(); DI != DE; ++DI) {
+          if (*DI == D) {  
+            Context.getTranslationUnitDecl()->removeDecl(D);
+            break;
+          }
+        }
+        // Either way, reassign the lexical decl context to our FunctionDecl.
+        D->setLexicalDeclContext(CurContext);
+      }
+
+      // If the decl has a non-null name, make accessible in the current scope.
+      if (!D->getName().empty())
+        PushOnScopeChains(D, FnBodyScope, /*AddToContext=*/false);
+
+      // Similarly, dive into enums and fish their constants out, making them
+      // accessible in this scope.
+      if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
+        for (EnumDecl::enumerator_iterator EI = ED->enumerator_begin(),
+               EE = ED->enumerator_end(); EI != EE; ++EI)
+          PushOnScopeChains(*EI, FnBodyScope, /*AddToContext=*/false);
+      }
+    }
+  }
+
   // Checking attributes of current function definition
   // dllimport attribute.
   DLLImportAttr *DA = FD->getAttr<DLLImportAttr>();
@@ -8179,7 +8229,12 @@
                   !isa<CXXRecordDecl>(Def) ||
                   cast<CXXRecordDecl>(Def)->getTemplateSpecializationKind() 
                                                == TSK_ExplicitSpecialization) {
-                Diag(NameLoc, diag::err_redefinition) << Name;
+                // A redeclaration in function prototype scope in C isn't
+                // visible elsewhere, so merely issue a warning.
+                if (!getLangOptions().CPlusPlus && S->containedInPrototypeScope())
+                  Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name;
+                else
+                  Diag(NameLoc, diag::err_redefinition) << Name;
                 Diag(Def->getLocation(), diag::note_previous_definition);
                 // If this is a redefinition, recover by making this
                 // struct be anonymous, which will make any later
@@ -8461,6 +8516,12 @@
         II->isStr("FILE"))
       Context.setFILEDecl(New);
 
+  // If we were in function prototype scope (and not in C++ mode), add this
+  // tag to the list of decls to inject into the function definition scope.
+  if (S->isFunctionPrototypeScope() && !getLangOptions().CPlusPlus &&
+      InFunctionDeclarator && Name)
+    DeclsInPrototypeScope.push_back(New);
+
   OwnedDecl = true;
   return New;
 }
@@ -8937,6 +8998,19 @@
   return false;
 }
 
+/// If the given constructor is user-provided, produce a diagnostic explaining
+/// that it makes the class non-trivial.
+static bool DiagnoseNontrivialUserProvidedCtor(Sema &S, QualType QT,
+                                               CXXConstructorDecl *CD,
+                                               Sema::CXXSpecialMember CSM) {
+  if (!CD->isUserProvided())
+    return false;
+
+  SourceLocation CtorLoc = CD->getLocation();
+  S.Diag(CtorLoc, diag::note_nontrivial_user_defined) << QT << CSM;
+  return true;
+}
+
 /// DiagnoseNontrivial - Given that a class has a non-trivial
 /// special member, figure out why.
 void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) {
@@ -8951,17 +9025,20 @@
   case CXXDefaultConstructor:
     if (RD->hasUserDeclaredConstructor()) {
       typedef CXXRecordDecl::ctor_iterator ctor_iter;
-      for (ctor_iter ci = RD->ctor_begin(), ce = RD->ctor_end(); ci != ce;++ci){
-        const FunctionDecl *body = 0;
-        ci->hasBody(body);
-        if (!body || !cast<CXXConstructorDecl>(body)->isImplicitlyDefined()) {
-          SourceLocation CtorLoc = ci->getLocation();
-          Diag(CtorLoc, diag::note_nontrivial_user_defined) << QT << member;
+      for (ctor_iter CI = RD->ctor_begin(), CE = RD->ctor_end(); CI != CE; ++CI)
+        if (DiagnoseNontrivialUserProvidedCtor(*this, QT, *CI, member))
           return;
-        }
-      }
 
-      llvm_unreachable("found no user-declared constructors");
+      // No user-provided constructors; look for constructor templates.
+      typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl>
+          tmpl_iter;
+      for (tmpl_iter TI(RD->decls_begin()), TE(RD->decls_end());
+           TI != TE; ++TI) {
+        CXXConstructorDecl *CD =
+            dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl());
+        if (CD && DiagnoseNontrivialUserProvidedCtor(*this, QT, CD, member))
+          return;
+      }
     }
     break;
 
@@ -10128,6 +10205,12 @@
 
   Enum->completeDefinition(BestType, BestPromotionType,
                            NumPositiveBits, NumNegativeBits);
+
+  // If we're declaring a function, ensure this decl isn't forgotten about -
+  // it needs to go into the function scope.
+  if (InFunctionDeclarator)
+    DeclsInPrototypeScope.push_back(Enum);
+
 }
 
 Decl *Sema::ActOnFileScopeAsmDecl(Expr *expr,

Modified: cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp Tue Feb 28 17:49:25 2012
@@ -3463,9 +3463,19 @@
 }
 
 static bool isKnownDeclSpecAttr(const AttributeList &Attr) {
-  return Attr.getKind() == AttributeList::AT_dllimport ||
-         Attr.getKind() == AttributeList::AT_dllexport ||
-         Attr.getKind() == AttributeList::AT_uuid;
+  switch (Attr.getKind()) {
+  default:
+    return false;
+  case AttributeList::AT_dllimport:
+  case AttributeList::AT_dllexport:
+  case AttributeList::AT_uuid:
+  case AttributeList::AT_deprecated:
+  case AttributeList::AT_noreturn:
+  case AttributeList::AT_nothrow:
+  case AttributeList::AT_naked:
+  case AttributeList::AT_noinline:
+    return true;
+  }
 }
 
 //===----------------------------------------------------------------------===//

Modified: cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp Tue Feb 28 17:49:25 2012
@@ -32,7 +32,6 @@
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Lex/Preprocessor.h"
-#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/STLExtras.h"
 #include <map>
@@ -1640,12 +1639,17 @@
   ExprResult Init = InitExpr;
   if (!FD->getType()->isDependentType() && !InitExpr->isTypeDependent()) {
     if (isa<InitListExpr>(InitExpr) && isStdInitializerList(FD->getType(), 0)) {
-    Diag(FD->getLocation(), diag::warn_dangling_std_initializer_list)
+      Diag(FD->getLocation(), diag::warn_dangling_std_initializer_list)
         << /*at end of ctor*/1 << InitExpr->getSourceRange();
     }
-    // FIXME: if there is no EqualLoc, this is list-initialization.
-    Init = PerformCopyInitialization(
-      InitializedEntity::InitializeMember(FD), EqualLoc, InitExpr);
+    Expr **Inits = &InitExpr;
+    unsigned NumInits = 1;
+    InitializedEntity Entity = InitializedEntity::InitializeMember(FD);
+    InitializationKind Kind = EqualLoc.isInvalid()
+        ? InitializationKind::CreateDirectList(InitExpr->getLocStart())
+        : InitializationKind::CreateCopy(InitExpr->getLocStart(), EqualLoc);
+    InitializationSequence Seq(*this, Entity, Kind, Inits, NumInits);
+    Init = Seq.Perform(*this, Entity, Kind, MultiExprArg(Inits, NumInits));
     if (Init.isInvalid()) {
       FD->setInvalidDecl();
       return;
@@ -3289,6 +3293,9 @@
       continue;
     if (FieldClassDecl->hasIrrelevantDestructor())
       continue;
+    // The destructor for an implicit anonymous union member is never invoked.
+    if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion())
+      continue;
 
     CXXDestructorDecl *Dtor = LookupDestructor(FieldClassDecl);
     assert(Dtor && "No dtor found for FieldClassDecl!");
@@ -3867,6 +3874,10 @@
     // FIXME: a compatible, but different, explicit exception specification
     // will be silently overridden. We should issue a warning if this happens.
     EPI.ExtInfo = CtorType->getExtInfo();
+
+    // Such a function is also trivial if the implicitly-declared function
+    // would have been.
+    CD->setTrivial(CD->getParent()->hasTrivialDefaultConstructor());
   }
 
   if (HadError) {
@@ -3962,6 +3973,10 @@
     //  -- [...] it shall have the same parameter type as if it had been
     //     implicitly declared.
     CD->setType(Context.getFunctionType(Context.VoidTy, &ArgType, 1, EPI));
+
+    // Such a function is also trivial if the implicitly-declared function
+    // would have been.
+    CD->setTrivial(CD->getParent()->hasTrivialCopyConstructor());
   }
 
   if (HadError) {
@@ -4049,6 +4064,10 @@
     EPI.RefQualifier = OperType->getRefQualifier();
     EPI.ExtInfo = OperType->getExtInfo();
     MD->setType(Context.getFunctionType(ReturnType, &ArgType, 1, EPI));
+
+    // Such a function is also trivial if the implicitly-declared function
+    // would have been.
+    MD->setTrivial(MD->getParent()->hasTrivialCopyAssignment());
   }
 
   if (HadError) {
@@ -4142,6 +4161,10 @@
     //  -- [...] it shall have the same parameter type as if it had been
     //     implicitly declared.
     CD->setType(Context.getFunctionType(Context.VoidTy, &ArgType, 1, EPI));
+
+    // Such a function is also trivial if the implicitly-declared function
+    // would have been.
+    CD->setTrivial(CD->getParent()->hasTrivialMoveConstructor());
   }
 
   if (HadError) {
@@ -4227,6 +4250,10 @@
     EPI.RefQualifier = OperType->getRefQualifier();
     EPI.ExtInfo = OperType->getExtInfo();
     MD->setType(Context.getFunctionType(ReturnType, &ArgType, 1, EPI));
+
+    // Such a function is also trivial if the implicitly-declared function
+    // would have been.
+    MD->setTrivial(MD->getParent()->hasTrivialMoveAssignment());
   }
 
   if (HadError) {
@@ -4274,6 +4301,10 @@
     // There are no parameters.
     EPI.ExtInfo = DtorType->getExtInfo();
     DD->setType(Context.getFunctionType(Context.VoidTy, 0, 0, EPI));
+
+    // Such a function is also trivial if the implicitly-declared function
+    // would have been.
+    DD->setTrivial(DD->getParent()->hasTrivialDestructor());
   }
 
   if (ShouldDeleteSpecialMember(DD, CXXDestructor)) {
@@ -4344,31 +4375,33 @@
                                  TQ & Qualifiers::Volatile);
   }
 
+  bool shouldDeleteForClassSubobject(CXXRecordDecl *Class, FieldDecl *Field);
+
   bool shouldDeleteForBase(CXXRecordDecl *BaseDecl, bool IsVirtualBase);
   bool shouldDeleteForField(FieldDecl *FD);
   bool shouldDeleteForAllConstMembers();
 };
 }
 
-/// Check whether we should delete a special member function due to the class
-/// having a particular direct or virtual base class.
-bool SpecialMemberDeletionInfo::shouldDeleteForBase(CXXRecordDecl *BaseDecl,
-                                                    bool IsVirtualBase) {
-  // C++11 [class.copy]p23:
-  // -- for the move assignment operator, any direct or indirect virtual
-  //    base class.
-  if (CSM == Sema::CXXMoveAssignment && IsVirtualBase)
-    return true;
-
+/// Check whether we should delete a special member function due to having a
+/// direct or virtual base class or static data member of class type M.
+bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
+    CXXRecordDecl *Class, FieldDecl *Field) {
   // C++11 [class.ctor]p5, C++11 [class.copy]p11, C++11 [class.dtor]p5:
   // -- any direct or virtual base class [...] has a type with a destructor
   //    that is deleted or inaccessible
   if (!IsAssignment) {
-    CXXDestructorDecl *BaseDtor = S.LookupDestructor(BaseDecl);
-    if (BaseDtor->isDeleted())
+    CXXDestructorDecl *Dtor = S.LookupDestructor(Class);
+    if (Dtor->isDeleted())
       return true;
-    if (S.CheckDestructorAccess(Loc, BaseDtor, S.PDiag())
-          != Sema::AR_accessible)
+    if (S.CheckDestructorAccess(Loc, Dtor, S.PDiag()) != Sema::AR_accessible)
+      return true;
+
+    // C++11 [class.dtor]p5:
+    // -- X is a union-like class that has a variant member with a non-trivial
+    //    destructor
+    if (CSM == Sema::CXXDestructor && Field && Field->getParent()->isUnion() &&
+        !Dtor->isTrivial())
       return true;
   }
 
@@ -4382,50 +4415,58 @@
   //    overload resolution, as applied to B's corresponding special member,
   //    results in an ambiguity or a function that is deleted or inaccessible
   //    from the defaulted special member
+  // FIXME: in-class initializers should be handled here
   if (CSM != Sema::CXXDestructor) {
-    Sema::SpecialMemberOverloadResult *SMOR = lookupIn(BaseDecl);
+    Sema::SpecialMemberOverloadResult *SMOR = lookupIn(Class);
     if (!SMOR->hasSuccess())
       return true;
 
-    CXXMethodDecl *BaseMember = SMOR->getMethod();
+    CXXMethodDecl *Member = SMOR->getMethod();
+    // A member of a union must have a trivial corresponding special member.
+    if (Field && Field->getParent()->isUnion() && !Member->isTrivial())
+      return true;
+
     if (IsConstructor) {
-      CXXConstructorDecl *BaseCtor = cast<CXXConstructorDecl>(BaseMember);
-      if (S.CheckConstructorAccess(Loc, BaseCtor, BaseCtor->getAccess(),
-                                   S.PDiag()) != Sema::AR_accessible)
+      CXXConstructorDecl *Ctor = cast<CXXConstructorDecl>(Member);
+      if (S.CheckConstructorAccess(Loc, Ctor, Ctor->getAccess(), S.PDiag())
+            != Sema::AR_accessible)
         return true;
 
       // -- for the move constructor, a [...] direct or virtual base class with
       //    a type that does not have a move constructor and is not trivially
       //    copyable.
-      if (IsMove && !BaseCtor->isMoveConstructor() &&
-          !BaseDecl->isTriviallyCopyable())
+      if (IsMove && !Ctor->isMoveConstructor() && !Class->isTriviallyCopyable())
         return true;
     } else {
       assert(IsAssignment && "unexpected kind of special member");
-      if (S.CheckDirectMemberAccess(Loc, BaseMember, S.PDiag())
+      if (S.CheckDirectMemberAccess(Loc, Member, S.PDiag())
             != Sema::AR_accessible)
         return true;
 
       // -- for the move assignment operator, a direct base class with a type
       //    that does not have a move assignment operator and is not trivially
       //    copyable.
-      if (IsMove && !BaseMember->isMoveAssignmentOperator() &&
-          !BaseDecl->isTriviallyCopyable())
+      if (IsMove && !Member->isMoveAssignmentOperator() &&
+          !Class->isTriviallyCopyable())
         return true;
     }
   }
 
-  // C++11 [class.dtor]p5:
-  // -- for a virtual destructor, lookup of the non-array deallocation function
-  //    results in an ambiguity or in a function that is deleted or inaccessible
-  if (CSM == Sema::CXXDestructor && MD->isVirtual()) {
-    FunctionDecl *OperatorDelete = 0;
-    DeclarationName Name =
-      S.Context.DeclarationNames.getCXXOperatorName(OO_Delete);
-    if (S.FindDeallocationFunction(Loc, MD->getParent(), Name,
-                                   OperatorDelete, false))
-      return true;
-  }
+  return false;
+}
+
+/// Check whether we should delete a special member function due to the class
+/// having a particular direct or virtual base class.
+bool SpecialMemberDeletionInfo::shouldDeleteForBase(CXXRecordDecl *BaseDecl,
+                                                    bool IsVirtualBase) {
+  // C++11 [class.copy]p23:
+  // -- for the move assignment operator, any direct or indirect virtual
+  //    base class.
+  if (CSM == Sema::CXXMoveAssignment && IsVirtualBase)
+    return true;
+
+  if (shouldDeleteForClassSubobject(BaseDecl, 0))
+    return true;
 
   return false;
 }
@@ -4444,6 +4485,15 @@
 
     if (inUnion() && !FieldType.isConstQualified())
       AllFieldsAreConst = false;
+
+    // C++11 [class.ctor]p5: any non-variant non-static data member of
+    // const-qualified type (or array thereof) with no
+    // brace-or-equal-initializer does not have a user-provided default
+    // constructor.
+    if (!inUnion() && FieldType.isConstQualified() &&
+        !FD->hasInClassInitializer() &&
+        (!FieldRecord || !FieldRecord->hasUserProvidedDefaultConstructor()))
+      return true;
   } else if (CSM == Sema::CXXCopyConstructor) {
     // For a copy constructor, data members must not be of rvalue reference
     // type.
@@ -4456,13 +4506,6 @@
   }
 
   if (FieldRecord) {
-    // For a default constructor, a const member must have a user-provided
-    // default constructor or else be explicitly initialized.
-    if (CSM == Sema::CXXDefaultConstructor && FieldType.isConstQualified() &&
-        !FD->hasInClassInitializer() &&
-        !FieldRecord->hasUserProvidedDefaultConstructor())
-      return true;
-
     // Some additional restrictions exist on the variant members.
     if (!inUnion() && FieldRecord->isUnion() &&
         FieldRecord->isAnonymousStructOrUnion()) {
@@ -4472,62 +4515,19 @@
                                          UE = FieldRecord->field_end();
            UI != UE; ++UI) {
         QualType UnionFieldType = S.Context.getBaseElementType(UI->getType());
-        CXXRecordDecl *UnionFieldRecord =
-          UnionFieldType->getAsCXXRecordDecl();
 
         if (!UnionFieldType.isConstQualified())
           AllVariantFieldsAreConst = false;
 
-        if (UnionFieldRecord) {
-          // FIXME: Checking for accessibility and validity of this
-          //        destructor is technically going beyond the
-          //        standard, but this is believed to be a defect.
-          if (!IsAssignment) {
-            CXXDestructorDecl *FieldDtor = S.LookupDestructor(UnionFieldRecord);
-            if (FieldDtor->isDeleted())
-              return true;
-            if (S.CheckDestructorAccess(Loc, FieldDtor, S.PDiag()) !=
-                Sema::AR_accessible)
-              return true;
-            if (!FieldDtor->isTrivial())
-              return true;
-          }
-
-          // FIXME: in-class initializers should be handled here
-          if (CSM != Sema::CXXDestructor) {
-            Sema::SpecialMemberOverloadResult *SMOR =
-                lookupIn(UnionFieldRecord);
-            // FIXME: Checking for accessibility and validity of this
-            //        corresponding member is technically going beyond the
-            //        standard, but this is believed to be a defect.
-            if (!SMOR->hasSuccess())
-              return true;
-
-            CXXMethodDecl *FieldMember = SMOR->getMethod();
-            // A member of a union must have a trivial corresponding
-            // special member.
-            if (!FieldMember->isTrivial())
-              return true;
-
-            if (IsConstructor) {
-              CXXConstructorDecl *FieldCtor =
-                  cast<CXXConstructorDecl>(FieldMember);
-              if (S.CheckConstructorAccess(Loc, FieldCtor,
-                                           FieldCtor->getAccess(),
-                                           S.PDiag()) != Sema::AR_accessible)
-              return true;
-            } else {
-              assert(IsAssignment && "unexpected kind of special member");
-              if (S.CheckDirectMemberAccess(Loc, FieldMember, S.PDiag())
-                  != Sema::AR_accessible)
-                return true;
-            }
-          }
-        }
+        CXXRecordDecl *UnionFieldRecord = UnionFieldType->getAsCXXRecordDecl();
+        if (UnionFieldRecord &&
+            shouldDeleteForClassSubobject(UnionFieldRecord, *UI))
+          return true;
       }
 
       // At least one member in each anonymous union must be non-const
-      if (CSM == Sema::CXXDefaultConstructor && AllVariantFieldsAreConst)
+      if (CSM == Sema::CXXDefaultConstructor && AllVariantFieldsAreConst &&
+          FieldRecord->field_begin() != FieldRecord->field_end())
         return true;
 
       // Don't try to initialize the anonymous union
@@ -4535,9 +4535,9 @@
       return false;
     }
 
-    // Unless we're doing assignment, the field's destructor must be
-    // accessible and not deleted.
-    if (!IsAssignment) {
+    // When checking a constructor, the field's destructor must be accessible
+    // and not deleted.
+    if (IsConstructor) {
       CXXDestructorDecl *FieldDtor = S.LookupDestructor(FieldRecord);
       if (FieldDtor->isDeleted())
         return true;
@@ -4549,13 +4549,18 @@
     // Check that the corresponding member of the field is accessible,
     // unique, and non-deleted. We don't do this if it has an explicit
     // initialization when default-constructing.
-    if (CSM != Sema::CXXDestructor &&
-        !(CSM == Sema::CXXDefaultConstructor && FD->hasInClassInitializer())) {
+    if (!(CSM == Sema::CXXDefaultConstructor && FD->hasInClassInitializer())) {
       Sema::SpecialMemberOverloadResult *SMOR = lookupIn(FieldRecord);
       if (!SMOR->hasSuccess())
         return true;
 
       CXXMethodDecl *FieldMember = SMOR->getMethod();
+
+      // We need the corresponding member of a union to be trivial so that
+      // we can safely process all members simultaneously.
+      if (inUnion() && !FieldMember->isTrivial())
+        return true;
+
       if (IsConstructor) {
         CXXConstructorDecl *FieldCtor = cast<CXXConstructorDecl>(FieldMember);
         if (S.CheckConstructorAccess(Loc, FieldCtor, FieldCtor->getAccess(),
@@ -4568,6 +4573,13 @@
         if (IsMove && !FieldCtor->isMoveConstructor() &&
             !FieldRecord->isTriviallyCopyable())
           return true;
+      } else if (CSM == Sema::CXXDestructor) {
+        CXXDestructorDecl *FieldDtor = S.LookupDestructor(FieldRecord);
+        if (FieldDtor->isDeleted())
+          return true;
+        if (S.CheckDestructorAccess(Loc, FieldDtor, S.PDiag()) !=
+            Sema::AR_accessible)
+          return true;
       } else {
         assert(IsAssignment && "unexpected kind of special member");
         if (S.CheckDirectMemberAccess(Loc, FieldMember, S.PDiag())
@@ -4581,19 +4593,7 @@
             !FieldRecord->isTriviallyCopyable())
           return true;
       }
-
-      // We need the corresponding member of a union to be trivial so that
-      // we can safely copy them all simultaneously.
-      // FIXME: Note that performing the check here (where we rely on the lack
-      // of an in-class initializer) is technically ill-formed. However, this
-      // seems most obviously to be a bug in the standard.
-      if (inUnion() && !FieldMember->isTrivial())
-        return true;
     }
-  } else if (CSM == Sema::CXXDefaultConstructor && !inUnion() &&
-             FieldType.isConstQualified() && !FD->hasInClassInitializer()) {
-    // We can't initialize a const member of non-class type to any value.
-    return true;
   } else if (IsAssignment && FieldType.isConstQualified()) {
     // C++11 [class.copy]p23:
     // -- a non-static data member of const non-class type (or array thereof)
@@ -4607,7 +4607,10 @@
 ///   A defaulted default constructor for a class X is defined as deleted if
 /// X is a union and all of its variant members are of const-qualified type.
 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
-  return CSM == Sema::CXXDefaultConstructor && inUnion() && AllFieldsAreConst;
+  // This is a silly definition, because it gives an empty union a deleted
+  // default constructor. Don't do that.
+  return CSM == Sema::CXXDefaultConstructor && inUnion() && AllFieldsAreConst &&
+    (MD->getParent()->field_begin() != MD->getParent()->field_end());
 }
 
 /// Determine whether a defaulted special member function should be defined as
@@ -4620,6 +4623,8 @@
   if (!LangOpts.CPlusPlus0x || RD->isInvalidDecl())
     return false;
 
+  // FIXME: Provide the ability to diagnose why a special member was deleted.
+
   // C++11 [expr.lambda.prim]p19:
   //   The closure type associated with a lambda-expression has a
   //   deleted (8.4.3) default constructor and a deleted copy
@@ -4628,6 +4633,18 @@
       (CSM == CXXDefaultConstructor || CSM == CXXCopyAssignment))
     return true;
 
+  // C++11 [class.dtor]p5:
+  // -- for a virtual destructor, lookup of the non-array deallocation function
+  //    results in an ambiguity or in a function that is deleted or inaccessible
+  if (CSM == Sema::CXXDestructor && MD->isVirtual()) {
+    FunctionDecl *OperatorDelete = 0;
+    DeclarationName Name =
+      Context.DeclarationNames.getCXXOperatorName(OO_Delete);
+    if (FindDeallocationFunction(MD->getLocation(), MD->getParent(), Name,
+                                 OperatorDelete, false))
+      return true;
+  }
+
   // For an anonymous struct or union, the copy and assignment special members
   // will never be used, so skip the check. For an anonymous union declared at
   // namespace scope, the constructor and destructor are used.
@@ -4640,8 +4657,6 @@
 
   SpecialMemberDeletionInfo SMI(*this, MD, CSM);
 
-  // FIXME: We should put some diagnostic logic right into this function.
-
   for (CXXRecordDecl::base_class_iterator BI = RD->bases_begin(),
                                           BE = RD->bases_end(); BI != BE; ++BI)
     if (!BI->isVirtual() &&
@@ -6464,7 +6479,7 @@
   // need to be repeated.
 
   struct UserData {
-    llvm::DenseSet<const CXXRecordDecl*> Bases;
+    llvm::SmallPtrSet<const CXXRecordDecl*, 4> Bases;
 
     static bool collect(const CXXRecordDecl *Base, void *OpaqueData) {
       UserData *Data = reinterpret_cast<UserData*>(OpaqueData);
@@ -7184,18 +7199,19 @@
   // This could be uniqued if it ever proves significant.
   Destructor->setTypeSourceInfo(Context.getTrivialTypeSourceInfo(Ty));
 
+  AddOverriddenMethods(ClassDecl, Destructor);
+
   if (ShouldDeleteSpecialMember(Destructor, CXXDestructor))
     Destructor->setDeletedAsWritten();
-  
-  AddOverriddenMethods(ClassDecl, Destructor);
-  
+
   return Destructor;
 }
 
 void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation,
                                     CXXDestructorDecl *Destructor) {
   assert((Destructor->isDefaulted() &&
-          !Destructor->doesThisDeclarationHaveABody()) &&
+          !Destructor->doesThisDeclarationHaveABody() &&
+          !Destructor->isDeleted()) &&
          "DefineImplicitDestructor - call it for implicit default dtor");
   CXXRecordDecl *ClassDecl = Destructor->getParent();
   assert(ClassDecl && "DefineImplicitDestructor - invalid destructor");
@@ -7645,7 +7661,8 @@
   assert((CopyAssignOperator->isDefaulted() && 
           CopyAssignOperator->isOverloadedOperator() &&
           CopyAssignOperator->getOverloadedOperator() == OO_Equal &&
-          !CopyAssignOperator->doesThisDeclarationHaveABody()) &&
+          !CopyAssignOperator->doesThisDeclarationHaveABody() &&
+          !CopyAssignOperator->isDeleted()) &&
          "DefineImplicitCopyAssignment called for wrong function");
 
   CXXRecordDecl *ClassDecl = CopyAssignOperator->getParent();
@@ -8073,7 +8090,8 @@
   assert((MoveAssignOperator->isDefaulted() && 
           MoveAssignOperator->isOverloadedOperator() &&
           MoveAssignOperator->getOverloadedOperator() == OO_Equal &&
-          !MoveAssignOperator->doesThisDeclarationHaveABody()) &&
+          !MoveAssignOperator->doesThisDeclarationHaveABody() &&
+          !MoveAssignOperator->isDeleted()) &&
          "DefineImplicitMoveAssignment called for wrong function");
 
   CXXRecordDecl *ClassDecl = MoveAssignOperator->getParent();
@@ -8560,7 +8578,8 @@
                                    CXXConstructorDecl *CopyConstructor) {
   assert((CopyConstructor->isDefaulted() &&
           CopyConstructor->isCopyConstructor() &&
-          !CopyConstructor->doesThisDeclarationHaveABody()) &&
+          !CopyConstructor->doesThisDeclarationHaveABody() &&
+          !CopyConstructor->isDeleted()) &&
          "DefineImplicitCopyConstructor - call it for implicit copy ctor");
 
   CXXRecordDecl *ClassDecl = CopyConstructor->getParent();
@@ -8715,7 +8734,8 @@
                                    CXXConstructorDecl *MoveConstructor) {
   assert((MoveConstructor->isDefaulted() &&
           MoveConstructor->isMoveConstructor() &&
-          !MoveConstructor->doesThisDeclarationHaveABody()) &&
+          !MoveConstructor->doesThisDeclarationHaveABody() &&
+          !MoveConstructor->isDeleted()) &&
          "DefineImplicitMoveConstructor - call it for implicit move ctor");
 
   CXXRecordDecl *ClassDecl = MoveConstructor->getParent();
@@ -8755,9 +8775,9 @@
 /// \brief Mark the call operator of the given lambda closure type as "used".
 static void markLambdaCallOperatorUsed(Sema &S, CXXRecordDecl *Lambda) {
   CXXMethodDecl *CallOperator 
-  = cast<CXXMethodDecl>(
-      *Lambda->lookup(
-        S.Context.DeclarationNames.getCXXOperatorName(OO_Call)).first);
+    = cast<CXXMethodDecl>(
+        *Lambda->lookup(
+          S.Context.DeclarationNames.getCXXOperatorName(OO_Call)).first);
   CallOperator->setReferenced();
   CallOperator->setUsed();
 }
@@ -8805,14 +8825,21 @@
        SourceLocation CurrentLocation,
        CXXConversionDecl *Conv) 
 {
+  CXXRecordDecl *Lambda = Conv->getParent();
+  
   // Make sure that the lambda call operator is marked used.
-  markLambdaCallOperatorUsed(*this, Conv->getParent());
+  CXXMethodDecl *CallOperator 
+    = cast<CXXMethodDecl>(
+        *Lambda->lookup(
+          Context.DeclarationNames.getCXXOperatorName(OO_Call)).first);
+  CallOperator->setReferenced();
+  CallOperator->setUsed();
   Conv->setUsed();
   
   ImplicitlyDefinedFunctionScope Scope(*this, Conv);
   DiagnosticErrorTrap Trap(Diags);
   
-  // Copy-initialize the lambda object as needed to capture
+  // Copy-initialize the lambda object as needed to capture it.
   Expr *This = ActOnCXXThis(CurrentLocation).take();
   Expr *DerefThis =CreateBuiltinUnaryOp(CurrentLocation, UO_Deref, This).take();
   ExprResult Init = PerformCopyInitialization(
@@ -8823,16 +8850,84 @@
   if (!Init.isInvalid())
     Init = ActOnFinishFullExpr(Init.take());
   
-  if (!Init.isInvalid())
-    Conv->setLambdaToBlockPointerCopyInit(Init.take());
-  else {
+  if (Init.isInvalid()) {
     Diag(CurrentLocation, diag::note_lambda_to_block_conv);
+    Conv->setInvalidDecl();
+    return;
   }
   
-  // Introduce a bogus body, which IR generation will override anyway.
-  Conv->setBody(new (Context) CompoundStmt(Context, 0, 0, Conv->getLocation(),
+  // Create the new block to be returned.
+  BlockDecl *Block = BlockDecl::Create(Context, Conv, Conv->getLocation());
+  
+  // Set the type information.
+  Block->setSignatureAsWritten(CallOperator->getTypeSourceInfo());
+  Block->setIsVariadic(CallOperator->isVariadic());
+  Block->setBlockMissingReturnType(false);
+  
+  // Add parameters.
+  SmallVector<ParmVarDecl *, 4> BlockParams;
+  for (unsigned I = 0, N = CallOperator->getNumParams(); I != N; ++I) {
+    ParmVarDecl *From = CallOperator->getParamDecl(I);
+    BlockParams.push_back(ParmVarDecl::Create(Context, Block,
+                                              From->getLocStart(),
+                                              From->getLocation(),
+                                              From->getIdentifier(),
+                                              From->getType(),
+                                              From->getTypeSourceInfo(),
+                                              From->getStorageClass(),
+                                            From->getStorageClassAsWritten(),
+                                              /*DefaultArg=*/0));
+  }
+  Block->setParams(BlockParams);
+  
+  // Add capture. The capture uses a fake variable, which doesn't correspond
+  // to any actual memory location. However, the initializer copy-initializes
+  // the lambda object.
+  TypeSourceInfo *CapVarTSI =
+      Context.getTrivialTypeSourceInfo(DerefThis->getType());
+  VarDecl *CapVar = VarDecl::Create(Context, Block, Conv->getLocation(),
+                                    Conv->getLocation(), 0,
+                                    DerefThis->getType(), CapVarTSI,
+                                    SC_None, SC_None);
+  BlockDecl::Capture Capture(/*Variable=*/CapVar, /*ByRef=*/false,
+                             /*Nested=*/false, /*Copy=*/Init.take());
+  Block->setCaptures(Context, &Capture, &Capture + 1, 
+                     /*CapturesCXXThis=*/false);
+  
+  // Add a fake function body to the block. IR generation is responsible
+  // for filling in the actual body, which cannot be expressed as an AST.
+  Block->setBody(new (Context) CompoundStmt(Context, 0, 0, 
+                                            Conv->getLocation(),
+                                            Conv->getLocation()));
+
+  // Create the block literal expression.
+  Expr *BuildBlock = new (Context) BlockExpr(Block, Conv->getConversionType());
+  ExprCleanupObjects.push_back(Block);
+  ExprNeedsCleanups = true;
+
+  // If we're not under ARC, make sure we still get the _Block_copy/autorelease
+  // behavior.
+  if (!getLangOptions().ObjCAutoRefCount)
+    BuildBlock = ImplicitCastExpr::Create(Context, BuildBlock->getType(),
+                                          CK_CopyAndAutoreleaseBlockObject,
+                                          BuildBlock, 0, VK_RValue);
+  
+  // Create the return statement that returns the block from the conversion
+  // function.
+  StmtResult Return = ActOnReturnStmt(Conv->getLocation(), BuildBlock);
+  if (Return.isInvalid()) {
+    Diag(CurrentLocation, diag::note_lambda_to_block_conv);
+    Conv->setInvalidDecl();
+    return;
+  }
+
+  // Set the body of the conversion function.
+  Stmt *ReturnS = Return.take();
+  Conv->setBody(new (Context) CompoundStmt(Context, &ReturnS, 1, 
+                                           Conv->getLocation(), 
                                            Conv->getLocation()));
   
+  // We're done; notify the mutation listener, if any.
   if (ASTMutationListener *L = getASTMutationListener()) {
     L->CompletedImplicitDefinition(Conv);
   }
@@ -8955,7 +9050,8 @@
 Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
                               MultiExprArg ArgsPtr,
                               SourceLocation Loc,                                    
-                              ASTOwningVector<Expr*> &ConvertedArgs) {
+                              ASTOwningVector<Expr*> &ConvertedArgs,
+                              bool AllowExplicit) {
   // FIXME: This duplicates a lot of code from Sema::ConvertArgumentsForCall.
   unsigned NumArgs = ArgsPtr.size();
   Expr **Args = (Expr **)ArgsPtr.get();
@@ -8976,7 +9072,7 @@
   SmallVector<Expr *, 8> AllArgs;
   bool Invalid = GatherArgumentsForCall(Loc, Constructor,
                                         Proto, 0, Args, NumArgs, AllArgs, 
-                                        CallType);
+                                        CallType, AllowExplicit);
   ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
 
   DiagnoseSentinelCalls(Constructor, Loc, AllArgs.data(), AllArgs.size());
@@ -10170,6 +10266,35 @@
     // recovery.
   }
   Fn->setDeletedAsWritten();
+
+  CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Dcl);
+  if (!MD)
+    return;
+
+  // A deleted special member function is trivial if the corresponding
+  // implicitly-declared function would have been.
+  switch (getSpecialMember(MD)) {
+  case CXXInvalid:
+    break;
+  case CXXDefaultConstructor:
+    MD->setTrivial(MD->getParent()->hasTrivialDefaultConstructor());
+    break;
+  case CXXCopyConstructor:
+    MD->setTrivial(MD->getParent()->hasTrivialCopyConstructor());
+    break;
+  case CXXMoveConstructor:
+    MD->setTrivial(MD->getParent()->hasTrivialMoveConstructor());
+    break;
+  case CXXCopyAssignment:
+    MD->setTrivial(MD->getParent()->hasTrivialCopyAssignment());
+    break;
+  case CXXMoveAssignment:
+    MD->setTrivial(MD->getParent()->hasTrivialMoveAssignment());
+    break;
+  case CXXDestructor:
+    MD->setTrivial(MD->getParent()->hasTrivialDestructor());
+    break;
+  }
 }
 
 void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation DefaultLoc) {

Modified: cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp Tue Feb 28 17:49:25 2012
@@ -242,7 +242,8 @@
   if (ND && ND->isDeprecated()) {
     S.Diag(ImplLoc, diag::warn_deprecated_def) << select;
     if (select == 0)
-      S.Diag(ND->getLocation(), diag::note_method_declared_at);
+      S.Diag(ND->getLocation(), diag::note_method_declared_at)
+        << ND->getDeclName();
     else
       S.Diag(ND->getLocation(), diag::note_previous_decl) << "class";
   }
@@ -988,6 +989,25 @@
   return ActOnObjCContainerStartDefinition(IMPDecl);
 }
 
+Sema::DeclGroupPtrTy
+Sema::ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef<Decl *> Decls) {
+  SmallVector<Decl *, 64> DeclsInGroup;
+  DeclsInGroup.reserve(Decls.size() + 1);
+
+  for (unsigned i = 0, e = Decls.size(); i != e; ++i) {
+    Decl *Dcl = Decls[i];
+    if (!Dcl)
+      continue;
+    if (Dcl->getDeclContext()->isFileContext())
+      Dcl->setTopLevelDeclInObjCContainer();
+    DeclsInGroup.push_back(Dcl);
+  }
+
+  DeclsInGroup.push_back(ObjCImpDecl);
+
+  return BuildDeclaratorGroup(DeclsInGroup.data(), DeclsInGroup.size(), false);
+}
+
 void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
                                     ObjCIvarDecl **ivars, unsigned numIvars,
                                     SourceLocation RBrace) {
@@ -1447,7 +1467,8 @@
   if (match) {
     Diag(ImpMethodDecl->getLocation(), 
          diag::warn_category_method_impl_match);
-    Diag(MethodDecl->getLocation(), diag::note_method_declared_at);
+    Diag(MethodDecl->getLocation(), diag::note_method_declared_at)
+      << MethodDecl->getDeclName();
   }
 }
 
@@ -1520,7 +1541,8 @@
             if (Diags.getDiagnosticLevel(DIAG, ImpLoc)
                 != DiagnosticsEngine::Ignored) {
               WarnUndefinedMethod(ImpLoc, method, IncompleteImpl, DIAG);
-              Diag(method->getLocation(), diag::note_method_declared_at);
+              Diag(method->getLocation(), diag::note_method_declared_at)
+                << method->getDeclName();
               Diag(CDecl->getLocation(), diag::note_required_for_protocol_at)
                 << PDecl->getDeclName();
             }
@@ -1542,7 +1564,8 @@
       if (Diags.getDiagnosticLevel(DIAG, ImpLoc) !=
             DiagnosticsEngine::Ignored) {
         WarnUndefinedMethod(ImpLoc, method, IncompleteImpl, DIAG);
-        Diag(method->getLocation(), diag::note_method_declared_at);
+        Diag(method->getLocation(), diag::note_method_declared_at)
+          << method->getDeclName();
         Diag(IDecl->getLocation(), diag::note_required_for_protocol_at) <<
           PDecl->getDeclName();
       }
@@ -2779,7 +2802,8 @@
       SourceLocation MethodLoc = IMD->getLocation();
       if (!getSourceManager().isInSystemHeader(MethodLoc)) {
         Diag(EndLoc, diag::warn_attribute_method_def);
-        Diag(MethodLoc, diag::note_method_declared_at);
+        Diag(MethodLoc, diag::note_method_declared_at)
+          << ObjCMethod->getDeclName();
       }
     }
   } else {

Modified: cfe/branches/tooling/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExpr.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExpr.cpp Tue Feb 28 17:49:25 2012
@@ -1257,7 +1257,7 @@
 bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
                                CorrectionCandidateCallback &CCC,
                                TemplateArgumentListInfo *ExplicitTemplateArgs,
-                               Expr **Args, unsigned NumArgs) {
+                               llvm::ArrayRef<Expr *> Args) {
   DeclarationName Name = R.getLookupName();
 
   unsigned diagnostic = diag::err_undeclared_var_use;
@@ -1387,11 +1387,11 @@
                    dyn_cast<FunctionTemplateDecl>(*CD))
             AddTemplateOverloadCandidate(
                 FTD, DeclAccessPair::make(FTD, AS_none), ExplicitTemplateArgs,
-                Args, NumArgs, OCS);
+                Args, OCS);
           else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(*CD))
             if (!ExplicitTemplateArgs || ExplicitTemplateArgs->size() == 0)
               AddOverloadCandidate(FD, DeclAccessPair::make(FD, AS_none),
-                                   Args, NumArgs, OCS);
+                                   Args, OCS);
         }
         switch (OCS.BestViableFunction(*this, R.getNameLoc(), Best)) {
           case OR_Success:
@@ -3248,7 +3248,8 @@
                                   unsigned FirstProtoArg,
                                   Expr **Args, unsigned NumArgs,
                                   SmallVector<Expr *, 8> &AllArgs,
-                                  VariadicCallType CallType) {
+                                  VariadicCallType CallType,
+                                  bool AllowExplicit) {
   unsigned NumArgsInProto = Proto->getNumArgs();
   unsigned NumArgsToCheck = NumArgs;
   bool Invalid = false;
@@ -3288,7 +3289,9 @@
                                                       Proto->isArgConsumed(i));
       ExprResult ArgE = PerformCopyInitialization(Entity,
                                                   SourceLocation(),
-                                                  Owned(Arg));
+                                                  Owned(Arg),
+                                                  /*TopLevelOfInitList=*/false,
+                                                  AllowExplicit);
       if (ArgE.isInvalid())
         return true;
 
@@ -3447,7 +3450,8 @@
     bool Dependent = false;
     if (Fn->isTypeDependent())
       Dependent = true;
-    else if (Expr::hasAnyTypeDependentArguments(Args, NumArgs))
+    else if (Expr::hasAnyTypeDependentArguments(
+        llvm::makeArrayRef(Args, NumArgs)))
       Dependent = true;
 
     if (Dependent) {
@@ -4725,6 +4729,14 @@
   }
   // Check Objective-C object pointer types and 'void *'
   if (LHSTy->isVoidPointerType() && RHSTy->isObjCObjectPointerType()) {
+    if (getLangOptions().ObjCAutoRefCount) {
+      // ARC forbids the implicit conversion of object pointers to 'void *',
+      // so these types are not compatible.
+      Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
+          << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+      LHS = RHS = true;
+      return QualType();
+    }
     QualType lhptee = LHSTy->getAs<PointerType>()->getPointeeType();
     QualType rhptee = RHSTy->getAs<ObjCObjectPointerType>()->getPointeeType();
     QualType destPointee
@@ -4737,6 +4749,14 @@
     return destType;
   }
   if (LHSTy->isObjCObjectPointerType() && RHSTy->isVoidPointerType()) {
+    if (getLangOptions().ObjCAutoRefCount) {
+      // ARC forbids the implicit conversion of object pointers to 'void *',
+      // so these types are not compatible.
+      Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
+          << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+      LHS = RHS = true;
+      return QualType();
+    }
     QualType lhptee = LHSTy->getAs<ObjCObjectPointerType>()->getPointeeType();
     QualType rhptee = RHSTy->getAs<PointerType>()->getPointeeType();
     QualType destPointee
@@ -4899,7 +4919,8 @@
     opaqueValue = new (Context) OpaqueValueExpr(commonExpr->getExprLoc(),
                                                 commonExpr->getType(),
                                                 commonExpr->getValueKind(),
-                                                commonExpr->getObjectKind());
+                                                commonExpr->getObjectKind(),
+                                                commonExpr);
     LHSExpr = CondExpr = opaqueValue;
   }
 
@@ -7591,6 +7612,25 @@
 ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
                                     BinaryOperatorKind Opc,
                                     Expr *LHSExpr, Expr *RHSExpr) {
+  if (getLangOptions().CPlusPlus0x && isa<InitListExpr>(RHSExpr)) {
+    // The syntax only allows initializer lists on the RHS of assignment,
+    // so we don't need to worry about accepting invalid code for
+    // non-assignment operators.
+    // C++11 5.17p9:
+    //   The meaning of x = {v} [...] is that of x = T(v) [...]. The meaning
+    //   of x = {} is x = T().
+    InitializationKind Kind =
+        InitializationKind::CreateDirectList(RHSExpr->getLocStart());
+    InitializedEntity Entity =
+        InitializedEntity::InitializeTemporary(LHSExpr->getType());
+    InitializationSequence InitSeq(*this, Entity, Kind, &RHSExpr, 1);
+    ExprResult Init = InitSeq.Perform(*this, Entity, Kind,
+                                      MultiExprArg(&RHSExpr, 1));
+    if (Init.isInvalid())
+      return Init;
+    RHSExpr = Init.take();
+  }
+
   ExprResult LHS = Owned(LHSExpr), RHS = Owned(RHSExpr);
   QualType ResultTy;     // Result type of the binary operator.
   // The following two variables are used for compound assignment operators
@@ -9277,12 +9317,14 @@
 
 void
 Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-                                      Decl *LambdaContextDecl) {
+                                      Decl *LambdaContextDecl,
+                                      bool IsDecltype) {
   ExprEvalContexts.push_back(
              ExpressionEvaluationContextRecord(NewContext,
                                                ExprCleanupObjects.size(),
                                                ExprNeedsCleanups,
-                                               LambdaContextDecl));
+                                               LambdaContextDecl,
+                                               IsDecltype));
   ExprNeedsCleanups = false;
   if (!MaybeODRUseExprs.empty())
     std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
@@ -9397,7 +9439,7 @@
 
   // Note that this declaration has been used.
   if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Func)) {
-    if (Constructor->isDefaulted()) {
+    if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
       if (Constructor->isDefaultConstructor()) {
         if (Constructor->isTrivial())
           return;
@@ -9415,12 +9457,14 @@
     MarkVTableUsed(Loc, Constructor->getParent());
   } else if (CXXDestructorDecl *Destructor =
                  dyn_cast<CXXDestructorDecl>(Func)) {
-    if (Destructor->isDefaulted() && !Destructor->isUsed(false))
+    if (Destructor->isDefaulted() && !Destructor->isDeleted() &&
+        !Destructor->isUsed(false))
       DefineImplicitDestructor(Loc, Destructor);
     if (Destructor->isVirtual())
       MarkVTableUsed(Loc, Destructor->getParent());
   } else if (CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
-    if (MethodDecl->isDefaulted() && MethodDecl->isOverloadedOperator() &&
+    if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted() &&
+        MethodDecl->isOverloadedOperator() &&
         MethodDecl->getOverloadedOperator() == OO_Equal) {
       if (!MethodDecl->isUsed(false)) {
         if (MethodDecl->isCopyAssignmentOperator())
@@ -10280,6 +10324,13 @@
   if (ReturnType->isVoidType() || !ReturnType->isIncompleteType())
     return false;
 
+  // If we're inside a decltype's expression, don't check for a valid return
+  // type or construct temporaries until we know whether this is the last call.
+  if (ExprEvalContexts.back().IsDecltype) {
+    ExprEvalContexts.back().DelayedDecltypeCalls.push_back(CE);
+    return false;
+  }
+
   PartialDiagnostic Note =
     FD ? PDiag(diag::note_function_with_incomplete_return_type_declared_here)
     << FD->getDeclName() : PDiag();

Modified: cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp Tue Feb 28 17:49:25 2012
@@ -771,7 +771,8 @@
   SourceLocation TyBeginLoc = TInfo->getTypeLoc().getBeginLoc();
 
   if (Ty->isDependentType() ||
-      CallExpr::hasAnyTypeDependentArguments(Exprs, NumExprs)) {
+      CallExpr::hasAnyTypeDependentArguments(
+        llvm::makeArrayRef(Exprs, NumExprs))) {
     exprs.release();
 
     return Owned(CXXUnresolvedConstructExpr::Create(Context, TInfo,
@@ -1018,6 +1019,13 @@
   } else if (Initializer && isa<InitListExpr>(Initializer))
     initStyle = CXXNewExpr::ListInit;
   else {
+    // In template instantiation, the initializer could be a CXXDefaultArgExpr
+    // unwrapped from a CXXConstructExpr that was implicitly built. There is no
+    // particularly sane way we can handle this (especially since it can even
+    // occur for array new), so we throw the initializer away and have it be
+    // rebuilt.
+    if (Initializer && isa<CXXDefaultArgExpr>(Initializer))
+      Initializer = 0;
     assert((!Initializer || isa<ImplicitValueInitExpr>(Initializer) ||
             isa<CXXConstructExpr>(Initializer)) &&
            "Initializer expression that cannot have been implicitly created.");
@@ -1198,7 +1206,8 @@
   unsigned NumPlaceArgs = PlacementArgs.size();
 
   if (!AllocType->isDependentType() &&
-      !Expr::hasAnyTypeDependentArguments(PlaceArgs, NumPlaceArgs) &&
+      !Expr::hasAnyTypeDependentArguments(
+        llvm::makeArrayRef(PlaceArgs, NumPlaceArgs)) &&
       FindAllocationFunctions(StartLoc,
                               SourceRange(PlacementLParen, PlacementRParen),
                               UseGlobal, AllocType, ArraySize, PlaceArgs,
@@ -1273,7 +1282,8 @@
   }
 
   if (!AllocType->isDependentType() &&
-      !Expr::hasAnyTypeDependentArguments(Inits, NumInits)) {
+      !Expr::hasAnyTypeDependentArguments(
+        llvm::makeArrayRef(Inits, NumInits))) {
     // C++11 [expr.new]p15:
     //   A new-expression that creates an object of type T initializes that
     //   object as follows:
@@ -1617,14 +1627,16 @@
 
     if (FunctionTemplateDecl *FnTemplate = dyn_cast<FunctionTemplateDecl>(D)) {
       AddTemplateOverloadCandidate(FnTemplate, Alloc.getPair(),
-                                   /*ExplicitTemplateArgs=*/0, Args, NumArgs,
+                                   /*ExplicitTemplateArgs=*/0,
+                                   llvm::makeArrayRef(Args, NumArgs),
                                    Candidates,
                                    /*SuppressUserConversions=*/false);
       continue;
     }
 
     FunctionDecl *Fn = cast<FunctionDecl>(D);
-    AddOverloadCandidate(Fn, Alloc.getPair(), Args, NumArgs, Candidates,
+    AddOverloadCandidate(Fn, Alloc.getPair(),
+                         llvm::makeArrayRef(Args, NumArgs), Candidates,
                          /*SuppressUserConversions=*/false);
   }
 
@@ -1654,9 +1666,13 @@
 
       Args[i] = Result.takeAs<Expr>();
     }
+
     Operator = FnDecl;
-    CheckAllocationAccess(StartLoc, Range, R.getNamingClass(), Best->FoundDecl,
-                          Diagnose);
+
+    if (CheckAllocationAccess(StartLoc, Range, R.getNamingClass(),
+                              Best->FoundDecl, Diagnose) == AR_inaccessible)
+      return true;
+
     return false;
   }
 
@@ -1664,7 +1680,8 @@
     if (Diagnose) {
       Diag(StartLoc, diag::err_ovl_no_viable_function_in_call)
         << Name << Range;
-      Candidates.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
+      Candidates.NoteCandidates(*this, OCD_AllCandidates,
+                                llvm::makeArrayRef(Args, NumArgs));
     }
     return true;
 
@@ -1672,7 +1689,8 @@
     if (Diagnose) {
       Diag(StartLoc, diag::err_ovl_ambiguous_call)
         << Name << Range;
-      Candidates.NoteCandidates(*this, OCD_ViableCandidates, Args, NumArgs);
+      Candidates.NoteCandidates(*this, OCD_ViableCandidates,
+                                llvm::makeArrayRef(Args, NumArgs));
     }
     return true;
 
@@ -1683,7 +1701,8 @@
         << Name 
         << getDeletedOrUnavailableSuffix(Best->Function)
         << Range;
-      Candidates.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
+      Candidates.NoteCandidates(*this, OCD_AllCandidates,
+                                llvm::makeArrayRef(Args, NumArgs));
     }
     return true;
   }
@@ -1874,13 +1893,16 @@
     if (Operator->isDeleted()) {
       if (Diagnose) {
         Diag(StartLoc, diag::err_deleted_function_use);
-        Diag(Operator->getLocation(), diag::note_unavailable_here) << true;
+        Diag(Operator->getLocation(), diag::note_unavailable_here)
+          << /*function*/ 1 << /*deleted*/ 1;
       }
       return true;
     }
 
-    CheckAllocationAccess(StartLoc, SourceRange(), Found.getNamingClass(),
-                          Matches[0], Diagnose);
+    if (CheckAllocationAccess(StartLoc, SourceRange(), Found.getNamingClass(),
+                              Matches[0], Diagnose) == AR_inaccessible)
+      return true;
+
     return false;
 
   // We found multiple suitable operators;  complain about the ambiguity.
@@ -3205,6 +3227,126 @@
   return BuildBinaryTypeTrait(BTT, KWLoc, LhsTSInfo, RhsTSInfo, RParen);
 }
 
+static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
+                              ArrayRef<TypeSourceInfo *> Args,
+                              SourceLocation RParenLoc) {
+  switch (Kind) {
+  case clang::TT_IsTriviallyConstructible: {
+    // C++11 [meta.unary.prop]:
+    //   is_trivially_constructible is defined as:
+    //
+    //     is_constructible<T, Args...>::value is true and the variable
+    //     definition for is_constructible, as defined below, is known to call no
+    //     operation that is not trivial.
+    //
+    //   The predicate condition for a template specialization 
+    //   is_constructible<T, Args...> shall be satisfied if and only if the 
+    //   following variable definition would be well-formed for some invented 
+    //   variable t:
+    //
+    //     T t(create<Args>()...);
+    if (Args.empty()) {
+      S.Diag(KWLoc, diag::err_type_trait_arity)
+        << 1 << 1 << 1 << (int)Args.size();
+      return false;
+    }
+    
+    bool SawVoid = false;
+    for (unsigned I = 0, N = Args.size(); I != N; ++I) {
+      if (Args[I]->getType()->isVoidType()) {
+        SawVoid = true;
+        continue;
+      }
+      
+      if (!Args[I]->getType()->isIncompleteType() &&
+        S.RequireCompleteType(KWLoc, Args[I]->getType(), 
+          diag::err_incomplete_type_used_in_type_trait_expr))
+        return false;
+    }
+    
+    // If any argument was 'void', of course it won't type-check.
+    if (SawVoid)
+      return false;
+    
+    llvm::SmallVector<OpaqueValueExpr, 2> OpaqueArgExprs;
+    llvm::SmallVector<Expr *, 2> ArgExprs;
+    ArgExprs.reserve(Args.size() - 1);
+    for (unsigned I = 1, N = Args.size(); I != N; ++I) {
+      QualType T = Args[I]->getType();
+      if (T->isObjectType() || T->isFunctionType())
+        T = S.Context.getRValueReferenceType(T);
+      OpaqueArgExprs.push_back(
+        OpaqueValueExpr(Args[I]->getTypeLoc().getSourceRange().getBegin(), 
+                        T.getNonLValueExprType(S.Context),
+                        Expr::getValueKindForType(T)));
+      ArgExprs.push_back(&OpaqueArgExprs.back());
+    }
+    
+    // Perform the initialization in an unevaluated context within a SFINAE 
+    // trap at translation unit scope.
+    EnterExpressionEvaluationContext Unevaluated(S, Sema::Unevaluated);
+    Sema::SFINAETrap SFINAE(S, /*AccessCheckingSFINAE=*/true);
+    Sema::ContextRAII TUContext(S, S.Context.getTranslationUnitDecl());
+    InitializedEntity To(InitializedEntity::InitializeTemporary(Args[0]));
+    InitializationKind InitKind(InitializationKind::CreateDirect(KWLoc, KWLoc,
+                                                                 RParenLoc));
+    InitializationSequence Init(S, To, InitKind, 
+                                ArgExprs.begin(), ArgExprs.size());
+    if (Init.Failed())
+      return false;
+    
+    ExprResult Result = Init.Perform(S, To, InitKind, 
+                                     MultiExprArg(ArgExprs.data(), 
+                                                  ArgExprs.size()));
+    if (Result.isInvalid() || SFINAE.hasErrorOccurred())
+      return false;
+    
+    // The initialization succeeded; not make sure there are no non-trivial 
+    // calls.
+    return !Result.get()->hasNonTrivialCall(S.Context);
+  }
+  }
+  
+  return false;
+}
+
+ExprResult Sema::BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, 
+                                ArrayRef<TypeSourceInfo *> Args, 
+                                SourceLocation RParenLoc) {
+  bool Dependent = false;
+  for (unsigned I = 0, N = Args.size(); I != N; ++I) {
+    if (Args[I]->getType()->isDependentType()) {
+      Dependent = true;
+      break;
+    }
+  }
+  
+  bool Value = false;
+  if (!Dependent)
+    Value = evaluateTypeTrait(*this, Kind, KWLoc, Args, RParenLoc);
+  
+  return TypeTraitExpr::Create(Context, Context.BoolTy, KWLoc, Kind,
+                               Args, RParenLoc, Value);
+}
+
+ExprResult Sema::ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc, 
+                                ArrayRef<ParsedType> Args, 
+                                SourceLocation RParenLoc) {
+  llvm::SmallVector<TypeSourceInfo *, 4> ConvertedArgs;
+  ConvertedArgs.reserve(Args.size());
+  
+  for (unsigned I = 0, N = Args.size(); I != N; ++I) {
+    TypeSourceInfo *TInfo;
+    QualType T = GetTypeFromParser(Args[I], &TInfo);
+    if (!TInfo)
+      TInfo = Context.getTrivialTypeSourceInfo(T, KWLoc);
+    
+    ConvertedArgs.push_back(TInfo);    
+  }
+  
+  return BuildTypeTrait(Kind, KWLoc, ConvertedArgs, RParenLoc);
+}
+
 static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT,
                                     QualType LhsT, QualType RhsT,
                                     SourceLocation KeyLoc) {
@@ -3294,6 +3436,54 @@
     ExprResult Result = Init.Perform(Self, To, Kind, MultiExprArg(&FromPtr, 1));
     return !Result.isInvalid() && !SFINAE.hasErrorOccurred();
   }
+      
+  case BTT_IsTriviallyAssignable: {
+    // C++11 [meta.unary.prop]p3:
+    //   is_trivially_assignable is defined as:
+    //     is_assignable<T, U>::value is true and the assignment, as defined by
+    //     is_assignable, is known to call no operation that is not trivial
+    //
+    //   is_assignable is defined as:
+    //     The expression declval<T>() = declval<U>() is well-formed when 
+    //     treated as an unevaluated operand (Clause 5).
+    //
+    //   For both, T and U shall be complete types, (possibly cv-qualified) 
+    //   void, or arrays of unknown bound.
+    if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType() &&
+        Self.RequireCompleteType(KeyLoc, LhsT, 
+          diag::err_incomplete_type_used_in_type_trait_expr))
+      return false;
+    if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType() &&
+        Self.RequireCompleteType(KeyLoc, RhsT, 
+          diag::err_incomplete_type_used_in_type_trait_expr))
+      return false;
+
+    // cv void is never assignable.
+    if (LhsT->isVoidType() || RhsT->isVoidType())
+      return false;
+
+    // Build expressions that emulate the effect of declval<T>() and 
+    // declval<U>().
+    if (LhsT->isObjectType() || LhsT->isFunctionType())
+      LhsT = Self.Context.getRValueReferenceType(LhsT);
+    if (RhsT->isObjectType() || RhsT->isFunctionType())
+      RhsT = Self.Context.getRValueReferenceType(RhsT);
+    OpaqueValueExpr Lhs(KeyLoc, LhsT.getNonLValueExprType(Self.Context),
+                        Expr::getValueKindForType(LhsT));
+    OpaqueValueExpr Rhs(KeyLoc, RhsT.getNonLValueExprType(Self.Context),
+                        Expr::getValueKindForType(RhsT));
+    
+    // Attempt the assignment 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());
+    ExprResult Result = Self.BuildBinOp(/*S=*/0, KeyLoc, BO_Assign, &Lhs, &Rhs);
+    if (Result.isInvalid() || SFINAE.hasErrorOccurred())
+      return false;
+
+    return !Result.get()->hasNonTrivialCall(Self.Context);
+  }
   }
   llvm_unreachable("Unknown type trait or not implemented");
 }
@@ -3326,6 +3516,7 @@
   case BTT_IsSame:         ResultType = Context.BoolTy; break;
   case BTT_TypeCompatible: ResultType = Context.IntTy; break;
   case BTT_IsConvertibleTo: ResultType = Context.BoolTy; break;
+  case BTT_IsTriviallyAssignable: ResultType = Context.BoolTy;
   }
 
   return Owned(new (Context) BinaryTypeTraitExpr(KWLoc, BTT, LhsTSInfo,
@@ -4315,11 +4506,14 @@
     }
   }
 
-  // That should be enough to guarantee that this type is complete.
+  // That should be enough to guarantee that this type is complete, if we're
+  // not processing a decltype expression.
   CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
   if (RD->isInvalidDecl() || RD->isDependentContext())
     return Owned(E);
-  CXXDestructorDecl *Destructor = LookupDestructor(RD);
+
+  bool IsDecltype = ExprEvalContexts.back().IsDecltype;
+  CXXDestructorDecl *Destructor = IsDecltype ? 0 : LookupDestructor(RD);
 
   if (Destructor) {
     MarkFunctionReferenced(E->getExprLoc(), Destructor);
@@ -4327,18 +4521,22 @@
                           PDiag(diag::err_access_dtor_temp)
                             << E->getType());
     DiagnoseUseOfDecl(Destructor, E->getExprLoc());
-  }
 
-  // If destructor is trivial, we can avoid the extra copy.
-  if (Destructor->isTrivial())
-    return Owned(E);
+    // If destructor is trivial, we can avoid the extra copy.
+    if (Destructor->isTrivial())
+      return Owned(E);
 
-  if (Destructor)
     // We need a cleanup, but we don't need to remember the temporary.
     ExprNeedsCleanups = true;
+  }
 
   CXXTemporary *Temp = CXXTemporary::Create(Context, Destructor);
-  return Owned(CXXBindTemporaryExpr::Create(Context, Temp, E));
+  CXXBindTemporaryExpr *Bind = CXXBindTemporaryExpr::Create(Context, Temp, E);
+
+  if (IsDecltype)
+    ExprEvalContexts.back().DelayedDecltypeBinds.push_back(Bind);
+
+  return Owned(Bind);
 }
 
 ExprResult
@@ -4390,6 +4588,95 @@
   return MaybeCreateExprWithCleanups(E);
 }
 
+/// Process the expression contained within a decltype. For such expressions,
+/// certain semantic checks on temporaries are delayed until this point, and
+/// are omitted for the 'topmost' call in the decltype expression. If the
+/// topmost call bound a temporary, strip that temporary off the expression.
+ExprResult Sema::ActOnDecltypeExpression(Expr *E) {
+  ExpressionEvaluationContextRecord &Rec = ExprEvalContexts.back();
+  assert(Rec.IsDecltype && "not in a decltype expression");
+
+  // C++11 [expr.call]p11:
+  //   If a function call is a prvalue of object type,
+  // -- if the function call is either
+  //   -- the operand of a decltype-specifier, or
+  //   -- the right operand of a comma operator that is the operand of a
+  //      decltype-specifier,
+  //   a temporary object is not introduced for the prvalue.
+
+  // Recursively rebuild ParenExprs and comma expressions to strip out the
+  // outermost CXXBindTemporaryExpr, if any.
+  if (ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
+    ExprResult SubExpr = ActOnDecltypeExpression(PE->getSubExpr());
+    if (SubExpr.isInvalid())
+      return ExprError();
+    if (SubExpr.get() == PE->getSubExpr())
+      return Owned(E);
+    return ActOnParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.take());
+  }
+  if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
+    if (BO->getOpcode() == BO_Comma) {
+      ExprResult RHS = ActOnDecltypeExpression(BO->getRHS());
+      if (RHS.isInvalid())
+        return ExprError();
+      if (RHS.get() == BO->getRHS())
+        return Owned(E);
+      return Owned(new (Context) BinaryOperator(BO->getLHS(), RHS.take(),
+                                                BO_Comma, BO->getType(),
+                                                BO->getValueKind(),
+                                                BO->getObjectKind(),
+                                                BO->getOperatorLoc()));
+    }
+  }
+
+  CXXBindTemporaryExpr *TopBind = dyn_cast<CXXBindTemporaryExpr>(E);
+  if (TopBind)
+    E = TopBind->getSubExpr();
+
+  // Disable the special decltype handling now.
+  Rec.IsDecltype = false;
+
+  // Perform the semantic checks we delayed until this point.
+  CallExpr *TopCall = dyn_cast<CallExpr>(E);
+  for (unsigned I = 0, N = Rec.DelayedDecltypeCalls.size(); I != N; ++I) {
+    CallExpr *Call = Rec.DelayedDecltypeCalls[I];
+    if (Call == TopCall)
+      continue;
+
+    if (CheckCallReturnType(Call->getCallReturnType(),
+                            Call->getSourceRange().getBegin(),
+                            Call, Call->getDirectCallee()))
+      return ExprError();
+  }
+
+  // Now all relevant types are complete, check the destructors are accessible
+  // and non-deleted, and annotate them on the temporaries.
+  for (unsigned I = 0, N = Rec.DelayedDecltypeBinds.size(); I != N; ++I) {
+    CXXBindTemporaryExpr *Bind = Rec.DelayedDecltypeBinds[I];
+    if (Bind == TopBind)
+      continue;
+
+    CXXTemporary *Temp = Bind->getTemporary();
+
+    CXXRecordDecl *RD =
+      Bind->getType()->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
+    CXXDestructorDecl *Destructor = LookupDestructor(RD);
+    Temp->setDestructor(Destructor);
+
+    MarkFunctionReferenced(E->getExprLoc(), Destructor);
+    CheckDestructorAccess(E->getExprLoc(), Destructor,
+                          PDiag(diag::err_access_dtor_temp)
+                            << E->getType());
+    DiagnoseUseOfDecl(Destructor, E->getExprLoc());
+
+    // We need a cleanup, but we don't need to remember the temporary.
+    ExprNeedsCleanups = true;
+  }
+
+  // Possibly strip off the top CXXBindTemporaryExpr.
+  return Owned(E);
+}
+
 ExprResult
 Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc,
                                    tok::TokenKind OpKind, ParsedType &ObjectType,

Modified: cfe/branches/tooling/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprMember.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprMember.cpp Tue Feb 28 17:49:25 2012
@@ -138,26 +138,28 @@
   if (Classes.empty())
     return IMA_Static;
 
+  bool IsCXX11UnevaluatedField = false;
+  if (SemaRef.getLangOptions().CPlusPlus0x && isField) {
+    // C++11 [expr.prim.general]p12:
+    //   An id-expression that denotes a non-static data member or non-static
+    //   member function of a class can only be used:
+    //   (...)
+    //   - if that id-expression denotes a non-static data member and it
+    //     appears in an unevaluated operand.
+    const Sema::ExpressionEvaluationContextRecord& record
+      = SemaRef.ExprEvalContexts.back();
+    if (record.Context == Sema::Unevaluated)
+      IsCXX11UnevaluatedField = true;
+  }
+
   // If the current context is not an instance method, it can't be
   // an implicit member reference.
   if (isStaticContext) {
     if (hasNonInstance)
-        return IMA_Mixed_StaticContext;
-        
-    if (SemaRef.getLangOptions().CPlusPlus0x && isField) {
-      // C++11 [expr.prim.general]p12:
-      //   An id-expression that denotes a non-static data member or non-static
-      //   member function of a class can only be used:
-      //   (...)
-      //   - if that id-expression denotes a non-static data member and it
-      //     appears in an unevaluated operand.
-      const Sema::ExpressionEvaluationContextRecord& record
-        = SemaRef.ExprEvalContexts.back();
-      if (record.Context == Sema::Unevaluated)
-        return IMA_Field_Uneval_Context;
-    }
-    
-    return IMA_Error_StaticContext;
+      return IMA_Mixed_StaticContext;
+
+    return IsCXX11UnevaluatedField ? IMA_Field_Uneval_Context
+                                   : IMA_Error_StaticContext;
   }
 
   CXXRecordDecl *contextClass;
@@ -173,15 +175,20 @@
   // ...if C is not X or a base class of X, the class member access expression
   // is ill-formed.
   if (R.getNamingClass() &&
-      contextClass != R.getNamingClass()->getCanonicalDecl() &&
+      contextClass->getCanonicalDecl() !=
+        R.getNamingClass()->getCanonicalDecl() &&
       contextClass->isProvablyNotDerivedFrom(R.getNamingClass()))
-    return (hasNonInstance ? IMA_Mixed_Unrelated : IMA_Error_Unrelated);
+    return hasNonInstance ? IMA_Mixed_Unrelated :
+           IsCXX11UnevaluatedField ? IMA_Field_Uneval_Context :
+                                     IMA_Error_Unrelated;
 
   // If we can prove that the current context is unrelated to all the
   // declaring classes, it can't be an implicit member reference (in
   // which case it's an error if any of those members are selected).
   if (IsProvablyNotDerivedFrom(SemaRef, contextClass, Classes))
-    return (hasNonInstance ? IMA_Mixed_Unrelated : IMA_Error_Unrelated);
+    return hasNonInstance ? IMA_Mixed_Unrelated :
+           IsCXX11UnevaluatedField ? IMA_Field_Uneval_Context :
+                                     IMA_Error_Unrelated;
 
   return (hasNonInstance ? IMA_Mixed : IMA_Instance);
 }
@@ -228,10 +235,13 @@
   case IMA_Unresolved:
     return BuildImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs, false);
 
+  case IMA_Field_Uneval_Context:
+    Diag(R.getNameLoc(), diag::warn_cxx98_compat_non_static_member_use)
+      << R.getLookupNameInfo().getName();
+    // Fall through.
   case IMA_Static:
   case IMA_Mixed_StaticContext:
   case IMA_Unresolved_StaticContext:
-  case IMA_Field_Uneval_Context:
     if (TemplateArgs || TemplateKWLoc.isValid())
       return BuildTemplateIdExpr(SS, TemplateKWLoc, R, false, TemplateArgs);
     return BuildDeclarationNameExpr(SS, R, false);

Modified: cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp Tue Feb 28 17:49:25 2012
@@ -113,9 +113,21 @@
       Ty = Context.getObjCConstantStringInterface();
       Ty = Context.getObjCObjectPointerType(Ty);
     } else {
-      // If there is no NSString interface defined then treat constant
-      // strings as untyped objects and let the runtime figure it out later.
-      Ty = Context.getObjCIdType();
+      // If there is no NSString interface defined, implicitly declare
+      // a @class NSString; and use that instead. This is to make sure
+      // type of an NSString literal is represented correctly, instead of
+      // being an 'id' type.
+      Ty = Context.getObjCNSStringType();
+      if (Ty.isNull()) {
+        ObjCInterfaceDecl *NSStringIDecl = 
+          ObjCInterfaceDecl::Create (Context, 
+                                     Context.getTranslationUnitDecl(), 
+                                     SourceLocation(), NSIdent, 
+                                     0, SourceLocation());
+        Ty = Context.getObjCInterfaceType(NSStringIDecl);
+        Context.setObjCNSStringType(Ty);
+      }
+      Ty = Context.getObjCObjectPointerType(Ty);
     }
   }
 
@@ -1294,7 +1306,8 @@
           if (Method) {
             Diag(Loc, diag::warn_instance_method_on_class_found)
               << Method->getSelector() << Sel;
-            Diag(Method->getLocation(), diag::note_method_declared_at);
+            Diag(Method->getLocation(), diag::note_method_declared_at)
+              << Method->getDeclName();
           }
         }
       } else {
@@ -1516,7 +1529,8 @@
                   // selector names a +1 method 
                   Diag(SelLoc, 
                        diag::err_arc_perform_selector_retains);
-                  Diag(SelMethod->getLocation(), diag::note_method_declared_at);
+                  Diag(SelMethod->getLocation(), diag::note_method_declared_at)
+                    << SelMethod->getDeclName();
                 }
                 break;
               default:
@@ -1525,7 +1539,8 @@
                   // selector names a +1 method
                   Diag(SelLoc, 
                        diag::err_arc_perform_selector_retains);
-                  Diag(SelMethod->getLocation(), diag::note_method_declared_at);
+                  Diag(SelMethod->getLocation(), diag::note_method_declared_at)
+                    << SelMethod->getDeclName();
                 }
                 break;
             }

Modified: cfe/branches/tooling/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaInit.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaInit.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaInit.cpp Tue Feb 28 17:49:25 2012
@@ -173,7 +173,7 @@
   bool hadError;
   bool VerifyOnly; // no diagnostics, no structure building
   bool AllowBraceElision;
-  std::map<InitListExpr *, InitListExpr *> SyntacticToSemantic;
+  llvm::DenseMap<InitListExpr *, InitListExpr *> SyntacticToSemantic;
   InitListExpr *FullyStructuredList;
 
   void CheckImplicitInitList(const InitializedEntity &Entity,
@@ -604,7 +604,9 @@
   CheckListElementTypes(Entity, IList, T, /*SubobjectIsDesignatorContext=*/true,
                         Index, StructuredList, StructuredIndex, TopLevelObject);
   if (!VerifyOnly) {
-    QualType ExprTy = T.getNonLValueExprType(SemaRef.Context);
+    QualType ExprTy = T;
+    if (!ExprTy->isArrayType())
+      ExprTy = ExprTy.getNonLValueExprType(SemaRef.Context);
     IList->setType(ExprTy);
     StructuredList->setType(ExprTy);
   }
@@ -1630,7 +1632,7 @@
 
     // Determine the structural initializer list that corresponds to the
     // current subobject.
-    StructuredList = IsFirstDesignator? SyntacticToSemantic[IList]
+    StructuredList = IsFirstDesignator? SyntacticToSemantic.lookup(IList)
       : getStructuredSubobjectInit(IList, Index, CurrentObjectType,
                                    StructuredList, StructuredIndex,
                                    SourceRange(D->getStartLocation(),
@@ -2044,7 +2046,7 @@
     return 0; // No structured list in verification-only mode.
   Expr *ExistingInit = 0;
   if (!StructuredList)
-    ExistingInit = SyntacticToSemantic[IList];
+    ExistingInit = SyntacticToSemantic.lookup(IList);
   else if (StructuredIndex < StructuredList->getNumInits())
     ExistingInit = StructuredList->getInit(StructuredIndex);
 
@@ -2077,7 +2079,10 @@
                                          InitRange.getBegin(), 0, 0,
                                          InitRange.getEnd());
 
-  Result->setType(CurrentObjectType.getNonLValueExprType(SemaRef.Context));
+  QualType ResultType = CurrentObjectType;
+  if (!ResultType->isArrayType())
+    ResultType = ResultType.getNonLValueExprType(SemaRef.Context);
+  Result->setType(ResultType);
 
   // Pre-allocate storage for the structured initializer list.
   unsigned NumElements = 0;
@@ -2733,11 +2738,11 @@
                 dyn_cast<FunctionTemplateDecl>(DefaultConstructor))
           S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl,
                                          /*ExplicitArgs*/ 0,
-                                         0, 0, CandidateSet,
+                                         ArrayRef<Expr*>(), CandidateSet,
                                          /*SuppressUserConversions*/ false);
         else
           S.AddOverloadCandidate(DefaultConstructor, FoundDecl,
-                                 0, 0, CandidateSet,
+                                 ArrayRef<Expr*>(), CandidateSet,
                                  /*SuppressUserConversions*/ false);
         Sequence.SetOverloadFailure(
                        InitializationSequence::FK_ListConstructorOverloadFailed,
@@ -2820,12 +2825,24 @@
       if (ConstructorTmpl)
         S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl,
                                        /*ExplicitArgs*/ 0,
-                                       Args, NumArgs, CandidateSet,
+                                       llvm::makeArrayRef(Args, NumArgs), CandidateSet,
                                        SuppressUserConversions);
-      else
+      else {
+        // C++ [over.match.copy]p1:
+        //   - When initializing a temporary to be bound to the first parameter 
+        //     of a constructor that takes a reference to possibly cv-qualified 
+        //     T as its first argument, called with a single argument in the 
+        //     context of direct-initialization, explicit conversion functions
+        //     are also considered.
+        bool AllowExplicitConv = AllowExplicit && !CopyInitializing && 
+                                 NumArgs == 1 &&
+                                 Constructor->isCopyOrMoveConstructor();
         S.AddOverloadCandidate(Constructor, FoundDecl,
-                               Args, NumArgs, CandidateSet,
-                               SuppressUserConversions);
+                               llvm::makeArrayRef(Args, NumArgs), CandidateSet,
+                               SuppressUserConversions,
+                               /*PartialOverloading=*/false,
+                               /*AllowExplicit=*/AllowExplicitConv);
+      }
     }
   }
 
@@ -3117,8 +3134,8 @@
 static OverloadingResult TryRefInitWithConversionFunction(Sema &S,
                                              const InitializedEntity &Entity,
                                              const InitializationKind &Kind,
-                                                          Expr *Initializer,
-                                                          bool AllowRValues,
+                                             Expr *Initializer,
+                                             bool AllowRValues,
                                              InitializationSequence &Sequence) {
   QualType DestType = Entity.getType();
   QualType cv1T1 = DestType->getAs<ReferenceType>()->getPointeeType();
@@ -3146,7 +3163,8 @@
   // Determine whether we are allowed to call explicit constructors or
   // explicit conversion operators.
   bool AllowExplicit = Kind.AllowExplicit();
-
+  bool AllowExplicitConvs = Kind.allowExplicitConversionFunctions();
+  
   const RecordType *T1RecordType = 0;
   if (AllowRValues && (T1RecordType = T1->getAs<RecordType>()) &&
       !S.RequireCompleteType(Kind.getLocation(), T1, 0)) {
@@ -3174,11 +3192,11 @@
         if (ConstructorTmpl)
           S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl,
                                          /*ExplicitArgs*/ 0,
-                                         &Initializer, 1, CandidateSet,
+                                         Initializer, CandidateSet,
                                          /*SuppressUserConversions=*/true);
         else
           S.AddOverloadCandidate(Constructor, FoundDecl,
-                                 &Initializer, 1, CandidateSet,
+                                 Initializer, CandidateSet,
                                  /*SuppressUserConversions=*/true);
       }
     }
@@ -3215,7 +3233,7 @@
       // FIXME: Do we need to make sure that we only consider conversion
       // candidates with reference-compatible results? That might be needed to
       // break recursion.
-      if ((AllowExplicit || !Conv->isExplicit()) &&
+      if ((AllowExplicitConvs || !Conv->isExplicit()) &&
           (AllowRValues || Conv->getConversionType()->isLValueReferenceType())){
         if (ConvTemplate)
           S.AddTemplateConversionCandidate(ConvTemplate, I.getPair(),
@@ -3712,11 +3730,11 @@
           if (ConstructorTmpl)
             S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl,
                                            /*ExplicitArgs*/ 0,
-                                           &Initializer, 1, CandidateSet,
+                                           Initializer, CandidateSet,
                                            /*SuppressUserConversions=*/true);
           else
             S.AddOverloadCandidate(Constructor, FoundDecl,
-                                   &Initializer, 1, CandidateSet,
+                                   Initializer, CandidateSet,
                                    /*SuppressUserConversions=*/true);
         }
       }
@@ -3980,7 +3998,7 @@
   QualType DestType = Entity.getType();
 
   if (DestType->isDependentType() ||
-      Expr::hasAnyTypeDependentArguments(Args, NumArgs)) {
+      Expr::hasAnyTypeDependentArguments(llvm::makeArrayRef(Args, NumArgs))) {
     SequenceKind = DependentSequence;
     return;
   }
@@ -4321,7 +4339,7 @@
       DeclAccessPair FoundDecl
         = DeclAccessPair::make(Constructor, Constructor->getAccess());
       S.AddOverloadCandidate(Constructor, FoundDecl,
-                             &CurInitExpr, 1, CandidateSet);
+                             CurInitExpr, CandidateSet);
       continue;
     }
 
@@ -4340,7 +4358,7 @@
     DeclAccessPair FoundDecl
       = DeclAccessPair::make(ConstructorTmpl, ConstructorTmpl->getAccess());
     S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl, 0,
-                                   &CurInitExpr, 1, CandidateSet, true);
+                                   CurInitExpr, CandidateSet, true);
   }
 }
 
@@ -4450,7 +4468,7 @@
            : diag::err_temp_copy_no_viable)
       << (int)Entity.getKind() << CurInitExpr->getType()
       << CurInitExpr->getSourceRange();
-    CandidateSet.NoteCandidates(S, OCD_AllCandidates, &CurInitExpr, 1);
+    CandidateSet.NoteCandidates(S, OCD_AllCandidates, CurInitExpr);
     if (!IsExtraneousCopy || S.isSFINAEContext())
       return ExprError();
     return move(CurInit);
@@ -4459,7 +4477,7 @@
     S.Diag(Loc, diag::err_temp_copy_ambiguous)
       << (int)Entity.getKind() << CurInitExpr->getType()
       << CurInitExpr->getSourceRange();
-    CandidateSet.NoteCandidates(S, OCD_ViableCandidates, &CurInitExpr, 1);
+    CandidateSet.NoteCandidates(S, OCD_ViableCandidates, CurInitExpr);
     return ExprError();
 
   case OR_Deleted:
@@ -4566,12 +4584,12 @@
 
   case OR_No_Viable_Function:
     S.Diag(Loc, Diag);
-    CandidateSet.NoteCandidates(S, OCD_AllCandidates, &CurInitExpr, 1);
+    CandidateSet.NoteCandidates(S, OCD_AllCandidates, CurInitExpr);
     break;
 
   case OR_Ambiguous:
     S.Diag(Loc, Diag);
-    CandidateSet.NoteCandidates(S, OCD_ViableCandidates, &CurInitExpr, 1);
+    CandidateSet.NoteCandidates(S, OCD_ViableCandidates, CurInitExpr);
     break;
 
   case OR_Deleted:
@@ -4623,20 +4641,29 @@
     // Force even a trivial, implicit default constructor to be
     // semantically checked. We do this explicitly because we don't build
     // the definition for completely trivial constructors.
-    CXXRecordDecl *ClassDecl = Constructor->getParent();
-    assert(ClassDecl && "No parent class for constructor.");
+    assert(Constructor->getParent() && "No parent class for constructor.");
     if (Constructor->isDefaulted() && Constructor->isDefaultConstructor() &&
-        ClassDecl->hasTrivialDefaultConstructor() &&
-        !Constructor->isUsed(false))
+        Constructor->isTrivial() && !Constructor->isUsed(false))
       S.DefineImplicitDefaultConstructor(Loc, Constructor);
   }
 
   ExprResult CurInit = S.Owned((Expr *)0);
 
+  // C++ [over.match.copy]p1:
+  //   - When initializing a temporary to be bound to the first parameter 
+  //     of a constructor that takes a reference to possibly cv-qualified 
+  //     T as its first argument, called with a single argument in the 
+  //     context of direct-initialization, explicit conversion functions
+  //     are also considered.
+  bool AllowExplicitConv = Kind.AllowExplicit() && !Kind.isCopyInit() &&
+                           Args.size() == 1 && 
+                           Constructor->isCopyOrMoveConstructor();
+
   // Determine the arguments required to actually perform the constructor
   // call.
   if (S.CompleteConstructorCall(Constructor, move(Args),
-                                Loc, ConstructorArgs))
+                                Loc, ConstructorArgs,
+                                AllowExplicitConv))
     return ExprError();
 
 
@@ -5406,14 +5433,16 @@
           << DestType << Args[0]->getType()
           << Args[0]->getSourceRange();
 
-      FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates, Args, NumArgs);
+      FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates,
+                                        llvm::makeArrayRef(Args, NumArgs));
       break;
 
     case OR_No_Viable_Function:
       S.Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition)
         << Args[0]->getType() << DestType.getNonReferenceType()
         << Args[0]->getSourceRange();
-      FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args, NumArgs);
+      FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates,
+                                        llvm::makeArrayRef(Args, NumArgs));
       break;
 
     case OR_Deleted: {
@@ -5554,7 +5583,7 @@
         S.Diag(Kind.getLocation(), diag::err_ovl_ambiguous_init)
           << DestType << ArgsRange;
         FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates,
-                                          Args, NumArgs);
+                                          llvm::makeArrayRef(Args, NumArgs));
         break;
 
       case OR_No_Viable_Function:
@@ -5599,7 +5628,8 @@
 
         S.Diag(Kind.getLocation(), diag::err_ovl_no_viable_function_in_init)
           << DestType << ArgsRange;
-        FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args, NumArgs);
+        FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates,
+                                          llvm::makeArrayRef(Args, NumArgs));
         break;
 
       case OR_Deleted: {
@@ -6094,7 +6124,8 @@
 Sema::PerformCopyInitialization(const InitializedEntity &Entity,
                                 SourceLocation EqualLoc,
                                 ExprResult Init,
-                                bool TopLevelOfInitList) {
+                                bool TopLevelOfInitList,
+                                bool AllowExplicit) {
   if (Init.isInvalid())
     return ExprError();
 
@@ -6105,7 +6136,8 @@
     EqualLoc = InitE->getLocStart();
 
   InitializationKind Kind = InitializationKind::CreateCopy(InitE->getLocStart(),
-                                                           EqualLoc);
+                                                           EqualLoc,
+                                                           AllowExplicit);
   InitializationSequence Seq(*this, Entity, Kind, &InitE, 1);
   Init.release();
 

Modified: cfe/branches/tooling/lib/Sema/SemaLambda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaLambda.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaLambda.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaLambda.cpp Tue Feb 28 17:49:25 2012
@@ -643,7 +643,7 @@
     //   non-explicit const conversion function to a block pointer having the
     //   same parameter and return types as the closure type's function call
     //   operator.
-    if (getLangOptions().Blocks)
+    if (getLangOptions().Blocks && getLangOptions().ObjC1)
       addBlockPointerConversion(*this, IntroducerRange, Class, CallOperator);
     
     // Finalize the lambda class.

Modified: cfe/branches/tooling/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaLookup.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaLookup.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaLookup.cpp Tue Feb 28 17:49:25 2012
@@ -31,7 +31,6 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/LangOptions.h"
-#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -1263,7 +1262,7 @@
   if (I == E) return false;
 
   // We have at least added all these contexts to the queue.
-  llvm::DenseSet<DeclContext*> Visited;
+  llvm::SmallPtrSet<DeclContext*, 8> Visited;
   Visited.insert(StartDC);
 
   // We have not yet looked into these namespaces, much less added
@@ -1274,7 +1273,7 @@
   // with its using-children.
   for (; I != E; ++I) {
     NamespaceDecl *ND = (*I)->getNominatedNamespace()->getOriginalNamespace();
-    if (Visited.insert(ND).second)
+    if (Visited.insert(ND))
       Queue.push_back(ND);
   }
 
@@ -1323,7 +1322,7 @@
 
     for (llvm::tie(I,E) = ND->getUsingDirectives(); I != E; ++I) {
       NamespaceDecl *Nom = (*I)->getNominatedNamespace();
-      if (Visited.insert(Nom).second)
+      if (Visited.insert(Nom))
         Queue.push_back(Nom);
     }
   }
@@ -2082,7 +2081,7 @@
 /// namespaces searched by argument-dependent lookup
 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
 void
-Sema::FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
+Sema::FindAssociatedClassesAndNamespaces(llvm::ArrayRef<Expr *> Args,
                                  AssociatedNamespaceSet &AssociatedNamespaces,
                                  AssociatedClassSet &AssociatedClasses) {
   AssociatedNamespaces.clear();
@@ -2097,7 +2096,7 @@
   //   classes is determined entirely by the types of the function
   //   arguments (and the namespace of any template template
   //   argument).
-  for (unsigned ArgIdx = 0; ArgIdx != NumArgs; ++ArgIdx) {
+  for (unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
     Expr *Arg = Args[ArgIdx];
 
     if (Arg->getType() != Context.OverloadTy) {
@@ -2372,10 +2371,11 @@
     if (CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(Cand)) {
       if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
         AddMethodCandidate(M, DeclAccessPair::make(M, AS_public), RD, ThisTy,
-                           Classification, &Arg, NumArgs, OCS, true);
+                           Classification, llvm::makeArrayRef(&Arg, NumArgs),
+                           OCS, true);
       else
-        AddOverloadCandidate(M, DeclAccessPair::make(M, AS_public), &Arg,
-                             NumArgs, OCS, true);
+        AddOverloadCandidate(M, DeclAccessPair::make(M, AS_public),
+                             llvm::makeArrayRef(&Arg, NumArgs), OCS, true);
 
       // Here we're looking for a const parameter to speed up creation of
       // implicit copy methods.
@@ -2391,11 +2391,13 @@
                  dyn_cast<FunctionTemplateDecl>(Cand)) {
       if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
         AddMethodTemplateCandidate(Tmpl, DeclAccessPair::make(Tmpl, AS_public),
-                                   RD, 0, ThisTy, Classification, &Arg, NumArgs,
+                                   RD, 0, ThisTy, Classification,
+                                   llvm::makeArrayRef(&Arg, NumArgs),
                                    OCS, true);
       else
         AddTemplateOverloadCandidate(Tmpl, DeclAccessPair::make(Tmpl, AS_public),
-                                     0, &Arg, NumArgs, OCS, true);
+                                     0, llvm::makeArrayRef(&Arg, NumArgs),
+                                     OCS, true);
     } else {
       assert(isa<UsingDecl>(Cand) && "illegal Kind of operator = Decl");
     }
@@ -2559,14 +2561,15 @@
 }
 
 void Sema::ArgumentDependentLookup(DeclarationName Name, bool Operator,
-                                   Expr **Args, unsigned NumArgs,
+                                   SourceLocation Loc,
+                                   llvm::ArrayRef<Expr *> Args,
                                    ADLResult &Result,
                                    bool StdNamespaceIsAssociated) {
   // Find all of the associated namespaces and classes based on the
   // arguments we have.
   AssociatedNamespaceSet AssociatedNamespaces;
   AssociatedClassSet AssociatedClasses;
-  FindAssociatedClassesAndNamespaces(Args, NumArgs,
+  FindAssociatedClassesAndNamespaces(Args,
                                      AssociatedNamespaces,
                                      AssociatedClasses);
   if (StdNamespaceIsAssociated && StdNamespace)
@@ -2575,10 +2578,17 @@
   QualType T1, T2;
   if (Operator) {
     T1 = Args[0]->getType();
-    if (NumArgs >= 2)
+    if (Args.size() >= 2)
       T2 = Args[1]->getType();
   }
 
+  // Try to complete all associated classes, in case they contain a
+  // declaration of a friend function.
+  for (AssociatedClassSet::iterator C = AssociatedClasses.begin(),
+                                    CEnd = AssociatedClasses.end();
+       C != CEnd; ++C)
+    RequireCompleteType(Loc, Context.getRecordType(*C), 0);
+
   // C++ [basic.lookup.argdep]p3:
   //   Let X be the lookup set produced by unqualified lookup (3.4.1)
   //   and let Y be the lookup set produced by argument dependent

Modified: cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp Tue Feb 28 17:49:25 2012
@@ -263,7 +263,7 @@
   if (!PIDecl) {
     // No matching property found in the primary class. Just fall thru
     // and add property to continuation class's primary class.
-    ObjCPropertyDecl *PDecl =
+    ObjCPropertyDecl *PrimaryPDecl =
       CreatePropertyDecl(S, CCPrimary, AtLoc,
                          FD, GetterSel, SetterSel, isAssign, isReadWrite,
                          Attributes,AttributesAsWritten, T, MethodImplKind, DC);
@@ -271,11 +271,13 @@
     // A case of continuation class adding a new property in the class. This
     // is not what it was meant for. However, gcc supports it and so should we.
     // Make sure setter/getters are declared here.
-    ProcessPropertyDecl(PDecl, CCPrimary, /* redeclaredProperty = */ 0,
+    ProcessPropertyDecl(PrimaryPDecl, CCPrimary, /* redeclaredProperty = */ 0,
                         /* lexicalDC = */ CDecl);
+    PDecl->setGetterMethodDecl(PrimaryPDecl->getGetterMethodDecl());
+    PDecl->setSetterMethodDecl(PrimaryPDecl->getSetterMethodDecl());
     if (ASTMutationListener *L = Context.getASTMutationListener())
-      L->AddedObjCPropertyInClassExtension(PDecl, /*OrigProp=*/0, CDecl);
-    return PDecl;
+      L->AddedObjCPropertyInClassExtension(PrimaryPDecl, /*OrigProp=*/0, CDecl);
+    return PrimaryPDecl;
   }
   if (!Context.hasSameType(PIDecl->getType(), PDecl->getType())) {
     bool IncompatibleObjC = false;
@@ -360,6 +362,8 @@
   *isOverridingProperty = true;
   // Make sure setter decl is synthesized, and added to primary class's list.
   ProcessPropertyDecl(PIDecl, CCPrimary, PDecl, CDecl);
+  PDecl->setGetterMethodDecl(PIDecl->getGetterMethodDecl());
+  PDecl->setSetterMethodDecl(PIDecl->getSetterMethodDecl());
   if (ASTMutationListener *L = Context.getASTMutationListener())
     L->AddedObjCPropertyInClassExtension(PDecl, PIDecl, CDecl);
   return 0;
@@ -578,6 +582,8 @@
     Diag(AtLoc, diag::error_missing_property_context);
     return 0;
   }
+  if (PropertyIvarLoc.isInvalid())
+    PropertyIvarLoc = PropertyLoc;
   ObjCPropertyDecl *property = 0;
   ObjCInterfaceDecl* IDecl = 0;
   // Find the class or category class where this property must have
@@ -725,7 +731,7 @@
       }
 
       Ivar = ObjCIvarDecl::Create(Context, ClassImpDecl,
-                                  PropertyLoc, PropertyLoc, PropertyIvar,
+                                  PropertyIvarLoc,PropertyIvarLoc, PropertyIvar,
                                   PropertyIvarType, /*Dinfo=*/0,
                                   ObjCIvarDecl::Private,
                                   (Expr *)0, true);
@@ -758,10 +764,8 @@
                                   PropertyIvarType->getAs<ObjCObjectPointerType>(),
                                   IvarType->getAs<ObjCObjectPointerType>());
       else {
-        SourceLocation Loc = PropertyIvarLoc;
-        if (Loc.isInvalid())
-          Loc = PropertyLoc;
-        compat = (CheckAssignmentConstraints(Loc, PropertyIvarType, IvarType)
+        compat = (CheckAssignmentConstraints(PropertyIvarLoc, PropertyIvarType,
+                                             IvarType)
                     == Compatible);
       }
       if (!compat) {
@@ -1277,7 +1281,8 @@
     for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
          E = PDecl->prop_end(); P != E; ++P) {
       ObjCPropertyDecl *Prop = (*P);
-      PropMap[Prop->getIdentifier()] = Prop;
+      if (!PropMap.count(Prop->getIdentifier()))
+        PropMap[Prop->getIdentifier()] = Prop;
     }
     // scan through protocol's protocols.
     for (ObjCProtocolDecl::protocol_iterator PI = PDecl->protocol_begin(),
@@ -1777,6 +1782,7 @@
           Attributes & ObjCDeclSpec::DQ_PR_copy ? "copy" : "retain (or strong)");
     Attributes &= ~(ObjCDeclSpec::DQ_PR_weak   | ObjCDeclSpec::DQ_PR_copy |
                     ObjCDeclSpec::DQ_PR_retain | ObjCDeclSpec::DQ_PR_strong);
+    PropertyDecl->setInvalidDecl();
   }
 
   // Check for more than one of { assign, copy, retain }.

Modified: cfe/branches/tooling/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaOverload.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaOverload.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaOverload.cpp Tue Feb 28 17:49:25 2012
@@ -2779,11 +2779,11 @@
       if (ConstructorTmpl)
         S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl,
                                        /*ExplicitArgs*/ 0,
-                                       &From, 1, CandidateSet,
+                                       From, CandidateSet,
                                        /*SuppressUserConversions=*/true);
       else
         S.AddOverloadCandidate(Constructor, FoundDecl,
-                               &From, 1, CandidateSet,
+                               From, CandidateSet,
                                /*SuppressUserConversions=*/true);
     }
   }
@@ -2907,7 +2907,8 @@
           if (ConstructorTmpl)
             S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl,
                                            /*ExplicitArgs*/ 0,
-                                           Args, NumArgs, CandidateSet,
+                                           llvm::makeArrayRef(Args, NumArgs),
+                                           CandidateSet,
                                            /*SuppressUserConversions=*/
                                            !ConstructorsOnly &&
                                              !ListInitializing);
@@ -2915,7 +2916,8 @@
             // Allow one user-defined conversion when user specifies a
             // From->ToType conversion via an static cast (c-style, etc).
             S.AddOverloadCandidate(Constructor, FoundDecl,
-                                   Args, NumArgs, CandidateSet,
+                                   llvm::makeArrayRef(Args, NumArgs),
+                                   CandidateSet,
                                    /*SuppressUserConversions=*/
                                    !ConstructorsOnly && !ListInitializing);
         }
@@ -3059,10 +3061,45 @@
     << From->getType() << ToType << From->getSourceRange();
   else
     return false;
-  CandidateSet.NoteCandidates(*this, OCD_AllCandidates, &From, 1);
+  CandidateSet.NoteCandidates(*this, OCD_AllCandidates, From);
   return true;
 }
 
+/// \brief Compare the user-defined conversion functions or constructors
+/// of two user-defined conversion sequences to determine whether any ordering
+/// is possible.
+static ImplicitConversionSequence::CompareKind
+compareConversionFunctions(Sema &S,
+                           FunctionDecl *Function1,
+                           FunctionDecl *Function2) {
+  if (!S.getLangOptions().ObjC1 || !S.getLangOptions().CPlusPlus0x)
+    return ImplicitConversionSequence::Indistinguishable;
+  
+  // Objective-C++:
+  //   If both conversion functions are implicitly-declared conversions from
+  //   a lambda closure type to a function pointer and a block pointer, 
+  //   respectively, always prefer the conversion to a function pointer,
+  //   because the function pointer is more lightweight and is more likely
+  //   to keep code working.
+  CXXConversionDecl *Conv1 = dyn_cast<CXXConversionDecl>(Function1);
+  if (!Conv1)
+    return ImplicitConversionSequence::Indistinguishable;
+    
+  CXXConversionDecl *Conv2 = dyn_cast<CXXConversionDecl>(Function2);
+  if (!Conv2)
+    return ImplicitConversionSequence::Indistinguishable;
+  
+  if (Conv1->getParent()->isLambda() && Conv2->getParent()->isLambda()) {
+    bool Block1 = Conv1->getConversionType()->isBlockPointerType();
+    bool Block2 = Conv2->getConversionType()->isBlockPointerType();
+    if (Block1 != Block2)
+      return Block1? ImplicitConversionSequence::Worse 
+                   : ImplicitConversionSequence::Better;
+  }
+
+  return ImplicitConversionSequence::Indistinguishable;
+}
+  
 /// CompareImplicitConversionSequences - Compare two implicit
 /// conversion sequences to determine whether one is better than the
 /// other or if they are indistinguishable (C++ 13.3.3.2).
@@ -3116,15 +3153,25 @@
       Result = CompareStandardConversionSequences(S,
                                                   ICS1.UserDefined.After,
                                                   ICS2.UserDefined.After);
+    else
+      Result = compareConversionFunctions(S, 
+                                          ICS1.UserDefined.ConversionFunction,
+                                          ICS2.UserDefined.ConversionFunction);
   }
 
   // List-initialization sequence L1 is a better conversion sequence than
   // list-initialization sequence L2 if L1 converts to std::initializer_list<X>
   // for some X and L2 does not.
   if (Result == ImplicitConversionSequence::Indistinguishable &&
+      !ICS1.isBad() &&
       ICS1.isListInitializationSequence() &&
       ICS2.isListInitializationSequence()) {
-    // FIXME: Find out if ICS1 converts to initializer_list and ICS2 doesn't.
+    if (ICS1.isStdInitializerListElement() &&
+        !ICS2.isStdInitializerListElement())
+      return ImplicitConversionSequence::Better;
+    if (!ICS1.isStdInitializerListElement() &&
+        ICS2.isStdInitializerListElement())
+      return ImplicitConversionSequence::Worse;
   }
 
   return Result;
@@ -4172,7 +4219,8 @@
 TryCopyInitialization(Sema &S, Expr *From, QualType ToType,
                       bool SuppressUserConversions,
                       bool InOverloadResolution,
-                      bool AllowObjCWritebackConversion);
+                      bool AllowObjCWritebackConversion,
+                      bool AllowExplicit = false);
 
 /// TryListConversion - Try to copy-initialize a value of type ToType from the
 /// initializer list From.
@@ -4199,11 +4247,12 @@
   //   all the elements can be implicitly converted to X, the implicit
   //   conversion sequence is the worst conversion necessary to convert an
   //   element of the list to X.
+  bool toStdInitializerList = false;
   QualType X;
   if (ToType->isArrayType())
     X = S.Context.getBaseElementType(ToType);
   else
-    (void)S.isStdInitializerList(ToType, &X);
+    toStdInitializerList = S.isStdInitializerList(ToType, &X);
   if (!X.isNull()) {
     for (unsigned i = 0, e = From->getNumInits(); i < e; ++i) {
       Expr *Init = From->getInit(i);
@@ -4223,6 +4272,7 @@
         Result = ICS;
     }
     Result.setListInitializationSequence();
+    Result.setStdInitializerListElement(toStdInitializerList);
     return Result;
   }
 
@@ -4372,7 +4422,8 @@
 TryCopyInitialization(Sema &S, Expr *From, QualType ToType,
                       bool SuppressUserConversions,
                       bool InOverloadResolution,
-                      bool AllowObjCWritebackConversion) {
+                      bool AllowObjCWritebackConversion,
+                      bool AllowExplicit) {
   if (InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
     return TryListConversion(S, FromInitList, ToType, SuppressUserConversions,
                              InOverloadResolution,AllowObjCWritebackConversion);
@@ -4381,7 +4432,7 @@
     return TryReferenceInit(S, From, ToType,
                             /*FIXME:*/From->getLocStart(),
                             SuppressUserConversions,
-                            /*AllowExplicit=*/false);
+                            AllowExplicit);
 
   return TryImplicitConversion(S, From, ToType,
                                SuppressUserConversions,
@@ -5059,10 +5110,11 @@
 void
 Sema::AddOverloadCandidate(FunctionDecl *Function,
                            DeclAccessPair FoundDecl,
-                           Expr **Args, unsigned NumArgs,
+                           llvm::ArrayRef<Expr *> Args,
                            OverloadCandidateSet& CandidateSet,
                            bool SuppressUserConversions,
-                           bool PartialOverloading) {
+                           bool PartialOverloading,
+                           bool AllowExplicit) {
   const FunctionProtoType* Proto
     = dyn_cast<FunctionProtoType>(Function->getType()->getAs<FunctionType>());
   assert(Proto && "Functions without a prototype cannot be overloaded");
@@ -5080,8 +5132,7 @@
       // is irrelevant.
       AddMethodCandidate(Method, FoundDecl, Method->getParent(),
                          QualType(), Expr::Classification::makeSimpleLValue(),
-                         Args, NumArgs, CandidateSet,
-                         SuppressUserConversions);
+                         Args, CandidateSet, SuppressUserConversions);
       return;
     }
     // We treat a constructor like a non-member function, since its object
@@ -5099,7 +5150,7 @@
     //   A member function template is never instantiated to perform the copy
     //   of a class object to an object of its class type.
     QualType ClassType = Context.getTypeDeclType(Constructor->getParent());
-    if (NumArgs == 1 &&
+    if (Args.size() == 1 &&
         Constructor->isSpecializationCopyingObject() &&
         (Context.hasSameUnqualifiedType(ClassType, Args[0]->getType()) ||
          IsDerivedFrom(Args[0]->getType(), ClassType)))
@@ -5107,20 +5158,20 @@
   }
 
   // Add this candidate
-  OverloadCandidate &Candidate = CandidateSet.addCandidate(NumArgs);
+  OverloadCandidate &Candidate = CandidateSet.addCandidate(Args.size());
   Candidate.FoundDecl = FoundDecl;
   Candidate.Function = Function;
   Candidate.Viable = true;
   Candidate.IsSurrogate = false;
   Candidate.IgnoreObjectArgument = false;
-  Candidate.ExplicitCallArguments = NumArgs;
+  Candidate.ExplicitCallArguments = Args.size();
 
   unsigned NumArgsInProto = Proto->getNumArgs();
 
   // (C++ 13.3.2p2): A candidate function having fewer than m
   // parameters is viable only if it has an ellipsis in its parameter
   // list (8.3.5).
-  if ((NumArgs + (PartialOverloading && NumArgs)) > NumArgsInProto &&
+  if ((Args.size() + (PartialOverloading && Args.size())) > NumArgsInProto &&
       !Proto->isVariadic()) {
     Candidate.Viable = false;
     Candidate.FailureKind = ovl_fail_too_many_arguments;
@@ -5133,7 +5184,7 @@
   // parameter list is truncated on the right, so that there are
   // exactly m parameters.
   unsigned MinRequiredArgs = Function->getMinRequiredArguments();
-  if (NumArgs < MinRequiredArgs && !PartialOverloading) {
+  if (Args.size() < MinRequiredArgs && !PartialOverloading) {
     // Not enough arguments.
     Candidate.Viable = false;
     Candidate.FailureKind = ovl_fail_too_few_arguments;
@@ -5151,7 +5202,7 @@
 
   // Determine the implicit conversion sequences for each of the
   // arguments.
-  for (unsigned ArgIdx = 0; ArgIdx < NumArgs; ++ArgIdx) {
+  for (unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
     if (ArgIdx < NumArgsInProto) {
       // (C++ 13.3.2p3): for F to be a viable function, there shall
       // exist for each argument an implicit conversion sequence
@@ -5163,7 +5214,8 @@
                                 SuppressUserConversions,
                                 /*InOverloadResolution=*/true,
                                 /*AllowObjCWritebackConversion=*/
-                                  getLangOptions().ObjCAutoRefCount);
+                                  getLangOptions().ObjCAutoRefCount,
+                                AllowExplicit);
       if (Candidate.Conversions[ArgIdx].isBad()) {
         Candidate.Viable = false;
         Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -5181,7 +5233,7 @@
 /// \brief Add all of the function declarations in the given function set to
 /// the overload canddiate set.
 void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns,
-                                 Expr **Args, unsigned NumArgs,
+                                 llvm::ArrayRef<Expr *> Args,
                                  OverloadCandidateSet& CandidateSet,
                                  bool SuppressUserConversions) {
   for (UnresolvedSetIterator F = Fns.begin(), E = Fns.end(); F != E; ++F) {
@@ -5191,10 +5243,10 @@
         AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
                            cast<CXXMethodDecl>(FD)->getParent(),
                            Args[0]->getType(), Args[0]->Classify(Context),
-                           Args + 1, NumArgs - 1,
-                           CandidateSet, SuppressUserConversions);
+                           Args.slice(1), CandidateSet,
+                           SuppressUserConversions);
       else
-        AddOverloadCandidate(FD, F.getPair(), Args, NumArgs, CandidateSet,
+        AddOverloadCandidate(FD, F.getPair(), Args, CandidateSet,
                              SuppressUserConversions);
     } else {
       FunctionTemplateDecl *FunTmpl = cast<FunctionTemplateDecl>(D);
@@ -5204,15 +5256,12 @@
                               cast<CXXRecordDecl>(FunTmpl->getDeclContext()),
                                    /*FIXME: explicit args */ 0,
                                    Args[0]->getType(),
-                                   Args[0]->Classify(Context),
-                                   Args + 1, NumArgs - 1,
-                                   CandidateSet,
-                                   SuppressUserConversions);
+                                   Args[0]->Classify(Context), Args.slice(1),
+                                   CandidateSet, SuppressUserConversions);
       else
         AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
-                                     /*FIXME: explicit args */ 0,
-                                     Args, NumArgs, CandidateSet,
-                                     SuppressUserConversions);
+                                     /*FIXME: explicit args */ 0, Args,
+                                     CandidateSet, SuppressUserConversions);
     }
   }
 }
@@ -5236,12 +5285,13 @@
            "Expected a member function template");
     AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
                                /*ExplicitArgs*/ 0,
-                               ObjectType, ObjectClassification, Args, NumArgs,
-                               CandidateSet,
+                               ObjectType, ObjectClassification,
+                               llvm::makeArrayRef(Args, NumArgs), CandidateSet,
                                SuppressUserConversions);
   } else {
     AddMethodCandidate(cast<CXXMethodDecl>(Decl), FoundDecl, ActingContext,
-                       ObjectType, ObjectClassification, Args, NumArgs,
+                       ObjectType, ObjectClassification,
+                       llvm::makeArrayRef(Args, NumArgs),
                        CandidateSet, SuppressUserConversions);
   }
 }
@@ -5257,7 +5307,7 @@
 Sema::AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
                          CXXRecordDecl *ActingContext, QualType ObjectType,
                          Expr::Classification ObjectClassification,
-                         Expr **Args, unsigned NumArgs,
+                         llvm::ArrayRef<Expr *> Args,
                          OverloadCandidateSet& CandidateSet,
                          bool SuppressUserConversions) {
   const FunctionProtoType* Proto
@@ -5273,19 +5323,19 @@
   EnterExpressionEvaluationContext Unevaluated(*this, Sema::Unevaluated);
 
   // Add this candidate
-  OverloadCandidate &Candidate = CandidateSet.addCandidate(NumArgs + 1);
+  OverloadCandidate &Candidate = CandidateSet.addCandidate(Args.size() + 1);
   Candidate.FoundDecl = FoundDecl;
   Candidate.Function = Method;
   Candidate.IsSurrogate = false;
   Candidate.IgnoreObjectArgument = false;
-  Candidate.ExplicitCallArguments = NumArgs;
+  Candidate.ExplicitCallArguments = Args.size();
 
   unsigned NumArgsInProto = Proto->getNumArgs();
 
   // (C++ 13.3.2p2): A candidate function having fewer than m
   // parameters is viable only if it has an ellipsis in its parameter
   // list (8.3.5).
-  if (NumArgs > NumArgsInProto && !Proto->isVariadic()) {
+  if (Args.size() > NumArgsInProto && !Proto->isVariadic()) {
     Candidate.Viable = false;
     Candidate.FailureKind = ovl_fail_too_many_arguments;
     return;
@@ -5297,7 +5347,7 @@
   // parameter list is truncated on the right, so that there are
   // exactly m parameters.
   unsigned MinRequiredArgs = Method->getMinRequiredArguments();
-  if (NumArgs < MinRequiredArgs) {
+  if (Args.size() < MinRequiredArgs) {
     // Not enough arguments.
     Candidate.Viable = false;
     Candidate.FailureKind = ovl_fail_too_few_arguments;
@@ -5324,7 +5374,7 @@
 
   // Determine the implicit conversion sequences for each of the
   // arguments.
-  for (unsigned ArgIdx = 0; ArgIdx < NumArgs; ++ArgIdx) {
+  for (unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
     if (ArgIdx < NumArgsInProto) {
       // (C++ 13.3.2p3): for F to be a viable function, there shall
       // exist for each argument an implicit conversion sequence
@@ -5361,7 +5411,7 @@
                                  TemplateArgumentListInfo *ExplicitTemplateArgs,
                                  QualType ObjectType,
                                  Expr::Classification ObjectClassification,
-                                 Expr **Args, unsigned NumArgs,
+                                 llvm::ArrayRef<Expr *> Args,
                                  OverloadCandidateSet& CandidateSet,
                                  bool SuppressUserConversions) {
   if (!CandidateSet.isNewCandidate(MethodTmpl))
@@ -5379,8 +5429,8 @@
   TemplateDeductionInfo Info(Context, CandidateSet.getLocation());
   FunctionDecl *Specialization = 0;
   if (TemplateDeductionResult Result
-      = DeduceTemplateArguments(MethodTmpl, ExplicitTemplateArgs,
-                                Args, NumArgs, Specialization, Info)) {
+      = DeduceTemplateArguments(MethodTmpl, ExplicitTemplateArgs, Args,
+                                Specialization, Info)) {
     OverloadCandidate &Candidate = CandidateSet.addCandidate();
     Candidate.FoundDecl = FoundDecl;
     Candidate.Function = MethodTmpl->getTemplatedDecl();
@@ -5388,7 +5438,7 @@
     Candidate.FailureKind = ovl_fail_bad_deduction;
     Candidate.IsSurrogate = false;
     Candidate.IgnoreObjectArgument = false;
-    Candidate.ExplicitCallArguments = NumArgs;
+    Candidate.ExplicitCallArguments = Args.size();
     Candidate.DeductionFailure = MakeDeductionFailureInfo(Context, Result,
                                                           Info);
     return;
@@ -5400,8 +5450,8 @@
   assert(isa<CXXMethodDecl>(Specialization) &&
          "Specialization is not a member function?");
   AddMethodCandidate(cast<CXXMethodDecl>(Specialization), FoundDecl,
-                     ActingContext, ObjectType, ObjectClassification,
-                     Args, NumArgs, CandidateSet, SuppressUserConversions);
+                     ActingContext, ObjectType, ObjectClassification, Args,
+                     CandidateSet, SuppressUserConversions);
 }
 
 /// \brief Add a C++ function template specialization as a candidate
@@ -5411,7 +5461,7 @@
 Sema::AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
                                    DeclAccessPair FoundDecl,
                                  TemplateArgumentListInfo *ExplicitTemplateArgs,
-                                   Expr **Args, unsigned NumArgs,
+                                   llvm::ArrayRef<Expr *> Args,
                                    OverloadCandidateSet& CandidateSet,
                                    bool SuppressUserConversions) {
   if (!CandidateSet.isNewCandidate(FunctionTemplate))
@@ -5429,8 +5479,8 @@
   TemplateDeductionInfo Info(Context, CandidateSet.getLocation());
   FunctionDecl *Specialization = 0;
   if (TemplateDeductionResult Result
-        = DeduceTemplateArguments(FunctionTemplate, ExplicitTemplateArgs,
-                                  Args, NumArgs, Specialization, Info)) {
+        = DeduceTemplateArguments(FunctionTemplate, ExplicitTemplateArgs, Args,
+                                  Specialization, Info)) {
     OverloadCandidate &Candidate = CandidateSet.addCandidate();
     Candidate.FoundDecl = FoundDecl;
     Candidate.Function = FunctionTemplate->getTemplatedDecl();
@@ -5438,7 +5488,7 @@
     Candidate.FailureKind = ovl_fail_bad_deduction;
     Candidate.IsSurrogate = false;
     Candidate.IgnoreObjectArgument = false;
-    Candidate.ExplicitCallArguments = NumArgs;
+    Candidate.ExplicitCallArguments = Args.size();
     Candidate.DeductionFailure = MakeDeductionFailureInfo(Context, Result,
                                                           Info);
     return;
@@ -5447,7 +5497,7 @@
   // Add the function template specialization produced by template argument
   // deduction as a candidate.
   assert(Specialization && "Missing function template specialization?");
-  AddOverloadCandidate(Specialization, FoundDecl, Args, NumArgs, CandidateSet,
+  AddOverloadCandidate(Specialization, FoundDecl, Args, CandidateSet,
                        SuppressUserConversions);
 }
 
@@ -5645,7 +5695,7 @@
                                  CXXRecordDecl *ActingContext,
                                  const FunctionProtoType *Proto,
                                  Expr *Object,
-                                 Expr **Args, unsigned NumArgs,
+                                 llvm::ArrayRef<Expr *> Args,
                                  OverloadCandidateSet& CandidateSet) {
   if (!CandidateSet.isNewCandidate(Conversion))
     return;
@@ -5653,14 +5703,14 @@
   // Overload resolution is always an unevaluated context.
   EnterExpressionEvaluationContext Unevaluated(*this, Sema::Unevaluated);
 
-  OverloadCandidate &Candidate = CandidateSet.addCandidate(NumArgs + 1);
+  OverloadCandidate &Candidate = CandidateSet.addCandidate(Args.size() + 1);
   Candidate.FoundDecl = FoundDecl;
   Candidate.Function = 0;
   Candidate.Surrogate = Conversion;
   Candidate.Viable = true;
   Candidate.IsSurrogate = true;
   Candidate.IgnoreObjectArgument = false;
-  Candidate.ExplicitCallArguments = NumArgs;
+  Candidate.ExplicitCallArguments = Args.size();
 
   // Determine the implicit conversion sequence for the implicit
   // object parameter.
@@ -5694,7 +5744,7 @@
   // (C++ 13.3.2p2): A candidate function having fewer than m
   // parameters is viable only if it has an ellipsis in its parameter
   // list (8.3.5).
-  if (NumArgs > NumArgsInProto && !Proto->isVariadic()) {
+  if (Args.size() > NumArgsInProto && !Proto->isVariadic()) {
     Candidate.Viable = false;
     Candidate.FailureKind = ovl_fail_too_many_arguments;
     return;
@@ -5702,7 +5752,7 @@
 
   // Function types don't have any default arguments, so just check if
   // we have enough arguments.
-  if (NumArgs < NumArgsInProto) {
+  if (Args.size() < NumArgsInProto) {
     // Not enough arguments.
     Candidate.Viable = false;
     Candidate.FailureKind = ovl_fail_too_few_arguments;
@@ -5711,7 +5761,7 @@
 
   // Determine the implicit conversion sequences for each of the
   // arguments.
-  for (unsigned ArgIdx = 0; ArgIdx < NumArgs; ++ArgIdx) {
+  for (unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
     if (ArgIdx < NumArgsInProto) {
       // (C++ 13.3.2p3): for F to be a viable function, there shall
       // exist for each argument an implicit conversion sequence
@@ -7403,8 +7453,8 @@
 /// candidate set (C++ [basic.lookup.argdep]).
 void
 Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
-                                           bool Operator,
-                                           Expr **Args, unsigned NumArgs,
+                                           bool Operator, SourceLocation Loc,
+                                           llvm::ArrayRef<Expr *> Args,
                                  TemplateArgumentListInfo *ExplicitTemplateArgs,
                                            OverloadCandidateSet& CandidateSet,
                                            bool PartialOverloading,
@@ -7419,7 +7469,7 @@
   // we supposed to consider on ADL candidates, anyway?
 
   // FIXME: Pass in the explicit template arguments?
-  ArgumentDependentLookup(Name, Operator, Args, NumArgs, Fns,
+  ArgumentDependentLookup(Name, Operator, Loc, Args, Fns,
                           StdNamespaceIsAssociated);
 
   // Erase all of the candidates we already knew about.
@@ -7440,12 +7490,12 @@
       if (ExplicitTemplateArgs)
         continue;
 
-      AddOverloadCandidate(FD, FoundDecl, Args, NumArgs, CandidateSet,
-                           false, PartialOverloading);
+      AddOverloadCandidate(FD, FoundDecl, Args, CandidateSet, false,
+                           PartialOverloading);
     } else
       AddTemplateOverloadCandidate(cast<FunctionTemplateDecl>(*I),
                                    FoundDecl, ExplicitTemplateArgs,
-                                   Args, NumArgs, CandidateSet);
+                                   Args, CandidateSet);
   }
 }
 
@@ -7536,6 +7586,15 @@
   if (UserDefinedConversion && Cand1.Function && Cand2.Function &&
       isa<CXXConversionDecl>(Cand1.Function) &&
       isa<CXXConversionDecl>(Cand2.Function)) {
+    // First check whether we prefer one of the conversion functions over the
+    // other. This only distinguishes the results in non-standard, extension
+    // cases such as the conversion from a lambda closure type to a function
+    // pointer or block.
+    ImplicitConversionSequence::CompareKind FuncResult
+      = compareConversionFunctions(S, Cand1.Function, Cand2.Function);
+    if (FuncResult != ImplicitConversionSequence::Indistinguishable)
+      return FuncResult;
+          
     switch (CompareStandardConversionSequences(S,
                                                Cand1.FinalConversion,
                                                Cand2.FinalConversion)) {
@@ -7995,7 +8054,7 @@
 
 /// Diagnose a failed template-argument deduction.
 void DiagnoseBadDeduction(Sema &S, OverloadCandidate *Cand,
-                          Expr **Args, unsigned NumArgs) {
+                          unsigned NumArgs) {
   FunctionDecl *Fn = Cand->Function; // pattern
 
   TemplateParameter Param = Cand->DeductionFailure.getTemplateParameter();
@@ -8143,7 +8202,7 @@
 /// more richly for those diagnostic clients that cared, but we'd
 /// still have to be just as careful with the default diagnostics.
 void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
-                           Expr **Args, unsigned NumArgs) {
+                           unsigned NumArgs) {
   FunctionDecl *Fn = Cand->Function;
 
   // Note deleted candidates, but only if they're viable.
@@ -8170,7 +8229,7 @@
     return DiagnoseArityMismatch(S, Cand, NumArgs);
 
   case ovl_fail_bad_deduction:
-    return DiagnoseBadDeduction(S, Cand, Args, NumArgs);
+    return DiagnoseBadDeduction(S, Cand, NumArgs);
 
   case ovl_fail_trivial_conversion:
   case ovl_fail_bad_final_conversion:
@@ -8407,7 +8466,7 @@
 /// CompleteNonViableCandidate - Normally, overload resolution only
 /// computes up to the first. Produces the FixIt set if possible.
 void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand,
-                                Expr **Args, unsigned NumArgs) {
+                                llvm::ArrayRef<Expr *> Args) {
   assert(!Cand->Viable);
 
   // Don't do anything on failures other than bad conversion.
@@ -8495,7 +8554,7 @@
 /// set.
 void OverloadCandidateSet::NoteCandidates(Sema &S,
                                           OverloadCandidateDisplayKind OCD,
-                                          Expr **Args, unsigned NumArgs,
+                                          llvm::ArrayRef<Expr *> Args,
                                           const char *Opc,
                                           SourceLocation OpLoc) {
   // Sort the candidates by viability and position.  Sorting directly would
@@ -8506,7 +8565,7 @@
     if (Cand->Viable)
       Cands.push_back(Cand);
     else if (OCD == OCD_AllCandidates) {
-      CompleteNonViableCandidate(S, Cand, Args, NumArgs);
+      CompleteNonViableCandidate(S, Cand, Args);
       if (Cand->Function || Cand->IsSurrogate)
         Cands.push_back(Cand);
       // Otherwise, this a non-viable builtin candidate.  We do not, in general,
@@ -8535,7 +8594,7 @@
     ++CandsShown;
 
     if (Cand->Function)
-      NoteFunctionCandidate(S, Cand, Args, NumArgs);
+      NoteFunctionCandidate(S, Cand, Args.size());
     else if (Cand->IsSurrogate)
       NoteSurrogateCandidate(S, Cand);
     else {
@@ -9088,7 +9147,7 @@
 static void AddOverloadedCallCandidate(Sema &S,
                                        DeclAccessPair FoundDecl,
                                  TemplateArgumentListInfo *ExplicitTemplateArgs,
-                                       Expr **Args, unsigned NumArgs,
+                                       llvm::ArrayRef<Expr *> Args,
                                        OverloadCandidateSet &CandidateSet,
                                        bool PartialOverloading,
                                        bool KnownValid) {
@@ -9101,16 +9160,15 @@
       assert(!KnownValid && "Explicit template arguments?");
       return;
     }
-    S.AddOverloadCandidate(Func, FoundDecl, Args, NumArgs, CandidateSet,
-                           false, PartialOverloading);
+    S.AddOverloadCandidate(Func, FoundDecl, Args, CandidateSet, false,
+                           PartialOverloading);
     return;
   }
 
   if (FunctionTemplateDecl *FuncTemplate
       = dyn_cast<FunctionTemplateDecl>(Callee)) {
     S.AddTemplateOverloadCandidate(FuncTemplate, FoundDecl,
-                                   ExplicitTemplateArgs,
-                                   Args, NumArgs, CandidateSet);
+                                   ExplicitTemplateArgs, Args, CandidateSet);
     return;
   }
 
@@ -9120,7 +9178,7 @@
 /// \brief Add the overload candidates named by callee and/or found by argument
 /// dependent lookup to the given overload set.
 void Sema::AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
-                                       Expr **Args, unsigned NumArgs,
+                                       llvm::ArrayRef<Expr *> Args,
                                        OverloadCandidateSet &CandidateSet,
                                        bool PartialOverloading) {
 
@@ -9163,16 +9221,15 @@
 
   for (UnresolvedLookupExpr::decls_iterator I = ULE->decls_begin(),
          E = ULE->decls_end(); I != E; ++I)
-    AddOverloadedCallCandidate(*this, I.getPair(), ExplicitTemplateArgs,
-                               Args, NumArgs, CandidateSet,
-                               PartialOverloading, /*KnownValid*/ true);
+    AddOverloadedCallCandidate(*this, I.getPair(), ExplicitTemplateArgs, Args,
+                               CandidateSet, PartialOverloading,
+                               /*KnownValid*/ true);
 
   if (ULE->requiresADL())
     AddArgumentDependentLookupCandidates(ULE->getName(), /*Operator*/ false,
-                                         Args, NumArgs,
-                                         ExplicitTemplateArgs,
-                                         CandidateSet,
-                                         PartialOverloading,
+                                         ULE->getExprLoc(),
+                                         Args, ExplicitTemplateArgs,
+                                         CandidateSet, PartialOverloading,
                                          ULE->isStdAssociatedNamespace());
 }
 
@@ -9186,7 +9243,7 @@
 DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc,
                        const CXXScopeSpec &SS, LookupResult &R,
                        TemplateArgumentListInfo *ExplicitTemplateArgs,
-                       Expr **Args, unsigned NumArgs) {
+                       llvm::ArrayRef<Expr *> Args) {
   if (SemaRef.ActiveTemplateInstantiations.empty() || !SS.isEmpty())
     return false;
 
@@ -9206,7 +9263,7 @@
       OverloadCandidateSet Candidates(FnLoc);
       for (LookupResult::iterator I = R.begin(), E = R.end(); I != E; ++I)
         AddOverloadedCallCandidate(SemaRef, I.getPair(),
-                                   ExplicitTemplateArgs, Args, NumArgs,
+                                   ExplicitTemplateArgs, Args,
                                    Candidates, false, /*KnownValid*/ false);
 
       OverloadCandidateSet::iterator Best;
@@ -9221,7 +9278,7 @@
       // declaring the function there instead.
       Sema::AssociatedNamespaceSet AssociatedNamespaces;
       Sema::AssociatedClassSet AssociatedClasses;
-      SemaRef.FindAssociatedClassesAndNamespaces(Args, NumArgs,
+      SemaRef.FindAssociatedClassesAndNamespaces(Args,
                                                  AssociatedNamespaces,
                                                  AssociatedClasses);
       // Never suggest declaring a function within namespace 'std'. 
@@ -9275,12 +9332,12 @@
 static bool
 DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op,
                                SourceLocation OpLoc,
-                               Expr **Args, unsigned NumArgs) {
+                               llvm::ArrayRef<Expr *> Args) {
   DeclarationName OpName =
     SemaRef.Context.DeclarationNames.getCXXOperatorName(Op);
   LookupResult R(SemaRef, OpName, OpLoc, Sema::LookupOperatorName);
   return DiagnoseTwoPhaseLookup(SemaRef, OpLoc, CXXScopeSpec(), R,
-                                /*ExplicitTemplateArgs=*/0, Args, NumArgs);
+                                /*ExplicitTemplateArgs=*/0, Args);
 }
 
 namespace {
@@ -9353,7 +9410,7 @@
 BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
                       UnresolvedLookupExpr *ULE,
                       SourceLocation LParenLoc,
-                      Expr **Args, unsigned NumArgs,
+                      llvm::MutableArrayRef<Expr *> Args,
                       SourceLocation RParenLoc,
                       bool EmptyLookup, bool AllowTypoCorrection) {
 
@@ -9370,16 +9427,16 @@
 
   LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
                  Sema::LookupOrdinaryName);
-  RecoveryCallCCC Validator(SemaRef, NumArgs, ExplicitTemplateArgs != 0);
+  RecoveryCallCCC Validator(SemaRef, Args.size(), ExplicitTemplateArgs != 0);
   NoTypoCorrectionCCC RejectAll;
   CorrectionCandidateCallback *CCC = AllowTypoCorrection ?
       (CorrectionCandidateCallback*)&Validator :
       (CorrectionCandidateCallback*)&RejectAll;
   if (!DiagnoseTwoPhaseLookup(SemaRef, Fn->getExprLoc(), SS, R,
-                              ExplicitTemplateArgs, Args, NumArgs) &&
+                              ExplicitTemplateArgs, Args) &&
       (!EmptyLookup ||
        SemaRef.DiagnoseEmptyLookup(S, SS, R, *CCC,
-                                   ExplicitTemplateArgs, Args, NumArgs)))
+                                   ExplicitTemplateArgs, Args)))
     return ExprError();
 
   assert(!R.empty() && "lookup results empty despite recovery");
@@ -9403,7 +9460,8 @@
   // an expression with viable lookup results, which should never
   // end up here.
   return SemaRef.ActOnCallExpr(/*Scope*/ 0, NewFn.take(), LParenLoc,
-                               MultiExprArg(Args, NumArgs), RParenLoc);
+                               MultiExprArg(Args.data(), Args.size()),
+                               RParenLoc);
 }
 
 /// ResolveOverloadedCallFn - Given the call expression that calls Fn
@@ -9448,7 +9506,8 @@
 
   // Add the functions denoted by the callee to the set of candidate
   // functions, including those from argument-dependent lookup.
-  AddOverloadedCallCandidates(ULE, Args, NumArgs, CandidateSet);
+  AddOverloadedCallCandidates(ULE, llvm::makeArrayRef(Args, NumArgs),
+                              CandidateSet);
 
   // If we found nothing, try to recover.
   // BuildRecoveryCallExpr diagnoses the error itself, so we just bail
@@ -9466,7 +9525,8 @@
       CE->setTypeDependent(true);
       return Owned(CE);
     }
-    return BuildRecoveryCallExpr(*this, S, Fn, ULE, LParenLoc, Args, NumArgs,
+    return BuildRecoveryCallExpr(*this, S, Fn, ULE, LParenLoc,
+                                 llvm::MutableArrayRef<Expr *>(Args, NumArgs),
                                  RParenLoc, /*EmptyLookup=*/true,
                                  AllowTypoCorrection);
   }
@@ -9489,7 +9549,8 @@
     // Try to recover by looking for viable functions which the user might
     // have meant to call.
     ExprResult Recovery = BuildRecoveryCallExpr(*this, S, Fn, ULE, LParenLoc,
-                                                Args, NumArgs, RParenLoc,
+                                  llvm::MutableArrayRef<Expr *>(Args, NumArgs),
+                                                RParenLoc,
                                                 /*EmptyLookup=*/false,
                                                 AllowTypoCorrection);
     if (!Recovery.isInvalid())
@@ -9498,14 +9559,16 @@
     Diag(Fn->getSourceRange().getBegin(),
          diag::err_ovl_no_viable_function_in_call)
       << ULE->getName() << Fn->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
+    CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
+                                llvm::makeArrayRef(Args, NumArgs));
     break;
   }
 
   case OR_Ambiguous:
     Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_ambiguous_call)
       << ULE->getName() << Fn->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Args, NumArgs);
+    CandidateSet.NoteCandidates(*this, OCD_ViableCandidates,
+                                llvm::makeArrayRef(Args, NumArgs));
     break;
 
   case OR_Deleted:
@@ -9515,7 +9578,8 @@
         << ULE->getName()
         << getDeletedOrUnavailableSuffix(Best->Function)
         << Fn->getSourceRange();
-      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
+      CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
+                                  llvm::makeArrayRef(Args, NumArgs));
 
       // We emitted an error for the unvailable/deleted function call but keep
       // the call in the AST.
@@ -9604,14 +9668,15 @@
   OverloadCandidateSet CandidateSet(OpLoc);
 
   // Add the candidates from the given function set.
-  AddFunctionCandidates(Fns, &Args[0], NumArgs, CandidateSet, false);
+  AddFunctionCandidates(Fns, llvm::makeArrayRef(Args, NumArgs), CandidateSet,
+                        false);
 
   // Add operator candidates that are member functions.
   AddMemberOperatorCandidates(Op, OpLoc, &Args[0], NumArgs, CandidateSet);
 
   // Add candidates from ADL.
   AddArgumentDependentLookupCandidates(OpName, /*Operator*/ true,
-                                       Args, NumArgs,
+                                       OpLoc, llvm::makeArrayRef(Args, NumArgs),
                                        /*ExplicitTemplateArgs*/ 0,
                                        CandidateSet);
 
@@ -9697,7 +9762,8 @@
     // This is an erroneous use of an operator which can be overloaded by
     // a non-member function. Check for non-member operators which were
     // defined too late to be candidates.
-    if (DiagnoseTwoPhaseOperatorLookup(*this, Op, OpLoc, Args, NumArgs))
+    if (DiagnoseTwoPhaseOperatorLookup(*this, Op, OpLoc,
+                                       llvm::makeArrayRef(Args, NumArgs)))
       // FIXME: Recover by calling the found function.
       return ExprError();
 
@@ -9710,7 +9776,8 @@
         << UnaryOperator::getOpcodeStr(Opc)
         << Input->getType()
         << Input->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Args, NumArgs,
+    CandidateSet.NoteCandidates(*this, OCD_ViableCandidates,
+                                llvm::makeArrayRef(Args, NumArgs),
                                 UnaryOperator::getOpcodeStr(Opc), OpLoc);
     return ExprError();
 
@@ -9720,7 +9787,8 @@
       << UnaryOperator::getOpcodeStr(Opc)
       << getDeletedOrUnavailableSuffix(Best->Function)
       << Input->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs,
+    CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
+                                llvm::makeArrayRef(Args, NumArgs),
                                 UnaryOperator::getOpcodeStr(Opc), OpLoc);
     return ExprError();
   }
@@ -9825,14 +9893,14 @@
   OverloadCandidateSet CandidateSet(OpLoc);
 
   // Add the candidates from the given function set.
-  AddFunctionCandidates(Fns, Args, 2, CandidateSet, false);
+  AddFunctionCandidates(Fns, Args, CandidateSet, false);
 
   // Add operator candidates that are member functions.
   AddMemberOperatorCandidates(Op, OpLoc, Args, 2, CandidateSet);
 
   // Add candidates from ADL.
   AddArgumentDependentLookupCandidates(OpName, /*Operator*/ true,
-                                       Args, 2,
+                                       OpLoc, Args,
                                        /*ExplicitTemplateArgs*/ 0,
                                        CandidateSet);
 
@@ -9958,7 +10026,7 @@
         // This is an erroneous use of an operator which can be overloaded by
         // a non-member function. Check for non-member operators which were
         // defined too late to be candidates.
-        if (DiagnoseTwoPhaseOperatorLookup(*this, Op, OpLoc, Args, 2))
+        if (DiagnoseTwoPhaseOperatorLookup(*this, Op, OpLoc, Args))
           // FIXME: Recover by calling the found function.
           return ExprError();
 
@@ -9969,7 +10037,7 @@
       assert(Result.isInvalid() &&
              "C++ binary operator overloading is missing candidates!");
       if (Result.isInvalid())
-        CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, 2,
+        CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args,
                                     BinaryOperator::getOpcodeStr(Opc), OpLoc);
       return move(Result);
     }
@@ -9979,7 +10047,7 @@
           << BinaryOperator::getOpcodeStr(Opc)
           << Args[0]->getType() << Args[1]->getType()
           << Args[0]->getSourceRange() << Args[1]->getSourceRange();
-      CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Args, 2,
+      CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Args,
                                   BinaryOperator::getOpcodeStr(Opc), OpLoc);
       return ExprError();
 
@@ -10002,7 +10070,7 @@
           << getDeletedOrUnavailableSuffix(Best->Function)
           << Args[0]->getSourceRange() << Args[1]->getSourceRange();
       }
-      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, 2,
+      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args,
                                   BinaryOperator::getOpcodeStr(Opc), OpLoc);
       return ExprError();
   }
@@ -10154,7 +10222,7 @@
         Diag(LLoc, diag::err_ovl_no_viable_subscript)
           << Args[0]->getType()
           << Args[0]->getSourceRange() << Args[1]->getSourceRange();
-      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, 2,
+      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args,
                                   "[]", LLoc);
       return ExprError();
     }
@@ -10164,7 +10232,7 @@
           << "[]"
           << Args[0]->getType() << Args[1]->getType()
           << Args[0]->getSourceRange() << Args[1]->getSourceRange();
-      CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Args, 2,
+      CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Args,
                                   "[]", LLoc);
       return ExprError();
 
@@ -10173,7 +10241,7 @@
         << Best->Function->isDeleted() << "[]"
         << getDeletedOrUnavailableSuffix(Best->Function)
         << Args[0]->getSourceRange() << Args[1]->getSourceRange();
-      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, 2,
+      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args,
                                   "[]", LLoc);
       return ExprError();
     }
@@ -10291,8 +10359,8 @@
 
       // Microsoft supports direct constructor calls.
       if (getLangOptions().MicrosoftExt && isa<CXXConstructorDecl>(Func)) {
-        AddOverloadCandidate(cast<CXXConstructorDecl>(Func), I.getPair(), Args, NumArgs,
-                             CandidateSet);
+        AddOverloadCandidate(cast<CXXConstructorDecl>(Func), I.getPair(),
+                             llvm::makeArrayRef(Args, NumArgs), CandidateSet);
       } else if ((Method = dyn_cast<CXXMethodDecl>(Func))) {
         // If explicit template arguments were provided, we can't call a
         // non-template member function.
@@ -10301,13 +10369,14 @@
 
         AddMethodCandidate(Method, I.getPair(), ActingDC, ObjectType,
                            ObjectClassification,
-                           Args, NumArgs, CandidateSet,
+                           llvm::makeArrayRef(Args, NumArgs), CandidateSet,
                            /*SuppressUserConversions=*/false);
       } else {
         AddMethodTemplateCandidate(cast<FunctionTemplateDecl>(Func),
                                    I.getPair(), ActingDC, TemplateArgs,
                                    ObjectType,  ObjectClassification,
-                                   Args, NumArgs, CandidateSet,
+                                   llvm::makeArrayRef(Args, NumArgs),
+                                   CandidateSet,
                                    /*SuppressUsedConversions=*/false);
       }
     }
@@ -10331,14 +10400,16 @@
       Diag(UnresExpr->getMemberLoc(),
            diag::err_ovl_no_viable_member_function_in_call)
         << DeclName << MemExprE->getSourceRange();
-      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
+      CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
+                                  llvm::makeArrayRef(Args, NumArgs));
       // FIXME: Leaking incoming expressions!
       return ExprError();
 
     case OR_Ambiguous:
       Diag(UnresExpr->getMemberLoc(), diag::err_ovl_ambiguous_member_call)
         << DeclName << MemExprE->getSourceRange();
-      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
+      CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
+                                  llvm::makeArrayRef(Args, NumArgs));
       // FIXME: Leaking incoming expressions!
       return ExprError();
 
@@ -10348,7 +10419,8 @@
         << DeclName 
         << getDeletedOrUnavailableSuffix(Best->Function)
         << MemExprE->getSourceRange();
-      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
+      CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
+                                  llvm::makeArrayRef(Args, NumArgs));
       // FIXME: Leaking incoming expressions!
       return ExprError();
     }
@@ -10508,7 +10580,8 @@
       if (const FunctionProtoType *Proto = ConvType->getAs<FunctionProtoType>())
       {
         AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
-                              Object.get(), Args, NumArgs, CandidateSet);
+                              Object.get(), llvm::makeArrayRef(Args, NumArgs),
+                              CandidateSet);
       }
     }
   }
@@ -10533,14 +10606,16 @@
       Diag(Object.get()->getSourceRange().getBegin(),
            diag::err_ovl_no_viable_object_call)
         << Object.get()->getType() << Object.get()->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
+    CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
+                                llvm::makeArrayRef(Args, NumArgs));
     break;
 
   case OR_Ambiguous:
     Diag(Object.get()->getSourceRange().getBegin(),
          diag::err_ovl_ambiguous_object_call)
       << Object.get()->getType() << Object.get()->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Args, NumArgs);
+    CandidateSet.NoteCandidates(*this, OCD_ViableCandidates,
+                                llvm::makeArrayRef(Args, NumArgs));
     break;
 
   case OR_Deleted:
@@ -10550,7 +10625,8 @@
       << Object.get()->getType() 
       << getDeletedOrUnavailableSuffix(Best->Function)
       << Object.get()->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
+    CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
+                                llvm::makeArrayRef(Args, NumArgs));
     break;
   }
 
@@ -10766,13 +10842,13 @@
     else
       Diag(OpLoc, diag::err_ovl_no_viable_oper)
         << "operator->" << Base->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_AllCandidates, &Base, 1);
+    CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Base);
     return ExprError();
 
   case OR_Ambiguous:
     Diag(OpLoc,  diag::err_ovl_ambiguous_oper_unary)
       << "->" << Base->getType() << Base->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, &Base, 1);
+    CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Base);
     return ExprError();
 
   case OR_Deleted:
@@ -10781,7 +10857,7 @@
       << "->" 
       << getDeletedOrUnavailableSuffix(Best->Function)
       << Base->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_AllCandidates, &Base, 1);
+    CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Base);
     return ExprError();
   }
 

Modified: cfe/branches/tooling/lib/Sema/SemaPseudoObject.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaPseudoObject.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaPseudoObject.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaPseudoObject.cpp Tue Feb 28 17:49:25 2012
@@ -222,8 +222,8 @@
   // Make a new OVE whose source is the given expression.
   OpaqueValueExpr *captured = 
     new (S.Context) OpaqueValueExpr(GenericLoc, e->getType(),
-                                    e->getValueKind());
-  captured->setSourceExpr(e);
+                                    e->getValueKind(), e->getObjectKind(),
+                                    e);
   
   // Make sure we bind that in the semantics.
   addSemanticExpr(captured);

Modified: cfe/branches/tooling/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaStmt.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaStmt.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaStmt.cpp Tue Feb 28 17:49:25 2012
@@ -1878,7 +1878,7 @@
     // Delay processing for now.  TODO: there are lots of dependent
     // types we can conclusively prove aren't void.
   } else if (FnRetType->isVoidType()) {
-    if (RetValExp &&
+    if (RetValExp && !isa<InitListExpr>(RetValExp) &&
         !(getLangOptions().CPlusPlus &&
           (RetValExp->isTypeDependent() ||
            RetValExp->getType()->isVoidType()))) {
@@ -1961,7 +1961,26 @@
   ReturnStmt *Result = 0;
   if (FnRetType->isVoidType()) {
     if (RetValExp) {
-      if (!RetValExp->isTypeDependent()) {
+      if (isa<InitListExpr>(RetValExp)) {
+        // We simply never allow init lists as the return value of void
+        // functions. This is compatible because this was never allowed before,
+        // so there's no legacy code to deal with.
+        NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
+        int FunctionKind = 0;
+        if (isa<ObjCMethodDecl>(CurDecl))
+          FunctionKind = 1;
+        else if (isa<CXXConstructorDecl>(CurDecl))
+          FunctionKind = 2;
+        else if (isa<CXXDestructorDecl>(CurDecl))
+          FunctionKind = 3;
+
+        Diag(ReturnLoc, diag::err_return_init_list)
+          << CurDecl->getDeclName() << FunctionKind
+          << RetValExp->getSourceRange();
+
+        // Drop the expression.
+        RetValExp = 0;
+      } else if (!RetValExp->isTypeDependent()) {
         // C99 6.8.6.4p1 (ext_ since GCC warns)
         unsigned D = diag::ext_return_has_expr;
         if (RetValExp->getType()->isVoidType())
@@ -1995,8 +2014,10 @@
         }
       }
 
-      CheckImplicitConversions(RetValExp, ReturnLoc);
-      RetValExp = MaybeCreateExprWithCleanups(RetValExp);
+      if (RetValExp) {
+        CheckImplicitConversions(RetValExp, ReturnLoc);
+        RetValExp = MaybeCreateExprWithCleanups(RetValExp);
+      }
     }
 
     Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, 0);

Modified: cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplate.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplate.cpp Tue Feb 28 17:49:25 2012
@@ -5350,6 +5350,7 @@
 /// \brief Strips various properties off an implicit instantiation
 /// that has just been explicitly specialized.
 static void StripImplicitInstantiation(NamedDecl *D) {
+  // FIXME: "make check" is clean if the call to dropAttrs() is commented out.
   D->dropAttrs();
 
   if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {

Modified: cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp Tue Feb 28 17:49:25 2012
@@ -548,7 +548,7 @@
 /// arguments in a set of argument packs.
 static void PrepareArgumentPackDeduction(Sema &S,
                        SmallVectorImpl<DeducedTemplateArgument> &Deduced,
-                             const SmallVectorImpl<unsigned> &PackIndices,
+                                           ArrayRef<unsigned> PackIndices,
                      SmallVectorImpl<DeducedTemplateArgument> &SavedPacks,
          SmallVectorImpl<
            SmallVector<DeducedTemplateArgument, 4> > &NewlyDeducedPacks) {
@@ -583,7 +583,7 @@
                             TemplateParameterList *TemplateParams,
                             bool HasAnyArguments,
                         SmallVectorImpl<DeducedTemplateArgument> &Deduced,
-                            const SmallVectorImpl<unsigned> &PackIndices,
+                            ArrayRef<unsigned> PackIndices,
                     SmallVectorImpl<DeducedTemplateArgument> &SavedPacks,
         SmallVectorImpl<
           SmallVector<DeducedTemplateArgument, 4> > &NewlyDeducedPacks,
@@ -2909,7 +2909,7 @@
 Sema::TemplateDeductionResult
 Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
                               TemplateArgumentListInfo *ExplicitTemplateArgs,
-                              Expr **Args, unsigned NumArgs,
+                              llvm::ArrayRef<Expr *> Args,
                               FunctionDecl *&Specialization,
                               TemplateDeductionInfo &Info) {
   FunctionDecl *Function = FunctionTemplate->getTemplatedDecl();
@@ -2918,10 +2918,10 @@
   //   Template argument deduction is done by comparing each function template
   //   parameter type (call it P) with the type of the corresponding argument
   //   of the call (call it A) as described below.
-  unsigned CheckArgs = NumArgs;
-  if (NumArgs < Function->getMinRequiredArguments())
+  unsigned CheckArgs = Args.size();
+  if (Args.size() < Function->getMinRequiredArguments())
     return TDK_TooFewArguments;
-  else if (NumArgs > Function->getNumParams()) {
+  else if (Args.size() > Function->getNumParams()) {
     const FunctionProtoType *Proto
       = Function->getType()->getAs<FunctionProtoType>();
     if (Proto->isTemplateVariadic())
@@ -3062,7 +3062,7 @@
     PrepareArgumentPackDeduction(*this, Deduced, PackIndices, SavedPacks,
                                  NewlyDeducedPacks);
     bool HasAnyArguments = false;
-    for (; ArgIdx < NumArgs; ++ArgIdx) {
+    for (; ArgIdx < Args.size(); ++ArgIdx) {
       HasAnyArguments = true;
 
       QualType OrigParamType = ParamPattern;

Modified: cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp Tue Feb 28 17:49:25 2012
@@ -158,7 +158,7 @@
 void
 Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc,
                                        UnexpandedParameterPackContext UPPC,
-             const SmallVectorImpl<UnexpandedParameterPack> &Unexpanded) {
+                                 ArrayRef<UnexpandedParameterPack> Unexpanded) {
   if (Unexpanded.empty())
     return;
   

Modified: cfe/branches/tooling/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaType.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaType.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaType.cpp Tue Feb 28 17:49:25 2012
@@ -1938,7 +1938,7 @@
   return T;
 }
 
-std::string getFunctionQualifiersAsString(const FunctionProtoType *FnTy) {
+static std::string getFunctionQualifiersAsString(const FunctionProtoType *FnTy){
   std::string Quals =
     Qualifiers::fromCVRMask(FnTy->getTypeQuals()).getAsString();
 

Modified: cfe/branches/tooling/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/TreeTransform.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/TreeTransform.h (original)
+++ cfe/branches/tooling/lib/Sema/TreeTransform.h Tue Feb 28 17:49:25 2012
@@ -2022,6 +2022,17 @@
     return getSema().BuildBinaryTypeTrait(Trait, StartLoc, LhsT, RhsT, RParenLoc);
   }
 
+  /// \brief Build a new type trait expression.
+  ///
+  /// By default, performs semantic analysis to build the new expression.
+  /// Subclasses may override this routine to provide different behavior.
+  ExprResult RebuildTypeTrait(TypeTrait Trait,
+                              SourceLocation StartLoc,
+                              ArrayRef<TypeSourceInfo *> Args,
+                              SourceLocation RParenLoc) {
+    return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
+  }
+  
   /// \brief Build a new array type trait expression.
   ///
   /// By default, performs semantic analysis to build the new expression.
@@ -4305,12 +4316,17 @@
   const DecltypeType *T = TL.getTypePtr();
 
   // decltype expressions are not potentially evaluated contexts
-  EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
+  EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated, 0,
+                                               /*IsDecltype=*/ true);
 
   ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
   if (E.isInvalid())
     return QualType();
 
+  E = getSema().ActOnDecltypeExpression(E.take());
+  if (E.isInvalid())
+    return QualType();
+
   QualType Result = TL.getType();
   if (getDerived().AlwaysRebuild() ||
       E.get() != T->getUnderlyingExpr()) {
@@ -7022,9 +7038,12 @@
     T = getSema().Context.getPointerType(
       getSema().Context.getRecordType(cast<CXXRecordDecl>(DC)));
 
-  if (!getDerived().AlwaysRebuild() && T == E->getType())
+  if (!getDerived().AlwaysRebuild() && T == E->getType()) {
+    // Make sure that we capture 'this'.
+    getSema().CheckCXXThisCapture(E->getLocStart());
     return SemaRef.Owned(E);
-
+  }
+  
   return getDerived().RebuildCXXThisExpr(E->getLocStart(), T, E->isImplicit());
 }
 
@@ -7431,6 +7450,128 @@
 
 template<typename Derived>
 ExprResult
+TreeTransform<Derived>::TransformTypeTraitExpr(TypeTraitExpr *E) {
+  bool ArgChanged = false;
+  llvm::SmallVector<TypeSourceInfo *, 4> Args;
+  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
+    TypeSourceInfo *From = E->getArg(I);
+    TypeLoc FromTL = From->getTypeLoc();
+    if (!isa<PackExpansionTypeLoc>(FromTL)) {
+      TypeLocBuilder TLB;
+      TLB.reserve(FromTL.getFullDataSize());
+      QualType To = getDerived().TransformType(TLB, FromTL);
+      if (To.isNull())
+        return ExprError();
+      
+      if (To == From->getType())
+        Args.push_back(From);
+      else {
+        Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
+        ArgChanged = true;
+      }
+      continue;
+    }
+    
+    ArgChanged = true;
+    
+    // We have a pack expansion. Instantiate it.
+    PackExpansionTypeLoc ExpansionTL = cast<PackExpansionTypeLoc>(FromTL);      
+    TypeLoc PatternTL = ExpansionTL.getPatternLoc();
+    SmallVector<UnexpandedParameterPack, 2> Unexpanded;
+    SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
+    
+    // Determine whether the set of unexpanded parameter packs can and should
+    // be expanded.
+    bool Expand = true;
+    bool RetainExpansion = false;
+    llvm::Optional<unsigned> OrigNumExpansions
+      = ExpansionTL.getTypePtr()->getNumExpansions();
+    llvm::Optional<unsigned> NumExpansions = OrigNumExpansions;
+    if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
+                                             PatternTL.getSourceRange(),
+                                             Unexpanded,
+                                             Expand, RetainExpansion,
+                                             NumExpansions))
+      return ExprError();
+    
+    if (!Expand) {
+      // The transform has determined that we should perform a simple
+      // transformation on the pack expansion, producing another pack 
+      // expansion.
+      Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
+      
+      TypeLocBuilder TLB;
+      TLB.reserve(From->getTypeLoc().getFullDataSize());
+
+      QualType To = getDerived().TransformType(TLB, PatternTL);
+      if (To.isNull())
+        return ExprError();
+
+      To = getDerived().RebuildPackExpansionType(To, 
+                                                 PatternTL.getSourceRange(),
+                                                 ExpansionTL.getEllipsisLoc(),
+                                                 NumExpansions);
+      if (To.isNull())
+        return ExprError();
+      
+      PackExpansionTypeLoc ToExpansionTL
+        = TLB.push<PackExpansionTypeLoc>(To);
+      ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
+      Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
+      continue;
+    }
+
+    // Expand the pack expansion by substituting for each argument in the
+    // pack(s).
+    for (unsigned I = 0; I != *NumExpansions; ++I) {
+      Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I);
+      TypeLocBuilder TLB;
+      TLB.reserve(PatternTL.getFullDataSize());
+      QualType To = getDerived().TransformType(TLB, PatternTL);
+      if (To.isNull())
+        return ExprError();
+
+      Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
+    }
+    
+    if (!RetainExpansion)
+      continue;
+    
+    // If we're supposed to retain a pack expansion, do so by temporarily
+    // forgetting the partially-substituted parameter pack.
+    ForgetPartiallySubstitutedPackRAII Forget(getDerived());
+
+    TypeLocBuilder TLB;
+    TLB.reserve(From->getTypeLoc().getFullDataSize());
+    
+    QualType To = getDerived().TransformType(TLB, PatternTL);
+    if (To.isNull())
+      return ExprError();
+    
+    To = getDerived().RebuildPackExpansionType(To, 
+                                               PatternTL.getSourceRange(),
+                                               ExpansionTL.getEllipsisLoc(),
+                                               NumExpansions);
+    if (To.isNull())
+      return ExprError();
+    
+    PackExpansionTypeLoc ToExpansionTL
+      = TLB.push<PackExpansionTypeLoc>(To);
+    ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
+    Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
+  }
+  
+  if (!getDerived().AlwaysRebuild() && !ArgChanged)
+    return SemaRef.Owned(E);
+
+  return getDerived().RebuildTypeTrait(E->getTrait(),
+                                       E->getLocStart(),
+                                       Args,
+                                       E->getLocEnd());
+}
+
+template<typename Derived>
+ExprResult
 TreeTransform<Derived>::TransformArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
   TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
   if (!T)
@@ -8401,6 +8542,7 @@
                                                  oldCapture));
       assert(blockScope->CaptureMap.count(newCapture));
     }
+    assert(oldBlock->capturesCXXThis() == blockScope->isCXXThisCaptured());
   }
 #endif
 

Modified: cfe/branches/tooling/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReader.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReader.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReader.cpp Tue Feb 28 17:49:25 2012
@@ -27,7 +27,7 @@
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLocVisitor.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1744,7 +1744,7 @@
           = F.PreprocessorDetailCursor.GetCurrentBitNo();
           
         if (!PP.getPreprocessingRecord())
-          PP.createPreprocessingRecord(true);
+          PP.createPreprocessingRecord();
         if (!PP.getPreprocessingRecord()->getExternalSource())
           PP.getPreprocessingRecord()->SetExternalSource(*this);
         break;
@@ -2288,7 +2288,7 @@
       
       unsigned StartingID;
       if (!PP.getPreprocessingRecord())
-        PP.createPreprocessingRecord(true);
+        PP.createPreprocessingRecord();
       if (!PP.getPreprocessingRecord()->getExternalSource())
         PP.getPreprocessingRecord()->SetExternalSource(*this);
       StartingID 

Modified: cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp Tue Feb 28 17:49:25 2012
@@ -1072,13 +1072,21 @@
   Data.HasProtectedFields = Record[Idx++];
   Data.HasPublicFields = Record[Idx++];
   Data.HasMutableFields = Record[Idx++];
+  Data.HasOnlyCMembers = Record[Idx++];
   Data.HasTrivialDefaultConstructor = Record[Idx++];
   Data.HasConstexprNonCopyMoveConstructor = Record[Idx++];
+  Data.DefaultedDefaultConstructorIsConstexpr = Record[Idx++];
+  Data.DefaultedCopyConstructorIsConstexpr = Record[Idx++];
+  Data.DefaultedMoveConstructorIsConstexpr = Record[Idx++];
+  Data.HasConstexprDefaultConstructor = Record[Idx++];
+  Data.HasConstexprCopyConstructor = Record[Idx++];
+  Data.HasConstexprMoveConstructor = Record[Idx++];
   Data.HasTrivialCopyConstructor = Record[Idx++];
   Data.HasTrivialMoveConstructor = Record[Idx++];
   Data.HasTrivialCopyAssignment = Record[Idx++];
   Data.HasTrivialMoveAssignment = Record[Idx++];
   Data.HasTrivialDestructor = Record[Idx++];
+  Data.HasIrrelevantDestructor = Record[Idx++];
   Data.HasNonLiteralTypeFieldsOrBases = Record[Idx++];
   Data.ComputedVisibleConversions = Record[Idx++];
   Data.UserProvidedDefaultConstructor = Record[Idx++];
@@ -1213,8 +1221,6 @@
 void ASTDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) {
   VisitCXXMethodDecl(D);
   D->IsExplicitSpecified = Record[Idx++];
-  if (D->isLambdaToBlockPointerConversion())
-    D->setLambdaToBlockPointerCopyInit(Reader.ReadExpr(F));
 }
 
 void ASTDeclReader::VisitImportDecl(ImportDecl *D) {

Modified: cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp Tue Feb 28 17:49:25 2012
@@ -618,6 +618,7 @@
   } else
     E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
   E->sawArrayRangeDesignator(Record[Idx++]);
+  E->setInitializesStdInitializerList(Record[Idx++]);
   unsigned NumInits = Record[Idx++];
   E->reserveInits(Reader.getContext(), NumInits);
   if (isArrayFiller) {
@@ -1327,6 +1328,17 @@
   E->RhsType = GetTypeSourceInfo(Record, Idx);
 }
 
+void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
+  VisitExpr(E);
+  E->TypeTraitExprBits.NumArgs = Record[Idx++];
+  E->TypeTraitExprBits.Kind = Record[Idx++];
+  E->TypeTraitExprBits.Value = Record[Idx++];
+  
+  TypeSourceInfo **Args = E->getTypeSourceInfos();
+  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
+    Args[I] = GetTypeSourceInfo(Record, Idx);
+}
+
 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
   VisitExpr(E);
   E->ATT = (ArrayTypeTrait)Record[Idx++];
@@ -2046,6 +2058,11 @@
       S = new (Context) BinaryTypeTraitExpr(Empty);
       break;
 
+    case EXPR_TYPE_TRAIT:
+      S = TypeTraitExpr::CreateDeserialized(Context, 
+            Record[ASTStmtReader::NumExprFields]);
+      break;
+        
     case EXPR_ARRAY_TYPE_TRAIT:
       S = new (Context) ArrayTypeTraitExpr(Empty);
       break;

Modified: cfe/branches/tooling/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTWriter.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTWriter.cpp Tue Feb 28 17:49:25 2012
@@ -3860,6 +3860,10 @@
   // We only keep track of the file-level declarations of each file.
   if (!D->getLexicalDeclContext()->isFileContext())
     return;
+  // FIXME: ParmVarDecls that are part of a function type of a parameter of
+  // a function/objc method, should not have TU as lexical context.
+  if (isa<ParmVarDecl>(D))
+    return;
 
   SourceManager &SM = Context->getSourceManager();
   SourceLocation FileLoc = SM.getFileLoc(Loc);
@@ -4292,13 +4296,21 @@
   Record.push_back(Data.HasProtectedFields);
   Record.push_back(Data.HasPublicFields);
   Record.push_back(Data.HasMutableFields);
+  Record.push_back(Data.HasOnlyCMembers);
   Record.push_back(Data.HasTrivialDefaultConstructor);
   Record.push_back(Data.HasConstexprNonCopyMoveConstructor);
+  Record.push_back(Data.DefaultedDefaultConstructorIsConstexpr);
+  Record.push_back(Data.DefaultedCopyConstructorIsConstexpr);
+  Record.push_back(Data.DefaultedMoveConstructorIsConstexpr);
+  Record.push_back(Data.HasConstexprDefaultConstructor);
+  Record.push_back(Data.HasConstexprCopyConstructor);
+  Record.push_back(Data.HasConstexprMoveConstructor);
   Record.push_back(Data.HasTrivialCopyConstructor);
   Record.push_back(Data.HasTrivialMoveConstructor);
   Record.push_back(Data.HasTrivialCopyAssignment);
   Record.push_back(Data.HasTrivialMoveAssignment);
   Record.push_back(Data.HasTrivialDestructor);
+  Record.push_back(Data.HasIrrelevantDestructor);
   Record.push_back(Data.HasNonLiteralTypeFieldsOrBases);
   Record.push_back(Data.ComputedVisibleConversions);
   Record.push_back(Data.UserProvidedDefaultConstructor);
@@ -4310,6 +4322,7 @@
   Record.push_back(Data.DeclaredDestructor);
   Record.push_back(Data.FailedImplicitMoveConstructor);
   Record.push_back(Data.FailedImplicitMoveAssignment);
+  // IsLambda bit is already saved.
 
   Record.push_back(Data.NumBases);
   if (Data.NumBases > 0)

Modified: cfe/branches/tooling/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTWriterDecl.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTWriterDecl.cpp Tue Feb 28 17:49:25 2012
@@ -965,8 +965,6 @@
 void ASTDeclWriter::VisitCXXConversionDecl(CXXConversionDecl *D) {
   VisitCXXMethodDecl(D);
   Record.push_back(D->IsExplicitSpecified);
-  if (D->isLambdaToBlockPointerConversion())
-    Writer.AddStmt(D->getLambdaToBlockPointerCopyInit());
   Code = serialization::DECL_CXX_CONVERSION;
 }
 

Modified: cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp Tue Feb 28 17:49:25 2012
@@ -598,6 +598,7 @@
   else
     Writer.AddDeclRef(E->getInitializedFieldInUnion(), Record);
   Record.push_back(E->hadArrayRangeDesignator());
+  Record.push_back(E->initializesStdInitializerList());
   Record.push_back(E->getNumInits());
   if (isArrayFiller) {
     // ArrayFiller may have filled "holes" due to designated initializer.
@@ -1341,6 +1342,16 @@
   Code = serialization::EXPR_BINARY_TYPE_TRAIT;
 }
 
+void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) {
+  VisitExpr(E);
+  Record.push_back(E->TypeTraitExprBits.NumArgs);
+  Record.push_back(E->TypeTraitExprBits.Kind); // FIXME: Stable encoding
+  Record.push_back(E->TypeTraitExprBits.Value);
+  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
+    Writer.AddTypeSourceInfo(E->getArg(I), Record);
+  Code = serialization::EXPR_TYPE_TRAIT;
+}
+
 void ASTStmtWriter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
   VisitExpr(E);
   Record.push_back(E->getTrait());

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=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp Tue Feb 28 17:49:25 2012
@@ -45,7 +45,7 @@
   mutable OwningPtr<BugType> BT;
   inline void initBugType() const {
     if (!BT)
-      BT.reset(new BugType("Taint Analysis", "General"));
+      BT.reset(new BugType("Use of Untrusted Data", "Untrusted Data"));
   }
 
   /// \brief Catch taint related bugs. Check if tainted data is passed to a
@@ -174,14 +174,15 @@
 const unsigned GenericTaintChecker::InvalidArgIndex;
 
 const char GenericTaintChecker::MsgUncontrolledFormatString[] =
-  "Tainted format string (CWE-134: Uncontrolled Format String)";
+  "Untrusted data is used as a format string "
+  "(CWE-134: Uncontrolled Format String)";
 
 const char GenericTaintChecker::MsgSanitizeSystemArgs[] =
-  "Tainted data passed to a system call "
+  "Untrusted data is passed to a system call "
   "(CERT/STR02-C. Sanitize data passed to complex subsystems)";
 
 const char GenericTaintChecker::MsgTaintedBufferSize[] =
-  "Tainted data is used to specify the buffer size "
+  "Untrusted data is used to specify the buffer size "
   "(CERT/STR31-C. Guarantee that storage for strings has sufficient space for "
   "character data and the null terminator)";
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp Tue Feb 28 17:49:25 2012
@@ -59,7 +59,7 @@
   void checkPreStmt(const ReturnStmt *S, CheckerContext &C) const;
   void checkPostStmt(const CallExpr *S, CheckerContext &C) const;
   void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
-  void checkEndPath(CheckerContext &Ctx) const;
+  void checkEndPath(CheckerContext &C) const;
 
 private:
   typedef std::pair<SymbolRef, const AllocationState*> AllocationPair;
@@ -101,8 +101,13 @@
                                          const Expr *ArgExpr,
                                          CheckerContext &C) const;
 
+  /// Find the allocation site for Sym on the path leading to the node N.
+  const Stmt *getAllocationSite(const ExplodedNode *N, SymbolRef Sym,
+                                CheckerContext &C) const;
+
   BugReport *generateAllocatedDataNotReleasedReport(const AllocationPair &AP,
-                                                    ExplodedNode *N) const;
+                                                    ExplodedNode *N,
+                                                    CheckerContext &C) const;
 
   /// Check if RetSym evaluates to an error value in the current state.
   bool definitelyReturnedError(SymbolRef RetSym,
@@ -498,19 +503,53 @@
   C.addTransition(state);
 }
 
+// TODO: This logic is the same as in Malloc checker.
+const Stmt *
+MacOSKeychainAPIChecker::getAllocationSite(const ExplodedNode *N,
+                                           SymbolRef Sym,
+                                           CheckerContext &C) const {
+  const LocationContext *LeakContext = N->getLocationContext();
+  // Walk the ExplodedGraph backwards and find the first node that referred to
+  // the tracked symbol.
+  const ExplodedNode *AllocNode = N;
+
+  while (N) {
+    if (!N->getState()->get<AllocatedData>(Sym))
+      break;
+    // Allocation node, is the last node in the current context in which the
+    // symbol was tracked.
+    if (N->getLocationContext() == LeakContext)
+      AllocNode = N;
+    N = N->pred_empty() ? NULL : *(N->pred_begin());
+  }
+
+  ProgramPoint P = AllocNode->getLocation();
+  if (!isa<StmtPoint>(P))
+    return 0;
+  return cast<clang::PostStmt>(P).getStmt();
+}
+
 BugReport *MacOSKeychainAPIChecker::
   generateAllocatedDataNotReleasedReport(const AllocationPair &AP,
-                                         ExplodedNode *N) const {
+                                         ExplodedNode *N,
+                                         CheckerContext &C) const {
   const ADFunctionInfo &FI = FunctionsToTrack[AP.second->AllocatorIdx];
   initBugType();
   SmallString<70> sbuf;
   llvm::raw_svector_ostream os(sbuf);
-
   os << "Allocated data is not released: missing a call to '"
       << FunctionsToTrack[FI.DeallocatorIdx].Name << "'.";
-  BugReport *Report = new BugReport(*BT, os.str(), N);
+
+  // Most bug reports are cached at the location where they occurred.
+  // With leaks, we want to unique them by the location where they were
+  // allocated, and only report a single path.
+  PathDiagnosticLocation LocUsedForUniqueing;
+  if (const Stmt *AllocStmt = getAllocationSite(N, AP.first, C))
+    LocUsedForUniqueing = PathDiagnosticLocation::createBegin(AllocStmt,
+                            C.getSourceManager(), N->getLocationContext());
+
+  BugReport *Report = new BugReport(*BT, os.str(), N, LocUsedForUniqueing);
   Report->addVisitor(new SecKeychainBugVisitor(AP.first));
-  Report->addRange(SourceRange());
   return Report;
 }
 
@@ -536,27 +575,31 @@
       continue;
     Errors.push_back(std::make_pair(I->first, &I->second));
   }
-  if (!Changed)
+  if (!Changed) {
+    // Generate the new, cleaned up state.
+    C.addTransition(State);
     return;
+  }
 
-  // Generate the new, cleaned up state.
-  ExplodedNode *N = C.addTransition(State);
-  if (!N)
-    return;
+  static SimpleProgramPointTag Tag("MacOSKeychainAPIChecker : DeadSymbolsLeak");
+  ExplodedNode *N = C.addTransition(C.getState(), C.getPredecessor(), &Tag);
 
   // Generate the error reports.
   for (AllocationPairVec::iterator I = Errors.begin(), E = Errors.end();
                                                        I != E; ++I) {
-    C.EmitReport(generateAllocatedDataNotReleasedReport(*I, N));
+    C.EmitReport(generateAllocatedDataNotReleasedReport(*I, N, C));
   }
+
+  // Generate the new, cleaned up state.
+  C.addTransition(State, N);
 }
 
 // TODO: Remove this after we ensure that checkDeadSymbols are always called.
-void MacOSKeychainAPIChecker::checkEndPath(CheckerContext &Ctx) const {
-  ProgramStateRef state = Ctx.getState();
+void MacOSKeychainAPIChecker::checkEndPath(CheckerContext &C) const {
+  ProgramStateRef state = C.getState();
 
   // If inside inlined call, skip it.
-  if (Ctx.getLocationContext()->getParent() != 0)
+  if (C.getLocationContext()->getParent() != 0)
     return;
 
   AllocatedSetTy AS = state->get<AllocatedData>();
@@ -574,25 +617,28 @@
     // allocation, do not report.
     if (state->getSymVal(I.getKey()) ||
         definitelyReturnedError(I->second.Region, state,
-                                Ctx.getSValBuilder())) {
+                                C.getSValBuilder())) {
       continue;
     }
     Errors.push_back(std::make_pair(I->first, &I->second));
   }
 
   // If no change, do not generate a new state.
-  if (!Changed)
+  if (!Changed) {
+    C.addTransition(state);
     return;
+  }
 
-  ExplodedNode *N = Ctx.addTransition(state);
-  if (!N)
-    return;
+  static SimpleProgramPointTag Tag("MacOSKeychainAPIChecker : EndPathLeak");
+  ExplodedNode *N = C.addTransition(C.getState(), C.getPredecessor(), &Tag);
 
   // Generate the error reports.
   for (AllocationPairVec::iterator I = Errors.begin(), E = Errors.end();
                                                        I != E; ++I) {
-    Ctx.EmitReport(generateAllocatedDataNotReleasedReport(*I, N));
+    C.EmitReport(generateAllocatedDataNotReleasedReport(*I, N, C));
   }
+
+  C.addTransition(state, N);
 }
 
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Tue Feb 28 17:49:25 2012
@@ -26,6 +26,8 @@
 #include "llvm/ADT/ImmutableMap.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/STLExtras.h"
+#include <climits>
+
 using namespace clang;
 using namespace ento;
 
@@ -97,11 +99,13 @@
   mutable OwningPtr<BugType> BT_UseFree;
   mutable OwningPtr<BugType> BT_BadFree;
   mutable IdentifierInfo *II_malloc, *II_free, *II_realloc, *II_calloc,
-                         *II_valloc, *II_reallocf;
+                         *II_valloc, *II_reallocf, *II_strndup, *II_strdup;
+
+  static const unsigned InvalidArgIndex = UINT_MAX;
 
 public:
   MallocChecker() : II_malloc(0), II_free(0), II_realloc(0), II_calloc(0),
-                    II_valloc(0), II_reallocf(0) {}
+                    II_valloc(0), II_reallocf(0), II_strndup(0), II_strdup(0) {}
 
   /// In pessimistic mode, the checker assumes that it does not know which
   /// functions might free the memory.
@@ -140,9 +144,9 @@
   /// pointed to by one of its arguments.
   bool isMemFunction(const FunctionDecl *FD, ASTContext &C) const;
 
-  static void MallocMem(CheckerContext &C, const CallExpr *CE);
-  static void MallocMemReturnsAttr(CheckerContext &C, const CallExpr *CE,
-                                   const OwnershipAttr* Att);
+  static ProgramStateRef MallocMemReturnsAttr(CheckerContext &C,
+                                              const CallExpr *CE,
+                                              const OwnershipAttr* Att);
   static ProgramStateRef MallocMemAux(CheckerContext &C, const CallExpr *CE,
                                      const Expr *SizeEx, SVal Init,
                                      ProgramStateRef state) {
@@ -150,20 +154,25 @@
                         state->getSVal(SizeEx, C.getLocationContext()),
                         Init, state);
   }
+
   static ProgramStateRef MallocMemAux(CheckerContext &C, const CallExpr *CE,
                                      SVal SizeEx, SVal Init,
                                      ProgramStateRef state);
 
-  void FreeMem(CheckerContext &C, const CallExpr *CE) const;
-  void FreeMemAttr(CheckerContext &C, const CallExpr *CE,
-                   const OwnershipAttr* Att) const;
+  /// Update the RefState to reflect the new memory allocation.
+  static ProgramStateRef MallocUpdateRefState(CheckerContext &C,
+                                              const CallExpr *CE,
+                                              ProgramStateRef state);
+
+  ProgramStateRef FreeMemAttr(CheckerContext &C, const CallExpr *CE,
+                              const OwnershipAttr* Att) const;
   ProgramStateRef FreeMemAux(CheckerContext &C, const CallExpr *CE,
                                  ProgramStateRef state, unsigned Num,
                                  bool Hold) const;
 
-  void ReallocMem(CheckerContext &C, const CallExpr *CE,
-                  bool FreesMemOnFailure) const;
-  static void CallocMem(CheckerContext &C, const CallExpr *CE);
+  ProgramStateRef ReallocMem(CheckerContext &C, const CallExpr *CE,
+                             bool FreesMemOnFailure) const;
+  static ProgramStateRef CallocMem(CheckerContext &C, const CallExpr *CE);
   
   bool checkEscape(SymbolRef Sym, const Stmt *S, CheckerContext &C) const;
   bool checkUseAfterFree(SymbolRef Sym, CheckerContext &C,
@@ -171,12 +180,18 @@
 
   /// Check if the function is not known to us. So, for example, we could
   /// conservatively assume it can free/reallocate it's pointer arguments.
-  bool hasUnknownBehavior(const FunctionDecl *FD, ProgramStateRef State) const;
+  bool doesNotFreeMemory(const CallOrObjCMessage *Call,
+                         ProgramStateRef State) const;
 
   static bool SummarizeValue(raw_ostream &os, SVal V);
   static bool SummarizeRegion(raw_ostream &os, const MemRegion *MR);
   void ReportBadFree(CheckerContext &C, SVal ArgVal, SourceRange range) const;
 
+  /// Find the location of the allocation for Sym on the path leading to the
+  /// exploded node N.
+  const Stmt *getAllocationSite(const ExplodedNode *N, SymbolRef Sym,
+                                CheckerContext &C) const;
+
   void reportLeak(SymbolRef Sym, ExplodedNode *N, CheckerContext &C) const;
 
   /// The bug visitor which allows us to print extra diagnostics along the
@@ -283,6 +298,10 @@
     II_calloc = &Ctx.Idents.get("calloc");
   if (!II_valloc)
     II_valloc = &Ctx.Idents.get("valloc");
+  if (!II_strdup)
+    II_strdup = &Ctx.Idents.get("strdup");
+  if (!II_strndup)
+    II_strndup = &Ctx.Idents.get("strndup");
 }
 
 bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext &C) const {
@@ -294,9 +313,9 @@
 
   initIdentifierInfo(C);
 
-  // TODO: Add more here : ex: reallocf!
   if (FunI == II_malloc || FunI == II_free || FunI == II_realloc ||
-      FunI == II_reallocf || FunI == II_calloc || FunI == II_valloc)
+      FunI == II_reallocf || FunI == II_calloc || FunI == II_valloc ||
+      FunI == II_strdup || FunI == II_strndup)
     return true;
 
   if (Filter.CMallocOptimistic && FD->hasAttrs() &&
@@ -318,75 +337,60 @@
   if (!FunI)
     return;
 
+  ProgramStateRef State = C.getState();
   if (FunI == II_malloc || FunI == II_valloc) {
-    MallocMem(C, CE);
-    return;
+    State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State);
   } else if (FunI == II_realloc) {
-    ReallocMem(C, CE, false);
-    return;
+    State = ReallocMem(C, CE, false);
   } else if (FunI == II_reallocf) {
-    ReallocMem(C, CE, true);
-    return;
+    State = ReallocMem(C, CE, true);
   } else if (FunI == II_calloc) {
-    CallocMem(C, CE);
-    return;
-  }else if (FunI == II_free) {
-    FreeMem(C, CE);
-    return;
-  }
-
-  if (Filter.CMallocOptimistic)
-  // Check all the attributes, if there are any.
-  // There can be multiple of these attributes.
-  if (FD->hasAttrs()) {
-    for (specific_attr_iterator<OwnershipAttr>
-                  i = FD->specific_attr_begin<OwnershipAttr>(),
-                  e = FD->specific_attr_end<OwnershipAttr>();
-         i != e; ++i) {
-      switch ((*i)->getOwnKind()) {
-      case OwnershipAttr::Returns: {
-        MallocMemReturnsAttr(C, CE, *i);
-        return;
-      }
-      case OwnershipAttr::Takes:
-      case OwnershipAttr::Holds: {
-        FreeMemAttr(C, CE, *i);
-        return;
-      }
+    State = CallocMem(C, CE);
+  } else if (FunI == II_free) {
+    State = FreeMemAux(C, CE, C.getState(), 0, false);
+  } else if (FunI == II_strdup) {
+    State = MallocUpdateRefState(C, CE, State);
+  } else if (FunI == II_strndup) {
+    State = MallocUpdateRefState(C, CE, State);
+  } else if (Filter.CMallocOptimistic) {
+    // Check all the attributes, if there are any.
+    // There can be multiple of these attributes.
+    if (FD->hasAttrs())
+      for (specific_attr_iterator<OwnershipAttr>
+          i = FD->specific_attr_begin<OwnershipAttr>(),
+          e = FD->specific_attr_end<OwnershipAttr>();
+          i != e; ++i) {
+        switch ((*i)->getOwnKind()) {
+        case OwnershipAttr::Returns:
+          State = MallocMemReturnsAttr(C, CE, *i);
+          break;
+        case OwnershipAttr::Takes:
+        case OwnershipAttr::Holds:
+          State = FreeMemAttr(C, CE, *i);
+          break;
+        }
       }
-    }
   }
+  C.addTransition(State);
 }
 
-void MallocChecker::MallocMem(CheckerContext &C, const CallExpr *CE) {
-  ProgramStateRef state = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(),
-                                      C.getState());
-  C.addTransition(state);
-}
-
-void MallocChecker::MallocMemReturnsAttr(CheckerContext &C, const CallExpr *CE,
-                                         const OwnershipAttr* Att) {
+ProgramStateRef MallocChecker::MallocMemReturnsAttr(CheckerContext &C,
+                                                    const CallExpr *CE,
+                                                    const OwnershipAttr* Att) {
   if (Att->getModule() != "malloc")
-    return;
+    return 0;
 
   OwnershipAttr::args_iterator I = Att->args_begin(), E = Att->args_end();
   if (I != E) {
-    ProgramStateRef state =
-        MallocMemAux(C, CE, CE->getArg(*I), UndefinedVal(), C.getState());
-    C.addTransition(state);
-    return;
+    return MallocMemAux(C, CE, CE->getArg(*I), UndefinedVal(), C.getState());
   }
-  ProgramStateRef state = MallocMemAux(C, CE, UnknownVal(), UndefinedVal(),
-                                        C.getState());
-  C.addTransition(state);
+  return MallocMemAux(C, CE, UnknownVal(), UndefinedVal(), C.getState());
 }
 
 ProgramStateRef MallocChecker::MallocMemAux(CheckerContext &C,
                                            const CallExpr *CE,
                                            SVal Size, SVal Init,
                                            ProgramStateRef state) {
-  SValBuilder &svalBuilder = C.getSValBuilder();
-
   // Get the return value.
   SVal retVal = state->getSVal(CE, C.getLocationContext());
 
@@ -400,44 +404,52 @@
   // Set the region's extent equal to the Size parameter.
   const SymbolicRegion *R =
       dyn_cast_or_null<SymbolicRegion>(retVal.getAsRegion());
-  if (!R || !isa<DefinedOrUnknownSVal>(Size))
+  if (!R)
     return 0;
+  if (isa<DefinedOrUnknownSVal>(Size)) {
+    SValBuilder &svalBuilder = C.getSValBuilder();
+    DefinedOrUnknownSVal Extent = R->getExtent(svalBuilder);
+    DefinedOrUnknownSVal DefinedSize = cast<DefinedOrUnknownSVal>(Size);
+    DefinedOrUnknownSVal extentMatchesSize =
+        svalBuilder.evalEQ(state, Extent, DefinedSize);
 
-  DefinedOrUnknownSVal Extent = R->getExtent(svalBuilder);
-  DefinedOrUnknownSVal DefinedSize = cast<DefinedOrUnknownSVal>(Size);
-  DefinedOrUnknownSVal extentMatchesSize =
-    svalBuilder.evalEQ(state, Extent, DefinedSize);
-
-  state = state->assume(extentMatchesSize, true);
-  assert(state);
+    state = state->assume(extentMatchesSize, true);
+    assert(state);
+  }
   
+  return MallocUpdateRefState(C, CE, state);
+}
+
+ProgramStateRef MallocChecker::MallocUpdateRefState(CheckerContext &C,
+                                                    const CallExpr *CE,
+                                                    ProgramStateRef state) {
+  // Get the return value.
+  SVal retVal = state->getSVal(CE, C.getLocationContext());
+
+  // We expect the malloc functions to return a pointer.
+  if (!isa<Loc>(retVal))
+    return 0;
+
   SymbolRef Sym = retVal.getAsLocSymbol();
   assert(Sym);
 
   // Set the symbol's state to Allocated.
   return state->set<RegionState>(Sym, RefState::getAllocateUnchecked(CE));
-}
-
-void MallocChecker::FreeMem(CheckerContext &C, const CallExpr *CE) const {
-  ProgramStateRef state = FreeMemAux(C, CE, C.getState(), 0, false);
 
-  if (state)
-    C.addTransition(state);
 }
 
-void MallocChecker::FreeMemAttr(CheckerContext &C, const CallExpr *CE,
-                                const OwnershipAttr* Att) const {
+ProgramStateRef MallocChecker::FreeMemAttr(CheckerContext &C,
+                                           const CallExpr *CE,
+                                           const OwnershipAttr* Att) const {
   if (Att->getModule() != "malloc")
-    return;
+    return 0;
 
   for (OwnershipAttr::args_iterator I = Att->args_begin(), E = Att->args_end();
        I != E; ++I) {
-    ProgramStateRef state =
-      FreeMemAux(C, CE, C.getState(), *I,
-                 Att->getOwnKind() == OwnershipAttr::Holds);
-    if (state)
-      C.addTransition(state);
+    return FreeMemAux(C, CE, C.getState(), *I,
+                      Att->getOwnKind() == OwnershipAttr::Holds);
   }
+  return 0;
 }
 
 ProgramStateRef MallocChecker::FreeMemAux(CheckerContext &C,
@@ -660,14 +672,15 @@
   }
 }
 
-void MallocChecker::ReallocMem(CheckerContext &C, const CallExpr *CE,
-                               bool FreesOnFail) const {
+ProgramStateRef MallocChecker::ReallocMem(CheckerContext &C,
+                                          const CallExpr *CE,
+                                          bool FreesOnFail) const {
   ProgramStateRef state = C.getState();
   const Expr *arg0Expr = CE->getArg(0);
   const LocationContext *LCtx = C.getLocationContext();
   SVal Arg0Val = state->getSVal(arg0Expr, LCtx);
   if (!isa<DefinedOrUnknownSVal>(Arg0Val))
-    return;
+    return 0;
   DefinedOrUnknownSVal arg0Val = cast<DefinedOrUnknownSVal>(Arg0Val);
 
   SValBuilder &svalBuilder = C.getSValBuilder();
@@ -678,12 +691,12 @@
   // Get the size argument. If there is no size arg then give up.
   const Expr *Arg1 = CE->getArg(1);
   if (!Arg1)
-    return;
+    return 0;
 
   // Get the value of the size argument.
   SVal Arg1ValG = state->getSVal(Arg1, LCtx);
   if (!isa<DefinedOrUnknownSVal>(Arg1ValG))
-    return;
+    return 0;
   DefinedOrUnknownSVal Arg1Val = cast<DefinedOrUnknownSVal>(Arg1ValG);
 
   // Compare the size argument to 0.
@@ -703,14 +716,13 @@
   // If the ptr is NULL and the size is not 0, the call is equivalent to 
   // malloc(size).
   if ( PrtIsNull && !SizeIsZero) {
-    ProgramStateRef stateMalloc = MallocMemAux(C, CE, CE->getArg(1), 
+    ProgramStateRef stateMalloc = MallocMemAux(C, CE, CE->getArg(1),
                                                UndefinedVal(), StatePtrIsNull);
-    C.addTransition(stateMalloc);
-    return;
+    return stateMalloc;
   }
 
   if (PrtIsNull && SizeIsZero)
-    return;
+    return 0;
 
   // Get the from and to pointer symbols as in toPtr = realloc(fromPtr, size).
   assert(!PrtIsNull);
@@ -718,7 +730,7 @@
   SVal RetVal = state->getSVal(CE, LCtx);
   SymbolRef ToPtr = RetVal.getAsSymbol();
   if (!FromPtr || !ToPtr)
-    return;
+    return 0;
 
   // If the size is 0, free the memory.
   if (SizeIsZero)
@@ -729,8 +741,7 @@
       stateFree = stateFree->set<ReallocPairs>(ToPtr,
                                             ReallocPair(FromPtr, FreesOnFail));
       C.getSymbolManager().addSymbolDependency(ToPtr, FromPtr);
-      C.addTransition(stateFree);
-      return;
+      return stateFree;
     }
 
   // Default behavior.
@@ -739,16 +750,16 @@
     ProgramStateRef stateRealloc = MallocMemAux(C, CE, CE->getArg(1),
                                                 UnknownVal(), stateFree);
     if (!stateRealloc)
-      return;
+      return 0;
     stateRealloc = stateRealloc->set<ReallocPairs>(ToPtr,
                                             ReallocPair(FromPtr, FreesOnFail));
     C.getSymbolManager().addSymbolDependency(ToPtr, FromPtr);
-    C.addTransition(stateRealloc);
-    return;
+    return stateRealloc;
   }
+  return 0;
 }
 
-void MallocChecker::CallocMem(CheckerContext &C, const CallExpr *CE) {
+ProgramStateRef MallocChecker::CallocMem(CheckerContext &C, const CallExpr *CE){
   ProgramStateRef state = C.getState();
   SValBuilder &svalBuilder = C.getSValBuilder();
   const LocationContext *LCtx = C.getLocationContext();
@@ -758,7 +769,32 @@
                                         svalBuilder.getContext().getSizeType());  
   SVal zeroVal = svalBuilder.makeZeroVal(svalBuilder.getContext().CharTy);
 
-  C.addTransition(MallocMemAux(C, CE, TotalSize, zeroVal, state));
+  return MallocMemAux(C, CE, TotalSize, zeroVal, state);
+}
+
+const Stmt *
+MallocChecker::getAllocationSite(const ExplodedNode *N, SymbolRef Sym,
+                                 CheckerContext &C) const {
+  const LocationContext *LeakContext = N->getLocationContext();
+  // Walk the ExplodedGraph backwards and find the first node that referred to
+  // the tracked symbol.
+  const ExplodedNode *AllocNode = N;
+
+  while (N) {
+    if (!N->getState()->get<RegionState>(Sym))
+      break;
+    // Allocation node, is the last node in the current context in which the
+    // symbol was tracked.
+    if (N->getLocationContext() == LeakContext)
+      AllocNode = N;
+    N = N->pred_empty() ? NULL : *(N->pred_begin());
+  }
+
+  ProgramPoint P = AllocNode->getLocation();
+  if (!isa<StmtPoint>(P))
+    return 0;
+
+  return cast<StmtPoint>(P).getStmt();
 }
 
 void MallocChecker::reportLeak(SymbolRef Sym, ExplodedNode *N,
@@ -774,8 +810,16 @@
     BT_Leak->setSuppressOnSink(true);
   }
 
+  // Most bug reports are cached at the location where they occurred.
+  // With leaks, we want to unique them by the location where they were
+  // allocated, and only report a single path.
+  PathDiagnosticLocation LocUsedForUniqueing;
+  if (const Stmt *AllocStmt = getAllocationSite(N, Sym, C))
+    LocUsedForUniqueing = PathDiagnosticLocation::createBegin(AllocStmt,
+                            C.getSourceManager(), N->getLocationContext());
+
   BugReport *R = new BugReport(*BT_Leak,
-                  "Memory is never released; potential memory leak", N);
+    "Memory is never released; potential memory leak", N, LocUsedForUniqueing);
   R->addVisitor(new MallocBugVisitor(Sym));
   C.EmitReport(R);
 }
@@ -813,14 +857,17 @@
     }
   }
 
-  ExplodedNode *N = C.addTransition(state->set<RegionState>(RS));
+  // Generate leak node.
+  static SimpleProgramPointTag Tag("MallocChecker : DeadSymbolsLeak");
+  ExplodedNode *N = C.addTransition(C.getState(), C.getPredecessor(), &Tag);
 
-  if (N && generateReport) {
+  if (generateReport) {
     for (llvm::SmallVector<SymbolRef, 2>::iterator
          I = Errors.begin(), E = Errors.end(); I != E; ++I) {
       reportLeak(*I, N, C);
     }
   }
+  C.addTransition(state->set<RegionState>(RS), N);
 }
 
 void MallocChecker::checkEndPath(CheckerContext &C) const {
@@ -881,7 +928,17 @@
     return;
 
   // Check if we are returning a symbol.
-  SymbolRef Sym = C.getState()->getSVal(E, C.getLocationContext()).getAsSymbol();
+  SVal RetVal = C.getState()->getSVal(E, C.getLocationContext());
+  SymbolRef Sym = RetVal.getAsSymbol();
+  if (!Sym)
+    // If we are returning a field of the allocated struct or an array element,
+    // the callee could still free the memory.
+    // TODO: This logic should be a part of generic symbol escape callback.
+    if (const MemRegion *MR = RetVal.getAsRegion())
+      if (isa<FieldRegion>(MR) || isa<ElementRegion>(MR))
+        if (const SymbolicRegion *BMR =
+              dyn_cast<SymbolicRegion>(MR->getBaseRegion()))
+          Sym = BMR->getSymbol();
   if (!Sym)
     return;
 
@@ -1004,28 +1061,93 @@
   return state;
 }
 
-// Check if the function is not known to us. So, for example, we could
+// Check if the function is known to us. So, for example, we could
 // conservatively assume it can free/reallocate it's pointer arguments.
 // (We assume that the pointers cannot escape through calls to system
 // functions not handled by this checker.)
-bool MallocChecker::hasUnknownBehavior(const FunctionDecl *FD,
-                                       ProgramStateRef State) const {
-  ASTContext &ASTC = State->getStateManager().getContext();
+bool MallocChecker::doesNotFreeMemory(const CallOrObjCMessage *Call,
+                                      ProgramStateRef State) const {
+  if (!Call)
+    return false;
 
-  // If it's one of the allocation functions we can reason about, we model it's
-  // behavior explicitly.
-  if (isMemFunction(FD, ASTC)) {
+  // For now, assume that any C++ call can free memory.
+  // TODO: If we want to be more optimistic here, we'll need to make sure that
+  // regions escape to C++ containers. They seem to do that even now, but for
+  // mysterious reasons.
+  if (Call->isCXXCall())
     return false;
+
+  const Decl *D = Call->getDecl();
+  if (!D)
+    return false;
+
+  ASTContext &ASTC = State->getStateManager().getContext();
+
+  // If it's one of the allocation functions we can reason about, we model
+  // it's behavior explicitly.
+  if (isa<FunctionDecl>(D) && isMemFunction(cast<FunctionDecl>(D), ASTC)) {
+    return true;
   }
 
-  // If it's a system call, we know it does not free the memory.
+  // If it's not a system call, assume it frees memory.
   SourceManager &SM = ASTC.getSourceManager();
-  if (SM.isInSystemHeader(FD->getLocation())) {
+  if (!SM.isInSystemHeader(D->getLocation()))
     return false;
+
+  // Process C/ObjC functions.
+  if (const FunctionDecl *FD  = dyn_cast_or_null<FunctionDecl>(D)) {
+    // White list the system functions whose arguments escape.
+    const IdentifierInfo *II = FD->getIdentifier();
+    if (!II)
+      return true;
+    StringRef FName = II->getName();
+
+    // White list thread local storage.
+    if (FName.equals("pthread_setspecific"))
+      return false;
+
+    // White list the 'XXXNoCopy' ObjC Methods.
+    if (FName.endswith("NoCopy")) {
+      // Look for the deallocator argument. We know that the memory ownership
+      // is not transfered only if the deallocator argument is
+      // 'kCFAllocatorNull'.
+      for (unsigned i = 1; i < Call->getNumArgs(); ++i) {
+        const Expr *ArgE = Call->getArg(i)->IgnoreParenCasts();
+        if (const DeclRefExpr *DE = dyn_cast<DeclRefExpr>(ArgE)) {
+          StringRef DeallocatorName = DE->getFoundDecl()->getName();
+          if (DeallocatorName == "kCFAllocatorNull")
+            return true;
+        }
+      }
+      return false;
+    }
+
+    // Otherwise, assume that the function does not free memory.
+    // Most system calls, do not free the memory.
+    return true;
+
+  // Process ObjC functions.
+  } else if (const ObjCMethodDecl * ObjCD = dyn_cast<ObjCMethodDecl>(D)) {
+    Selector S = ObjCD->getSelector();
+
+    // White list the ObjC functions which do free memory.
+    // - Anything containing 'freeWhenDone' param set to 1.
+    //   Ex: dataWithBytesNoCopy:length:freeWhenDone.
+    for (unsigned i = 1; i < S.getNumArgs(); ++i) {
+      if (S.getNameForSlot(i).equals("freeWhenDone")) {
+        if (Call->getArgSVal(i).isConstant(1))
+          return false;
+      }
+    }
+
+    // Otherwise, assume that the function does not free memory.
+    // Most system calls, do not free the memory.
+    return true;
   }
 
   // Otherwise, assume that the function can free memory.
-  return true;
+  return false;
+
 }
 
 // If the symbol we are tracking is invalidated, but not explicitly (ex: the &p
@@ -1037,17 +1159,15 @@
                                     ArrayRef<const MemRegion *> ExplicitRegions,
                                     ArrayRef<const MemRegion *> Regions,
                                     const CallOrObjCMessage *Call) const {
-  if (!invalidated)
+  if (!invalidated || invalidated->empty())
     return State;
   llvm::SmallPtrSet<SymbolRef, 8> WhitelistedSymbols;
 
-  const FunctionDecl *FD = (Call ?
-                            dyn_cast_or_null<FunctionDecl>(Call->getDecl()) :0);
-
   // If it's a call which might free or reallocate memory, we assume that all
-  // regions (explicit and implicit) escaped. Otherwise, whitelist explicit
-  // pointers; we still can track them.
-  if (!(FD && hasUnknownBehavior(FD, State))) {
+  // regions (explicit and implicit) escaped.
+
+  // Otherwise, whitelist explicit pointers; we still can track them.
+  if (!Call || doesNotFreeMemory(Call, State)) {
     for (ArrayRef<const MemRegion *>::iterator I = ExplicitRegions.begin(),
         E = ExplicitRegions.end(); I != E; ++I) {
       if (const SymbolicRegion *R = (*I)->StripCasts()->getAs<SymbolicRegion>())

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Tue Feb 28 17:49:25 2012
@@ -2114,14 +2114,16 @@
   };
 }
 
+// Find the first node in the current function context that referred to the
+// tracked symbol and the memory location that value was stored to. Note, the
+// value is only reported if the allocation occurred in the same function as
+// the leak.
 static std::pair<const ExplodedNode*,const MemRegion*>
 GetAllocationSite(ProgramStateManager& StateMgr, const ExplodedNode *N,
                   SymbolRef Sym) {
-
-  // Find both first node that referred to the tracked symbol and the
-  // memory location that value was store to.
   const ExplodedNode *Last = N;
   const MemRegion* FirstBinding = 0;
+  const LocationContext *LeakContext = N->getLocationContext();
 
   while (N) {
     ProgramStateRef St = N->getState();
@@ -2134,10 +2136,20 @@
     StateMgr.iterBindings(St, FB);
     if (FB) FirstBinding = FB.getRegion();
 
-    Last = N;
+    // Allocation node, is the last node in the current context in which the
+    // symbol was tracked.
+    if (N->getLocationContext() == LeakContext)
+      Last = N;
+
     N = N->pred_empty() ? NULL : *(N->pred_begin());
   }
 
+  // If allocation happened in a function different from the leak node context,
+  // do not report the binding.
+  if (N->getLocationContext() != LeakContext) {
+    FirstBinding = 0;
+  }
+
   return std::make_pair(Last, FirstBinding);
 }
 
@@ -2257,15 +2269,14 @@
   // Fill in the description of the bug.
   Description.clear();
   llvm::raw_string_ostream os(Description);
-  unsigned AllocLine = SMgr.getExpansionLineNumber(AllocStmt->getLocStart());
   os << "Potential leak ";
   if (GCEnabled)
     os << "(when using garbage collection) ";
-  os << "of an object allocated on line " << AllocLine;
+  os << "of an object";
 
   // FIXME: AllocBinding doesn't get populated for RegionStore yet.
   if (AllocBinding)
-    os << " and stored into '" << AllocBinding->getString() << '\'';
+    os << " stored into '" << AllocBinding->getString() << '\'';
 
   addVisitor(new CFRefLeakReportVisitor(sym, GCEnabled, Log));
 }
@@ -3069,8 +3080,23 @@
 // Handle return statements.
 //===----------------------------------------------------------------------===//
 
+// Return true if the current LocationContext has no caller context.
+static bool inTopFrame(CheckerContext &C) {
+  const LocationContext *LC = C.getLocationContext();
+  return LC->getParent() == 0;  
+}
+
 void RetainCountChecker::checkPreStmt(const ReturnStmt *S,
                                       CheckerContext &C) const {
+
+  // Only adjust the reference count if this is the top-level call frame,
+  // and not the result of inlining.  In the future, we should do
+  // better checking even for inlined calls, and see if they match
+  // with their expected semantics (e.g., the method should return a retained
+  // object, etc.).
+  if (!inTopFrame(C))
+    return;
+
   const Expr *RetE = S->getRetValue();
   if (!RetE)
     return;

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp Tue Feb 28 17:49:25 2012
@@ -15,7 +15,7 @@
 #include "ClangSACheckers.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtVisitor.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp Tue Feb 28 17:49:25 2012
@@ -136,11 +136,14 @@
   OwningPtr<ParentMap> PM;
   NodeMapClosure NMC;
 public:
+  const LocationContext *LC;
+  
   PathDiagnosticBuilder(GRBugReporter &br,
                         BugReport *r, NodeBackMap *Backmap,
                         PathDiagnosticConsumer *pdc)
     : BugReporterContext(br),
-      R(r), PDC(pdc), NMC(Backmap) {}
+      R(r), PDC(pdc), NMC(Backmap), LC(r->getErrorNode()->getLocationContext())
+  {}
 
   PathDiagnosticLocation ExecutionContinues(const ExplodedNode *N);
 
@@ -150,12 +153,8 @@
   BugReport *getBugReport() { return R; }
 
   Decl const &getCodeDecl() { return R->getErrorNode()->getCodeDecl(); }
-
-  const LocationContext* getLocationContext() {
-    return R->getErrorNode()->getLocationContext();
-  }
-
-  ParentMap& getParentMap() { return R->getErrorNode()->getParentMap(); }
+  
+  ParentMap& getParentMap() { return LC->getParentMap(); }
 
   const Stmt *getParent(const Stmt *S) {
     return getParentMap().getParent(S);
@@ -178,7 +177,7 @@
 PathDiagnosticLocation
 PathDiagnosticBuilder::ExecutionContinues(const ExplodedNode *N) {
   if (const Stmt *S = GetNextStmt(N))
-    return PathDiagnosticLocation(S, getSourceManager(), getLocationContext());
+    return PathDiagnosticLocation(S, getSourceManager(), LC);
 
   return PathDiagnosticLocation::createDeclEnd(N->getLocationContext(),
                                                getSourceManager());
@@ -239,7 +238,6 @@
   assert(S && "Null Stmt *passed to getEnclosingStmtLocation");
   ParentMap &P = getParentMap();
   SourceManager &SMgr = getSourceManager();
-  const LocationContext *LC = getLocationContext();
 
   while (IsNested(S, P)) {
     const Stmt *Parent = P.getParentIgnoreParens(S);
@@ -447,7 +445,7 @@
       PathDiagnosticLocation L =
         PathDiagnosticLocation::createBegin(S, BR.getSourceManager(),
                                                    Pred->getLocationContext());
-      PD.path.push_front(new PathDiagnosticEventPiece(L, os.str()));
+      PD.getActivePath().push_front(new PathDiagnosticEventPiece(L, os.str()));
     }
 
     return true;
@@ -521,14 +519,41 @@
                                           const ExplodedNode *N) {
 
   SourceManager& SMgr = PDB.getSourceManager();
-  const LocationContext *LC = PDB.getLocationContext();
+  const LocationContext *LC = PDB.LC;
   const ExplodedNode *NextNode = N->pred_empty()
                                         ? NULL : *(N->pred_begin());
   while (NextNode) {
     N = NextNode;
+    PDB.LC = N->getLocationContext();
     NextNode = GetPredecessorNode(N);
 
     ProgramPoint P = N->getLocation();
+    
+    if (const CallExit *CE = dyn_cast<CallExit>(&P)) {
+      PathDiagnosticCallPiece *C =
+        PathDiagnosticCallPiece::construct(N, *CE, SMgr);
+      PD.getActivePath().push_front(C);
+      PD.pushActivePath(&C->path);
+      continue;      
+    }
+    
+    if (const CallEnter *CE = dyn_cast<CallEnter>(&P)) {
+      PD.popActivePath();
+      // The current active path should never be empty.  Either we
+      // just added a bunch of stuff to the top-level path, or
+      // we have a previous CallExit.  If the front of the active
+      // path is not a PathDiagnosticCallPiece, it means that the
+      // path terminated within a function call.  We must then take the
+      // current contents of the active path and place it within
+      // a new PathDiagnosticCallPiece.
+      assert(!PD.getActivePath().empty());
+      PathDiagnosticCallPiece *C = 
+        dyn_cast<PathDiagnosticCallPiece>(PD.getActivePath().front());
+      if (!C)
+        C = PathDiagnosticCallPiece::construct(PD.getActivePath());
+      C->setCallee(*CE, SMgr);
+      continue;
+    }
 
     if (const BlockEdge *BE = dyn_cast<BlockEdge>(&P)) {
       const CFGBlock *Src = BE->getSrc();
@@ -559,7 +584,7 @@
 
           os << "Control jumps to line "
           << End.asLocation().getExpansionLineNumber();
-          PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+          PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                                 os.str()));
           break;
         }
@@ -611,13 +636,13 @@
                 break;
               }
             }
-            PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+            PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                              os.str()));
           }
           else {
             os << "'Default' branch taken. ";
             const PathDiagnosticLocation &End = PDB.ExecutionContinues(os, N);
-            PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+            PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                              os.str()));
           }
 
@@ -629,7 +654,7 @@
           std::string sbuf;
           llvm::raw_string_ostream os(sbuf);
           PathDiagnosticLocation End = PDB.ExecutionContinues(os, N);
-          PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+          PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                            os.str()));
           break;
         }
@@ -651,7 +676,7 @@
           if (const Stmt *S = End.asStmt())
             End = PDB.getEnclosingStmtLocation(S);
 
-          PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+          PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                            os.str()));
           break;
         }
@@ -674,14 +699,14 @@
               PathDiagnosticLocation End(B->getLHS(), SMgr, LC);
               PathDiagnosticLocation Start =
                 PathDiagnosticLocation::createOperatorLoc(B, SMgr);
-              PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+              PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                                os.str()));
             }
             else {
               os << "true";
               PathDiagnosticLocation Start(B->getLHS(), SMgr, LC);
               PathDiagnosticLocation End = PDB.ExecutionContinues(N);
-              PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+              PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                                os.str()));
             }
           }
@@ -693,7 +718,7 @@
               os << "false";
               PathDiagnosticLocation Start(B->getLHS(), SMgr, LC);
               PathDiagnosticLocation End = PDB.ExecutionContinues(N);
-              PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+              PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                                os.str()));
             }
             else {
@@ -701,7 +726,7 @@
               PathDiagnosticLocation End(B->getLHS(), SMgr, LC);
               PathDiagnosticLocation Start =
                 PathDiagnosticLocation::createOperatorLoc(B, SMgr);
-              PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+              PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                                os.str()));
             }
           }
@@ -720,7 +745,7 @@
             if (const Stmt *S = End.asStmt())
               End = PDB.getEnclosingStmtLocation(S);
 
-            PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+            PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                              os.str()));
           }
           else {
@@ -729,7 +754,7 @@
             if (const Stmt *S = End.asStmt())
               End = PDB.getEnclosingStmtLocation(S);
 
-            PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+            PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                               "Loop condition is false.  Exiting loop"));
           }
 
@@ -747,7 +772,7 @@
             if (const Stmt *S = End.asStmt())
               End = PDB.getEnclosingStmtLocation(S);
 
-            PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+            PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                              os.str()));
           }
           else {
@@ -755,7 +780,7 @@
             if (const Stmt *S = End.asStmt())
               End = PDB.getEnclosingStmtLocation(S);
 
-            PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+            PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                             "Loop condition is true.  Entering loop body"));
           }
 
@@ -769,10 +794,10 @@
             End = PDB.getEnclosingStmtLocation(S);
 
           if (*(Src->succ_begin()+1) == Dst)
-            PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+            PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                         "Taking false branch"));
           else
-            PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
+            PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
                                                          "Taking true branch"));
 
           break;
@@ -786,7 +811,7 @@
       for (BugReport::visitor_iterator I = R->visitor_begin(),
            E = R->visitor_end(); I!=E; ++I) {
         if (PathDiagnosticPiece *p = (*I)->VisitNode(N, NextNode, PDB, *R))
-          PD.path.push_front(p);
+          PD.getActivePath().push_front(p);
       }
     }
 
@@ -884,7 +909,7 @@
       }
 
       if (S != Original)
-        L = PathDiagnosticLocation(S, L.getManager(), PDB.getLocationContext());
+        L = PathDiagnosticLocation(S, L.getManager(), PDB.LC);
     }
 
     if (firstCharOnly)
@@ -921,7 +946,7 @@
     // Finally, add an initial edge from the start location of the first
     // statement (if it doesn't already exist).
     PathDiagnosticLocation L = PathDiagnosticLocation::createDeclBegin(
-                                                       PDB.getLocationContext(),
+                                                       PDB.LC,
                                                        PDB.getSourceManager());
     if (L.isValid())
       rawAddEdge(L);
@@ -1019,7 +1044,7 @@
       PrevLocClean.asLocation().getExpansionLoc())
     return;
 
-  PD.path.push_front(new PathDiagnosticControlFlowPiece(NewLocClean, PrevLocClean));
+  PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(NewLocClean, PrevLocClean));
   PrevLoc = NewLoc;
 }
 
@@ -1104,7 +1129,7 @@
   if (!S)
     return;
 
-  PathDiagnosticLocation L(S, PDB.getSourceManager(), PDB.getLocationContext());
+  PathDiagnosticLocation L(S, PDB.getSourceManager(), PDB.LC);
 
   while (!CLocs.empty()) {
     const PathDiagnosticLocation &TopContextLoc = CLocs.back();
@@ -1146,15 +1171,39 @@
                                    LCtx);
         EB.addEdge(Loc, true);
         EB.flushLocations();
+        PathDiagnosticCallPiece *C =
+          PathDiagnosticCallPiece::construct(N, *CE, SM);
+        PD.getActivePath().push_front(C);
+        PD.pushActivePath(&C->path);
         break;
       }
-      
-      // Was the predecessor in a different stack frame?
-      if (NextNode &&
-          !isa<CallExit>(NextNode->getLocation()) &&
-          NextNode->getLocationContext()->getCurrentStackFrame() !=
-          N->getLocationContext()->getCurrentStackFrame()) {
+
+      // Note that is important that we update the LocationContext
+      // after looking at CallExits.  CallExit basically adds an
+      // edge in the *caller*, so we don't want to update the LocationContext
+      // too soon.
+      PDB.LC = N->getLocationContext();
+
+      // Pop the call hierarchy if we are done walking the contents
+      // of a function call.
+      if (const CallEnter *CE = dyn_cast<CallEnter>(&P)) {
+        PD.popActivePath();
+        // The current active path should never be empty.  Either we
+        // just added a bunch of stuff to the top-level path, or
+        // we have a previous CallExit.  If the front of the active
+        // path is not a PathDiagnosticCallPiece, it means that the
+        // path terminated within a function call.  We must then take the
+        // current contents of the active path and place it within
+        // a new PathDiagnosticCallPiece.
+        assert(!PD.getActivePath().empty());
+        PathDiagnosticCallPiece *C = 
+          dyn_cast<PathDiagnosticCallPiece>(PD.getActivePath().front());
+        if (!C)
+          C = PathDiagnosticCallPiece::construct(PD.getActivePath());
+        C->setCallee(*CE, SM);
         EB.flushLocations();
+        EB.addContext(CE->getCallExpr());
+        break;
       }
 
       // Block edges.
@@ -1164,7 +1213,7 @@
 
         // Are we jumping to the head of a loop?  Add a special diagnostic.
         if (const Stmt *Loop = BE->getDst()->getLoopTarget()) {
-          PathDiagnosticLocation L(Loop, SM, PDB.getLocationContext());
+          PathDiagnosticLocation L(Loop, SM, PDB.LC);
           const CompoundStmt *CS = NULL;
 
           if (!Term) {
@@ -1179,7 +1228,7 @@
                                         "Looping back to the head of the loop");
 
           EB.addEdge(p->getLocation(), true);
-          PD.path.push_front(p);
+          PD.getActivePath().push_front(p);
 
           if (CS) {
             PathDiagnosticLocation BL =
@@ -1221,7 +1270,7 @@
       if (PathDiagnosticPiece *p = (*I)->VisitNode(N, NextNode, PDB, *R)) {
         const PathDiagnosticLocation &Loc = p->getLocation();
         EB.addEdge(Loc, true);
-        PD.path.push_front(p);
+        PD.getActivePath().push_front(p);
         if (const Stmt *S = Loc.asStmt())
           EB.addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
       }
@@ -1270,7 +1319,9 @@
 void BugReport::Profile(llvm::FoldingSetNodeID& hash) const {
   hash.AddPointer(&BT);
   hash.AddString(Description);
-  if (Location.isValid()) {
+  if (UniqueingLocation.isValid()) {
+    UniqueingLocation.Profile(hash);
+  } else if (Location.isValid()) {
     Location.Profile(hash);
   } else {
     assert(ErrorNode);
@@ -1550,8 +1601,8 @@
 /// CompactPathDiagnostic - This function postprocesses a PathDiagnostic object
 ///  and collapses PathDiagosticPieces that are expanded by macros.
 static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM) {
-  typedef std::vector<std::pair<IntrusiveRefCntPtr<PathDiagnosticMacroPiece>, SourceLocation> >
-          MacroStackTy;
+  typedef std::vector<std::pair<IntrusiveRefCntPtr<PathDiagnosticMacroPiece>,
+                                SourceLocation> > MacroStackTy;
 
   typedef std::vector<IntrusiveRefCntPtr<PathDiagnosticPiece> >
           PiecesTy;
@@ -1559,7 +1610,8 @@
   MacroStackTy MacroStack;
   PiecesTy Pieces;
 
-  for (PathPieces::iterator I = PD.path.begin(), E = PD.path.end(); I!=E; ++I) {
+  for (PathPieces::const_iterator I = PD.path.begin(), E = PD.path.end();
+       I!=E; ++I) {
     // Get the location of the PathDiagnosticPiece.
     const FullSourceLoc Loc = (*I)->getLocation().asLocation();
 
@@ -1628,13 +1680,13 @@
   }
 
   // Now take the pieces and construct a new PathDiagnostic.
-  PD.path.clear();
+  PD.getMutablePieces().clear();
 
   for (PiecesTy::iterator I=Pieces.begin(), E=Pieces.end(); I!=E; ++I) {
     if (PathDiagnosticMacroPiece *MP = dyn_cast<PathDiagnosticMacroPiece>(*I))
       if (!MP->containsEvent())
         continue;
-    PD.path.push_back(*I);
+    PD.getMutablePieces().push_back(*I);
   }
 }
 
@@ -1670,11 +1722,6 @@
   // Register additional node visitors.
   R->addVisitor(new NilReceiverBRVisitor());
   R->addVisitor(new ConditionBRVisitor());
-  
-  // If inlining is turning out, emit diagnostics for CallEnter and
-  // CallExit at the top level.
-  bool showTopLevel = Eng.getAnalysisManager().shouldInlineCall();
-  R->addVisitor(new CallEnterExitBRVisitor(showTopLevel));
 
   // Generate the very last diagnostic piece - the piece is visible before 
   // the trace is expanded.
@@ -1690,7 +1737,7 @@
   if (!LastPiece)
     LastPiece = BugReporterVisitor::getDefaultEndPath(PDB, N, *R);
   if (LastPiece)
-    PD.path.push_back(LastPiece);
+    PD.getActivePath().push_back(LastPiece);
   else
     return;
 
@@ -1955,7 +2002,7 @@
                                  exampleReport->getDescription());
 
     for ( ; Beg != End; ++Beg) piece->addRange(*Beg);
-    D->path.push_back(piece);
+    D->getActivePath().push_back(piece);
   }
 
   PD->HandlePathDiagnostic(D.take());

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Tue Feb 28 17:49:25 2012
@@ -709,51 +709,3 @@
   return new PathDiagnosticEventPiece(Loc, Out.str());
 }
 
-static PathDiagnosticLocation getLastStmtLoc(const ExplodedNode *N,
-                                             const SourceManager &SM) {
-  while (N) {
-    ProgramPoint PP = N->getLocation();
-    if (const StmtPoint *SP = dyn_cast<StmtPoint>(&PP))
-      return PathDiagnosticLocation(SP->getStmt(), SM, PP.getLocationContext());
-    if (N->pred_empty())
-      break;
-    N = *N->pred_begin();
-  }
-  return PathDiagnosticLocation();
-}
-
-PathDiagnosticPiece *
-CallEnterExitBRVisitor::VisitNode(const ExplodedNode *N,
-                                  const ExplodedNode *PrevN,
-                                  BugReporterContext &BRC,
-                                  BugReport &BR) {
-  ProgramPoint PP = N->getLocation();
-  SmallString<256> buf;
-  llvm::raw_svector_ostream Out(buf);
-  PathDiagnosticLocation pos;
-
-  if (const CallEnter *CEnter = dyn_cast<CallEnter>(&PP)) {
-    const Decl *callee = CEnter->getCalleeContext()->getDecl();
-    pos = PathDiagnosticLocation(CEnter->getCallExpr(), BRC.getSourceManager(),
-                                 PP.getLocationContext());
-    if (isa<BlockDecl>(callee))
-      Out << "Entering call to block";
-    else if (const NamedDecl *ND = dyn_cast<NamedDecl>(callee))
-      Out << "Entering call to '" << *ND << "'";
-    StringRef msg = Out.str();
-    if (msg.empty())
-      return 0;
-    return new PathDiagnosticCallEnterPiece(pos, msg);
-  }
-  else if (const CallExit *CExit = dyn_cast<CallExit>(&PP)) {
-    const Decl *caller = CExit->getLocationContext()->getParent()->getDecl();
-    pos = getLastStmtLoc(PrevN, BRC.getSourceManager());
-    if (const NamedDecl *ND = dyn_cast<NamedDecl>(caller))
-      Out << "Returning to '" << *ND << "'";
-    else
-      Out << "Returning to caller";
-    return new PathDiagnosticCallExitPiece(pos, Out.str());
-  }
-
-  return 0;
-} 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/Environment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/Environment.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/Environment.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/Environment.cpp Tue Feb 28 17:49:25 2012
@@ -90,6 +90,16 @@
         continue;
       case Stmt::ObjCPropertyRefExprClass:
         return loc::ObjCPropRef(cast<ObjCPropertyRefExpr>(E));
+      case Stmt::ObjCStringLiteralClass: {
+        MemRegionManager &MRMgr = svalBuilder.getRegionManager();
+        const ObjCStringLiteral *SL = cast<ObjCStringLiteral>(E);
+        return svalBuilder.makeLoc(MRMgr.getObjCStringRegion(SL));
+      }
+      case Stmt::StringLiteralClass: {
+        MemRegionManager &MRMgr = svalBuilder.getRegionManager();
+        const StringLiteral *SL = cast<StringLiteral>(E);
+        return svalBuilder.makeLoc(MRMgr.getStringRegion(SL));
+      }
       case Stmt::ReturnStmtClass: {
         const ReturnStmt *RS = cast<ReturnStmt>(E);
         if (const Expr *RE = RS->getRetValue()) {

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp Tue Feb 28 17:49:25 2012
@@ -13,6 +13,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "ExprEngine"
+
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
@@ -27,6 +29,7 @@
 #include "clang/Basic/PrettyStackTrace.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/ADT/ImmutableList.h"
+#include "llvm/ADT/Statistic.h"
 
 #ifndef NDEBUG
 #include "llvm/Support/GraphWriter.h"
@@ -36,6 +39,11 @@
 using namespace ento;
 using llvm::APSInt;
 
+STATISTIC(NumRemoveDeadBindings,
+            "The # of times RemoveDeadBindings is called");
+STATISTIC(NumRemoveDeadBindingsSkipped,
+            "The # of times RemoveDeadBindings is skipped");
+
 //===----------------------------------------------------------------------===//
 // Utility functions.
 //===----------------------------------------------------------------------===//
@@ -230,7 +238,11 @@
   // Is this on a non-expression?
   if (!isa<Expr>(S.getStmt()))
     return true;
-  
+    
+  // Run before processing a call.
+  if (isa<CallExpr>(S.getStmt()))
+    return true;
+
   // Is this an expression that is consumed by another expression?  If so,
   // postpone cleaning out the state.
   ParentMap &PM = LC->getAnalysisDeclContext()->getParentMap();
@@ -257,6 +269,7 @@
   SymbolReaper SymReaper(LC, currentStmt, SymMgr, getStoreManager());
 
   if (shouldRemoveDeadBindings(AMgr, S, Pred, LC)) {
+    NumRemoveDeadBindings++;
     getCheckerManager().runCheckersForLiveSymbols(CleanedState, SymReaper);
 
     const StackFrameContext *SFC = LC->getCurrentStackFrame();
@@ -265,6 +278,8 @@
     // and the store. TODO: The function should just return new env and store,
     // not a new state.
     CleanedState = StateMgr.removeDeadBindings(CleanedState, SFC, SymReaper);
+  } else {
+    NumRemoveDeadBindingsSkipped++;
   }
 
   // Process any special transfer function for dead symbols.
@@ -478,6 +493,7 @@
     case Stmt::DependentScopeDeclRefExprClass:
     case Stmt::UnaryTypeTraitExprClass:
     case Stmt::BinaryTypeTraitExprClass:
+    case Stmt::TypeTraitExprClass:
     case Stmt::ArrayTypeTraitExprClass:
     case Stmt::ExpressionTraitExprClass:
     case Stmt::UnresolvedLookupExprClass:
@@ -571,7 +587,6 @@
     case Stmt::ObjCIsaExprClass:
     case Stmt::ObjCProtocolExprClass:
     case Stmt::ObjCSelectorExprClass:
-    case Stmt::ObjCStringLiteralClass:
     case Stmt::ParenListExprClass:
     case Stmt::PredefinedExprClass:
     case Stmt::ShuffleVectorExprClass:
@@ -590,6 +605,8 @@
     case Stmt::CXXBoolLiteralExprClass:
     case Stmt::FloatingLiteralClass:
     case Stmt::SizeOfPackExprClass:
+    case Stmt::StringLiteralClass:
+    case Stmt::ObjCStringLiteralClass:
     case Stmt::CXXNullPtrLiteralExprClass: {
       Bldr.takeNodes(Pred);
       ExplodedNodeSet preVisit;
@@ -882,14 +899,6 @@
       break;
     }
 
-    case Stmt::StringLiteralClass: {
-      ProgramStateRef state = Pred->getState();
-      SVal V = state->getLValue(cast<StringLiteral>(S));
-      Bldr.generateNode(S, Pred, state->BindExpr(S, Pred->getLocationContext(),
-                                                 V));
-      return;
-    }
-
     case Stmt::UnaryOperatorClass: {
       Bldr.takeNodes(Pred);
       const UnaryOperator *U = cast<UnaryOperator>(S);

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp Tue Feb 28 17:49:25 2012
@@ -218,6 +218,7 @@
       case CK_ARCConsumeObject:
       case CK_ARCReclaimReturnedObject:
       case CK_ARCExtendBlockObject: // Fall-through.
+      case CK_CopyAndAutoreleaseBlockObject:
         // The analyser can ignore atomic casts for now, although some future
         // checkers may want to make certain that you're not modifying the same
         // value through atomic and nonatomic pointers.

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Tue Feb 28 17:49:25 2012
@@ -14,7 +14,7 @@
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "clang/AST/DeclCXX.h"
 
 using namespace clang;
@@ -187,6 +187,23 @@
     return;
 
   if (const FunctionDecl *FDecl = dyn_cast<FunctionDecl>(CallDecl)) {
+    const IdentifierInfo *II = FDecl->getIdentifier();
+
+    // List the cases, where the region should be invalidated even if the
+    // argument is const.
+    if (II) {
+      StringRef FName = II->getName();
+      //  - 'int pthread_setspecific(ptheread_key k, const void *)' stores a
+      // value into thread local storage. The value can later be retrieved with
+      // 'void *ptheread_getspecific(pthread_key)'. So even thought the
+      // parameter is 'const void *', the region escapes through the call.
+      //  - ObjC functions that end with "NoCopy" can free memory, of the passed
+      // in buffer.
+      if (FName == "pthread_setspecific" ||
+          FName.endswith("NoCopy"))
+        return;
+    }
+
     for (unsigned Idx = 0, E = Call.getNumArgs(); Idx != E; ++Idx) {
       if (FDecl && Idx < FDecl->getNumParams()) {
         if (isPointerToConst(FDecl->getParamDecl(Idx)))
@@ -418,7 +435,4 @@
       B.generateNode(RS, *it, (*it)->getState());
     }
   }
-  else {
-    B.takeNodes(dstPreVisit);
-  }
 }

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Tue Feb 28 17:49:25 2012
@@ -95,8 +95,31 @@
   }
 }
 
+static void flattenPath(PathPieces &path, const PathPieces &oldPath) {
+  for (PathPieces::const_iterator it = oldPath.begin(), et = oldPath.end();
+       it != et; ++it ) {
+    PathDiagnosticPiece *piece = it->getPtr();
+    if (const PathDiagnosticCallPiece *call =
+        dyn_cast<PathDiagnosticCallPiece>(piece)) {
+      IntrusiveRefCntPtr<PathDiagnosticEventPiece> callEnter =
+        call->getCallEnterEvent();
+      if (callEnter)
+        path.push_back(callEnter);
+      flattenPath(path, call->path);
+      IntrusiveRefCntPtr<PathDiagnosticEventPiece> callExit =
+        call->getCallExitEvent();
+      if (callExit)
+        path.push_back(callExit);
+      continue;
+    }
+
+    path.push_back(piece);
+  }
+}
+
 void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
-                                 SmallVectorImpl<std::string> *FilesMade){
+                                 SmallVectorImpl<std::string> *FilesMade) {
+    
   // Create the HTML directory if it is missing.
   if (!createdDir) {
     createdDir = true;
@@ -119,11 +142,15 @@
   if (noDir)
     return;
 
-  const SourceManager &SMgr = (*D.path.begin())->getLocation().getManager();
+  // First flatten out the entire path to make it easier to use.
+  PathPieces path;
+  flattenPath(path, D.path);
+  
+  const SourceManager &SMgr = (*path.begin())->getLocation().getManager();
   FileID FID;
 
   // Verify that the entire path is from the same FileID.
-  for (PathPieces::const_iterator I = D.path.begin(), E = D.path.end();
+  for (PathPieces::const_iterator I = path.begin(), E = path.end();
        I != E; ++I) {
     FullSourceLoc L = (*I)->getLocation().asLocation().getExpansionLoc();
 
@@ -152,10 +179,11 @@
   Rewriter R(const_cast<SourceManager&>(SMgr), PP.getLangOptions());
 
   // Process the path.
-  unsigned n = D.path.size();
+  unsigned n = path.size();
   unsigned max = n;
 
-  for (PathPieces::const_reverse_iterator I = D.path.rbegin(), E=D.path.rend();
+  for (PathPieces::const_reverse_iterator I = path.rbegin(), 
+       E = path.rend();
         I != E; ++I, --n)
     HandlePiece(R, FID, **I, n, max);
 
@@ -200,9 +228,9 @@
       << html::EscapeText(Entry->getName())
       << "</td></tr>\n<tr><td class=\"rowname\">Location:</td><td>"
          "<a href=\"#EndPath\">line "
-      << (*D.path.rbegin())->getLocation().asLocation().getExpansionLineNumber()
+      << (*path.rbegin())->getLocation().asLocation().getExpansionLineNumber()
       << ", column "
-      << (*D.path.rbegin())->getLocation().asLocation().getExpansionColumnNumber()
+      << (*path.rbegin())->getLocation().asLocation().getExpansionColumnNumber()
       << "</a></td></tr>\n"
          "<tr><td class=\"rowname\">Description:</td><td>"
       << D.getDescription() << "</td></tr>\n";
@@ -240,10 +268,10 @@
     os << "\n<!-- BUGFILE " << DirName << Entry->getName() << " -->\n";
 
     os << "\n<!-- BUGLINE "
-       << D.path.back()->getLocation().asLocation().getExpansionLineNumber()
+       << path.back()->getLocation().asLocation().getExpansionLineNumber()
        << " -->\n";
 
-    os << "\n<!-- BUGPATHLENGTH " << D.path.size() << " -->\n";
+    os << "\n<!-- BUGPATHLENGTH " << path.size() << " -->\n";
 
     // Mark the end of the tags.
     os << "\n<!-- BUGMETAEND -->\n";
@@ -332,8 +360,8 @@
 
   const char *Kind = 0;
   switch (P.getKind()) {
-  case PathDiagnosticPiece::CallEnter:
-  case PathDiagnosticPiece::CallExit:
+  case PathDiagnosticPiece::Call:
+      llvm_unreachable("Calls should already be handled");
   case PathDiagnosticPiece::Event:  Kind = "Event"; break;
   case PathDiagnosticPiece::ControlFlow: Kind = "Control"; break;
     // Setting Kind to "Control" is intentional.

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/MemRegion.cpp Tue Feb 28 17:49:25 2012
@@ -262,6 +262,14 @@
   ID.AddPointer(superRegion);
 }
 
+void ObjCStringRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
+                                     const ObjCStringLiteral* Str,
+                                     const MemRegion* superRegion) {
+  ID.AddInteger((unsigned) ObjCStringRegionKind);
+  ID.AddPointer(Str);
+  ID.AddPointer(superRegion);
+}
+
 void AllocaRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
                                  const Expr *Ex, unsigned cnt,
                                  const MemRegion *) {
@@ -486,6 +494,10 @@
   Str->printPretty(os, 0, PrintingPolicy(getContext().getLangOptions()));
 }
 
+void ObjCStringRegion::dumpToStream(raw_ostream &os) const {
+  Str->printPretty(os, 0, PrintingPolicy(getContext().getLangOptions()));
+}
+
 void SymbolicRegion::dumpToStream(raw_ostream &os) const {
   os << "SymRegion{" << sym << '}';
 }
@@ -613,6 +625,11 @@
   return getSubRegion<StringRegion>(Str, getGlobalsRegion());
 }
 
+const ObjCStringRegion *
+MemRegionManager::getObjCStringRegion(const ObjCStringLiteral* Str){
+  return getSubRegion<ObjCStringRegion>(Str, getGlobalsRegion());
+}
+
 const VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
                                                 const LocationContext *LC) {
   const MemRegion *sReg = 0;

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp Tue Feb 28 17:49:25 2012
@@ -51,11 +51,10 @@
 
 PathDiagnosticPiece::~PathDiagnosticPiece() {}
 PathDiagnosticEventPiece::~PathDiagnosticEventPiece() {}
-PathDiagnosticCallEnterPiece::~PathDiagnosticCallEnterPiece() {}
-PathDiagnosticCallExitPiece::~PathDiagnosticCallExitPiece() {}
+PathDiagnosticCallPiece::~PathDiagnosticCallPiece() {}
 PathDiagnosticControlFlowPiece::~PathDiagnosticControlFlowPiece() {}
 PathDiagnosticMacroPiece::~PathDiagnosticMacroPiece() {}
-PathDiagnostic::PathDiagnostic() {}
+PathDiagnostic::PathDiagnostic() : path(pathImpl) {}
 PathPieces::~PathPieces() {}
 PathDiagnostic::~PathDiagnostic() {}
 
@@ -63,7 +62,8 @@
                                StringRef category)
   : BugType(StripTrailingDots(bugtype)),
     Desc(StripTrailingDots(desc)),
-    Category(StripTrailingDots(category)) {}
+    Category(StripTrailingDots(category)),
+    path(pathImpl) {}
 
 void PathDiagnosticConsumer::anchor() { }
 
@@ -96,9 +96,12 @@
 
   if (PathDiagnostic *orig = Diags.FindNodeOrInsertPos(profile, InsertPos)) {
     // Keep the PathDiagnostic with the shorter path.
-    if (orig->path.size() <= D->path.size()) {
+    const unsigned orig_size = orig->full_size();
+    const unsigned new_size = D->full_size();
+    
+    if (orig_size <= new_size) {
       bool shouldKeepOriginal = true;
-      if (orig->path.size() == D->path.size()) {
+      if (orig_size == new_size) {
         // Here we break ties in a fairly arbitrary, but deterministic, way.
         llvm::FoldingSetNodeID fullProfile, fullProfileOrig;
         D->FullProfile(fullProfile);
@@ -421,6 +424,114 @@
   }
 }
 
+PathDiagnosticLocation PathDiagnostic::getLocation() const {
+  assert(path.size() > 0 &&
+         "getLocation() requires a non-empty PathDiagnostic.");
+  
+  PathDiagnosticPiece *p = path.rbegin()->getPtr();
+  
+  while (true) {
+    if (PathDiagnosticCallPiece *cp = dyn_cast<PathDiagnosticCallPiece>(p)) {
+      assert(!cp->path.empty());
+      p = cp->path.rbegin()->getPtr();
+      continue;
+    }
+    break;
+  }
+  
+  return p->getLocation();
+}
+
+//===----------------------------------------------------------------------===//
+// Manipulation of PathDiagnosticCallPieces.
+//===----------------------------------------------------------------------===//
+
+static PathDiagnosticLocation getLastStmtLoc(const ExplodedNode *N,
+                                             const SourceManager &SM) {
+  while (N) {
+    ProgramPoint PP = N->getLocation();
+    if (const StmtPoint *SP = dyn_cast<StmtPoint>(&PP))
+      return PathDiagnosticLocation(SP->getStmt(), SM, PP.getLocationContext());
+    if (N->pred_empty())
+      break;
+    N = *N->pred_begin();
+  }
+  return PathDiagnosticLocation();
+}
+
+PathDiagnosticCallPiece *
+PathDiagnosticCallPiece::construct(const ExplodedNode *N,
+                                   const CallExit &CE,
+                                   const SourceManager &SM) {
+  const Decl *caller = CE.getLocationContext()->getParent()->getDecl();
+  PathDiagnosticLocation pos = getLastStmtLoc(N, SM);
+  return new PathDiagnosticCallPiece(caller, pos);
+}
+
+PathDiagnosticCallPiece *
+PathDiagnosticCallPiece::construct(PathPieces &path) {
+  PathDiagnosticCallPiece *C = new PathDiagnosticCallPiece(path);
+  path.clear();
+  path.push_front(C);
+  return C;
+}
+
+void PathDiagnosticCallPiece::setCallee(const CallEnter &CE,
+                                        const SourceManager &SM) {
+  const Decl *D = CE.getCalleeContext()->getDecl();
+  Callee = D;
+  callEnter = PathDiagnosticLocation(CE.getCallExpr(), SM,
+                                     CE.getLocationContext());  
+}
+
+IntrusiveRefCntPtr<PathDiagnosticEventPiece>
+PathDiagnosticCallPiece::getCallEnterEvent() const {
+  if (!Callee)
+    return 0;  
+  SmallString<256> buf;
+  llvm::raw_svector_ostream Out(buf);
+  if (isa<BlockDecl>(Callee))
+    Out << "Entering call to block";
+  else if (const NamedDecl *ND = dyn_cast<NamedDecl>(Callee))
+    Out << "Entering call to '" << *ND << "'";
+  StringRef msg = Out.str();
+  if (msg.empty())
+    return 0;
+  return new PathDiagnosticEventPiece(callEnter, msg);
+}
+
+IntrusiveRefCntPtr<PathDiagnosticEventPiece> 
+PathDiagnosticCallPiece::getCallExitEvent() const {
+  if (!Caller)
+    return 0;
+  SmallString<256> buf;
+  llvm::raw_svector_ostream Out(buf);
+  if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(Caller))
+    Out << "Returning to '" << *ND << "'";
+  else
+    Out << "Returning to caller";
+  return new PathDiagnosticEventPiece(callReturn, Out.str());
+}
+
+static void compute_path_size(const PathPieces &pieces, unsigned &size) {
+  for (PathPieces::const_iterator it = pieces.begin(),
+                                  et = pieces.end(); it != et; ++it) {
+    const PathDiagnosticPiece *piece = it->getPtr();
+    if (const PathDiagnosticCallPiece *cp = 
+        dyn_cast<PathDiagnosticCallPiece>(piece)) {
+      compute_path_size(cp->path, size);
+    }
+    else
+      ++size;
+  }
+}
+
+unsigned PathDiagnostic::full_size() {
+  unsigned size = 0;
+  compute_path_size(path, size);
+  return size;
+}
+
 //===----------------------------------------------------------------------===//
 // FoldingSet profiling methods.
 //===----------------------------------------------------------------------===//
@@ -443,6 +554,14 @@
   }  
 }
 
+void PathDiagnosticCallPiece::Profile(llvm::FoldingSetNodeID &ID) const {
+  PathDiagnosticPiece::Profile(ID);
+  for (PathPieces::const_iterator it = path.begin(), 
+       et = path.end(); it != et; ++it) {
+    ID.Add(**it);
+  }
+}
+
 void PathDiagnosticSpotPiece::Profile(llvm::FoldingSetNodeID &ID) const {
   PathDiagnosticPiece::Profile(ID);
   ID.Add(Pos);

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Tue Feb 28 17:49:25 2012
@@ -240,6 +240,33 @@
   Indent(o, indent); o << "</dict>\n";
 }
 
+static void ReportPiece(raw_ostream &o,
+                        const PathDiagnosticPiece &P,
+                        const FIDMap& FM, const SourceManager &SM,
+                        const LangOptions &LangOpts,
+                        unsigned indent,
+                        bool includeControlFlow);
+
+static void ReportCall(raw_ostream &o,
+                       const PathDiagnosticCallPiece &P,
+                       const FIDMap& FM, const SourceManager &SM,
+                       const LangOptions &LangOpts,
+                       unsigned indent) {
+  
+  IntrusiveRefCntPtr<PathDiagnosticEventPiece> callEnter =
+    P.getCallEnterEvent();  
+  if (callEnter)
+    ReportPiece(o, *callEnter, FM, SM, LangOpts, indent, true);
+
+  for (PathPieces::const_iterator I = P.path.begin(), E = P.path.end();I!=E;++I)
+    ReportPiece(o, **I, FM, SM, LangOpts, indent, true);
+  
+  IntrusiveRefCntPtr<PathDiagnosticEventPiece> callExit =
+    P.getCallExitEvent();
+  if (callExit)  
+    ReportPiece(o, *callExit, FM, SM, LangOpts, indent, true);
+}
+
 static void ReportMacro(raw_ostream &o,
                         const PathDiagnosticMacroPiece& P,
                         const FIDMap& FM, const SourceManager &SM,
@@ -248,43 +275,40 @@
 
   for (PathPieces::const_iterator I = P.subPieces.begin(), E=P.subPieces.end();
        I!=E; ++I) {
-
-    switch ((*I)->getKind()) {
-    default:
-      break;
-    case PathDiagnosticPiece::Event:
-      ReportEvent(o, cast<PathDiagnosticEventPiece>(**I), FM, SM, LangOpts,
-                  indent);
-      break;
-    case PathDiagnosticPiece::Macro:
-      ReportMacro(o, cast<PathDiagnosticMacroPiece>(**I), FM, SM, LangOpts,
-                  indent);
-      break;
-    }
+    ReportPiece(o, **I, FM, SM, LangOpts, indent, false);
   }
 }
 
 static void ReportDiag(raw_ostream &o, const PathDiagnosticPiece& P,
                        const FIDMap& FM, const SourceManager &SM,
                        const LangOptions &LangOpts) {
+  ReportPiece(o, P, FM, SM, LangOpts, 4, true);
+}
 
-  unsigned indent = 4;
-
+static void ReportPiece(raw_ostream &o,
+                        const PathDiagnosticPiece &P,
+                        const FIDMap& FM, const SourceManager &SM,
+                        const LangOptions &LangOpts,
+                        unsigned indent,
+                        bool includeControlFlow) {
   switch (P.getKind()) {
-  case PathDiagnosticPiece::ControlFlow:
-    ReportControlFlow(o, cast<PathDiagnosticControlFlowPiece>(P), FM, SM,
-                      LangOpts, indent);
-    break;
-  case PathDiagnosticPiece::CallEnter:
-  case PathDiagnosticPiece::CallExit:
-  case PathDiagnosticPiece::Event:
-    ReportEvent(o, cast<PathDiagnosticSpotPiece>(P), FM, SM, LangOpts,
-                indent);
-    break;
-  case PathDiagnosticPiece::Macro:
-    ReportMacro(o, cast<PathDiagnosticMacroPiece>(P), FM, SM, LangOpts,
-                indent);
-    break;
+    case PathDiagnosticPiece::ControlFlow:
+      if (includeControlFlow)
+        ReportControlFlow(o, cast<PathDiagnosticControlFlowPiece>(P), FM, SM,
+                          LangOpts, indent);
+      break;
+    case PathDiagnosticPiece::Call:
+      ReportCall(o, cast<PathDiagnosticCallPiece>(P), FM, SM, LangOpts,
+                 indent);
+      break;
+    case PathDiagnosticPiece::Event:
+      ReportEvent(o, cast<PathDiagnosticSpotPiece>(P), FM, SM, LangOpts,
+                  indent);
+      break;
+    case PathDiagnosticPiece::Macro:
+      ReportMacro(o, cast<PathDiagnosticMacroPiece>(P), FM, SM, LangOpts,
+                  indent);
+      break;
   }
 }
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/Store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/Store.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/Store.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/Store.cpp Tue Feb 28 17:49:25 2012
@@ -120,6 +120,7 @@
     case MemRegion::CompoundLiteralRegionKind:
     case MemRegion::FieldRegionKind:
     case MemRegion::ObjCIvarRegionKind:
+    case MemRegion::ObjCStringRegionKind:
     case MemRegion::VarRegionKind:
     case MemRegion::CXXTempObjectRegionKind:
     case MemRegion::CXXBaseObjectRegionKind:

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Tue Feb 28 17:49:25 2012
@@ -35,6 +35,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/Statistic.h"
 
 using namespace clang;
 using namespace ento;
@@ -157,6 +158,8 @@
                                   Opts.UnoptimizedCFG, Opts.CFGAddImplicitDtors,
                                   Opts.CFGAddInitializers,
                                   Opts.EagerlyTrimEGraph));
+    if (Opts.PrintStats)
+      llvm::EnableStatistics();
   }
 
   virtual void HandleTranslationUnit(ASTContext &C);

Modified: cfe/branches/tooling/runtime/compiler-rt/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/runtime/compiler-rt/Makefile?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/runtime/compiler-rt/Makefile (original)
+++ cfe/branches/tooling/runtime/compiler-rt/Makefile Tue Feb 28 17:49:25 2012
@@ -29,7 +29,10 @@
 COMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT)/projects/compiler-rt
 
 # Additional flags to pass to Clang.
-CLANG_CCFLAGS := -no-integrated-as
+CLANG_CCFLAGS :=
+ifeq ($(ARCH), arm)
+CLANG_CCFLAGS += -no-integrated-as
+endif
 
 # We don't currently support building runtime libraries when we are
 # cross-compiling. The issue is that we really want to be set up so that the

Modified: cfe/branches/tooling/test/ARCMT/GC-no-arc-runtime.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/GC-no-arc-runtime.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/GC-no-arc-runtime.m (original)
+++ cfe/branches/tooling/test/ARCMT/GC-no-arc-runtime.m Tue Feb 28 17:49:25 2012
@@ -12,9 +12,7 @@
   id x = NSMakeCollectable(cft);
 }
 
- at interface I1 {
-  __strong I1 *myivar;
-}
+ at interface I1
 @end
 
 @implementation I1

Modified: cfe/branches/tooling/test/ARCMT/GC-no-arc-runtime.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/GC-no-arc-runtime.m.result?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/GC-no-arc-runtime.m.result (original)
+++ cfe/branches/tooling/test/ARCMT/GC-no-arc-runtime.m.result Tue Feb 28 17:49:25 2012
@@ -12,9 +12,7 @@
   id x = CFBridgingRelease(cft);
 }
 
- at interface I1 {
-   I1 *myivar;
-}
+ at interface I1
 @end
 
 @implementation I1

Modified: cfe/branches/tooling/test/ARCMT/GC-no-finalize-removal.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/GC-no-finalize-removal.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/GC-no-finalize-removal.m (original)
+++ cfe/branches/tooling/test/ARCMT/GC-no-finalize-removal.m Tue Feb 28 17:49:25 2012
@@ -12,9 +12,7 @@
   id x = NSMakeCollectable(cft);
 }
 
- at interface I1 {
-  __strong I1 *myivar;
-}
+ at interface I1
 @end
 
 @implementation I1

Modified: cfe/branches/tooling/test/ARCMT/GC-no-finalize-removal.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/GC-no-finalize-removal.m.result?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/GC-no-finalize-removal.m.result (original)
+++ cfe/branches/tooling/test/ARCMT/GC-no-finalize-removal.m.result Tue Feb 28 17:49:25 2012
@@ -12,9 +12,7 @@
   id x = CFBridgingRelease(cft);
 }
 
- at interface I1 {
-   I1 *myivar;
-}
+ at interface I1
 @end
 
 @implementation I1

Modified: cfe/branches/tooling/test/ARCMT/GC.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/GC.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/GC.m (original)
+++ cfe/branches/tooling/test/ARCMT/GC.m Tue Feb 28 17:49:25 2012
@@ -12,9 +12,7 @@
   id x = NSMakeCollectable(cft);
 }
 
- at interface I1 {
-  __strong I1 *myivar;
-}
+ at interface I1
 @end
 
 @implementation I1
@@ -90,3 +88,8 @@
 @implementation rdar10532449
 @synthesize assign_prop, strong_readonly_prop, weak_prop;
 @end
+
+void test2(id p, __strong I1 *ap[]) {
+  for (__strong I1 *specRule in p) {
+  }
+}

Modified: cfe/branches/tooling/test/ARCMT/GC.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/GC.m.result?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/GC.m.result (original)
+++ cfe/branches/tooling/test/ARCMT/GC.m.result Tue Feb 28 17:49:25 2012
@@ -12,9 +12,7 @@
   id x = CFBridgingRelease(cft);
 }
 
- at interface I1 {
-   I1 *myivar;
-}
+ at interface I1
 @end
 
 @implementation I1
@@ -85,3 +83,8 @@
 @implementation rdar10532449
 @synthesize assign_prop, strong_readonly_prop, weak_prop;
 @end
+
+void test2(id p, __strong I1 *ap[]) {
+  for (__strong I1 *specRule in p) {
+  }
+}

Modified: cfe/branches/tooling/test/Analysis/inline-unique-reports.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/inline-unique-reports.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/inline-unique-reports.c (original)
+++ cfe/branches/tooling/test/Analysis/inline-unique-reports.c Tue Feb 28 17:49:25 2012
@@ -16,7 +16,6 @@
 }
 
 // CHECK: <?xml version="1.0" encoding="UTF-8"?>
-// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 // CHECK: <plist version="1.0">
 // CHECK: <dict>
 // CHECK:  <key>files</key>
@@ -35,47 +34,13 @@
 // CHECK:         <key>start</key>
 // CHECK:          <array>
 // CHECK:           <dict>
-// CHECK:            <key>line</key><integer>5</integer>
-// CHECK:            <key>col</key><integer>3</integer>
-// CHECK:            <key>file</key><integer>0</integer>
-// CHECK:           </dict>
-// CHECK:           <dict>
-// CHECK:            <key>line</key><integer>5</integer>
-// CHECK:            <key>col</key><integer>3</integer>
-// CHECK:            <key>file</key><integer>0</integer>
-// CHECK:           </dict>
-// CHECK:          </array>
-// CHECK:         <key>end</key>
-// CHECK:          <array>
-// CHECK:           <dict>
 // CHECK:            <key>line</key><integer>9</integer>
-// CHECK:            <key>col</key><integer>12</integer>
-// CHECK:            <key>file</key><integer>0</integer>
-// CHECK:           </dict>
-// CHECK:           <dict>
-// CHECK:            <key>line</key><integer>9</integer>
-// CHECK:            <key>col</key><integer>12</integer>
-// CHECK:            <key>file</key><integer>0</integer>
-// CHECK:           </dict>
-// CHECK:          </array>
-// CHECK:        </dict>
-// CHECK:       </array>
-// CHECK:     </dict>
-// CHECK:     <dict>
-// CHECK:      <key>kind</key><string>control</string>
-// CHECK:      <key>edges</key>
-// CHECK:       <array>
-// CHECK:        <dict>
-// CHECK:         <key>start</key>
-// CHECK:          <array>
-// CHECK:           <dict>
-// CHECK:            <key>line</key><integer>9</integer>
-// CHECK:            <key>col</key><integer>12</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>9</integer>
-// CHECK:            <key>col</key><integer>12</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -88,7 +53,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>10</integer>
-// CHECK:            <key>col</key><integer>8</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -103,6 +68,21 @@
 // CHECK:       <key>col</key><integer>3</integer>
 // CHECK:       <key>file</key><integer>0</integer>
 // CHECK:      </dict>
+// CHECK:      <key>ranges</key>
+// CHECK:      <array>
+// CHECK:        <array>
+// CHECK:         <dict>
+// CHECK:          <key>line</key><integer>10</integer>
+// CHECK:          <key>col</key><integer>3</integer>
+// CHECK:          <key>file</key><integer>0</integer>
+// CHECK:         </dict>
+// CHECK:         <dict>
+// CHECK:          <key>line</key><integer>10</integer>
+// CHECK:          <key>col</key><integer>8</integer>
+// CHECK:          <key>file</key><integer>0</integer>
+// CHECK:         </dict>
+// CHECK:        </array>
+// CHECK:      </array>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Entering call to 'bug'</string>
 // CHECK:      <key>message</key>
@@ -150,3 +130,4 @@
 // CHECK:  </array>
 // CHECK: </dict>
 // CHECK: </plist>
+

Modified: cfe/branches/tooling/test/Analysis/keychainAPI.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/keychainAPI.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/keychainAPI.m (original)
+++ cfe/branches/tooling/test/Analysis/keychainAPI.m Tue Feb 28 17:49:25 2012
@@ -275,7 +275,7 @@
   st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &bytes);
   if (st == noErr) {
     CFStringRef userStr = CFStringCreateWithBytesNoCopy(alloc, bytes, length, 5, 0, kCFAllocatorNull); // expected-warning{{Allocated data is not released}}
-    CFRelease(userStr);
+    CFRelease(userStr); 
   }
 }
 
@@ -370,9 +370,18 @@
       my_FreeParam(ptr, outData);
 }
 
-void allocNoFree2() {
+void consumeChar(char);
+
+void allocNoFree2(int x) {
     OSStatus st = 0;
-    void *outData = my_AllocateReturn(&st); // expected-warning{{Allocated data is not released:}}
+    void *outData = my_AllocateReturn(&st); 
+    if (x) {
+      consumeChar(*(char*)outData); // expected-warning{{Allocated data is not released:}}
+      return;
+    } else {
+      consumeChar(*(char*)outData);
+    }
+    return;
 }
 
 void allocAndFree2(void *attrList) {
@@ -384,8 +393,10 @@
 
 void allocNoFree3() {
     UInt32 length = 32;
-    void *outData;
+    void *outData;    
+    void *outData2;
     OSStatus st = my_Allocate_Param(&outData, &length); // expected-warning{{Allocated data is not released}}
+    st = my_Allocate_Param(&outData2, &length); // expected-warning{{Allocated data is not released}}
 }
 
 void allocAndFree3(void *attrList) {
@@ -394,6 +405,5 @@
     OSStatus st = my_Allocate_Param(&outData, &length); 
     if (st == noErr)
       SecKeychainItemFreeContent(attrList, outData);
-
 }
 

Modified: cfe/branches/tooling/test/Analysis/malloc-interprocedural.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc-interprocedural.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc-interprocedural.c (original)
+++ cfe/branches/tooling/test/Analysis/malloc-interprocedural.c Tue Feb 28 17:49:25 2012
@@ -38,8 +38,10 @@
   my_free1(data);
 }
 
-static void test2() {
-  void * data = my_malloc2(1, 4);
+static void testUniqueingByallocationSiteInTopLevelFunction() {
+  void *data = my_malloc2(1, 4);
+  data = 0;
+  int x = 5;// expected-warning {{Memory is never released; potential memory leak}}
   data = my_malloc2(1, 4);// expected-warning {{Memory is never released; potential memory leak}}
 }
 
@@ -69,3 +71,28 @@
   int *data;
   my_free1((int*)data);
 }
+
+static char *reshape(char *in) {
+    return 0;
+}
+
+void testThatRemoveDeadBindingsRunBeforeEachCall() {
+    char *v = malloc(12);
+    v = reshape(v);
+    v = reshape(v);// expected-warning {{Memory is never released; potential memory leak}}
+}
+
+// Test that we keep processing after 'return;'
+void fooWithEmptyReturn(int x) {
+  if (x)
+    return;
+  x++;
+  return;
+}
+
+int uafAndCallsFooWithEmptyReturn() {
+  int *x = (int*)malloc(12);
+  free(x);
+  fooWithEmptyReturn(12);
+  return *x; // expected-warning {{Use of memory after it is freed}}
+}

Modified: cfe/branches/tooling/test/Analysis/malloc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc.c (original)
+++ cfe/branches/tooling/test/Analysis/malloc.c Tue Feb 28 17:49:25 2012
@@ -379,7 +379,7 @@
 
 void mallocMalloc() {
   int *p = malloc(12);
-  p = malloc(12); // expected-warning{{Memory is never released; potential memory leak}}
+  p = malloc(12); // expected-warning 2 {{Memory is never released; potential memory leak}}
 }
 
 void mallocFreeMalloc() {
@@ -631,6 +631,62 @@
   p = ((__builtin_object_size (p, 0) != (size_t) -1) ? __builtin___strcpy_chk (p, s, __builtin_object_size (p, 2 > 1)) : __inline_strcpy_chk (p, s));
   free(p);
 }
+
+// Here we are returning a pointer one past the allocated value. An idiom which
+// can be used for implementing special malloc. The correct uses of this might
+// be rare enough so that we could keep this as a warning.
+static void *specialMalloc(int n){
+  int *p;
+  p = malloc( n+8 );
+  if( p ){
+    p[0] = n;
+    p++;
+  }
+  return p;
+}
+
+// Potentially, the user could free the struct by performing pointer arithmetic on the return value.
+// This is a variation of the specialMalloc issue, though probably would be more rare in correct code.
+int *specialMallocWithStruct() {
+  struct StructWithInt *px= malloc(sizeof(struct StructWithInt));
+  return &(px->g);
+}
+
+// Test various allocation/deallocation functions.
+
+char *strdup(const char *s);
+char *strndup(const char *s, size_t n);
+
+void testStrdup(const char *s, unsigned validIndex) {
+  char *s2 = strdup(s);
+  s2[validIndex + 1] = 'b';// expected-warning {{Memory is never released; potential memory leak}}
+}
+
+int testStrndup(const char *s, unsigned validIndex, unsigned size) {
+  char *s2 = strndup(s, size);
+  s2 [validIndex + 1] = 'b';
+  if (s2[validIndex] != 'a')
+    return 0;
+  else
+    return 1;// expected-warning {{Memory is never released; potential memory leak}}
+}
+
+void testStrdupContentIsDefined(const char *s, unsigned validIndex) {
+  char *s2 = strdup(s);
+  char result = s2[1];// no warning
+  free(s2);
+}
+
+// Test the system library functions to which the pointer can escape.
+
+// For now, we assume memory passed to pthread_specific escapes.
+// TODO: We could check that if a new pthread binding is set, the existing
+// binding must be freed; otherwise, a memory leak can occur.
+void testPthereadSpecificEscape(pthread_key_t key) {
+  void *buf = malloc(12);
+  pthread_setspecific(key, buf); // no warning
+}
+
 // Below are the known false positives.
 
 // TODO: There should be no warning here. This one might be difficult to get rid of.
@@ -650,20 +706,6 @@
   return;
 }
 
-// TODO: Should this be a warning?
-// Here we are returning a pointer one past the allocated value. An idiom which
-// can be used for implementing special malloc. The correct uses of this might
-// be rare enough so that we could keep this as a warning.
-static void *specialMalloc(int n){
-  int *p;
-  p = malloc( n+8 );
-  if( p ){
-    p[0] = n;
-    p++;
-  }
-  return p;// expected-warning {{Memory is never released; potential memory leak}}
-}
-
 // False negatives.
 
 // TODO: This requires tracking symbols stored inside the structs/arrays.
@@ -673,6 +715,16 @@
   pSt->memP = malloc(12);
 }
 
+// TODO: This is another false negative.
+void testMallocWithParam(int **p) {
+  *p = (int*) malloc(sizeof(int));
+  *p = 0;
+}
+
+void testMallocWithParam_2(int **p) {
+  *p = (int*) malloc(sizeof(int));
+}
+
 // TODO: This should produce a warning, similar to the previous issue.
 void localArrayTest() {
   char *p = (char*)malloc(12);

Modified: cfe/branches/tooling/test/Analysis/malloc.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc.mm?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc.mm (original)
+++ cfe/branches/tooling/test/Analysis/malloc.mm Tue Feb 28 17:49:25 2012
@@ -1,61 +1,5 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify %s
-
-typedef unsigned int UInt32;
-typedef signed long CFIndex;
-typedef signed char BOOL;
-typedef unsigned long NSUInteger;
- at class NSString, Protocol;
-extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
-typedef struct _NSZone NSZone;
- at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
- at protocol NSObject
-- (BOOL)isEqual:(id)object;
-- (id)retain;
-- (oneway void)release;
-- (id)autorelease;
-- (id)init;
- at end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
- at end  @protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone;
- at end  @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
- at end
- at interface NSObject <NSObject> {}
-+ (id)allocWithZone:(NSZone *)zone;
-+ (id)alloc;
-- (void)dealloc;
- at end
- at interface NSObject (NSCoderMethods)
-- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
- at end
-extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
-typedef struct {
-}
-NSFastEnumerationState;
- at protocol NSFastEnumeration  - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
- at end           @class NSString, NSDictionary;
- at interface NSValue : NSObject <NSCopying, NSCoding>  - (void)getValue:(void *)value;
- at end  @interface NSNumber : NSValue  - (char)charValue;
-- (id)initWithInt:(int)value;
- at end   @class NSString;
- at interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>  - (NSUInteger)count;
- at end  @interface NSArray (NSArrayCreation)  + (id)array;
- at end       @interface NSAutoreleasePool : NSObject {
-}
-- (void)drain;
- at end extern NSString * const NSBundleDidLoadNotification;
-typedef double NSTimeInterval;
- at interface NSDate : NSObject <NSCopying, NSCoding>  - (NSTimeInterval)timeIntervalSinceReferenceDate;
- at end            typedef unsigned short unichar;
- at interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
-- (NSUInteger)length;
-- (NSString *)stringByAppendingString:(NSString *)aString;
-- ( const char *)UTF8String;
-- (id)initWithUTF8String:(const char *)nullTerminatedCString;
-+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
- at end        @class NSString, NSURL, NSError;
- at interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding>  - (NSUInteger)length;
-+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
-+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
- at end 
+#include "system-header-simulator-objc.h"
 
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
@@ -68,9 +12,74 @@
   free(data); // no warning
 }
 
-// False Negative
-void testNSDatafFreeWhenDone(NSUInteger dataLength) {
+void testNSDataFreeWhenDoneYES(NSUInteger dataLength) {
+  unsigned char *data = (unsigned char *)malloc(42);
+  NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+void testNSDataFreeWhenDoneYES2(NSUInteger dataLength) {
+  unsigned char *data = (unsigned char *)malloc(42);
+  NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+
+void testNSStringFreeWhenDoneYES(NSUInteger dataLength) {
+  unsigned char *data = (unsigned char *)malloc(42);
+  NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:1]; // no-warning
+}
+
+void testNSStringFreeWhenDoneYES2(NSUInteger dataLength) {
+  unichar *data = (unichar*)malloc(42);
+  NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+
+void testNSDataFreeWhenDoneNO(NSUInteger dataLength) {
+  unsigned char *data = (unsigned char *)malloc(42);
+  NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+void testNSDataFreeWhenDoneNO2(NSUInteger dataLength) {
+  unsigned char *data = (unsigned char *)malloc(42);
+  NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+
+void testNSStringFreeWhenDoneNO(NSUInteger dataLength) {
+  unsigned char *data = (unsigned char *)malloc(42);
+  NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+void testNSStringFreeWhenDoneNO2(NSUInteger dataLength) {
+  unichar *data = (unichar*)malloc(42);
+  NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+// TODO: False Negative.
+void testNSDatafFreeWhenDoneFN(NSUInteger dataLength) {
   unsigned char *data = (unsigned char *)malloc(42);
   NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:1];
   free(data); // false negative
 }
+
+// Test CF/NS...NoCopy. PR12100.
+
+void testNSDatafFreeWhenDone(NSUInteger dataLength) {
+  CFStringRef str;
+  char *bytes = (char*)malloc(12);
+  str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // no warning
+  CFRelease(str); // default allocator also frees bytes
+}
+
+void stringWithExternalContentsExample(void) {
+#define BufferSize 1000
+    CFMutableStringRef mutStr;
+    UniChar *myBuffer;
+ 
+    myBuffer = (UniChar *)malloc(BufferSize * sizeof(UniChar));
+ 
+    mutStr = CFStringCreateMutableWithExternalCharactersNoCopy(0, myBuffer, 0, BufferSize, kCFAllocatorNull); // expected-warning{{leak}}
+ 
+    CFRelease(mutStr);
+    //free(myBuffer);
+}

Modified: cfe/branches/tooling/test/Analysis/method-arg-decay.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/method-arg-decay.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/method-arg-decay.m (original)
+++ cfe/branches/tooling/test/Analysis/method-arg-decay.m Tue Feb 28 17:49:25 2012
@@ -56,7 +56,7 @@
 @interface PBXProjectModule : PBXModule <PBXFindableText> {
 }
 @end @class PBXBookmark;
- at protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection;  // expected-note {{method declared here}}
+ at protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection;  // expected-note {{method 'performAction:withSelection:' declared here}}
 @end @class XCPropertyDictionary, XCPropertyCondition, XCPropertyConditionSet, XCMutablePropertyConditionSet;
 extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExposedModulesOnly);
 @interface NSString (StringUtilities) - (NSString *) trimToLength:(NSInteger)length preserveRange:(NSRange)range;
@@ -72,8 +72,7 @@
 }
 - (PBXModule *) moduleForTab:(NSTabViewItem *)item; // expected-note {{method definition for 'moduleForTab:' not found}}
 @end  
- at implementation XCPerspectiveModule // expected-warning {{incomplete implementation}} \
-				    // expected-warning {{method in protocol not implemented}}
+ at implementation XCPerspectiveModule // expected-warning {{incomplete implementation}} expected-warning {{method 'performAction:withSelection:' in protocol not implemented}}}
 + (void) openForProjectDocument:(PBXProjectDocument *)projectDocument {
 }
 - (PBXModule *) type:(Class)type inPerspective:(id)perspectiveIdentifer  matchingFunction:(BOOL (void *, void *))comparator usingData:(void *)data {

Modified: cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m (original)
+++ cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m Tue Feb 28 17:49:25 2012
@@ -48,7 +48,7 @@
 }
 
 void createFoo5() {
-  MyClass *obj = @"";  
+  MyClass *obj = (id)@"";  
   
   double d = [obj doubleM]; // no-warning
 }

Modified: cfe/branches/tooling/test/Analysis/plist-output-alternate.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/plist-output-alternate.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/plist-output-alternate.m (original)
+++ cfe/branches/tooling/test/Analysis/plist-output-alternate.m Tue Feb 28 17:49:25 2012
@@ -990,7 +990,7 @@
 // CHECK: <string>Object leaked: object allocated and stored into 'value' is not referenced later in this execution path and has a retain count of +1</string>
 // CHECK:     </dict>
 // CHECK:    </array>
-// CHECK:    <key>description</key><string>Potential leak of an object allocated on line 53 and stored into 'value'</string>
+// CHECK:    <key>description</key><string>Potential leak of an object stored into 'value'</string>
 // CHECK:    <key>category</key><string>Memory (Core Foundation/Objective-C)</string>
 // CHECK:    <key>type</key><string>Leak</string>
 // CHECK:   <key>location</key>

Modified: cfe/branches/tooling/test/Analysis/retain-release-gc-only.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/retain-release-gc-only.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/retain-release-gc-only.m (original)
+++ cfe/branches/tooling/test/Analysis/retain-release-gc-only.m Tue Feb 28 17:49:25 2012
@@ -279,7 +279,7 @@
 
 @implementation TestReturnNotOwnedWhenExpectedOwned
 - (NSString*)newString {
-  NSString *s = [NSString stringWithUTF8String:"hello"]; // expected-warning{{Potential leak (when using garbage collection) of an object allocated}}
+  NSString *s = [NSString stringWithUTF8String:"hello"]; // expected-warning{{Potential leak (when using garbage collection) of an object}}
   CFRetain(s);
   return s;
 }

Modified: cfe/branches/tooling/test/Analysis/retain-release-inline.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/retain-release-inline.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/retain-release-inline.m (original)
+++ cfe/branches/tooling/test/Analysis/retain-release-inline.m Tue Feb 28 17:49:25 2012
@@ -253,6 +253,19 @@
 + (id)array;
 @end
 
+enum {
+    NSASCIIStringEncoding = 1,
+    NSNEXTSTEPStringEncoding = 2,
+    NSJapaneseEUCStringEncoding = 3,
+    NSUTF8StringEncoding = 4,
+    NSISOLatin1StringEncoding = 5,
+    NSSymbolStringEncoding = 6,
+    NSNonLossyASCIIStringEncoding = 7,
+};
+typedef struct __CFString * CFMutableStringRef;
+typedef NSUInteger NSStringEncoding;
+
+extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
 
 //===----------------------------------------------------------------------===//
 // Test cases.
@@ -281,3 +294,23 @@
   bar(s);
 }
 
+//===----------------------------------------------------------------------===//
+// Test returning retained and not-retained values.
+//===----------------------------------------------------------------------===//
+
+// On return (intraprocedural), assume CF objects are leaked.
+CFStringRef test_return_ratained_CF(char *bytes) {
+  CFStringRef str;
+  return CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // expected-warning {{leak}}
+}
+
+// On return (intraprocedural), assume NSObjects are not leaked.
+id test_return_retained_NS() {
+  return [[NSString alloc] init]; // no-warning
+}
+
+void test_test_return_retained() {
+  id x = test_return_retained_NS(); // expected-warning {{leak}}
+  [x retain];
+  [x release];
+}

Modified: cfe/branches/tooling/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/retain-release.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/retain-release.m (original)
+++ cfe/branches/tooling/test/Analysis/retain-release.m Tue Feb 28 17:49:25 2012
@@ -1468,7 +1468,7 @@
     while (error_to_dump != ((void*)0)) {
         CFDictionaryRef info;
 
-        info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object allocated on line}}
+        info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object}}
 
         if (info != ((void*)0)) {
         }

Modified: cfe/branches/tooling/test/Analysis/system-header-simulator.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/system-header-simulator.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/system-header-simulator.h (original)
+++ cfe/branches/tooling/test/Analysis/system-header-simulator.h Tue Feb 28 17:49:25 2012
@@ -11,3 +11,7 @@
 
 char *strcpy(char *restrict s1, const char *restrict s2);
 
+typedef unsigned long __darwin_pthread_key_t;
+typedef __darwin_pthread_key_t pthread_key_t;
+int pthread_setspecific(pthread_key_t ,
+         const void *);

Modified: cfe/branches/tooling/test/Analysis/taint-generic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/taint-generic.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/taint-generic.c (original)
+++ cfe/branches/tooling/test/Analysis/taint-generic.c Tue Feb 28 17:49:25 2012
@@ -111,11 +111,11 @@
   char buffer[156];
   char addr[128];
   scanf("%s", addr);
-  system(addr); // expected-warning {{Tainted data passed to a system call}}
+  system(addr); // expected-warning {{Untrusted data is passed to a system call}}
 
   // Test that spintf transfers taint.
   sprintf(buffer, "/bin/mail %s < /tmp/email", addr);
-  system(buffer); // expected-warning {{Tainted data passed to a system call}}
+  system(buffer); // expected-warning {{Untrusted data is passed to a system call}}
 }
 
 void testTaintSystemCall2() {
@@ -124,7 +124,7 @@
   char addr[128];
   scanf("%s", addr);
   __builtin_snprintf(buffern, 10, "/bin/mail %s < /tmp/email", addr);
-  system(buffern); // expected-warning {{Tainted data passed to a system call}}
+  system(buffern); // expected-warning {{Untrusted data is passed to a system call}}
 }
 
 void testTaintSystemCall3() {
@@ -133,20 +133,20 @@
   char addr[128];
   scanf("%s %d", addr, &numt);
   __builtin_snprintf(buffern2, numt, "/bin/mail %s < /tmp/email", "abcd");
-  system(buffern2); // expected-warning {{Tainted data passed to a system call}}
+  system(buffern2); // expected-warning {{Untrusted data is passed to a system call}}
 }
 
 void testTaintedBufferSize() {
   size_t ts;
   scanf("%zd", &ts);
 
-  int *buf1 = (int*)malloc(ts*sizeof(int)); // expected-warning {{Tainted data is used to specify the buffer size}}
-  char *dst = (char*)calloc(ts, sizeof(char)); //expected-warning {{Tainted data is used to specify the buffer size}}
-  bcopy(buf1, dst, ts); // expected-warning {{Tainted data is used to specify the buffer size}}
-  __builtin_memcpy(dst, buf1, (ts + 4)*sizeof(char)); // expected-warning {{Tainted data is used to specify the buffer size}}
+  int *buf1 = (int*)malloc(ts*sizeof(int)); // expected-warning {{Untrusted data is used to specify the buffer size}}
+  char *dst = (char*)calloc(ts, sizeof(char)); //expected-warning {{Untrusted data is used to specify the buffer size}}
+  bcopy(buf1, dst, ts); // expected-warning {{Untrusted data is used to specify the buffer size}}
+  __builtin_memcpy(dst, buf1, (ts + 4)*sizeof(char)); // expected-warning {{Untrusted data is used to specify the buffer size}}
 
   // If both buffers are trusted, do not issue a warning.
-  char *dst2 = (char*)malloc(ts*sizeof(char)); // expected-warning {{Tainted data is used to specify the buffer size}}
+  char *dst2 = (char*)malloc(ts*sizeof(char)); // expected-warning {{Untrusted data is used to specify the buffer size}}
   strncat(dst2, dst, ts); // no-warning
 }
 
@@ -164,7 +164,7 @@
 
   sock = socket(AF_INET, SOCK_STREAM, 0);
   read(sock, buffer, 100);
-  execl(buffer, "filename", 0); // expected-warning {{Tainted data passed to a system call}}
+  execl(buffer, "filename", 0); // expected-warning {{Untrusted data is passed to a system call}}
 
   sock = socket(AF_LOCAL, SOCK_STREAM, 0);
   read(sock, buffer, 100);

Modified: cfe/branches/tooling/test/CXX/class/class.union/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/class/class.union/p1.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/class/class.union/p1.cpp (original)
+++ cfe/branches/tooling/test/CXX/class/class.union/p1.cpp Tue Feb 28 17:49:25 2012
@@ -19,6 +19,9 @@
 class Ctor2 {
   Ctor2(); // expected-note 3 {{because type 'Ctor2' has a user-declared constructor}}
 };
+class CtorTmpl {
+  template<typename T> CtorTmpl(); // expected-note {{because type 'CtorTmpl' has a user-declared constructor}}
+};
 
 class CopyCtor {
   CopyCtor(CopyCtor &cc) { abort(); } // expected-note 4 {{because type 'CopyCtor' has a user-declared copy constructor}}
@@ -38,6 +41,7 @@
   VirtualBase vbase; // expected-error {{union member 'vbase' has a non-trivial copy constructor}}
   Ctor ctor; // expected-error {{union member 'ctor' has a non-trivial constructor}}
   Ctor2 ctor2; // expected-error {{union member 'ctor2' has a non-trivial constructor}}
+  CtorTmpl ctortmpl; // expected-error {{union member 'ctortmpl' has a non-trivial constructor}}
   CopyCtor copyctor; // expected-error {{union member 'copyctor' has a non-trivial copy constructor}}
   CopyAssign copyassign; // expected-error {{union member 'copyassign' has a non-trivial copy assignment operator}}
   Dtor dtor; // expected-error {{union member 'dtor' has a non-trivial destructor}}

Modified: cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp (original)
+++ cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp Tue Feb 28 17:49:25 2012
@@ -13,9 +13,9 @@
   
   auto *b; // expected-error{{declaration of variable 'b' with type 'auto *' requires an initializer}}
 
-  if (auto b) {} // expected-error {{expected '='}}
-  for (;auto b;) {} // expected-error {{expected '='}}
-  while (auto b) {} // expected-error {{expected '='}}
+  if (auto b) {} // expected-error {{must have an initializer}}
+  for (;auto b;) {} // expected-error {{must have an initializer}}
+  while (auto b) {} // expected-error {{must have an initializer}}
   if (auto b = true) { (void)b; }
 }
 

Modified: cfe/branches/tooling/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp (original)
+++ cfe/branches/tooling/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp Tue Feb 28 17:49:25 2012
@@ -35,7 +35,8 @@
 };
 constexpr S3 s3a = S3(0);
 constexpr S3 s3b = s3a;
-constexpr S3 s3c = S3(); // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
+constexpr S3 s3c = S3();
+constexpr S3 s3d; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
 
 struct S4 {
   S4() = default;

Modified: cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp Tue Feb 28 17:49:25 2012
@@ -27,4 +27,12 @@
 class Poly { virtual ~Poly(); };
 const std::type_info& k = typeid(S::m);
 const std::type_info& m = typeid(*(Poly*)S::m); // expected-error {{invalid use of nonstatic data member}}
-const std::type_info& n = typeid(*(Poly*)(0*sizeof S::m)); 
\ No newline at end of file
+const std::type_info& n = typeid(*(Poly*)(0*sizeof S::m)); 
+
+namespace PR11956 {
+  struct X { char a; };
+  struct Y { int f() { return sizeof(X::a); } }; // ok
+
+  struct A { enum E {} E; };
+  struct B { int f() { return sizeof(A::E); } }; // ok
+}

Modified: cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp Tue Feb 28 17:49:25 2012
@@ -7,3 +7,14 @@
   int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
   int sz = sizeof(this); // ok
 };
+
+namespace CaptureThis {
+  struct X {
+    int n = 10;
+    int m = [&]{return n + 1; }();
+    int o = [&]{return this->m + 1; }();
+    int p = [&]{return [&](int x) { return this->m + x;}(o); }();
+  };
+  
+  X x;
+}

Removed: cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp?rev=151670&view=auto
==============================================================================
--- cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp (original)
+++ cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp (removed)
@@ -1,57 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 -fblocks %s -verify
-
-void block_capture_errors() {
-  __block int var; // expected-note 2{{'var' declared here}}
-  (void)[var] { }; // expected-error{{__block variable 'var' cannot be captured in a lambda}}
-
-  (void)[=] { var = 17; }; // expected-error{{__block variable 'var' cannot be captured in a lambda}}
-}
-
-void conversion_to_block(int captured) {
-  int (^b1)(int) = [=](int x) { return x + captured; };
-
-  const auto lambda = [=](int x) { return x + captured; };
-  int (^b2)(int) = lambda;
-}
-
-template<typename T>
-class ConstCopyConstructorBoom {
-public:
-  ConstCopyConstructorBoom(ConstCopyConstructorBoom&);
-
-  ConstCopyConstructorBoom(const ConstCopyConstructorBoom&) {
-    T *ptr = 1; // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}}
-  }
-
-  void foo() const;
-};
-
-void conversion_to_block_init(ConstCopyConstructorBoom<int> boom,
-                              ConstCopyConstructorBoom<float> boom2) {
-  const auto& lambda1([=] { boom.foo(); }); // okay
-
-  const auto& lambda2([=] { boom2.foo(); }); // expected-note{{in instantiation of member function}}
-  void (^block)(void) = lambda2;
-}
-
-
-void nesting() {
-  int array[7]; // expected-note 2{{'array' declared here}}
-  [=] () mutable {
-    [&] {
-      ^ {
-        int i = array[2];
-        i += array[3];
-      }();
-    }();
-  }();
-
-  [&] {
-    [=] () mutable {
-      ^ {
-        int i = array[2]; // expected-error{{cannot refer to declaration with an array type inside block}}
-        i += array[3]; // expected-error{{cannot refer to declaration with an array type inside block}}
-      }();
-    }();
-  }();
-}

Modified: cfe/branches/tooling/test/CXX/special/class.ctor/p5-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.ctor/p5-0x.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.ctor/p5-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.ctor/p5-0x.cpp Tue Feb 28 17:49:25 2012
@@ -25,10 +25,8 @@
 Deleted1a d1a; // expected-error {{implicitly-deleted default constructor}}
 union NotDeleted1a { DefaultedDefCtor1 nu; };
 NotDeleted1a nd1a;
-// FIXME: clang implements the pre-FDIS rule, under which DefaultedDefCtor2's
-// default constructor is non-trivial.
-union NotDeleted1b { DefaultedDefCtor2 nu; }; // unexpected-note {{defined here}}
-NotDeleted1b nd1b; // unexpected-error {{implicitly-deleted default constructor}}
+union NotDeleted1b { DefaultedDefCtor2 nu; };
+NotDeleted1b nd1b;
 
 // - any non-static data member with no brace-or-equal-initializer is of
 // reference type,
@@ -37,10 +35,16 @@
   int &a; 
 }; 
 Deleted2a d2a; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted2b { // expected-note {{here}}
+  int &&b;
+};
+Deleted2b d2b; // expected-error {{deleted default constructor}}
 class NotDeleted2a { int &a = n; };
 NotDeleted2a nd2a;
 class NotDeleted2b { int &a = error; }; // expected-error {{undeclared identifier}}
 NotDeleted2b nd2b;
+class NotDeleted2c { int &&a = 0; };
+NotDeleted2c nd2c;
 
 // - any non-variant non-static data member of const qualified type (or array
 // thereof) with no brace-or-equal-initializer does not have a user-provided
@@ -61,27 +65,26 @@
 NotDeleted3c nd3c;
 union NotDeleted3d { const int a; int b; };
 NotDeleted3d nd3d;
-// FIXME: this class should not have a deleted default constructor.
-union NotDeleted3e { const DefaultedDefCtor1 a[42]; int b; }; // unexpected-note {{here}}
-NotDeleted3e nd3e; // unexpected-error {{implicitly-deleted default constructor}}
-// FIXME: clang implements the pre-FDIS rule, under which DefaultedDefCtor2 is
-// non-trivial.
-union NotDeleted3f { const DefaultedDefCtor2 a; int b; }; // unexpected-note {{here}}
-NotDeleted3f nd3f; // unexpected-error {{implicitly-deleted default constructor}}
+union NotDeleted3e { const DefaultedDefCtor1 a[42]; int b; };
+NotDeleted3e nd3e;
+union NotDeleted3f { const DefaultedDefCtor2 a; int b; };
+NotDeleted3f nd3f;
+struct NotDeleted3g { union { const int a; int b; }; };
+NotDeleted3g nd3g;
 
 // - X is a union and all of its variant members are of const-qualified type (or
 // array thereof),
 union Deleted4a { const int a; const int b; const UserProvidedDefCtor c; }; // expected-note {{here}}
 Deleted4a d4a; // expected-error {{implicitly-deleted default constructor}}
-union Deleted4b { const int a; int b; };
-Deleted4b d4b;
+union NotDeleted4a { const int a; int b; };
+NotDeleted4a nd4a;
 
 // - X is a non-union class and all members of any anonymous union member are of
 // const-qualified type (or array thereof),
 struct Deleted5a { union { const int a; }; union { int b; }; }; // expected-note {{here}}
 Deleted5a d5a; // expected-error {{implicitly-deleted default constructor}}
-struct Deleted5b { union { const int a; int b; }; union { const int c; int d; }; };
-Deleted5b d5b;
+struct NotDeleted5a { union { const int a; int b; }; union { const int c; int d; }; };
+NotDeleted5a nd5a;
 
 // - any direct or virtual base class, or non-static data member with no
 // brace-or-equal-initializer, has class type M (or array thereof) and either
@@ -170,4 +173,3 @@
 
 template<typename T> class Trivial5 { Trivial5() = delete; };
 static_assert(__has_trivial_constructor(Trivial5<int>), "Trivial5 is trivial");
-

Modified: cfe/branches/tooling/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/temp/temp.decls/temp.variadic/p4.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/temp/temp.decls/temp.variadic/p4.cpp (original)
+++ cfe/branches/tooling/test/CXX/temp/temp.decls/temp.variadic/p4.cpp Tue Feb 28 17:49:25 2012
@@ -91,6 +91,16 @@
   X() : member()... { } // expected-error{{pack expansion for initialization of member 'member'}}
 };
 
+// There was a bug in the delayed parsing code for the
+// following case.
+template<typename ...T>
+struct DelayedParseTest : T...
+{
+  int a;
+  DelayedParseTest(T... i) : T{i}..., a{10} {}
+};
+
+
 // In a template-argument-list (14.3); the pattern is a template-argument.
 template<typename ...Types>
 struct tuple_of_refs {

Modified: cfe/branches/tooling/test/CodeGen/complex-init-list.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/complex-init-list.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/complex-init-list.c (original)
+++ cfe/branches/tooling/test/CodeGen/complex-init-list.c Tue Feb 28 17:49:25 2012
@@ -9,4 +9,10 @@
 
 _Complex float f(float x, float y) { _Complex float z = { x, y }; return z; }
 // CHECK: define <2 x float> @f
-// CHECK: alloca { float, float }
\ No newline at end of file
+// CHECK: alloca { float, float }
+// CHECK: alloca { float, float }
+
+_Complex float f2(float x, float y) { return (_Complex float){ x, y }; }
+// CHECK: define <2 x float> @f2
+// CHECK: alloca { float, float }
+// CHECK: alloca { float, float }

Modified: cfe/branches/tooling/test/CodeGen/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/init.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/init.c (original)
+++ cfe/branches/tooling/test/CodeGen/init.c Tue Feb 28 17:49:25 2012
@@ -123,3 +123,10 @@
   struct test12 (*p)(void);
 } test12g;
 
+
+void test13(int x) {
+  struct X { int a; int b : 10; int c; };
+  struct X y = {.c = x};
+  // CHECK: @test13
+  // CHECK: and i32 {{.*}}, -1024
+}

Modified: cfe/branches/tooling/test/CodeGenCXX/blocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/blocks.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/blocks.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/blocks.cpp Tue Feb 28 17:49:25 2012
@@ -211,3 +211,18 @@
     return ^{ return *p; }();
   }
 }
+
+namespace test8 {
+  // <rdar://problem/10832617>: failure to capture this after skipping rebuild
+  // of the 'this' pointer.
+  struct X {
+    int x;
+
+    template<typename T>
+    int foo() {
+      return ^ { return x; }();
+    }
+  };
+
+  template int X::foo<int>();
+}

Modified: cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp Tue Feb 28 17:49:25 2012
@@ -254,6 +254,42 @@
   }
 }
 
+// PR12067
+namespace VirtualMembers {
+  struct A {
+    constexpr A(double d) : d(d) {}
+    virtual void f();
+    double d;
+  };
+  struct B : A {
+    constexpr B() : A(2.0), c{'h', 'e', 'l', 'l', 'o'} {}
+    constexpr B(int n) : A(n), c{'w', 'o', 'r', 'l', 'd'} {}
+    virtual void g();
+    char c[5];
+  };
+  struct C {
+    constexpr C() : n(64) {}
+    int n;
+  };
+  struct D : C, A, B {
+    constexpr D() : A(1.0), B(), s(5) {}
+    short s;
+  };
+  struct E : D, B {
+    constexpr E() : B(3), c{'b','y','e'} {}
+    char c[3];
+  };
+
+  // CHECK: @_ZN14VirtualMembers1eE = global { i8**, double, i32, i8**, double, [5 x i8], i16, i8**, double, [5 x i8], [3 x i8] } { i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 2), double 1.000000e+00, i32 64, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 5), double 2.000000e+00, [5 x i8] c"hello", i16 5, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 9), double 3.000000e+00, [5 x i8] c"world", [3 x i8] c"bye" }
+  E e;
+
+  struct nsMemoryImpl {
+    virtual void f();
+  };
+  // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { i8** getelementptr inbounds ([3 x i8*]* @_ZTVN14VirtualMembers12nsMemoryImplE, i64 0, i64 2) }
+  static nsMemoryImpl sGlobalMemory;
+}
+
 // Constant initialization tests go before this point,
 // dynamic initialization tests go after.
 

Modified: cfe/branches/tooling/test/CodeGenCXX/constructor-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/constructor-init.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/constructor-init.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/constructor-init.cpp Tue Feb 28 17:49:25 2012
@@ -201,7 +201,7 @@
     pair2(const pair2&) = default;
   };
 
-  struct pair {
+  struct pair : X { // Make the copy constructor non-trivial, so we actually generate it.
     int second[4];
     // CHECK-PR10720: define linkonce_odr void @_ZN7PR107204pairC2ERKS0_
     // CHECK-PR10720-NOT: ret
@@ -220,4 +220,3 @@
   }
 
 }
-

Modified: cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp Tue Feb 28 17:49:25 2012
@@ -32,6 +32,10 @@
   };
 }
 
+// CHECK: @_ZL25globalInitList1__initlist = internal global [3 x i32] [i32 1, i32 2, i32 3]
+// CHECK: @globalInitList1 = global {{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZL25globalInitList1__initlist, {{[^)]*}}), i32*
+std::initializer_list<int> globalInitList1 = {1, 2, 3};
+
 void fn1(int i) {
   // CHECK: define void @_Z3fn1i
   // temporary array

Modified: cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp Tue Feb 28 17:49:25 2012
@@ -32,6 +32,38 @@
   };
 }
 
+struct destroyme1 {
+  ~destroyme1();
+};
+struct destroyme2 {
+  ~destroyme2();
+};
+struct witharg1 {
+  witharg1(const destroyme1&);
+  ~witharg1();
+};
+struct wantslist1 {
+  wantslist1(std::initializer_list<destroyme1>);
+  ~wantslist1();
+};
+
+// CHECK: @_ZL25globalInitList1__initlist = internal global [3 x i32] [i32 1, i32 2, i32 3]
+// CHECK: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZL25globalInitList1__initlist, i32 0, i32 0), i{{32|64}} 3 }
+std::initializer_list<int> globalInitList1 = {1, 2, 3};
+
+// CHECK: @_ZL25globalInitList2__initlist = internal global [2 x %{{[^ ]*}}] zeroinitializer
+// CHECK: @globalInitList2 = global %{{[^ ]+}} { %[[WITHARG:[^ *]+]]* getelementptr inbounds ([2 x
+// CHECK: appending global
+// CHECK: define internal void
+// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 0
+// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 1
+// CHECK: __cxa_atexit
+// CHECK: call void @_ZN10destroyme1D1Ev
+// CHECK: call void @_ZN10destroyme1D1Ev
+std::initializer_list<witharg1> globalInitList2 = {
+  witharg1(destroyme1()), witharg1(destroyme1())
+};
+
 void fn1(int i) {
   // CHECK: define void @_Z3fn1i
   // temporary array
@@ -52,21 +84,6 @@
   std::initializer_list<int> intlist{1, 2, i};
 }
 
-struct destroyme1 {
-  ~destroyme1();
-};
-struct destroyme2 {
-  ~destroyme2();
-};
-struct witharg1 {
-  witharg1(const destroyme1&);
-  ~witharg1();
-};
-struct wantslist1 {
-  wantslist1(std::initializer_list<destroyme1>);
-  ~wantslist1();
-};
-
 void fn2() {
   // CHECK: define void @_Z3fn2v
   void target(std::initializer_list<destroyme1>);

Modified: cfe/branches/tooling/test/CodeGenCXX/debug-info-artificial-arg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/debug-info-artificial-arg.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/debug-info-artificial-arg.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/debug-info-artificial-arg.cpp Tue Feb 28 17:49:25 2012
@@ -23,8 +23,8 @@
 }
 
 // FIXME: The numbers are truly awful.
-// CHECK: !18 = metadata !{i32 786447, i32 0, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !19} ; [ DW_TAG_pointer_type ]
-// CHECK: !19 = metadata !{i32 786434, null, metadata !"A", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, metadata !19, null} ; [ DW_TAG_class_type ]
+// CHECK: !18 = metadata !{i32 {{.*}}, i32 0, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !19} ; [ DW_TAG_pointer_type ]
+// CHECK: !19 = metadata !{i32 {{.*}}, null, metadata !"A", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, metadata !19, null} ; [ DW_TAG_class_type ]
 // CHECK: metadata !19, metadata !"A", metadata !"A", metadata !"", metadata !6, i32 12, metadata !45, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !47} ; [ DW_TAG_subprogram ]
 // CHECK: metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !46, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
 // CHECK: !46 = metadata !{null, metadata !18, metadata !9, metadata !34}

Modified: cfe/branches/tooling/test/CodeGenCXX/mangle-exprs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/mangle-exprs.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/mangle-exprs.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/mangle-exprs.cpp Tue Feb 28 17:49:25 2012
@@ -1,5 +1,37 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
 
+namespace std {
+  typedef decltype(sizeof(int)) size_t;
+
+  // libc++'s implementation
+  template <class _E>
+  class initializer_list
+  {
+    const _E* __begin_;
+    size_t    __size_;
+
+    initializer_list(const _E* __b, size_t __s)
+      : __begin_(__b),
+        __size_(__s)
+    {}
+
+  public:
+    typedef _E        value_type;
+    typedef const _E& reference;
+    typedef const _E& const_reference;
+    typedef size_t    size_type;
+
+    typedef const _E* iterator;
+    typedef const _E* const_iterator;
+
+    initializer_list() : __begin_(nullptr), __size_(0) {}
+
+    size_t    size()  const {return __size_;}
+    const _E* begin() const {return __begin_;}
+    const _E* end()   const {return __begin_ + __size_;}
+  };
+}
+
 template < bool condition, typename T = void >
 struct enable_if { typedef T type; };
 
@@ -132,3 +164,30 @@
     a(x, &X::member, ip);
   }
 }
+
+namespace test4 {
+  struct X {
+    X(int);
+  };
+
+  template <typename T>
+  void tf1(decltype(new T(1)) p)
+  {}
+
+  template <typename T>
+  void tf2(decltype(new T({1})) p)
+  {}
+
+  template <typename T>
+  void tf3(decltype(new T{1}) p)
+  {}
+
+  // CHECK: void @_ZN5test43tf1INS_1XEEEvDTnw_T_piLi1EEE
+  template void tf1<X>(X*);
+
+  // CHECK: void @_ZN5test43tf2INS_1XEEEvDTnw_T_piilLi1EEEE
+  template void tf2<X>(X*);
+
+  // CHECK: void @_ZN5test43tf3INS_1XEEEvDTnw_T_ilLi1EEE
+  template void tf3<X>(X*);
+}

Modified: cfe/branches/tooling/test/CodeGenCXX/pr9965.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/pr9965.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/pr9965.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/pr9965.cpp Tue Feb 28 17:49:25 2012
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+struct A { A(); };
 template<typename T>
-struct X
+struct X : A // default constructor is not trivial
 {
     X() = default;
     ~X() {} // not a literal type

Modified: cfe/branches/tooling/test/CodeGenCXX/visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/visibility.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/visibility.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/visibility.cpp Tue Feb 28 17:49:25 2012
@@ -5,6 +5,21 @@
 #define PROTECTED __attribute__((visibility("protected")))
 #define DEFAULT __attribute__((visibility("default")))
 
+namespace test25 {
+  template<typename T>
+  struct X {
+    template<typename U>
+    struct definition {
+    };
+  };
+
+  class DEFAULT A { };
+
+  X<int>::definition<A> a;
+  // CHECK: @_ZN6test251aE = global
+  // CHECK-HIDDEN: @_ZN6test251aE = hidden global
+}
+
 // CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10
 // CHECK: @_ZN5Test71aE = hidden global
 // CHECK: @_ZN5Test71bE = global
@@ -22,6 +37,26 @@
 // CHECK-HIDDEN: @_ZN6Test143varE = external global
 // CHECK: @_ZN6Test154TempINS_1AEE5Inner6bufferE = external global [0 x i8]
 // CHECK-HIDDEN: @_ZN6Test154TempINS_1AEE5Inner6bufferE = external global [0 x i8]
+
+namespace test27 {
+  template<typename T>
+  class C {
+    class __attribute__((visibility("default"))) D {
+      void f();
+    };
+  };
+
+  template<>
+  class C<int>::D {
+    virtual void g();
+  };
+
+  void C<int>::D::g() {
+  }
+  // CHECK: _ZTVN6test271CIiE1DE = unnamed_addr constant
+  // CHECK-HIDDEN: _ZTVN6test271CIiE1DE = unnamed_addr constant
+}
+
 // CHECK: @_ZZN6Test193fooIiEEvvE1a = linkonce_odr global
 // CHECK: @_ZGVZN6Test193fooIiEEvvE1a = linkonce_odr global i64
 // CHECK-HIDDEN: @_ZZN6Test193fooIiEEvvE1a = linkonce_odr hidden global
@@ -500,3 +535,65 @@
   // CHECK: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv
   // CHECK-HIDDEN: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv
 }
+
+namespace test23 {
+  // Having a template argument that is explicitly visible should not make
+  // the template instantiation visible.
+  template <typename T>
+  struct X {
+    static void f() {
+    }
+  };
+
+  class DEFAULT A;
+
+  void g() {
+    X<A> y;
+    y.f();
+  }
+  // CHECK: define linkonce_odr void @_ZN6test231XINS_1AEE1fEv
+  // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test231XINS_1AEE1fEv
+}
+
+namespace PR12001 {
+  template <typename P1>
+  void Bind(const P1& p1) {
+  }
+
+  class DEFAULT Version { };
+
+  void f() {
+    Bind(Version());
+  }
+  // CHECK: define linkonce_odr void @_ZN7PR120014BindINS_7VersionEEEvRKT_
+  // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN7PR120014BindINS_7VersionEEEvRKT_
+}
+
+namespace test24 {
+  class DEFAULT A { };
+
+  struct S {
+    template <typename T>
+    void mem() {}
+  };
+
+  void test() {
+    S s;
+    s.mem<A>();
+  }
+  // CHECK: define linkonce_odr void @_ZN6test241S3memINS_1AEEEvv
+  // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test241S3memINS_1AEEEvv
+}
+
+namespace test26 {
+  template<typename T>
+  class C {
+    __attribute__((visibility("default")))  void f();
+  };
+
+  template<>
+  void C<int>::f() { }
+
+  // CHECK: define void @_ZN6test261CIiE1fEv
+  // CHECK-HIDDEN: define void @_ZN6test261CIiE1fEv
+}

Modified: cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m Tue Feb 28 17:49:25 2012
@@ -510,3 +510,7 @@
   // CHECK-NEXT: ret void
 }
 
+// <rdar://problem/10907510>
+void test14() {
+  void (^const x[1])(void) = { ^{} };
+}

Modified: cfe/branches/tooling/test/CodeGenObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/arc.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/arc.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/arc.m Tue Feb 28 17:49:25 2012
@@ -1533,3 +1533,15 @@
 // CHECK:      [[T0:%.*]] = load [[TEST69]]** [[SELF]], align 8
 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST69]]* [[T0]] to i8*
 // CHECK-NEXT: ret i8* [[T1]]
+
+// rdar://problem/10907547
+void test70(id i) {
+  // CHECK: define void @test70
+  // CHECK: store i8* null, i8**
+  // CHECK: store i8* null, i8**
+  // CHECK: [[ID:%.*]] = call i8* @objc_retain(i8*
+  // CHECK: store i8* [[ID]], i8**
+  id x[3] = {
+    [2] = i
+  };
+}

Modified: cfe/branches/tooling/test/CodeGenObjCXX/debug-info.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjCXX/debug-info.mm?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjCXX/debug-info.mm (original)
+++ cfe/branches/tooling/test/CodeGenObjCXX/debug-info.mm Tue Feb 28 17:49:25 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -emit-obj %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -emit-llvm %s -o /dev/null
 
 // This test passes if clang doesn't crash.
 

Modified: cfe/branches/tooling/test/Driver/darwin-as.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/darwin-as.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/darwin-as.c (original)
+++ cfe/branches/tooling/test/Driver/darwin-as.c Tue Feb 28 17:49:25 2012
@@ -11,7 +11,7 @@
 // CHECK-STATIC-64: as{{(.exe)?}}" "-arch" "x86_64" "-force_cpusubtype_ALL" "-o"
 
 // RUN: %clang -target x86_64-apple-darwin10 -### \
-// RUN:   -arch armv6 -x assembler -c %s 2>%t
+// RUN:   -arch armv6 -no-integrated-as -x assembler -c %s 2>%t
 // RUN: FileCheck -check-prefix=ARMV6 --input-file %t %s
 //
 // CHECK-ARMV6: as{{(.exe)?}}" "-arch" "armv6" "-o"

Modified: cfe/branches/tooling/test/Driver/debug-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/debug-options.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/debug-options.c (original)
+++ cfe/branches/tooling/test/Driver/debug-options.c Tue Feb 28 17:49:25 2012
@@ -2,18 +2,26 @@
 // rdar://10383444
 
 // RUN: %clang -### -c -g %s 2>&1 | FileCheck -check-prefix=G %s
+// RUN: %clang -### -c -g2 %s 2>&1 | FileCheck -check-prefix=G2 %s
 // RUN: %clang -### -c -g3 %s 2>&1 | FileCheck -check-prefix=G3 %s
 // RUN: %clang -### -c -ganything %s 2>&1 | FileCheck -check-prefix=GANY %s
+// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=GGDB %s
 // RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=GFOO %s
 //
 // G: "-cc1"
 // G: "-g"
 //
+// G2: "-cc1"
+// G2: "-g"
+//
 // G3: "-cc1"
 // G3: "-g"
 //
 // GANY: "-cc1"
 // GANY-NOT: "-g"
 //
+// GGDB: "-cc1"
+// GGDB: "-g"
+//
 // GFOO: "-cc1"
 // GFOO-NOT: "-g"

Modified: cfe/branches/tooling/test/Driver/gcc-toolchain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/gcc-toolchain.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/gcc-toolchain.cpp (original)
+++ cfe/branches/tooling/test/Driver/gcc-toolchain.cpp Tue Feb 28 17:49:25 2012
@@ -4,22 +4,20 @@
 // RUN:     -target i386-unknown-linux \
 // RUN:     -gcc-toolchain %S/Inputs/ubuntu_11.04_multiarch_tree/usr \
 // RUN:   | FileCheck %s
-
+//
+// Test for header search toolchain detection.
 // CHECK: "-internal-isystem"
 // CHECK: "[[TOOLCHAIN:[^"]+]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5"
 // CHECK: "-internal-isystem"
 // CHECK: "[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/i686-linux-gnu"
 // CHECK: "-internal-isystem"
 // CHECK: "[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/backward"
-// CHECK: "-internal-isystem"
-// CHECK: "/usr/local/include"
-// CHECK: "-internal-isystem"
-// CHECK: lib/clang/3.1/include"
-// CHECK: "-internal-externc-isystem"
-// CHECK: "/include"
-// CHECK: "-internal-externc-isystem"
-// CHECK: "/usr/include"
+// CHECK: "-internal-isystem" "/usr/local/include"
+//
+// Test for linker toolchain detection. Note that only the '-L' flags will use
+// the same precise formatting of the path as the '-internal-system' flags
+// above, so we just blanket wildcard match the 'crtbegin.o'.
 // CHECK: "{{[^"]*}}ld{{(.exe)?}}"
 // CHECK: "{{[^"]*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o"
-// CHECK: "-L{{[^"]*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
-// CHECK: "-L{{[^"]*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
+// CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
+// CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."

Modified: cfe/branches/tooling/test/Driver/linux-header-search.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/linux-header-search.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/linux-header-search.cpp (original)
+++ cfe/branches/tooling/test/Driver/linux-header-search.cpp Tue Feb 28 17:49:25 2012
@@ -15,3 +15,61 @@
 // CHECK-UBUNTU-11-04: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
 // CHECK-UBUNTU-11-04: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-UBUNTU-11-04: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
+// Thoroughly exercise the Debian multiarch environment.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN:     -target i686-linux-gnu \
+// RUN:     --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-X86 %s
+// CHECK-DEBIAN-X86: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-X86: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5/i686-linux-gnu"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-X86: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-X86: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/i386-linux-gnu"
+// CHECK-DEBIAN-X86: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-X86: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN:     -target x86_64-linux-gnu \
+// RUN:     --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-X86-64 %s
+// CHECK-DEBIAN-X86-64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-X86-64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../../include/c++/4.5/x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-X86-64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-X86-64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN:     -target powerpc-linux-gnu \
+// RUN:     --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-PPC %s
+// CHECK-DEBIAN-PPC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-PPC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../../include/c++/4.5/powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-PPC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-PPC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN:     -target powerpc64-linux-gnu \
+// RUN:     --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-PPC64 %s
+// CHECK-DEBIAN-PPC64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-PPC64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../../include/c++/4.5/powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-PPC64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-PPC64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"

Modified: cfe/branches/tooling/test/Driver/linux-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/linux-ld.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/linux-ld.c (original)
+++ cfe/branches/tooling/test/Driver/linux-ld.c Tue Feb 28 17:49:25 2012
@@ -194,3 +194,54 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL %s
 // CHECK-MIPS64EL: "{{.*}}ld{{(.exe)?}}"
 // CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}"
+//
+// Thoroughly exercise the Debian multiarch environment.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target i686-linux-gnu \
+// RUN:     --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-X86 %s
+// CHECK-DEBIAN-X86: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86: "{{.*}}/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../i386-linux-gnu"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target x86_64-linux-gnu \
+// RUN:     --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-X86-64 %s
+// CHECK-DEBIAN-X86-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86-64: "{{.*}}/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target powerpc-linux-gnu \
+// RUN:     --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-PPC %s
+// CHECK-DEBIAN-PPC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC: "{{.*}}/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target powerpc64-linux-gnu \
+// RUN:     --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-PPC64 %s
+// CHECK-DEBIAN-PPC64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC64: "{{.*}}/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib"
+//

Modified: cfe/branches/tooling/test/Index/annotate-tokens-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/annotate-tokens-cxx0x.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/annotate-tokens-cxx0x.cpp (original)
+++ cfe/branches/tooling/test/Index/annotate-tokens-cxx0x.cpp Tue Feb 28 17:49:25 2012
@@ -6,6 +6,11 @@
 void test() {
   int a;
   decltype(a) b;
+
+  typedef int Integer;
+  typedef float Float;
+  typedef bool Bool;
+  bool b2 = __is_trivially_constructible(Integer, Float, Bool);
 }
 
 // RUN: c-index-test -test-annotate-tokens=%s:1:1:5:1 -fno-delayed-template-parsing -std=c++11 %s | FileCheck %s
@@ -14,3 +19,9 @@
 
 // RUN: c-index-test -test-annotate-tokens=%s:8:1:9:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-DECLTYPE %s
 // CHECK-DECLTYPE: Identifier: "a" [8:12 - 8:13] DeclRefExpr=a:7:7
+
+// RUN: c-index-test -test-annotate-tokens=%s:13:1:14:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-TRAIT %s
+// CHECK-TRAIT: Identifier: "Integer" [13:42 - 13:49] TypeRef=Integer:10:15
+// CHECK-TRAIT: Identifier: "Float" [13:51 - 13:56] TypeRef=Float:11:17
+// CHECK-TRAIT: Identifier: "Bool" [13:58 - 13:62] TypeRef=Bool:12:16
+

Modified: cfe/branches/tooling/test/Index/get-cursor.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/get-cursor.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/get-cursor.m (original)
+++ cfe/branches/tooling/test/Index/get-cursor.m Tue Feb 28 17:49:25 2012
@@ -26,6 +26,18 @@
 @synthesize name = _name;
 @end
 
+ at interface rdar10902015
+ at end
+
+ at implementation rdar10902015
+
+struct S {};
+
+-(void)mm:(struct S*)s {
+  rdar10902015 *i = 0;
+}
+ at end
+
 // RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s
 // CHECK-PROP: ObjCPropertyDecl=foo1:4:26
 // CHECK-PROP: ObjCPropertyDecl=foo2:5:27
@@ -35,3 +47,6 @@
 
 // RUN: c-index-test -cursor-at=%s:20:10 %s | FileCheck -check-prefix=CHECK-METHOD %s
 // CHECK-METHOD: ObjCInstanceMethodDecl=name:20:1
+
+// RUN: c-index-test -cursor-at=%s:37:17 %s | FileCheck -check-prefix=CHECK-IN-IMPL %s
+// CHECK-IN-IMPL: VarDecl=i:37:17

Modified: cfe/branches/tooling/test/Index/index-refs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/index-refs.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/index-refs.cpp (original)
+++ cfe/branches/tooling/test/Index/index-refs.cpp Tue Feb 28 17:49:25 2012
@@ -61,6 +61,14 @@
 const int default_param = 3;
 void foo4(int p = default_param);
 
+struct S2 {
+  int x,y;
+};
+
+void foo5() {
+  struct S2 s = { .y = 1, .x = 4};
+}
+
 // RUN: c-index-test -index-file %s | FileCheck %s
 // CHECK:      [indexDeclaration]: kind: namespace | name: NS
 // CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
@@ -108,3 +116,6 @@
 // CHECK:      [indexEntityReference]: kind: variable | name: array_size | {{.*}} | loc: 59:22
 // CHECK:      [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
 // CHECK-NOT:  [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
+
+// CHECK:      [indexEntityReference]: kind: field | name: y | {{.*}} | loc: 69:20
+// CHECK-NEXT: [indexEntityReference]: kind: field | name: x | {{.*}} | loc: 69:28

Removed: cfe/branches/tooling/test/Index/nested-macro-instantiations.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/nested-macro-instantiations.cpp?rev=151670&view=auto
==============================================================================
--- cfe/branches/tooling/test/Index/nested-macro-instantiations.cpp (original)
+++ cfe/branches/tooling/test/Index/nested-macro-instantiations.cpp (removed)
@@ -1,20 +0,0 @@
-#define FOO(x) x
-#define BAR(x) FOO(x)
-#define WIBBLE(x) BAR(x)
-
-WIBBLE(int x);
-
-// RUN: env CINDEXTEST_NESTED_MACROS=1 c-index-test -test-load-source all %s | FileCheck -check-prefix CHECK-WITH-NESTED %s
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_NESTED_MACROS=1 c-index-test -test-load-source all %s | FileCheck -check-prefix CHECK-WITH-NESTED %s
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_NESTED_MACROS=1 c-index-test -test-load-source-reparse 5 all %s | FileCheck -check-prefix CHECK-WITH-NESTED %s
-// CHECK-WITH-NESTED: nested-macro-instantiations.cpp:5:1: macro expansion=WIBBLE:3:9 Extent=[5:1 - 5:14]
-// CHECK-WITH-NESTED: nested-macro-instantiations.cpp:3:19: macro expansion=BAR:2:9 Extent=[3:19 - 5:14]
-// CHECK-WITH-NESTED: nested-macro-instantiations.cpp:2:16: macro expansion=FOO:1:9 Extent=[2:16 - 5:14]
-// CHECK-WITH-NESTED: nested-macro-instantiations.cpp:5:1: VarDecl=x:5:1 (Definition) Extent=[5:1 - 5:14]
-
-// RUN: c-index-test -test-load-source all %s | FileCheck -check-prefix CHECK-WITHOUT-NESTED %s
-// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source all %s | FileCheck -check-prefix CHECK-WITHOUT-NESTED %s
-// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 all %s | FileCheck -check-prefix CHECK-WITHOUT-NESTED %s
-// CHECK-WITHOUT-NESTED: nested-macro-instantiations.cpp:5:1: macro expansion=WIBBLE:3:9 Extent=[5:1 - 5:14]
-// CHECK-WITHOUT-NESTED-NOT: nested-macro-instantiations.cpp:3:19: macro expansion=BAR:2:9 Extent=[3:19 - 5:14]
-// CHECK-WITHOUT-NESTED: nested-macro-instantiations.cpp:5:1: VarDecl=x:5:1 (Definition) Extent=[5:1 - 5:14]

Modified: cfe/branches/tooling/test/Lexer/has_extension.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Lexer/has_extension.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Lexer/has_extension.c (original)
+++ cfe/branches/tooling/test/Lexer/has_extension.c Tue Feb 28 17:49:25 2012
@@ -36,3 +36,9 @@
 int no_c_alignas();
 #endif
 
+// Arbitrary feature to test that the extension name can be surrounded with
+// double underscores.
+// CHECK-PED-NONE: has_double_underscores
+#if __has_extension(__c_alignas__)
+int has_double_underscores();
+#endif

Modified: cfe/branches/tooling/test/Lexer/has_feature_cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Lexer/has_feature_cxx0x.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Lexer/has_feature_cxx0x.cpp (original)
+++ cfe/branches/tooling/test/Lexer/has_feature_cxx0x.cpp Tue Feb 28 17:49:25 2012
@@ -16,7 +16,7 @@
 int no_lambdas();
 #endif
 
-// CHECK-0X: no_lambdas
+// CHECK-0X: has_lambdas
 // CHECK-NO-0X: no_lambdas
 
 
@@ -226,3 +226,12 @@
 
 // CHECK-0X: has_constexpr
 // CHECK-NO-0X: no_constexpr
+
+#if __has_feature(cxx_generalized_initializers)
+int has_generalized_initializers();
+#else
+int no_generalized_initializers();
+#endif
+
+// CHECK-0X: has_generalized_initializers
+// CHECK-NO-0X: no_generalized_initializers

Modified: cfe/branches/tooling/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/warning-flags.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/warning-flags.c (original)
+++ cfe/branches/tooling/test/Misc/warning-flags.c Tue Feb 28 17:49:25 2012
@@ -17,7 +17,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (257):
+CHECK: Warnings without flags (256):
 CHECK-NEXT:   ext_anonymous_struct_union_qualified
 CHECK-NEXT:   ext_binary_literal
 CHECK-NEXT:   ext_cast_fn_obj
@@ -137,7 +137,6 @@
 CHECK-NEXT:   warn_conv_to_self_not_used
 CHECK-NEXT:   warn_conv_to_void_not_used
 CHECK-NEXT:   warn_cxx0x_right_shift_in_template_arg
-CHECK-NEXT:   warn_decl_in_param_list
 CHECK-NEXT:   warn_delete_array_type
 CHECK-NEXT:   warn_division_by_zero
 CHECK-NEXT:   warn_double_const_requires_fp64

Modified: cfe/branches/tooling/test/PCH/cxx-traits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/cxx-traits.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/PCH/cxx-traits.cpp (original)
+++ cfe/branches/tooling/test/PCH/cxx-traits.cpp Tue Feb 28 17:49:25 2012
@@ -1,8 +1,11 @@
 // Test this without pch.
-// RUN: %clang_cc1 -include %S/cxx-traits.h -fsyntax-only -verify %s
+// RUN: %clang_cc1 -include %S/cxx-traits.h -std=c++11 -fsyntax-only -verify %s
 
-// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-traits.h
-// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %S/cxx-traits.h
+// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s
 
 bool _Is_pod_comparator = __is_pod<int>::__value;
 bool _Is_empty_check = __is_empty<int>::__value;
+
+bool default_construct_int = is_trivially_constructible<int>::value;
+bool copy_construct_int = is_trivially_constructible<int, const int&>::value;

Modified: cfe/branches/tooling/test/PCH/cxx-traits.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/cxx-traits.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/PCH/cxx-traits.h (original)
+++ cfe/branches/tooling/test/PCH/cxx-traits.h Tue Feb 28 17:49:25 2012
@@ -9,3 +9,8 @@
 struct __is_empty {
   enum { __value };
 };
+
+template<typename T, typename ...Args>
+struct is_trivially_constructible {
+  static const bool value = __is_trivially_constructible(T, Args...);
+};

Modified: cfe/branches/tooling/test/PCH/cxx0x-default-delete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/cxx0x-default-delete.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/PCH/cxx0x-default-delete.cpp (original)
+++ cfe/branches/tooling/test/PCH/cxx0x-default-delete.cpp Tue Feb 28 17:49:25 2012
@@ -12,6 +12,14 @@
   void bar() = delete; // expected-note{{deleted here}}
 };
 
+struct baz {
+  ~baz() = delete; // expected-note{{deleted here}}
+};
+
+class quux {
+  ~quux() = default; // expected-note{{private here}}
+};
+
 #else
 
 foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}}
@@ -20,4 +28,7 @@
   f.bar(); // expected-error{{deleted function}}
 }
 
+baz bz; // expected-error{{deleted function}}
+quux qx; // expected-error{{private destructor}}
+
 #endif

Removed: cfe/branches/tooling/test/PCH/cxx11-lambdas.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/cxx11-lambdas.cpp?rev=151670&view=auto
==============================================================================
--- cfe/branches/tooling/test/PCH/cxx11-lambdas.cpp (original)
+++ cfe/branches/tooling/test/PCH/cxx11-lambdas.cpp (removed)
@@ -1,48 +0,0 @@
-// RUN: %clang_cc1 -pedantic-errors -fblocks -std=c++11 -emit-pch %s -o %t-cxx11
-// RUN: %clang_cc1 -ast-print -pedantic-errors -fblocks -std=c++11 -include-pch %t-cxx11  %s | FileCheck -check-prefix=CHECK-PRINT %s
-
-#ifndef HEADER_INCLUDED
-
-#define HEADER_INCLUDED
-template<typename T>
-T add_slowly(const T& x, const T &y) {
-  return [=, &y] { return x + y; }();
-};
-
-inline int add_int_slowly_twice(int x, int y) {
-  int i = add_slowly(x, y);
-  auto lambda = [&](int z) { return x + z; };
-  return i + lambda(y);
-}
-
-inline int sum_array(int n) {
-  int array[5] = { 1, 2, 3, 4, 5};
-  auto lambda = [=](int N) -> int {
-    int sum = 0;
-    for (unsigned I = 0; I < N; ++I)
-      sum += array[N];
-    return sum;
-  };
-
-  return lambda(n);
-}
-
-inline int to_block_pointer(int n) {
-  auto lambda = [=](int m) { return n + m; };
-  int (^block)(int) = lambda;
-  return block(17);
-}
-
-#else
-
-// CHECK-PRINT: T add_slowly
-// CHECK-PRINT: return [=, &y]
-template float add_slowly(const float&, const float&);
-
-int add(int x, int y) {
-  return add_int_slowly_twice(x, y) + sum_array(4) + to_block_pointer(5);
-}
-
-// CHECK-PRINT: inline int add_int_slowly_twice 
-// CHECK-PRINT: lambda = [&] (int z)
-#endif

Modified: cfe/branches/tooling/test/PCH/objc_exprs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/objc_exprs.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/PCH/objc_exprs.m (original)
+++ cfe/branches/tooling/test/PCH/objc_exprs.m Tue Feb 28 17:49:25 2012
@@ -6,7 +6,7 @@
 // RUN: %clang_cc1 -fblocks -include-pch %t -fsyntax-only -verify %s 
 
 // Expressions
-int *A1 = (objc_string)0;   // expected-warning {{aka 'id'}}
+int *A1 = (objc_string)0;   // expected-warning {{aka 'NSString *'}}
 
 char A2 = (objc_encode){};  // expected-error {{not a compile-time constant}} \
                                expected-warning {{char [2]}}

Modified: cfe/branches/tooling/test/Parser/DelayedTemplateParsing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/DelayedTemplateParsing.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/DelayedTemplateParsing.cpp (original)
+++ cfe/branches/tooling/test/Parser/DelayedTemplateParsing.cpp Tue Feb 28 17:49:25 2012
@@ -63,3 +63,30 @@
 
 }
 
+
+namespace PR11931 {
+
+template <typename RunType>
+struct BindState;
+
+  template<>
+struct BindState<void(void*)> {
+  static void Run() { }
+};
+
+class Callback {
+public:
+  typedef void RunType();
+
+  template <typename RunType>
+  Callback(BindState<RunType> bind_state) {
+    BindState<RunType>::Run();
+  }
+};
+
+
+Callback Bind() {
+  return Callback(BindState<void(void*)>());
+}
+
+}

Modified: cfe/branches/tooling/test/Parser/bracket-crash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/bracket-crash.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/bracket-crash.cpp (original)
+++ cfe/branches/tooling/test/Parser/bracket-crash.cpp Tue Feb 28 17:49:25 2012
@@ -1,6 +1,6 @@
-// RUN: not %clang_cc1 -fsyntax-only %s
+// RUN: not %clang_cc1 -fsyntax-only -std=c++11 %s
 // PR7481
+decltype(;
 struct{
   a
 }
-

Modified: cfe/branches/tooling/test/Parser/cxx-condition.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/cxx-condition.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/cxx-condition.cpp (original)
+++ cfe/branches/tooling/test/Parser/cxx-condition.cpp Tue Feb 28 17:49:25 2012
@@ -1,11 +1,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
+struct S { S(int); operator bool(); };
+
 void f() {
   int a;
   while (a) ;
-  while (int x) ; // expected-error {{expected '=' after declarator}}
+  while (int x) ; // expected-error {{variable declaration in condition must have an initializer}}
   while (float x = 0) ;
   if (const int x = a) ; // expected-warning{{empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
   switch (int x = a+10) {}
   for (; int x = ++a; ) ;
+
+  if (S a(42)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}}
 }

Modified: cfe/branches/tooling/test/Preprocessor/feature_tests.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/feature_tests.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/feature_tests.c (original)
+++ cfe/branches/tooling/test/Preprocessor/feature_tests.c Tue Feb 28 17:49:25 2012
@@ -21,7 +21,9 @@
 #error Clang should not have this
 #endif
 
-
+#if !__has_feature(__attribute_deprecated_with_message__)
+#error Feature name in double underscores does not work
+#endif
 
 // Make sure we have x86 builtins only (forced with target triple).
 

Modified: cfe/branches/tooling/test/Rewriter/func-in-impl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/func-in-impl.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/func-in-impl.m (original)
+++ cfe/branches/tooling/test/Rewriter/func-in-impl.m Tue Feb 28 17:49:25 2012
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o - | FileCheck %s
+// RUN: %clang_cc1 -E %s -o %t.m
+// RUN: %clang_cc1 -fobjc-fragile-abi -rewrite-objc %t.m -o - | FileCheck %s
 
 @interface I {
   id _delegate;

Modified: cfe/branches/tooling/test/Rewriter/rewrite-ivar-use.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-ivar-use.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-ivar-use.m (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-ivar-use.m Tue Feb 28 17:49:25 2012
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi  -fms-extensions %s -o -
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
 // radar 7490331
 
+void *sel_registerName(const char *);
+
 @interface Foo {
         int a;
         id b;

Modified: cfe/branches/tooling/test/Rewriter/rewrite-modern-class.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-modern-class.mm?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-modern-class.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-modern-class.mm Tue Feb 28 17:49:25 2012
@@ -59,3 +59,12 @@
   return arg->p_super; 
 }
 @end
+
+ at class FORM_CLASS;
+ at interface INTF_DECL  {
+}
+ at end
+
+double Meth(INTF_DECL *p, FORM_CLASS *f) {
+  return 1.34;
+}

Modified: cfe/branches/tooling/test/Rewriter/rewrite-nested-ivar.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-nested-ivar.mm?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-nested-ivar.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-nested-ivar.mm Tue Feb 28 17:49:25 2012
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
 // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw-modern.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw-modern.cpp
 // radar 7583971
 
 

Modified: cfe/branches/tooling/test/Sema/MicrosoftCompatibility.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/MicrosoftCompatibility.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/MicrosoftCompatibility.c (original)
+++ cfe/branches/tooling/test/Sema/MicrosoftCompatibility.c Tue Feb 28 17:49:25 2012
@@ -10,3 +10,7 @@
   ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
   ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
 };
+
+__declspec(noreturn) void f6( void ) {
+	return;  // expected-warning {{function 'f6' declared 'noreturn' should not return}}
+}

Modified: cfe/branches/tooling/test/Sema/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/MicrosoftExtensions.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/MicrosoftExtensions.c (original)
+++ cfe/branches/tooling/test/Sema/MicrosoftExtensions.c Tue Feb 28 17:49:25 2012
@@ -86,3 +86,17 @@
 typedef struct {
   AA; // expected-warning {{anonymous structs are a Microsoft extension}}
 } BB;
+
+__declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1;
+struct __declspec(deprecated) DS1 { int i; float f; };
+
+#define MY_TEXT		"This is also deprecated"
+__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {}
+
+void test( void ) {
+	e1 = one;	// expected-warning {{'e1' is deprecated: This is deprecated}}
+	struct DS1 s = { 0 };	// expected-warning {{'DS1' is deprecated}}
+	Dfunc1();	// expected-warning {{'Dfunc1' is deprecated: This is also deprecated}}
+
+	enum DE1 no;	// no warning because E1 is not deprecated
+}

Modified: cfe/branches/tooling/test/Sema/const-eval.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/const-eval.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/const-eval.c (original)
+++ cfe/branches/tooling/test/Sema/const-eval.c Tue Feb 28 17:49:25 2012
@@ -112,3 +112,8 @@
 // PR11391.
 struct PR11391 { _Complex float f; } pr11391;
 EVAL_EXPR(42, __builtin_constant_p(pr11391.f = 1))
+
+// PR12043
+float varfloat;
+const float constfloat = 0;
+EVAL_EXPR(43, varfloat && constfloat) // expected-error {{must have a constant size}}

Modified: cfe/branches/tooling/test/Sema/format-strings-c90.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/format-strings-c90.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/format-strings-c90.c (original)
+++ cfe/branches/tooling/test/Sema/format-strings-c90.c Tue Feb 28 17:49:25 2012
@@ -5,9 +5,8 @@
 int printf(const char *restrict, ...);
 
 void foo(char **sp, float *fp, int *ip) {
-  /* TODO: Warn that the 'a' length modifier is an extension. */
-  scanf("%as", sp);
-  scanf("%a[abc]", sp);
+  scanf("%as", sp); /* expected-warning{{'a' is a non-standard length modifier}} */
+  scanf("%a[abc]", sp); /* expected-warning{{'a' is a non-standard length modifier}} */
 
   /* TODO: Warn that the 'a' conversion specifier is a C99 feature. */
   scanf("%a", fp);
@@ -21,7 +20,11 @@
   scanf("%da", ip);
 
   /* Test argument type check for the 'a' length modifier. */
-  scanf("%as", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} */
-  scanf("%aS", fp); /* expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}} */
-  scanf("%a[abc]", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} */
+  scanf("%as", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+                       expected-warning{{'a' is a non-standard length modifier}} */
+  scanf("%aS", fp); /* expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}}
+                       expected-warning{{'a' is a non-standard length modifier}}
+                       expected-warning{{'S' is a non-standard conversion specifier}} */
+  scanf("%a[abc]", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+                           expected-warning{{'a' is a non-standard length modifier}} */
 }

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=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/format-strings.c (original)
+++ cfe/branches/tooling/test/Sema/format-strings.c Tue Feb 28 17:49:25 2012
@@ -268,7 +268,6 @@
   // FIXME: This test reports inconsistent results. On Windows, '%C' expects
   // 'unsigned short'.
   // printf("%C", 10);
-  // FIXME: we report the expected type as 'int*' instead of 'wchar_t*'
   printf("%S", "hello"); // expected-warning{{but the argument has type 'char *'}}
 }
 

Modified: cfe/branches/tooling/test/Sema/pragma-pack-2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/pragma-pack-2.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/pragma-pack-2.c (original)
+++ cfe/branches/tooling/test/Sema/pragma-pack-2.c Tue Feb 28 17:49:25 2012
@@ -22,32 +22,32 @@
 // Test scope of definition
 
 #pragma pack(push, 2)
-struct s2_0 {
-#pragma pack(pop)
+struct s2_0 { // expected-error {{expected ';'}}
+#pragma pack(pop) // expected-error {{type name}} expected-error {{member name}} expected-warning {{type specifier}}
   char f0;
   int  f1;
 };
 extern int a2_0[offsetof(struct s2_0, f1) == 2 ? 1 : -1];
 
 struct s2_1 {
-  char f0;
-#pragma pack(push, 2)
-  int  f1;
-#pragma pack(pop)
+  char f0; // expected-error {{expected ';'}}
+#pragma pack(push, 2) // expected-error {{type name}} expected-error {{member name}} expected-warning {{type specifier}}
+  int  f1; // expected-error {{expected ';'}}
+#pragma pack(pop) // expected-error {{type name}} expected-error {{member name}} expected-warning {{type specifier}}
 };
 extern int a2_1[offsetof(struct s2_1, f1) == 4 ? 1 : -1];
 
 struct s2_2 {
   char f0;
-  int  f1;
-#pragma pack(push, 2)
+  int  f1; // expected-error {{expected ';'}}
+#pragma pack(push, 2) // expected-error {{type name}} expected-error {{member name}} expected-warning {{type specifier}}
 };
 #pragma pack(pop)
 extern int a2_2[offsetof(struct s2_2, f1) == 4 ? 1 : -1];
 
 struct s2_3 {
-  char f0;
-#pragma pack(push, 2)
+  char f0; // expected-error {{expected ';'}}
+#pragma pack(push, 2) // expected-error {{type name}} expected-error {{member name}} expected-warning {{type specifier}}
   struct s2_3_0 { 
 #pragma pack(pop)
     int f0; 
@@ -58,10 +58,10 @@
 struct s2_4 {
   char f0;
   struct s2_4_0 { 
-    int f0; 
-#pragma pack(push, 2)
-  } f1;
-#pragma pack(pop)
+    int f0; // expected-error {{expected ';'}}
+#pragma pack(push, 2) // expected-error {{type name}} expected-error {{member name}} expected-warning {{type specifier}}
+  } f1; // expected-error {{expected ';'}}
+#pragma pack(pop) // expected-error {{type name}} expected-error {{member name}} expected-warning {{type specifier}}
 };
 extern int a2_4[offsetof(struct s2_4, f1) == 4 ? 1 : -1];
 
@@ -91,3 +91,15 @@
 };
 extern int a4_0[offsetof(struct s4_0, f1) == 1 ? 1 : -1];
 extern int a4_1[offsetof(struct s4_1, f1) == 4 ? 1 : -1];
+
+void f() {
+  #pragma pack(push, 2)
+  struct s5_0 {
+    char f0;
+    struct s2_4_0 { 
+      int f0;
+    } f1;
+  };
+  #pragma pack(pop)
+  extern int s5_0[offsetof(struct s5_0, f1) == 2 ? 1 : -1];
+}

Modified: cfe/branches/tooling/test/SemaCXX/PR9461.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/PR9461.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/PR9461.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/PR9461.cpp Tue Feb 28 17:49:25 2012
@@ -26,7 +26,7 @@
 :us(_S_construct)
 {string a;}
 
-struct runtime_error{runtime_error(string);}; // expected-note 2 {{candidate constructor}}
+struct runtime_error{runtime_error(string);};
 
-struct system_error:runtime_error{ // expected-note {{to match}} expected-note {{specified here}}
-system_error():time_error("" // expected-error 4 {{expected}} expected-error {{initializer}} expected-note {{to match}} expected-error {{no matching constructor}}
+struct system_error:runtime_error{ // expected-note {{to match}}
+system_error():time_error("" // expected-error 3 {{expected}} expected-note {{to match}}

Modified: cfe/branches/tooling/test/SemaCXX/array-bounds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/array-bounds.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/array-bounds.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/array-bounds.cpp Tue Feb 28 17:49:25 2012
@@ -247,3 +247,9 @@
   double a[5]; // expected-note {{array 'a' declared here}}
   test_pr11007_aux("foo", a[1000]); // expected-warning {{array index 1000 is past the end of the array}}
 }
+
+void test_rdar10916006(void)
+{
+	int a[128]; // expected-note {{array 'a' declared here}}
+	a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is past the end of the array}}
+}

Modified: cfe/branches/tooling/test/SemaCXX/constructor-initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/constructor-initializer.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/constructor-initializer.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/constructor-initializer.cpp Tue Feb 28 17:49:25 2012
@@ -268,3 +268,15 @@
 };
 
 }
+
+namespace PR12049 {
+  int function();
+
+  class Class
+  {
+  public:
+      Class() : member(function() {} // expected-note {{to match this '('}}
+
+      int member; // expected-error {{expected ')'}}
+  };
+}

Modified: cfe/branches/tooling/test/SemaCXX/cxx0x-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx0x-class.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-class.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-class.cpp Tue Feb 28 17:49:25 2012
@@ -26,3 +26,14 @@
     static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo'}}
   };
 }
+
+
+namespace Foo {
+  // Regression test -- forward declaration of Foo should not cause error about
+  // nonstatic data member.
+  class Foo;
+  class Foo {
+    int x;
+    int y = x;
+  };
+}

Modified: cfe/branches/tooling/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx0x-deleted-default-ctor.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-deleted-default-ctor.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-deleted-default-ctor.cpp Tue Feb 28 17:49:25 2012
@@ -121,11 +121,11 @@
 
 // See also rdar://problem/8125400.
 namespace empty {
-  static union {}; // expected-error {{implicitly-deleted default constructor}} expected-note {{here}}
-  static union { union {}; }; // expected-error {{implicitly-deleted default constructor}} expected-note {{here}}
+  static union {};
+  static union { union {}; };
   static union { struct {}; };
-  static union { union { union {}; }; }; // expected-error {{implicitly-deleted default constructor}} expected-note {{here}}
+  static union { union { union {}; }; };
   static union { union { struct {}; }; };
-  static union { struct { union {}; }; }; // expected-error {{implicitly-deleted default constructor}} expected-note {{here}}
+  static union { struct { union {}; }; };
   static union { struct { struct {}; }; };
 }

Modified: cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-constructor.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-constructor.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-constructor.cpp Tue Feb 28 17:49:25 2012
@@ -153,9 +153,9 @@
     G(std::initializer_list<int>, T ...);  // expected-note 3 {{not viable}}
   };
 
-  struct H { // expected-note 6 {{not viable}}
+  struct H { // expected-note 8 {{not viable}}
     explicit H(int, int); // expected-note 3 {{not viable}}
-    H(int, void*); // expected-note 3 {{not viable}}
+    H(int, void*); // expected-note 4 {{not viable}}
   };
 
   void edge_cases() {
@@ -186,4 +186,29 @@
     (void) new H{1, 2};
     (void) H{1, 2};
   }
+
+  struct memberinit {
+    H h1{1, nullptr};
+    H h2 = {1, nullptr};
+    H h3{1, 1};
+    H h4 = {1, 1}; // expected-error {{no matching constructor}}
+  };
+}
+
+namespace PR12092 {
+
+  struct S {
+    S(const char*);
+  };
+  struct V {
+    template<typename T> V(T, T);
+    void f(std::initializer_list<S>);
+    void f(const V &);
+  };
+
+  void g() {
+    extern V s;
+    s.f({"foo", "bar"});
+  }
+
 }

Modified: cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-scalars.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-scalars.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-scalars.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-scalars.cpp Tue Feb 28 17:49:25 2012
@@ -15,6 +15,8 @@
     // FIXME: Redundant warnings.
     { const short a{100000}; } // expected-error {{cannot be narrowed}} expected-note {{inserting an explicit cast}} expected-warning {{changes value}}
     { const short a = {100000}; } // expected-error {{cannot be narrowed}} expected-note {{inserting an explicit cast}} expected-warning {{changes value}}
+    { if (const int a{1}) static_assert(a == 1, ""); }
+    { if (const int a = {1}) static_assert(a == 1, ""); }
   }
 
   int direct_usage() {

Modified: cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Tue Feb 28 17:49:25 2012
@@ -130,6 +130,7 @@
 
 struct haslist1 {
   std::initializer_list<int> il = {1, 2, 3}; // expected-warning{{at the end of the constructor}}
+  std::initializer_list<int> jl{1, 2, 3}; // expected-warning{{at the end of the constructor}}
   haslist1();
 };
 

Modified: cfe/branches/tooling/test/SemaCXX/cxx0x-nontrivial-union.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx0x-nontrivial-union.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-nontrivial-union.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-nontrivial-union.cpp Tue Feb 28 17:49:25 2012
@@ -25,3 +25,7 @@
     non_trivial nt;
   };
 };
+
+// Don't crash on this.
+struct TemplateCtor { template<typename T> TemplateCtor(T); };
+union TemplateCtorMember { TemplateCtor s; };

Modified: cfe/branches/tooling/test/SemaCXX/cxx0x-return-init-list.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx0x-return-init-list.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-return-init-list.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-return-init-list.cpp Tue Feb 28 17:49:25 2012
@@ -1,17 +1,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-// This test checks for a teeny tiny subset of the functionality in
-// the C++11 generalized initializer lists feature, which happens to
-// be used in libstdc++ 4.5. We accept only this syntax so that Clang
-// can handle the libstdc++ 4.5 headers.
+// Test that a very basic variation of generalized initializer returns (that
+// required for libstdc++ 4.5) is supported in C++98.
 
 int test0(int i) {
-  return { i }; // expected-warning{{generalized initializer lists are a C++11 extension unsupported in Clang}}
+  return { i }; // expected-warning{{generalized initializer lists are a C++11 extension}}
 }
 
 template<typename T, typename U>
 T test1(U u) {
-  return { u }; // expected-warning{{generalized initializer lists are a C++11 extension unsupported in Clang}}
+  return { u }; // expected-warning{{generalized initializer lists are a C++11 extension}}
 }
 
 template int test1(char);

Modified: cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp Tue Feb 28 17:49:25 2012
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
 
+namespace std { struct type_info; }
+
 template<typename ...T>  // expected-warning {{variadic templates are incompatible with C++98}}
 class Variadic1 {};
 
@@ -43,6 +45,8 @@
   (void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
                // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
   int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
+  S<int> s = {}; // ok, aggregate
+  s = {}; // expected-warning {{generalized initializer lists are incompatible with C++98}}
   return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
 }
 
@@ -99,6 +103,7 @@
 char32_t c32 = 0; // expected-warning {{'char32_t' type specifier is incompatible with C++98}}
 constexpr int const_expr = 0; // expected-warning {{'constexpr' specifier is incompatible with C++98}}
 decltype(const_expr) decl_type = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}}
+__decltype(const_expr) decl_type2 = 0; // ok
 void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}}
 bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}}
 void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}}
@@ -267,3 +272,12 @@
     return;
   }
 }
+
+namespace UnevaluatedMemberAccess {
+  struct S {
+    int n;
+    int f() { return sizeof(S::n); } // ok
+  };
+  int k = sizeof(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}}
+  const std::type_info &ti = typeid(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}}
+}

Modified: cfe/branches/tooling/test/SemaCXX/defaulted-private-dtor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/defaulted-private-dtor.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/defaulted-private-dtor.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/defaulted-private-dtor.cpp Tue Feb 28 17:49:25 2012
@@ -12,6 +12,15 @@
   BadDtor dd; // expected-error {{private destructor}}
   throw dd; // expected-error {{private destructor}}
 }
+struct V { // expected-note {{here}}
+  V();
+  BadDtor bd;
+};
+V v; // expected-error {{deleted function}}
+struct W : BadDtor { // expected-note {{here}}
+  W();
+};
+W w; // expected-error {{deleted function}}
 struct X : BadDtor { // expected-error {{private destructor}}
   ~X() {}
 };

Modified: cfe/branches/tooling/test/SemaCXX/deleted-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/deleted-operator.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/deleted-operator.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/deleted-operator.cpp Tue Feb 28 17:49:25 2012
@@ -11,3 +11,8 @@
   if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 6 {{built-in candidate}}
   if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 81 {{built-in candidate}}
 }
+
+struct DelOpDel {
+  virtual ~DelOpDel() {} // expected-error {{deleted function}}
+  void operator delete(void*) = delete; // expected-note {{deleted here}}
+};

Modified: cfe/branches/tooling/test/SemaCXX/explicit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/explicit.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/explicit.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/explicit.cpp Tue Feb 28 17:49:25 2012
@@ -43,16 +43,8 @@
     class Y { }; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y &' for 1st argument}} \
 					          expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y &&' for 1st argument}} \
                     expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y &' for 1st argument}} \
-                    expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y' for 1st argument}} \
-					expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y' for 1st argument}} \
-					expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y' for 1st argument}} \
-					expected-note {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}} \
-					expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y' for 1st argument}} \
-					expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y' for 1st argument}} \
-					expected-note {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}} \
-					expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y' for 1st argument}} \
-          expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y &&' for 1st argument}} \
-					expected-note {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
+          expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y &&' for 1st argument}}
+
     struct Z {
       explicit operator Y() const;
       explicit operator int() const;
@@ -61,10 +53,9 @@
     Z z;
     // 13.3.1.4p1 & 8.5p16:
     Y y2 = z; // expected-error {{no viable conversion from 'Conversion::Z' to 'Conversion::Y'}}
-    // FIXME: These are well-formed per C++0x 13.3.1.4p1 (see DR899).
-    Y y3 = (Y)z; // expected-error {{no matching conversion for C-style cast from 'Conversion::Z' to 'Conversion::Y'}}
-    Y y4 = Y(z); // expected-error {{no matching conversion for functional-style cast from 'Conversion::Z' to 'Conversion::Y'}}
-    Y y5 = static_cast<Y>(z); // expected-error {{no matching conversion for static_cast from 'Conversion::Z' to 'Conversion::Y'}}
+    Y y3 = (Y)z;
+    Y y4 = Y(z);
+    Y y5 = static_cast<Y>(z);
     // 13.3.1.5p1 & 8.5p16:
     int i1 = (int)z;
     int i2 = int(z);

Modified: cfe/branches/tooling/test/SemaCXX/format-strings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/format-strings.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/format-strings.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/format-strings.cpp Tue Feb 28 17:49:25 2012
@@ -9,8 +9,7 @@
 }
 
 void f(char **sp, float *fp) {
-  // TODO: Warn that the 'a' length modifier is an extension.
-  scanf("%as", sp);
+  scanf("%as", sp); // expected-warning{{'a' is a non-standard length modifier}}
 
   // TODO: Warn that the 'a' conversion specifier is a C++11 feature.
   printf("%a", 1.0);

Modified: cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp Tue Feb 28 17:49:25 2012
@@ -101,3 +101,28 @@
     f(v, [](){});
   }
 }
+
+namespace NullPtr {
+  int &f(int *p);
+  char &f(...);
+  void g() {
+    int n = 0;
+    [=] {
+      char &k = f(n); // not a null pointer constant
+    } ();
+
+    const int m = 0;
+    [=] {
+      int &k = f(m); // a null pointer constant
+    } ();
+
+    [=] () -> bool {
+      int &k = f(m); // a null pointer constant
+      return &m == 0;
+    } ();
+
+    [m] {
+      int &k = f(m); // a null pointer constant
+    } ();
+  }
+}

Modified: cfe/branches/tooling/test/SemaCXX/new-delete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/new-delete.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/new-delete.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/new-delete.cpp Tue Feb 28 17:49:25 2012
@@ -460,3 +460,43 @@
       return 0;
   }
 }
+
+namespace PR12061 {
+  template <class C> struct scoped_array {
+    scoped_array(C* p = __null);
+  };
+  template <class Payload> struct Foo {
+    Foo() : a_(new scoped_array<int>[5]) { }
+    scoped_array< scoped_array<int> > a_;
+  };
+  class Bar {};
+  Foo<Bar> x;
+
+  template <class C> struct scoped_array2 {
+    scoped_array2(C* p = __null, C* q = __null);
+  };
+  template <class Payload> struct Foo2 {
+    Foo2() : a_(new scoped_array2<int>[5]) { }
+    scoped_array2< scoped_array2<int> > a_;
+  };
+  class Bar2 {};
+  Foo2<Bar2> x2;
+
+  class MessageLoop {
+  public:
+    explicit MessageLoop(int type = 0);
+  };
+  template <class CookieStoreTestTraits>
+  class CookieStoreTest {
+  protected:
+    CookieStoreTest() {
+      new MessageLoop;
+    }
+  };
+  struct CookieMonsterTestTraits {
+  };
+  class DeferredCookieTaskTest : public CookieStoreTest<CookieMonsterTestTraits>
+  {
+    DeferredCookieTaskTest() {}
+  };
+}

Modified: cfe/branches/tooling/test/SemaCXX/overload-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/overload-call.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/overload-call.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/overload-call.cpp Tue Feb 28 17:49:25 2012
@@ -534,3 +534,32 @@
     int &ir = (&foo)(0);
   }
 }
+
+namespace IncompleteArg {
+  // Ensure that overload resolution attempts to complete argument types when
+  // performing ADL.
+  template<typename T> struct S {
+    friend int f(const S&);
+  };
+  extern S<int> s;
+  int k = f(s);
+
+  template<typename T> struct Op {
+    friend bool operator==(const Op &, const Op &);
+  };
+  extern Op<char> op;
+  bool b = op == op;
+
+  // ... and not in other cases! Nothing here requires U<int()> to be complete.
+  // (Note that instantiating U<int()> will fail.)
+  template<typename T> struct U {
+    T t;
+  };
+  struct Consumer {
+    template<typename T>
+    int operator()(const U<T> &);
+  };
+  template<typename T> U<T> &make();
+  Consumer c;
+  int n = sizeof(c(make<int()>()));
+}

Modified: cfe/branches/tooling/test/SemaCXX/pragma-visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/pragma-visibility.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/pragma-visibility.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/pragma-visibility.cpp Tue Feb 28 17:49:25 2012
@@ -10,3 +10,14 @@
 } // expected-note{{surrounding namespace with visibility attribute ends here}}
 
 #pragma GCC visibility pop // expected-error{{#pragma visibility pop with no matching #pragma visibility push}}
+
+// <rdar://problem/10871094>
+struct A {
+  #pragma GCC visibility push(protected)
+  #pragma GCC visibility pop
+};
+
+void f() {
+  #pragma GCC visibility push(protected)
+  #pragma GCC visibility pop
+}

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=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/type-traits.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/type-traits.cpp Tue Feb 28 17:49:25 2012
@@ -39,6 +39,18 @@
 struct HasCons { HasCons(int); };
 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
+struct HasDefaultTrivialCopyAssign { 
+  HasDefaultTrivialCopyAssign &operator =(const HasDefaultTrivialCopyAssign&)
+    = default; 
+};
+struct TrivialMoveButNotCopy { 
+  TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default;
+  TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&);
+};
+struct NonTrivialDefault {
+  NonTrivialDefault();
+};
+
 struct HasDest { ~HasDest(); };
 class  HasPriv { int priv; };
 class  HasProt { protected: int prot; };
@@ -96,6 +108,10 @@
   ~AllPrivate() throw();
 };
 
+struct ThreeArgCtor {
+  ThreeArgCtor(int*, char*, int);
+};
+
 void is_pod()
 {
   { int arr[T(__is_pod(int))]; }
@@ -916,6 +932,41 @@
   NonTCStruct(const NonTCStruct&) {}
 };
 
+struct AllDefaulted {
+  AllDefaulted() = default;
+  AllDefaulted(const AllDefaulted &) = default;
+  AllDefaulted(AllDefaulted &&) = default;
+  AllDefaulted &operator=(const AllDefaulted &) = default;
+  AllDefaulted &operator=(AllDefaulted &&) = default;
+  ~AllDefaulted() = default;
+};
+
+struct AllDeleted {
+  AllDeleted() = delete;
+  AllDeleted(const AllDeleted &) = delete;
+  AllDeleted(AllDeleted &&) = delete;
+  AllDeleted &operator=(const AllDeleted &) = delete;
+  AllDeleted &operator=(AllDeleted &&) = delete;
+  ~AllDeleted() = delete;
+};
+
+struct ExtDefaulted {
+  ExtDefaulted();
+  ExtDefaulted(const ExtDefaulted &);
+  ExtDefaulted(ExtDefaulted &&);
+  ExtDefaulted &operator=(const ExtDefaulted &);
+  ExtDefaulted &operator=(ExtDefaulted &&);
+  ~ExtDefaulted();
+};
+
+// Despite being defaulted, these functions are not trivial.
+ExtDefaulted::ExtDefaulted() = default;
+ExtDefaulted::ExtDefaulted(const ExtDefaulted &) = default;
+ExtDefaulted::ExtDefaulted(ExtDefaulted &&) = default;
+ExtDefaulted &ExtDefaulted::operator=(const ExtDefaulted &) = default;
+ExtDefaulted &ExtDefaulted::operator=(ExtDefaulted &&) = default;
+ExtDefaulted::~ExtDefaulted() = default;
+
 void is_trivial2()
 {
   int t01[T(__is_trivial(char))];
@@ -940,11 +991,14 @@
   int t20[T(__is_trivial(Union))];
   int t21[T(__is_trivial(UnionAr))];
   int t22[T(__is_trivial(TrivialStruct))];
+  int t23[T(__is_trivial(AllDefaulted))];
+  int t24[T(__is_trivial(AllDeleted))];
 
   int t30[F(__is_trivial(void))];
   int t31[F(__is_trivial(NonTrivialStruct))];
   int t32[F(__is_trivial(SuperNonTrivialStruct))];
   int t33[F(__is_trivial(NonTCStruct))];
+  int t34[F(__is_trivial(ExtDefaulted))];
 }
 
 void is_trivially_copyable2()
@@ -972,10 +1026,13 @@
   int t21[T(__is_trivially_copyable(UnionAr))];
   int t22[T(__is_trivially_copyable(TrivialStruct))];
   int t23[T(__is_trivially_copyable(NonTrivialStruct))];
+  int t24[T(__is_trivially_copyable(AllDefaulted))];
+  int t25[T(__is_trivially_copyable(AllDeleted))];
 
   int t30[F(__is_trivially_copyable(void))];
-  int t32[F(__is_trivially_copyable(SuperNonTrivialStruct))];
-  int t31[F(__is_trivially_copyable(NonTCStruct))];
+  int t31[F(__is_trivially_copyable(SuperNonTrivialStruct))];
+  int t32[F(__is_trivially_copyable(NonTCStruct))];
+  int t33[F(__is_trivially_copyable(ExtDefaulted))];
 }
 
 struct CStruct {
@@ -1131,6 +1188,8 @@
   { int arr[T(__has_trivial_constructor(HasCopyAssign))]; }
   { int arr[T(__has_trivial_constructor(HasMoveAssign))]; }
   { int arr[T(__has_trivial_constructor(const Int))]; }
+  { int arr[T(__has_trivial_constructor(AllDefaulted))]; }
+  { int arr[T(__has_trivial_constructor(AllDeleted))]; }
 
   { int arr[F(__has_trivial_constructor(HasCons))]; }
   { int arr[F(__has_trivial_constructor(HasRef))]; }
@@ -1141,6 +1200,7 @@
   { int arr[F(__has_trivial_constructor(cvoid))]; }
   { int arr[F(__has_trivial_constructor(HasTemplateCons))]; }
   { int arr[F(__has_trivial_constructor(AllPrivate))]; }
+  { int arr[F(__has_trivial_constructor(ExtDefaulted))]; }
 }
 
 void has_trivial_copy_constructor() {
@@ -1161,6 +1221,8 @@
   { int arr[T(__has_trivial_copy(HasCopyAssign))]; }
   { int arr[T(__has_trivial_copy(HasMoveAssign))]; }
   { int arr[T(__has_trivial_copy(const Int))]; }
+  { int arr[T(__has_trivial_copy(AllDefaulted))]; }
+  { int arr[T(__has_trivial_copy(AllDeleted))]; }
 
   { int arr[F(__has_trivial_copy(HasCopy))]; }
   { int arr[F(__has_trivial_copy(HasTemplateCons))]; }
@@ -1169,6 +1231,7 @@
   { int arr[F(__has_trivial_copy(void))]; }
   { int arr[F(__has_trivial_copy(cvoid))]; }
   { int arr[F(__has_trivial_copy(AllPrivate))]; }
+  { int arr[F(__has_trivial_copy(ExtDefaulted))]; }
 }
 
 void has_trivial_copy_assignment() {
@@ -1185,6 +1248,8 @@
   { int arr[T(__has_trivial_assign(HasCopy))]; }
   { int arr[T(__has_trivial_assign(HasMove))]; }
   { int arr[T(__has_trivial_assign(HasMoveAssign))]; }
+  { int arr[T(__has_trivial_assign(AllDefaulted))]; }
+  { int arr[T(__has_trivial_assign(AllDeleted))]; }
 
   { int arr[F(__has_trivial_assign(IntRef))]; }
   { int arr[F(__has_trivial_assign(HasCopyAssign))]; }
@@ -1196,6 +1261,7 @@
   { int arr[F(__has_trivial_assign(void))]; }
   { int arr[F(__has_trivial_assign(cvoid))]; }
   { int arr[F(__has_trivial_assign(AllPrivate))]; }
+  { int arr[F(__has_trivial_assign(ExtDefaulted))]; }
 }
 
 void has_trivial_destructor() {
@@ -1218,11 +1284,14 @@
   { int arr[T(__has_trivial_destructor(const Int))]; }
   { int arr[T(__has_trivial_destructor(DerivesAr))]; }
   { int arr[T(__has_trivial_destructor(VirtAr))]; }
+  { int arr[T(__has_trivial_destructor(AllDefaulted))]; }
+  { int arr[T(__has_trivial_destructor(AllDeleted))]; }
 
   { int arr[F(__has_trivial_destructor(HasDest))]; }
   { int arr[F(__has_trivial_destructor(void))]; }
   { int arr[F(__has_trivial_destructor(cvoid))]; }
   { int arr[F(__has_trivial_destructor(AllPrivate))]; }
+  { int arr[F(__has_trivial_destructor(ExtDefaulted))]; }
 }
 
 struct A { ~A() {} };
@@ -1444,13 +1513,11 @@
   isBaseOfF<DerivedB<int>, BaseA<int> >();
 }
 
-#if 0
 template<class T, class U>
 class TemplateClass {};
 
 template<class T>
 using TemplateAlias = TemplateClass<T, int>;
-#endif
 
 typedef class Base BaseTypedef;
 
@@ -1458,9 +1525,7 @@
 {
   int t01[T(__is_same(Base, Base))];
   int t02[T(__is_same(Base, BaseTypedef))];
-#if 0
   int t03[T(__is_same(TemplateClass<int, int>, TemplateAlias<int>))];
-#endif
 
   int t10[F(__is_same(Base, const Base))];
   int t11[F(__is_same(Base, Base&))];
@@ -1594,7 +1659,7 @@
   { int arr[F(__is_trivial(cvoid))]; }
 }
 
-void is_trivially_copyable()
+void trivial_checks()
 {
   { int arr[T(__is_trivially_copyable(int))]; }
   { int arr[T(__is_trivially_copyable(Enum))]; }
@@ -1637,6 +1702,108 @@
   { int arr[F(__is_trivially_copyable(DerivesHasVirt))]; }
   { int arr[F(__is_trivially_copyable(void))]; }
   { int arr[F(__is_trivially_copyable(cvoid))]; }
+
+  { int arr[T((__is_trivially_constructible(int)))]; }
+  { int arr[T((__is_trivially_constructible(int, int)))]; }
+  { int arr[T((__is_trivially_constructible(int, float)))]; }
+  { int arr[T((__is_trivially_constructible(int, int&)))]; }
+  { int arr[T((__is_trivially_constructible(int, const int&)))]; }
+  { int arr[T((__is_trivially_constructible(int, int)))]; }
+  { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign)))]; }
+  { int arr[T((__is_trivially_constructible(HasCopyAssign, const HasCopyAssign&)))]; }
+  { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign&&)))]; }
+  { int arr[T((__is_trivially_constructible(HasCopyAssign)))]; }
+  { int arr[T((__is_trivially_constructible(NonTrivialDefault,
+                                            const NonTrivialDefault&)))]; }
+  { int arr[T((__is_trivially_constructible(NonTrivialDefault,
+                                            NonTrivialDefault&&)))]; }
+  { int arr[T((__is_trivially_constructible(AllDefaulted)))]; }
+  { int arr[T((__is_trivially_constructible(AllDefaulted,
+                                            const AllDefaulted &)))]; }
+  { int arr[T((__is_trivially_constructible(AllDefaulted,
+                                            AllDefaulted &&)))]; }
+
+  { int arr[F((__is_trivially_constructible(int, int*)))]; }
+  { int arr[F((__is_trivially_constructible(NonTrivialDefault)))]; }
+  { int arr[F((__is_trivially_constructible(ThreeArgCtor, int*, char*, int&)))]; }
+  { int arr[F((__is_trivially_constructible(AllDeleted)))]; }
+  { int arr[F((__is_trivially_constructible(AllDeleted,
+                                            const AllDeleted &)))]; }
+  { int arr[F((__is_trivially_constructible(AllDeleted,
+                                            AllDeleted &&)))]; }
+  { int arr[F((__is_trivially_constructible(ExtDefaulted)))]; }
+  { int arr[F((__is_trivially_constructible(ExtDefaulted,
+                                            const ExtDefaulted &)))]; }
+  { int arr[F((__is_trivially_constructible(ExtDefaulted,
+                                            ExtDefaulted &&)))]; }
+
+  { int arr[T((__is_trivially_assignable(int&, int)))]; }
+  { int arr[T((__is_trivially_assignable(int&, int&)))]; }
+  { int arr[T((__is_trivially_assignable(int&, int&&)))]; }
+  { int arr[T((__is_trivially_assignable(int&, const int&)))]; }
+  { int arr[T((__is_trivially_assignable(POD&, POD)))]; }
+  { int arr[T((__is_trivially_assignable(POD&, POD&)))]; }
+  { int arr[T((__is_trivially_assignable(POD&, POD&&)))]; }
+  { int arr[T((__is_trivially_assignable(POD&, const POD&)))]; }
+  { int arr[T((__is_trivially_assignable(int*&, int*)))]; }
+  { int arr[T((__is_trivially_assignable(AllDefaulted,
+                                         const AllDefaulted &)))]; }
+  { int arr[T((__is_trivially_assignable(AllDefaulted,
+                                         AllDefaulted &&)))]; }
+
+  { int arr[F((__is_trivially_assignable(int*&, float*)))]; }
+  { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign)))]; }
+  { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&)))]; }
+  { int arr[F((__is_trivially_assignable(HasCopyAssign&, const HasCopyAssign&)))]; }
+  { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&&)))]; }
+  { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&,
+                                        TrivialMoveButNotCopy&)))]; }
+  { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&,
+                                        const TrivialMoveButNotCopy&)))]; }
+  { int arr[F((__is_trivially_assignable(AllDeleted,
+                                         const AllDeleted &)))]; }
+  { int arr[F((__is_trivially_assignable(AllDeleted,
+                                         AllDeleted &&)))]; }
+  { int arr[F((__is_trivially_assignable(ExtDefaulted,
+                                         const ExtDefaulted &)))]; }
+  { int arr[F((__is_trivially_assignable(ExtDefaulted,
+                                         ExtDefaulted &&)))]; }
+
+  { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&,
+                                         HasDefaultTrivialCopyAssign&)))]; }
+  { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&,
+                                       const HasDefaultTrivialCopyAssign&)))]; }
+  { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&,
+                                         TrivialMoveButNotCopy)))]; }
+  { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&,
+                                         TrivialMoveButNotCopy&&)))]; }
+}
+
+// Instantiation of __is_trivially_constructible
+template<typename T, typename ...Args>
+struct is_trivially_constructible {
+  static const bool value = __is_trivially_constructible(T, Args...);
+};
+
+void is_trivially_constructible_test() {
+  { int arr[T((is_trivially_constructible<int>::value))]; }
+  { int arr[T((is_trivially_constructible<int, int>::value))]; }
+  { int arr[T((is_trivially_constructible<int, float>::value))]; }
+  { int arr[T((is_trivially_constructible<int, int&>::value))]; }
+  { int arr[T((is_trivially_constructible<int, const int&>::value))]; }
+  { int arr[T((is_trivially_constructible<int, int>::value))]; }
+  { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign>::value))]; }
+  { int arr[T((is_trivially_constructible<HasCopyAssign, const HasCopyAssign&>::value))]; }
+  { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign&&>::value))]; }
+  { int arr[T((is_trivially_constructible<HasCopyAssign>::value))]; }
+  { int arr[T((is_trivially_constructible<NonTrivialDefault,
+                                            const NonTrivialDefault&>::value))]; }
+  { int arr[T((is_trivially_constructible<NonTrivialDefault,
+                                            NonTrivialDefault&&>::value))]; }
+
+  { int arr[F((is_trivially_constructible<int, int*>::value))]; }
+  { int arr[F((is_trivially_constructible<NonTrivialDefault>::value))]; }
+  { int arr[F((is_trivially_constructible<ThreeArgCtor, int*, char*, int&>::value))]; }
 }
 
 void array_rank() {

Modified: cfe/branches/tooling/test/SemaCXX/typo-correction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/typo-correction.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/typo-correction.cpp Tue Feb 28 17:49:25 2012
@@ -167,3 +167,19 @@
 };
 class Child: public Parent {};
 void Child::add_types(int value) {} // expected-error{{out-of-line definition of 'add_types' does not match any declaration in 'Child'}}
+
+// Fix the callback based filtering of typo corrections within
+// Sema::ActOnIdExpression by Parser::ParseCastExpression to allow type names as
+// potential corrections for template arguments.
+namespace clash {
+class ConstructExpr {}; // expected-note{{'clash::ConstructExpr' declared here}}
+}
+class ClashTool {
+  bool HaveConstructExpr();
+  template <class T> T* getExprAs();
+
+  void test() {
+    ConstructExpr *expr = // expected-error{{unknown type name 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}}
+        getExprAs<ConstructExpr>(); // expected-error{{use of undeclared identifier 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}}
+  }
+};

Modified: cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp Tue Feb 28 17:49:25 2012
@@ -2100,3 +2100,17 @@
 } // end namespace SelfLockingTest
 
 
+namespace InvalidNonstatic {
+
+// Forward decl here causes bogus "invalid use of non-static data member"
+// on reference to mutex_ in guarded_by attribute.
+class Foo;
+
+class Foo {
+  Mutex* mutex_;
+
+  int foo __attribute__((guarded_by(mutex_)));
+};
+
+}  // end namespace InvalidNonStatic
+

Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 28 17:49:25 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-151084
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-151662

Modified: cfe/branches/tooling/test/SemaObjC/arc-peformselector.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-peformselector.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-peformselector.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-peformselector.m Tue Feb 28 17:49:25 2012
@@ -2,12 +2,12 @@
 // rdar://9659270
 
 @interface NSObject
-- (id)copy; // expected-note {{method declared here}}
-- (id) test __attribute__((ns_returns_retained)); // expected-note {{method declared here}}
-+ (id) new ; // expected-note {{method declared here}}
+- (id)copy; // expected-note {{method 'copy' declared here}}
+- (id) test __attribute__((ns_returns_retained)); // expected-note {{method 'test' declared here}}
++ (id) new ; // expected-note {{method 'new' declared here}}
 - (id) init __attribute__((ns_returns_not_retained));
 - (id)PlusZero;
-- (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method declared here}}
+- (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method 'PlusOne' declared here}}
 @end
 
 @interface I : NSObject

Modified: cfe/branches/tooling/test/SemaObjC/arc-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-property.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-property.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-property.m Tue Feb 28 17:49:25 2012
@@ -46,3 +46,12 @@
 @synthesize z;  // suppressed
 @end
 
+// rdar://problem/10904479
+// Don't crash.
+ at interface Test2
+// Minor FIXME: kill the redundant error
+ at property (strong) UndeclaredClass *test2;  // expected-error {{unknown type name 'UndeclaredClass'}} expected-error {{must be of object type}}
+ at end
+ at implementation Test2
+ at synthesize test2;
+ at end

Modified: cfe/branches/tooling/test/SemaObjC/arc-type-conversion.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-type-conversion.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-type-conversion.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-type-conversion.m Tue Feb 28 17:49:25 2012
@@ -90,3 +90,9 @@
   (void)(Block)&lv; // expected-error {{cast of an indirect pointer to an Objective-C pointer to 'Block'}}
   (void)(Block*)lv; // expected-error {{cast of an Objective-C pointer to '__strong Block *'}}
 }
+
+// <rdar://problem/10486347>
+void conversion_in_conditional(id a, void* b) {
+  id c = 1 ? a : b; // expected-error {{operands to conditional of types 'id' and 'void *' are incompatible in ARC mode}}
+  id d = 1 ? b : a; // expected-error {{operands to conditional of types 'void *' and 'id' are incompatible in ARC mode}}
+}

Modified: cfe/branches/tooling/test/SemaObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc.m Tue Feb 28 17:49:25 2012
@@ -42,10 +42,10 @@
 // rdar://8843638
 
 @interface I
-- (id)retain; // expected-note {{method declared here}}
-- (id)autorelease; // expected-note {{method declared here}}
-- (oneway void)release; // expected-note {{method declared here}}
-- (NSUInteger)retainCount; // expected-note {{method declared here}}
+- (id)retain; // expected-note {{method 'retain' declared here}}
+- (id)autorelease; // expected-note {{method 'autorelease' declared here}}
+- (oneway void)release; // expected-note {{method 'release' declared here}}
+- (NSUInteger)retainCount; // expected-note {{method 'retainCount' declared here}}
 @end
 
 @implementation I

Modified: cfe/branches/tooling/test/SemaObjC/category-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/category-1.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/category-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/category-1.m Tue Feb 28 17:49:25 2012
@@ -62,7 +62,7 @@
 // <rdar://problem/7249233>
 
 @protocol MultipleCat_P
--(void) im0; // expected-note {{method declared here}}
+-(void) im0; // expected-note {{method 'im0' declared here}}
 @end
 
 @interface MultipleCat_I @end // expected-note {{required for direct or indirect protocol 'MultipleCat_P'}}
@@ -72,7 +72,7 @@
 @interface MultipleCat_I() <MultipleCat_P>  @end
 
 @implementation MultipleCat_I // expected-warning {{incomplete implementation}} \
-                              // expected-warning {{method in protocol not implemented}}
+                              // expected-warning {{method 'im0' in protocol not implemented}}
 @end
 
 // <rdar://problem/7680391> - Handle nameless categories with no name that refer

Modified: cfe/branches/tooling/test/SemaObjC/class-message-protocol-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/class-message-protocol-lookup.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/class-message-protocol-lookup.m (original)
+++ cfe/branches/tooling/test/SemaObjC/class-message-protocol-lookup.m Tue Feb 28 17:49:25 2012
@@ -13,7 +13,7 @@
 
 @protocol Test2Protocol
 + (id)alloc;
-- (id)alloc2; // expected-note 2 {{method declared here}}
+- (id)alloc2; // expected-note 2 {{method 'alloc2' declared here}}
 @end
 
 @implementation RandomObject

Modified: cfe/branches/tooling/test/SemaObjC/compare-qualified-id.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/compare-qualified-id.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/compare-qualified-id.m (original)
+++ cfe/branches/tooling/test/SemaObjC/compare-qualified-id.m Tue Feb 28 17:49:25 2012
@@ -5,7 +5,7 @@
 typedef struct _NSZone NSZone;
 @class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
 @protocol NSObject  - (BOOL)isEqual:(id)object; @end
- at protocol NSCopying  - (id)copyWithZone:(NSZone *)zone; @end // expected-note {{method declared here}}
+ at protocol NSCopying  - (id)copyWithZone:(NSZone *)zone; @end // expected-note {{method 'copyWithZone:' declared here}}
 @protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone; @end
 @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder; @end
 @interface NSObject <NSObject> {} @end
@@ -24,7 +24,7 @@
 @end
 
 @implementation XCPropertyExpansionContext // expected-warning {{incomplete implementation}} \
-					   // expected-warning {{method in protocol not implemented}}
+					   // expected-warning {{method 'copyWithZone:' in protocol not implemented}}
 - (NSString *)expandedValueForProperty:(NSString *)property {
   id <XCPropertyValues> cachedValueNode = [_propNamesToPropValuesCache objectForKey:property]; // expected-warning {{method '-objectForKey:' not found (return type defaults to 'id')}}
   if (cachedValueNode == ((void *)0)) { }

Modified: cfe/branches/tooling/test/SemaObjC/incomplete-implementation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/incomplete-implementation.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/incomplete-implementation.m (original)
+++ cfe/branches/tooling/test/SemaObjC/incomplete-implementation.m Tue Feb 28 17:49:25 2012
@@ -2,7 +2,7 @@
 
 @interface I
 - Meth; // expected-note{{method definition for 'Meth' not found}} \
-        // expected-note{{method declared here}}
+        // expected-note{{method 'Meth' declared here}}
 @end
 
 @implementation  I  // expected-warning{{incomplete implementation}}
@@ -14,7 +14,7 @@
 
 #pragma GCC diagnostic ignored "-Wincomplete-implementation"
 @interface I2
-- Meth; // expected-note{{method declared here}}
+- Meth; // expected-note{{method 'Meth' declared here}}
 @end
 
 @implementation  I2

Modified: cfe/branches/tooling/test/SemaObjC/method-attributes.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-attributes.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-attributes.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-attributes.m Tue Feb 28 17:49:25 2012
@@ -13,9 +13,9 @@
 @interface INTF
 - (int) foo1: (int)arg1 __attribute__((deprecated));
 
-- (int) foo: (int)arg1;  // expected-note {{method declared here}}
+- (int) foo: (int)arg1;  // expected-note {{method 'foo:' declared here}}
 
-- (int) foo2: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{method declared here}}
+- (int) foo2: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{method 'foo2:' declared here}}
 - (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self));
 @end
 
@@ -39,7 +39,7 @@
 
 @interface Foo 
 - (void)doSomething1:(id)sender;
-- (void)doSomething2:(id)sender; // expected-note {{method declared here}}
+- (void)doSomething2:(id)sender; // expected-note {{method 'doSomething2:' declared here}}
 @end
 
 @implementation Foo

Modified: cfe/branches/tooling/test/SemaObjC/method-undef-category-warn-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-undef-category-warn-1.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-undef-category-warn-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-undef-category-warn-1.m Tue Feb 28 17:49:25 2012
@@ -4,8 +4,8 @@
 @end
 
 @protocol P
-- (void) Pmeth;	  // expected-note {{method declared here}}
-- (void) Pmeth1;    // expected-note {{method declared here}}
+- (void) Pmeth;	  // expected-note {{method 'Pmeth' declared here}}
+- (void) Pmeth1;    // expected-note {{method 'Pmeth1' declared here}}
 @end
 
 @interface MyClass1(CAT) <P> // expected-note {{required for direct or indirect protocol 'P'}}
@@ -13,7 +13,7 @@
 @end
 
 @implementation MyClass1(CAT) // expected-warning {{incomplete implementation}}  \
-				// expected-warning {{method in protocol not implemented}}
+				// expected-warning {{method 'Pmeth' in protocol not implemented}}
 - (void) Pmeth1{}
 @end
 
@@ -22,7 +22,7 @@
 @end
 
 @implementation MyClass1(DOG) // expected-warning {{incomplete implementation}} \
-		// expected-warning {{method in protocol not implemented}}
+		// expected-warning {{method 'Pmeth1' in protocol not implemented}}
 - (void) Pmeth {}
 @end
 

Modified: cfe/branches/tooling/test/SemaObjC/method-undef-extension-warn-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-undef-extension-warn-1.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-undef-extension-warn-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-undef-extension-warn-1.m Tue Feb 28 17:49:25 2012
@@ -5,7 +5,7 @@
 
 @protocol P
 - (void)Pmeth;
-- (void)Pmeth1; // expected-note {{method declared here}}
+- (void)Pmeth1; // expected-note {{method 'Pmeth1' declared here}}
 @end
 
 // Class extension
@@ -19,6 +19,6 @@
 @end
 
 @implementation MyClass // expected-warning {{incomplete implementation}}  \
-			// expected-warning {{method in protocol not implemented}}
+			// expected-warning {{method 'Pmeth1' in protocol not implemented}}
 - (void)Pmeth {}
 @end

Modified: cfe/branches/tooling/test/SemaObjC/protocol-implementing-class-methods.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/protocol-implementing-class-methods.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/protocol-implementing-class-methods.m (original)
+++ cfe/branches/tooling/test/SemaObjC/protocol-implementing-class-methods.m Tue Feb 28 17:49:25 2012
@@ -5,11 +5,11 @@
 @optional
 - (int) PMeth;
 @required
-- (void) : (double) arg; // expected-note {{method declared here}}
+- (void) : (double) arg; // expected-note {{method ':' declared here}}
 @end
 
 @interface NSImage <P1>
-- (void) initialize; // expected-note {{method declared here}}
+- (void) initialize; // expected-note {{method 'initialize' declared here}}
 @end
 
 @interface NSImage (AirPortUI)
@@ -17,7 +17,7 @@
 @end
 
 @interface NSImage()
-- (void) CEMeth; // expected-note {{method declared here}}
+- (void) CEMeth; // expected-note {{method 'CEMeth' declared here}}
 @end
 
 @implementation NSImage (AirPortUI)

Modified: cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m (original)
+++ cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m Tue Feb 28 17:49:25 2012
@@ -150,7 +150,7 @@
 
 // <rdar://problem/9340699>
 @interface G 
-- (id)_ABC_init __attribute__((objc_method_family(init))); // expected-note {{method declared here}}
+- (id)_ABC_init __attribute__((objc_method_family(init))); // expected-note {{method '_ABC_init' declared here}}
 @end
 
 @interface G (Additions)

Modified: cfe/branches/tooling/test/SemaObjC/undef-protocol-methods-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/undef-protocol-methods-1.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/undef-protocol-methods-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/undef-protocol-methods-1.m Tue Feb 28 17:49:25 2012
@@ -1,25 +1,25 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 @protocol P1
-- (void) P1proto;  // expected-note {{method declared here}}
-+ (void) ClsP1Proto;    // expected-note {{method declared here}}
+- (void) P1proto;  // expected-note {{method 'P1proto' declared here}}
++ (void) ClsP1Proto;    // expected-note {{method 'ClsP1Proto' declared here}}
 - (void) DefP1proto;
 @end
 @protocol P2
-- (void) P2proto;   // expected-note {{method declared here}}
-+ (void) ClsP2Proto;  // expected-note {{method declared here}}
+- (void) P2proto;   // expected-note {{method 'P2proto' declared here}}
++ (void) ClsP2Proto;  // expected-note {{method 'ClsP2Proto' declared here}}
 @end
 
 @protocol P3<P2>
-- (void) P3proto;   // expected-note {{method declared here}}
-+ (void) ClsP3Proto;   // expected-note {{method declared here}}
+- (void) P3proto;   // expected-note {{method 'P3proto' declared here}}
++ (void) ClsP3Proto;   // expected-note {{method 'ClsP3Proto' declared here}}
 + (void) DefClsP3Proto;
 @end
 
 @protocol PROTO<P1, P3>
-- (void) meth;		  // expected-note {{method declared here}}
-- (void) meth : (int) arg1;   // expected-note {{method declared here}}
-+ (void) cls_meth : (int) arg1;   // expected-note {{method declared here}}
+- (void) meth;		  // expected-note {{method 'meth' declared here}}
+- (void) meth : (int) arg1;   // expected-note {{method 'meth:' declared here}}
++ (void) cls_meth : (int) arg1;   // expected-note {{method 'cls_meth:' declared here}}
 @end
 
 @interface INTF <PROTO> // expected-note 3 {{required for direct or indirect protocol 'PROTO'}} \
@@ -29,7 +29,7 @@
 @end
 
 @implementation INTF   // expected-warning {{incomplete implementation}} \
-                       // expected-warning 9 {{method in protocol not implemented}}
+                       // expected-warning 9 {{in protocol not implemented}}
 - (void) DefP1proto{}
 
 + (void) DefClsP3Proto{}

Modified: cfe/branches/tooling/test/SemaObjC/warn-deprecated-implementations.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/warn-deprecated-implementations.m?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/warn-deprecated-implementations.m (original)
+++ cfe/branches/tooling/test/SemaObjC/warn-deprecated-implementations.m Tue Feb 28 17:49:25 2012
@@ -2,15 +2,15 @@
 // rdar://8973810
 
 @protocol P
-- (void) D __attribute__((deprecated)); // expected-note {{method declared here}}
+- (void) D __attribute__((deprecated)); // expected-note {{method 'D' declared here}}
 @end
 
 @interface A <P>
-+ (void)F __attribute__((deprecated)); // expected-note {{method declared here}}
++ (void)F __attribute__((deprecated)); // expected-note {{method 'F' declared here}}
 @end
 
 @interface A()
-- (void) E __attribute__((deprecated)); // expected-note {{method declared here}}
+- (void) E __attribute__((deprecated)); // expected-note {{method 'E' declared here}}
 @end
 
 @implementation A
@@ -34,7 +34,7 @@
 @end
 
 @interface BASE
-- (void) B __attribute__((deprecated)); // expected-note {{method declared here}}
+- (void) B __attribute__((deprecated)); // expected-note {{method 'B' declared here}}
 @end
 
 @interface SUB : BASE

Modified: cfe/branches/tooling/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/c-index-test/c-index-test.c?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/tools/c-index-test/c-index-test.c (original)
+++ cfe/branches/tooling/tools/c-index-test/c-index-test.c Tue Feb 28 17:49:25 2012
@@ -37,8 +37,6 @@
     options |= clang_defaultEditingTranslationUnitOptions();
   if (getenv("CINDEXTEST_COMPLETION_CACHING"))
     options |= CXTranslationUnit_CacheCompletionResults;
-  if (getenv("CINDEXTEST_NESTED_MACROS"))
-    options |= CXTranslationUnit_NestedMacroExpansions;
   if (getenv("CINDEXTEST_COMPLETION_NO_CACHING"))
     options &= ~CXTranslationUnit_CacheCompletionResults;
   
@@ -1811,6 +1809,7 @@
   const CXIdxObjCCategoryDeclInfo *CatInfo;
   const CXIdxObjCInterfaceDeclInfo *InterInfo;
   const CXIdxObjCProtocolRefListInfo *ProtoInfo;
+  const CXIdxObjCPropertyDeclInfo *PropInfo;
   const CXIdxCXXClassDeclInfo *CXXClassInfo;
   unsigned i;
   index_data = (IndexData *)client_data;
@@ -1872,6 +1871,17 @@
     printProtocolList(ProtoInfo, client_data);
   }
 
+  if ((PropInfo = clang_index_getObjCPropertyDeclInfo(info))) {
+    if (PropInfo->getter) {
+      printEntityInfo("     <getter>", client_data, PropInfo->getter);
+      printf("\n");
+    }
+    if (PropInfo->setter) {
+      printEntityInfo("     <setter>", client_data, PropInfo->setter);
+      printf("\n");
+    }
+  }
+
   if ((CXXClassInfo = clang_index_getCXXClassDeclInfo(info))) {
     for (i = 0; i != CXXClassInfo->numBases; ++i) {
       printBaseClassInfo(client_data, CXXClassInfo->bases[i]);

Modified: cfe/branches/tooling/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CIndex.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CIndex.cpp Tue Feb 28 17:49:25 2012
@@ -35,7 +35,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -1755,6 +1755,7 @@
   void VisitWhileStmt(WhileStmt *W);
   void VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E);
   void VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E);
+  void VisitTypeTraitExpr(TypeTraitExpr *E);
   void VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E);
   void VisitExpressionTraitExpr(ExpressionTraitExpr *E);
   void VisitUnresolvedMemberExpr(UnresolvedMemberExpr *U);
@@ -2056,6 +2057,11 @@
   AddTypeLoc(E->getLhsTypeSourceInfo());
 }
 
+void EnqueueVisitor::VisitTypeTraitExpr(TypeTraitExpr *E) {
+  for (unsigned I = E->getNumArgs(); I > 0; --I)
+    AddTypeLoc(E->getArg(I-1));
+}
+
 void EnqueueVisitor::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
   AddTypeLoc(E->getQueriedTypeSourceInfo());
 }
@@ -2448,8 +2454,7 @@
                                           const char * const *command_line_args,
                                           unsigned num_unsaved_files,
                                           struct CXUnsavedFile *unsaved_files) {
-  unsigned Options = CXTranslationUnit_DetailedPreprocessingRecord |
-                     CXTranslationUnit_NestedMacroExpansions;
+  unsigned Options = CXTranslationUnit_DetailedPreprocessingRecord;
   return clang_parseTranslationUnit(CIdx, source_filename,
                                     command_line_args, num_command_line_args,
                                     unsaved_files, num_unsaved_files,
@@ -2551,12 +2556,9 @@
     Args->push_back(source_filename);
 
   // Do we need the detailed preprocessing record?
-  bool NestedMacroExpansions = false;
   if (options & CXTranslationUnit_DetailedPreprocessingRecord) {
     Args->push_back("-Xclang");
     Args->push_back("-detailed-preprocessing-record");
-    NestedMacroExpansions
-      = (options & CXTranslationUnit_NestedMacroExpansions);
   }
   
   unsigned NumErrors = Diags->getClient()->getNumErrors();
@@ -2573,8 +2575,7 @@
                                  /*RemappedFilesKeepOriginalName=*/true,
                                  PrecompilePreamble,
                                  TUKind,
-                                 CacheCodeCompetionResults,
-                                 NestedMacroExpansions));
+                                 CacheCodeCompetionResults));
 
   if (NumErrors != Diags->getClient()->getNumErrors()) {
     // Make sure to check that 'Unit' is non-NULL.

Modified: cfe/branches/tooling/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CXCursor.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CXCursor.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CXCursor.cpp Tue Feb 28 17:49:25 2012
@@ -206,6 +206,7 @@
   case Stmt::AtomicExprClass:
   case Stmt::BinaryConditionalOperatorClass:
   case Stmt::BinaryTypeTraitExprClass:
+  case Stmt::TypeTraitExprClass:
   case Stmt::CXXBindTemporaryExprClass:
   case Stmt::CXXDefaultArgExprClass:
   case Stmt::CXXScalarValueInitExprClass:

Modified: cfe/branches/tooling/tools/libclang/IndexBody.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexBody.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexBody.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexBody.cpp Tue Feb 28 17:49:25 2012
@@ -51,6 +51,17 @@
     return true;
   }
 
+  bool VisitDesignatedInitExpr(DesignatedInitExpr *E) {
+    for (DesignatedInitExpr::reverse_designators_iterator
+           D = E->designators_rbegin(), DEnd = E->designators_rend();
+           D != DEnd; ++D) {
+      if (D->isFieldDesignator())
+        IndexCtx.handleReference(D->getField(), D->getFieldLoc(),
+                                 Parent, ParentDC, E);
+    }
+    return true;
+  }
+
   bool VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
     IndexCtx.handleReference(E->getDecl(), E->getLocation(),
                              Parent, ParentDC, E);

Modified: cfe/branches/tooling/tools/libclang/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexDecl.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexDecl.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexDecl.cpp Tue Feb 28 17:49:25 2012
@@ -41,6 +41,24 @@
     }
   }
 
+  void handleObjCMethod(ObjCMethodDecl *D) {
+    IndexCtx.handleObjCMethod(D);
+    if (D->isImplicit())
+      return;
+
+    IndexCtx.indexTypeSourceInfo(D->getResultTypeSourceInfo(), D);
+    for (ObjCMethodDecl::param_iterator
+           I = D->param_begin(), E = D->param_end(); I != E; ++I)
+      handleDeclarator(*I, D);
+
+    if (D->isThisDeclarationADefinition()) {
+      const Stmt *Body = D->getBody();
+      if (Body) {
+        IndexCtx.indexBody(Body, D, D);
+      }
+    }
+  }
+
   bool VisitFunctionDecl(FunctionDecl *D) {
     IndexCtx.handleFunction(D);
     handleDeclarator(D);
@@ -161,22 +179,22 @@
   }
 
   bool VisitObjCMethodDecl(ObjCMethodDecl *D) {
-    IndexCtx.handleObjCMethod(D);
-    IndexCtx.indexTypeSourceInfo(D->getResultTypeSourceInfo(), D);
-    for (ObjCMethodDecl::param_iterator
-           I = D->param_begin(), E = D->param_end(); I != E; ++I)
-      handleDeclarator(*I, D);
+    // Methods associated with a property, even user-declared ones, are
+    // handled when we handle the property.
+    if (D->isSynthesized())
+      return true;
 
-    if (D->isThisDeclarationADefinition()) {
-      const Stmt *Body = D->getBody();
-      if (Body) {
-        IndexCtx.indexBody(Body, D, D);
-      }
-    }
+    handleObjCMethod(D);
     return true;
   }
 
   bool VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
+    if (ObjCMethodDecl *MD = D->getGetterMethodDecl())
+      if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
+        handleObjCMethod(MD);
+    if (ObjCMethodDecl *MD = D->getSetterMethodDecl())
+      if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
+        handleObjCMethod(MD);
     IndexCtx.handleObjCProperty(D);
     IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);
     return true;
@@ -198,11 +216,13 @@
 
     if (ObjCMethodDecl *MD = PD->getGetterMethodDecl()) {
       if (MD->isSynthesized())
-        IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation());
+        IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation(),
+                                             D->getLexicalDeclContext());
     }
     if (ObjCMethodDecl *MD = PD->getSetterMethodDecl()) {
       if (MD->isSynthesized())
-        IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation());
+        IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation(),
+                                             D->getLexicalDeclContext());
     }
     return true;
   }

Modified: cfe/branches/tooling/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/Indexing.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/Indexing.cpp (original)
+++ cfe/branches/tooling/tools/libclang/Indexing.cpp Tue Feb 28 17:49:25 2012
@@ -369,7 +369,6 @@
   bool CacheCodeCompletionResults = false;
   PreprocessorOptions &PPOpts = CInvok->getPreprocessorOpts(); 
   PPOpts.DetailedRecord = false;
-  PPOpts.DetailedRecordIncludesNestedMacroExpansions = false;
 
   if (requestedToGetTU) {
     OnlyLocalDecls = CXXIdx->getOnlyLocalDecls();
@@ -379,8 +378,6 @@
       = TU_options & CXTranslationUnit_CacheCompletionResults;
     if (TU_options & CXTranslationUnit_DetailedPreprocessingRecord) {
       PPOpts.DetailedRecord = true;
-      PPOpts.DetailedRecordIncludesNestedMacroExpansions
-          = (TU_options & CXTranslationUnit_NestedMacroExpansions);
     }
   }
 
@@ -611,6 +608,18 @@
   return 0;
 }
 
+const CXIdxObjCPropertyDeclInfo *
+clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *DInfo) {
+  if (!DInfo)
+    return 0;
+
+  const DeclInfo *DI = static_cast<const DeclInfo *>(DInfo);
+  if (const ObjCPropertyDeclInfo *PropInfo = dyn_cast<ObjCPropertyDeclInfo>(DI))
+    return &PropInfo->ObjCPropDeclInfo;
+
+  return 0;
+}
+
 const CXIdxIBOutletCollectionAttrInfo *
 clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *AInfo) {
   if (!AInfo)

Modified: cfe/branches/tooling/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexingContext.cpp?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexingContext.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexingContext.cpp Tue Feb 28 17:49:25 2012
@@ -257,7 +257,8 @@
 
 bool IndexingContext::handleDecl(const NamedDecl *D,
                                  SourceLocation Loc, CXCursor Cursor,
-                                 DeclInfo &DInfo) {
+                                 DeclInfo &DInfo,
+                                 const DeclContext *LexicalDC) {
   if (!CB.indexDeclaration || !D)
     return false;
   if (D->isImplicit() && shouldIgnoreIfImplicit(D))
@@ -269,6 +270,9 @@
       || Loc.isInvalid())
     return false;
 
+  if (!LexicalDC)
+    LexicalDC = D->getLexicalDeclContext();
+
   if (shouldSuppressRefs())
     markEntityOccurrenceInFile(D, Loc);
   
@@ -284,7 +288,7 @@
   getContainerInfo(D->getDeclContext(), DInfo.SemanticContainer);
   DInfo.semanticContainer = &DInfo.SemanticContainer;
 
-  if (D->getLexicalDeclContext() == D->getDeclContext()) {
+  if (LexicalDC == D->getDeclContext()) {
     DInfo.lexicalContainer = &DInfo.SemanticContainer;
   } else if (isTemplateImplicitInstantiation(D)) {
     // Implicit instantiations have the lexical context of where they were
@@ -295,7 +299,7 @@
     //   information anyway.
     DInfo.lexicalContainer = &DInfo.SemanticContainer;
   } else {
-    getContainerInfo(D->getLexicalDeclContext(), DInfo.LexicalContainer);
+    getContainerInfo(LexicalDC, DInfo.LexicalContainer);
     DInfo.lexicalContainer = &DInfo.LexicalContainer;
   }
 
@@ -510,15 +514,34 @@
 }
 
 bool IndexingContext::handleSynthesizedObjCMethod(const ObjCMethodDecl *D,
-                                                  SourceLocation Loc) {
+                                                  SourceLocation Loc,
+                                                 const DeclContext *LexicalDC) {
   DeclInfo DInfo(/*isRedeclaration=*/true, /*isDefinition=*/true,
                  /*isContainer=*/false);
-  return handleDecl(D, Loc, getCursor(D), DInfo);
+  return handleDecl(D, Loc, getCursor(D), DInfo, LexicalDC);
 }
 
 bool IndexingContext::handleObjCProperty(const ObjCPropertyDecl *D) {
-  DeclInfo DInfo(/*isRedeclaration=*/false, /*isDefinition=*/false,
-                 /*isContainer=*/false);
+  ObjCPropertyDeclInfo DInfo;
+  EntityInfo GetterEntity;
+  EntityInfo SetterEntity;
+  ScratchAlloc SA(*this);
+
+  DInfo.ObjCPropDeclInfo.declInfo = &DInfo;
+
+  if (ObjCMethodDecl *Getter = D->getGetterMethodDecl()) {
+    getEntityInfo(Getter, GetterEntity, SA);
+    DInfo.ObjCPropDeclInfo.getter = &GetterEntity;
+  } else {
+    DInfo.ObjCPropDeclInfo.getter = 0;
+  }
+  if (ObjCMethodDecl *Setter = D->getSetterMethodDecl()) {
+    getEntityInfo(Setter, SetterEntity, SA);
+    DInfo.ObjCPropDeclInfo.setter = &SetterEntity;
+  } else {
+    DInfo.ObjCPropDeclInfo.setter = 0;
+  }
+
   return handleDecl(D, D->getLocation(), getCursor(D), DInfo);
 }
 

Modified: cfe/branches/tooling/tools/libclang/IndexingContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexingContext.h?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexingContext.h (original)
+++ cfe/branches/tooling/tools/libclang/IndexingContext.h Tue Feb 28 17:49:25 2012
@@ -53,6 +53,8 @@
       Info_ObjCProtocol,
       Info_ObjCCategory,
 
+    Info_ObjCProperty,
+
     Info_CXXClass
   };
   
@@ -168,6 +170,20 @@
   static bool classof(const ObjCCategoryDeclInfo *D) { return true; }
 };
 
+struct ObjCPropertyDeclInfo : public DeclInfo {
+  CXIdxObjCPropertyDeclInfo ObjCPropDeclInfo;
+
+  ObjCPropertyDeclInfo()
+    : DeclInfo(Info_ObjCProperty,
+               /*isRedeclaration=*/false, /*isDefinition=*/false,
+               /*isContainer=*/false) { }
+
+  static bool classof(const DeclInfo *D) {
+    return D->Kind == Info_ObjCProperty;
+  }
+  static bool classof(const ObjCPropertyDeclInfo *D) { return true; }
+};
+
 struct CXXClassDeclInfo : public DeclInfo {
   CXIdxCXXClassDeclInfo CXXClassInfo;
 
@@ -390,7 +406,8 @@
   bool handleObjCMethod(const ObjCMethodDecl *D);
 
   bool handleSynthesizedObjCProperty(const ObjCPropertyImplDecl *D);
-  bool handleSynthesizedObjCMethod(const ObjCMethodDecl *D, SourceLocation Loc);
+  bool handleSynthesizedObjCMethod(const ObjCMethodDecl *D, SourceLocation Loc,
+                                   const DeclContext *LexicalDC);
 
   bool handleObjCProperty(const ObjCPropertyDecl *D);
 
@@ -436,7 +453,8 @@
 private:
   bool handleDecl(const NamedDecl *D,
                   SourceLocation Loc, CXCursor Cursor,
-                  DeclInfo &DInfo);
+                  DeclInfo &DInfo,
+                  const DeclContext *LexicalDC = 0);
 
   bool handleObjCContainer(const ObjCContainerDecl *D,
                            SourceLocation Loc, CXCursor Cursor,

Modified: cfe/branches/tooling/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/libclang.exports?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/libclang.exports (original)
+++ cfe/branches/tooling/tools/libclang/libclang.exports Tue Feb 28 17:49:25 2012
@@ -158,6 +158,7 @@
 clang_index_getObjCCategoryDeclInfo
 clang_index_getObjCContainerDeclInfo
 clang_index_getObjCInterfaceDeclInfo
+clang_index_getObjCPropertyDeclInfo
 clang_index_getObjCProtocolRefListInfo
 clang_index_isEntityObjCContainerKind
 clang_index_setClientContainer

Modified: cfe/branches/tooling/tools/scan-build/set-xcode-analyzer
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/scan-build/set-xcode-analyzer?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/tools/scan-build/set-xcode-analyzer (original)
+++ cfe/branches/tooling/tools/scan-build/set-xcode-analyzer Tue Feb 28 17:49:25 2012
@@ -5,6 +5,7 @@
 # This one has the scripting bridge enabled.
 
 import os
+import subprocess
 import sys
 import re
 import tempfile
@@ -13,6 +14,7 @@
 from AppKit import *
 
 def FindClangSpecs(path):
+  print "(+) Searching for xcspec file in: ", path
   for root, dirs, files in os.walk(path):
     for f in files:
       if f.endswith(".xcspec") and f.startswith("Clang LLVM"):
@@ -73,7 +75,13 @@
     print "(+) Using the Clang bundled with Xcode"
     path = options.default
   
-  for x in FindClangSpecs('/Developer'):
+  xcode_path = subprocess.check_output(["xcode-select", "-print-path"])
+  if (re.search("Xcode.app", xcode_path)):
+    # Cut off the 'Developer' dir, as the xcspec lies in another part
+    # of the Xcode.app subtree.
+    xcode_path = os.path.dirname(xcode_path)
+  
+  for x in FindClangSpecs(xcode_path):
     ModifySpec(x, path)
 
 if __name__ == '__main__':

Modified: cfe/branches/tooling/www/analyzer/annotations.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/analyzer/annotations.html?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/www/analyzer/annotations.html (original)
+++ cfe/branches/tooling/www/analyzer/annotations.html Tue Feb 28 17:49:25 2012
@@ -139,7 +139,7 @@
 
 <p><b>Placing on Objective-C methods</b>: For Objective-C methods, this
 annotation essentially tells the analyzer to treat the method as if its name
-begins with "alloc" or "new" or contais the word
+begins with "alloc" or "new" or contains the word
 "copy".</p>
 
 <p><b>Placing on C functions</b>: For C functions returning Cocoa objects, the

Modified: cfe/branches/tooling/www/analyzer/latest_checker.html.incl
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/analyzer/latest_checker.html.incl?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/www/analyzer/latest_checker.html.incl (original)
+++ cfe/branches/tooling/www/analyzer/latest_checker.html.incl Tue Feb 28 17:49:25 2012
@@ -1 +1 @@
-<b><a href="http://bit.ly/wpAqVP">checker-260.tar.bz2</a></b> (built January 25, 2012)
+<b><a href="http://bit.ly/yN1Awv">checker-261.tar.bz2</a></b> (built February 22, 2012)

Modified: cfe/branches/tooling/www/analyzer/release_notes.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/analyzer/release_notes.html?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/www/analyzer/release_notes.html (original)
+++ cfe/branches/tooling/www/analyzer/release_notes.html Tue Feb 28 17:49:25 2012
@@ -15,6 +15,22 @@
 
 <h1>Release notes for <tt>checker-XXX</tt> builds</h1>
 
+<h4 id="checker_261">checker-261</h4>
+
+<p><b>built: </b>February 22, 2012<br>
+<b>download:</b> <a href="http://bit.ly/yN1Awv">checker-261.tar.bz2</a></p>
+<p><b>highlights:</b></p>
+
+<ul>
+  <li>Contains a new experimental malloc/free checker.</li>
+  <li>Better support for projects using ARC.</li>
+  <li>Warns about null pointers passed as arguments to C string functions.</li>
+  <li>Warns about common anti-patterns in 'strncat' size argument, which can lead to buffer overflows.</li>
+  <li>set-xcode-analyzer now supports self-contained Xcode.app (Xcode 4.3 and later).</li>
+  <li>Contains a newer version of the analyzer than Xcode 4.3.</li>
+  <li>Misc. bug fixes and performance work.</li>
+</ul>
+
 <h4 id="checker_260">checker-260</h4>
 
 <p><b>built: </b>January 25, 2012<br>

Modified: cfe/branches/tooling/www/cxx_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/cxx_status.html?rev=151671&r1=151670&r2=151671&view=diff
==============================================================================
--- cfe/branches/tooling/www/cxx_status.html (original)
+++ cfe/branches/tooling/www/cxx_status.html Tue Feb 28 17:49:25 2012
@@ -3,7 +3,7 @@
 <html>
 <head>
   <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-  <title>Clang - C++ and C++'11 Status</title>
+  <title>Clang - C++98 and C++11 Status</title>
   <link type="text/css" rel="stylesheet" href="menu.css">
   <link type="text/css" rel="stylesheet" href="content.css">
   <style type="text/css">
@@ -20,18 +20,20 @@
 <div id="content">
 
 <!--*************************************************************************-->
-<h1>C++ and C++'11 Support in Clang</h1>
+<h1>C++98 and C++11 Support in Clang</h1>
 <!--*************************************************************************-->
 <p>Last updated: $Date$</p>
 
+<h2 id="cxx98">C++98 implementation status</h2>
+
 <p>Clang currently implements all of the ISO C++ 1998 standard
   (including the defects addressed in the ISO C++ 2003 standard)
-  except for 'export' (which has been removed in C++'11)
+  except for 'export' (which has been removed in C++11)
   and is considered a production-quality C++ compiler.  The <a
    href="http://llvm.org/bugs/">LLVM bug tracker</a> contains a Clang
   C++ component that tracks known Clang C++ bugs.</p>
 
-<h2 id="cxx11">C++11 Implementation status</h2>
+<h2 id="cxx11">C++11 implementation status</h2>
 
   <p>Clang provides support for a number of features included in the new <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=50372">ISO C++ Standard, ISO/IEC 14882:2011</a>. The following table describes which C++11 features have been implemented in Clang and in which Clang versions they became available.</p>
 
@@ -43,7 +45,7 @@
 <table width="689" border="1" cellspacing="0">
  <tr>
     <th>Language Feature</th>
-    <th>C++0x Proposal</th>
+    <th>C++11 Proposal</th>
     <th>Available in Clang?</th>
  </tr>
      <tr>
@@ -79,7 +81,7 @@
     <tr>
       <td>Initializer lists</td>
       <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm">N2672</a></td>
-      <td class="none" align="center">No</td>
+      <td class="svn" align="center">SVN</td>
     </tr>
     <tr>
       <td>Static assertions</td>
@@ -107,9 +109,9 @@
       <td class="full" align="center">Clang 2.9</td>
     </tr>
     <tr>
-      <td>New wording for C++0x lambdas</td>
+      <td>Lambda expressions</td>
       <td><a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2927.pdf">N2927</a></td>
-      <td class="none" align="center">No</td>
+      <td class="svn" align="center">SVN</td>
     </tr>
     <tr>
       <td>Declared type of an expression</td>
@@ -153,9 +155,7 @@
     </tr>
     <tr>
       <td>Forward declarations for enums</td>
-      <td>
-	<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf">N2764
-      </a></td>
+      <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf">N2764</a></td>
       <td class="none" align="center">No</td>
     </tr>
     <tr>
@@ -237,8 +237,9 @@
     </tr>
     <tr>
       <td>Extending <code>sizeof</code></td>
-      <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html">N2253</a></td>
-      <td class="none" align="center">No</td>
+      <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html">N2253</a>
+      <br><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#850">DR850</a></td>
+      <td class="svn" align="center">SVN</td>
     </tr>
     <tr>
       <td>Inline namespaces</td>
@@ -263,8 +264,8 @@
     <tr>
       <td>Explicit virtual overrides</td>
       <td><a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm">N2928</a>
-	<br><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm">N3206</a>
-<br><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm">N3272</a></td>
+      <br><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm">N3206</a>
+      <br><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm">N3272</a></td>
       <td class="full" align="center">Clang 3.0</td>
     </tr>
     <tr>
@@ -344,7 +345,7 @@
     </tr>
 
     <tr class="separator">
-      <th align="center" colspan="3">C99 Features in C++0x</th>
+      <th align="center" colspan="3">C99 Features in C++11</th>
     </tr>
     <tr>
       <td><code>__func__</code> predefined identifier</td>





More information about the llvm-branch-commits mailing list