[llvm-branch-commits] [cfe-branch] r154919 [1/2] - in /cfe/branches/tooling: ./ INPUTS/ docs/ examples/clang-interpreter/ include/clang-c/ include/clang/AST/ include/clang/Analysis/ include/clang/Basic/ include/clang/Config/ include/clang/Driver/ include/clang/Frontend/ include/clang/Index/ include/clang/Lex/ include/clang/Parse/ include/clang/Sema/ include/clang/StaticAnalyzer/Checkers/ include/clang/StaticAnalyzer/Core/ include/clang/StaticAnalyzer/Core/BugReporter/ include/clang/StaticAnalyzer/Core/PathSensitive/ include/c...

Manuel Klimek klimek at google.com
Tue Apr 17 04:08:29 PDT 2012


Author: klimek
Date: Tue Apr 17 06:08:26 2012
New Revision: 154919

URL: http://llvm.org/viewvc/llvm-project?rev=154919&view=rev
Log:
Merging tooling from mainline. The change was a little more involved, so there might be lose ends around.

Added:
    cfe/branches/tooling/include/clang/AST/DeclLookups.h
      - copied unchanged from r154672, cfe/trunk/include/clang/AST/DeclLookups.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Checkers/CommonBugCategories.h
      - copied unchanged from r154672, cfe/trunk/include/clang/StaticAnalyzer/Checkers/CommonBugCategories.h
    cfe/branches/tooling/include/clang/Tooling/CompilationDatabase.h   (props changed)
      - copied unchanged from r154675, cfe/trunk/include/clang/Tooling/CompilationDatabase.h
    cfe/branches/tooling/include/clang/Tooling/Tooling.h   (props changed)
      - copied unchanged from r154676, cfe/trunk/include/clang/Tooling/Tooling.h
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CommonBugCategories.cpp
      - copied unchanged from r154672, cfe/trunk/lib/StaticAnalyzer/Checkers/CommonBugCategories.cpp
    cfe/branches/tooling/lib/Tooling/CompilationDatabase.cpp   (props changed)
      - copied unchanged from r154675, cfe/trunk/lib/Tooling/CompilationDatabase.cpp
    cfe/branches/tooling/lib/Tooling/Tooling.cpp   (props changed)
      - copied unchanged from r154676, cfe/trunk/lib/Tooling/Tooling.cpp
    cfe/branches/tooling/test/Analysis/check-deserialization.cpp
      - copied unchanged from r154672, cfe/trunk/test/Analysis/check-deserialization.cpp
    cfe/branches/tooling/test/Analysis/dynamic-cast.cpp
      - copied unchanged from r154672, cfe/trunk/test/Analysis/dynamic-cast.cpp
    cfe/branches/tooling/test/Analysis/lambdas.cpp
      - copied unchanged from r154672, cfe/trunk/test/Analysis/lambdas.cpp
    cfe/branches/tooling/test/Analysis/objc-method-coverage.m
      - copied unchanged from r154672, cfe/trunk/test/Analysis/objc-method-coverage.m
    cfe/branches/tooling/test/Analysis/redefined_system.c
      - copied unchanged from r154672, cfe/trunk/test/Analysis/redefined_system.c
    cfe/branches/tooling/test/CXX/class.access/class.protected/p1-cxx11.cpp
      - copied unchanged from r154672, cfe/trunk/test/CXX/class.access/class.protected/p1-cxx11.cpp
    cfe/branches/tooling/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp
      - copied unchanged from r154672, cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp
    cfe/branches/tooling/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp
      - copied unchanged from r154672, cfe/trunk/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp
    cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
      - copied unchanged from r154672, cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
    cfe/branches/tooling/test/CodeGen/arm-homogenous.c
      - copied unchanged from r154672, cfe/trunk/test/CodeGen/arm-homogenous.c
    cfe/branches/tooling/test/CodeGen/builtinshufflevector2.c
      - copied unchanged from r154672, cfe/trunk/test/CodeGen/builtinshufflevector2.c
    cfe/branches/tooling/test/CodeGen/debug-line-1.c
      - copied unchanged from r154672, cfe/trunk/test/CodeGen/debug-line-1.c
    cfe/branches/tooling/test/CodeGenCXX/apple-kext.cpp
      - copied unchanged from r154672, cfe/trunk/test/CodeGenCXX/apple-kext.cpp
    cfe/branches/tooling/test/CodeGenCXX/atomicinit.cpp
      - copied unchanged from r154672, cfe/trunk/test/CodeGenCXX/atomicinit.cpp
    cfe/branches/tooling/test/CodeGenCXX/block.cpp
      - copied unchanged from r154672, cfe/trunk/test/CodeGenCXX/block.cpp
    cfe/branches/tooling/test/CodeGenCXX/debug-info-static-fns.cpp
      - copied unchanged from r154672, cfe/trunk/test/CodeGenCXX/debug-info-static-fns.cpp
    cfe/branches/tooling/test/CodeGenCXX/mangle-nullptr-arg.cpp
      - copied unchanged from r154672, cfe/trunk/test/CodeGenCXX/mangle-nullptr-arg.cpp
    cfe/branches/tooling/test/CodeGenObjC/debug-info-impl.m
      - copied unchanged from r154672, cfe/trunk/test/CodeGenObjC/debug-info-impl.m
    cfe/branches/tooling/test/Driver/arm-mfpmath.c
      - copied unchanged from r154672, cfe/trunk/test/Driver/arm-mfpmath.c
    cfe/branches/tooling/test/Driver/gold-lto.c
      - copied unchanged from r154672, cfe/trunk/test/Driver/gold-lto.c
    cfe/branches/tooling/test/Driver/linux-as.c
      - copied unchanged from r154672, cfe/trunk/test/Driver/linux-as.c
    cfe/branches/tooling/test/Driver/mips-as.c
      - copied unchanged from r154672, cfe/trunk/test/Driver/mips-as.c
    cfe/branches/tooling/test/Driver/no-objc-default-synthesize-properties.m
      - copied unchanged from r154672, cfe/trunk/test/Driver/no-objc-default-synthesize-properties.m
    cfe/branches/tooling/test/Driver/pic.c
      - copied unchanged from r154672, cfe/trunk/test/Driver/pic.c
    cfe/branches/tooling/test/Driver/redundant-args.c
      - copied unchanged from r154672, cfe/trunk/test/Driver/redundant-args.c
    cfe/branches/tooling/test/FixIt/no-fixit.cpp
      - copied unchanged from r154672, cfe/trunk/test/FixIt/no-fixit.cpp
    cfe/branches/tooling/test/Lexer/ms-extensions.cpp
      - copied unchanged from r154672, cfe/trunk/test/Lexer/ms-extensions.cpp
    cfe/branches/tooling/test/Lexer/newline-eof-c++11.cpp
      - copied unchanged from r154672, cfe/trunk/test/Lexer/newline-eof-c++11.cpp
    cfe/branches/tooling/test/Lexer/newline-eof-c++98-compat.cpp
      - copied unchanged from r154672, cfe/trunk/test/Lexer/newline-eof-c++98-compat.cpp
    cfe/branches/tooling/test/Modules/Inputs/redecl_namespaces_left.h
      - copied unchanged from r154672, cfe/trunk/test/Modules/Inputs/redecl_namespaces_left.h
    cfe/branches/tooling/test/Modules/Inputs/redecl_namespaces_right.h
      - copied unchanged from r154672, cfe/trunk/test/Modules/Inputs/redecl_namespaces_right.h
    cfe/branches/tooling/test/Modules/redecl-namespaces.mm
      - copied unchanged from r154672, cfe/trunk/test/Modules/redecl-namespaces.mm
    cfe/branches/tooling/test/PCH/cxx-functions.cpp
      - copied unchanged from r154672, cfe/trunk/test/PCH/cxx-functions.cpp
    cfe/branches/tooling/test/PCH/cxx-functions.h
      - copied unchanged from r154672, cfe/trunk/test/PCH/cxx-functions.h
    cfe/branches/tooling/test/Parser/objcxx11-attributes.mm
      - copied unchanged from r154672, cfe/trunk/test/Parser/objcxx11-attributes.mm
    cfe/branches/tooling/test/Parser/recovery.cpp
      - copied unchanged from r154672, cfe/trunk/test/Parser/recovery.cpp
    cfe/branches/tooling/test/Parser/skip-function-bodies.mm
      - copied unchanged from r154672, cfe/trunk/test/Parser/skip-function-bodies.mm
    cfe/branches/tooling/test/Preprocessor/Inputs/
      - copied from r154672, cfe/trunk/test/Preprocessor/Inputs/
    cfe/branches/tooling/test/Preprocessor/Inputs/TestFramework.framework/
      - copied from r154672, cfe/trunk/test/Preprocessor/Inputs/TestFramework.framework/
    cfe/branches/tooling/test/Preprocessor/Inputs/TestFramework.framework/.system_framework
      - copied unchanged from r154672, cfe/trunk/test/Preprocessor/Inputs/TestFramework.framework/.system_framework
    cfe/branches/tooling/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/
      - copied from r154672, cfe/trunk/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/
    cfe/branches/tooling/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/
      - copied from r154672, cfe/trunk/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/
    cfe/branches/tooling/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/
      - copied from r154672, cfe/trunk/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/
    cfe/branches/tooling/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h
      - copied unchanged from r154672, cfe/trunk/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h
    cfe/branches/tooling/test/Preprocessor/Inputs/TestFramework.framework/Headers/
      - copied from r154672, cfe/trunk/test/Preprocessor/Inputs/TestFramework.framework/Headers/
    cfe/branches/tooling/test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h
      - copied unchanged from r154672, cfe/trunk/test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h
    cfe/branches/tooling/test/Preprocessor/_Pragma-in-macro-arg.c
      - copied unchanged from r154672, cfe/trunk/test/Preprocessor/_Pragma-in-macro-arg.c
    cfe/branches/tooling/test/Preprocessor/user_defined_system_framework.c
      - copied unchanged from r154672, cfe/trunk/test/Preprocessor/user_defined_system_framework.c
    cfe/branches/tooling/test/Rewriter/objc-bool-literal-modern-1.mm
      - copied unchanged from r154672, cfe/trunk/test/Rewriter/objc-bool-literal-modern-1.mm
    cfe/branches/tooling/test/Rewriter/objc-modern-container-subscript.mm
      - copied unchanged from r154672, cfe/trunk/test/Rewriter/objc-modern-container-subscript.mm
    cfe/branches/tooling/test/Rewriter/objc-modern-implicit-cast.mm
      - copied unchanged from r154672, cfe/trunk/test/Rewriter/objc-modern-implicit-cast.mm
    cfe/branches/tooling/test/Rewriter/objc-modern-linkage-spec.mm
      - copied unchanged from r154672, cfe/trunk/test/Rewriter/objc-modern-linkage-spec.mm
    cfe/branches/tooling/test/Rewriter/rewrite-modern-array-literal.mm
      - copied unchanged from r154672, cfe/trunk/test/Rewriter/rewrite-modern-array-literal.mm
    cfe/branches/tooling/test/Rewriter/rewrite-modern-block.mm
      - copied unchanged from r154672, cfe/trunk/test/Rewriter/rewrite-modern-block.mm
    cfe/branches/tooling/test/Rewriter/rewrite-modern-container-literal.mm
      - copied unchanged from r154672, cfe/trunk/test/Rewriter/rewrite-modern-container-literal.mm
    cfe/branches/tooling/test/Rewriter/rewrite-modern-super.mm
      - copied unchanged from r154672, cfe/trunk/test/Rewriter/rewrite-modern-super.mm
    cfe/branches/tooling/test/SemaCXX/PR12481.cpp
      - copied unchanged from r154672, cfe/trunk/test/SemaCXX/PR12481.cpp
    cfe/branches/tooling/test/SemaCXX/new-delete-0x.cpp
      - copied unchanged from r154672, cfe/trunk/test/SemaCXX/new-delete-0x.cpp
    cfe/branches/tooling/test/SemaObjC/attr-root-class.m
      - copied unchanged from r154672, cfe/trunk/test/SemaObjC/attr-root-class.m
    cfe/branches/tooling/test/SemaObjC/weak-receiver-warn.m
      - copied unchanged from r154672, cfe/trunk/test/SemaObjC/weak-receiver-warn.m
    cfe/branches/tooling/tools/clang-check/ClangCheck.cpp   (props changed)
      - copied unchanged from r154916, cfe/trunk/tools/clang-check/ClangCheck.cpp
    cfe/branches/tooling/unittests/Tooling/CompilationDatabaseTest.cpp   (props changed)
      - copied unchanged from r154673, cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
    cfe/branches/tooling/unittests/Tooling/ToolingTest.cpp   (props changed)
      - copied unchanged from r154676, cfe/trunk/unittests/Tooling/ToolingTest.cpp
Removed:
    cfe/branches/tooling/include/clang/Index/
    cfe/branches/tooling/lib/Index/
    cfe/branches/tooling/test/CodeGen/atomic_init.c
    cfe/branches/tooling/test/Misc/pubnames.c
Modified:
    cfe/branches/tooling/   (props changed)
    cfe/branches/tooling/INPUTS/all-std-headers.cpp
    cfe/branches/tooling/docs/LanguageExtensions.html
    cfe/branches/tooling/docs/ReleaseNotes.html
    cfe/branches/tooling/examples/clang-interpreter/CMakeLists.txt
    cfe/branches/tooling/include/clang-c/Index.h
    cfe/branches/tooling/include/clang/AST/DeclBase.h
    cfe/branches/tooling/include/clang/AST/DeclCXX.h
    cfe/branches/tooling/include/clang/AST/DeclObjC.h
    cfe/branches/tooling/include/clang/AST/Expr.h
    cfe/branches/tooling/include/clang/AST/ExprCXX.h
    cfe/branches/tooling/include/clang/AST/NSAPI.h
    cfe/branches/tooling/include/clang/AST/TemplateBase.h
    cfe/branches/tooling/include/clang/Analysis/CallGraph.h
    cfe/branches/tooling/include/clang/Basic/Attr.td
    cfe/branches/tooling/include/clang/Basic/Builtins.def
    cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td
    cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/branches/tooling/include/clang/Basic/LangOptions.def
    cfe/branches/tooling/include/clang/Basic/Specifiers.h
    cfe/branches/tooling/include/clang/Basic/TokenKinds.def
    cfe/branches/tooling/include/clang/Config/config.h.in
    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/FrontendActions.h
    cfe/branches/tooling/include/clang/Frontend/FrontendOptions.h
    cfe/branches/tooling/include/clang/Lex/DirectoryLookup.h
    cfe/branches/tooling/include/clang/Lex/HeaderSearch.h
    cfe/branches/tooling/include/clang/Lex/Preprocessor.h
    cfe/branches/tooling/include/clang/Parse/ParseAST.h
    cfe/branches/tooling/include/clang/Parse/Parser.h
    cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h
    cfe/branches/tooling/include/clang/Sema/DeclSpec.h
    cfe/branches/tooling/include/clang/Sema/Initialization.h
    cfe/branches/tooling/include/clang/Sema/Sema.h
    cfe/branches/tooling/include/clang/Sema/TypoCorrection.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/CheckerManager.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
    cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
    cfe/branches/tooling/include/clang/Tooling/Refactoring.h
    cfe/branches/tooling/lib/AST/ASTContext.cpp
    cfe/branches/tooling/lib/AST/ASTImporter.cpp
    cfe/branches/tooling/lib/AST/DeclObjC.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/ExprConstant.cpp
    cfe/branches/tooling/lib/AST/ItaniumMangle.cpp
    cfe/branches/tooling/lib/AST/NSAPI.cpp
    cfe/branches/tooling/lib/AST/StmtPrinter.cpp
    cfe/branches/tooling/lib/AST/TemplateBase.cpp
    cfe/branches/tooling/lib/AST/Type.cpp
    cfe/branches/tooling/lib/AST/TypePrinter.cpp
    cfe/branches/tooling/lib/Analysis/CFG.cpp
    cfe/branches/tooling/lib/Analysis/CMakeLists.txt
    cfe/branches/tooling/lib/Analysis/CallGraph.cpp
    cfe/branches/tooling/lib/Basic/SourceManager.cpp
    cfe/branches/tooling/lib/Basic/Targets.cpp
    cfe/branches/tooling/lib/CMakeLists.txt
    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/CGCall.cpp
    cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
    cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h
    cfe/branches/tooling/lib/CodeGen/CGDeclCXX.cpp
    cfe/branches/tooling/lib/CodeGen/CGExpr.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/CGStmt.cpp
    cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h
    cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
    cfe/branches/tooling/lib/CodeGen/CodeGenTypes.cpp
    cfe/branches/tooling/lib/CodeGen/MicrosoftCXXABI.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/FrontendAction.cpp
    cfe/branches/tooling/lib/Frontend/FrontendActions.cpp
    cfe/branches/tooling/lib/Frontend/InitPreprocessor.cpp
    cfe/branches/tooling/lib/FrontendTool/ExecuteCompilerInvocation.cpp
    cfe/branches/tooling/lib/Headers/avxintrin.h
    cfe/branches/tooling/lib/Lex/HeaderSearch.cpp
    cfe/branches/tooling/lib/Lex/Lexer.cpp
    cfe/branches/tooling/lib/Lex/MacroArgs.cpp
    cfe/branches/tooling/lib/Lex/PPCaching.cpp
    cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp
    cfe/branches/tooling/lib/Lex/Pragma.cpp
    cfe/branches/tooling/lib/Lex/Preprocessor.cpp
    cfe/branches/tooling/lib/Makefile
    cfe/branches/tooling/lib/Parse/ParseAST.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/ParseInit.cpp
    cfe/branches/tooling/lib/Parse/ParseObjc.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/CodeCompleteConsumer.cpp
    cfe/branches/tooling/lib/Sema/DeclSpec.cpp
    cfe/branches/tooling/lib/Sema/SemaAccess.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/SemaOverload.cpp
    cfe/branches/tooling/lib/Sema/SemaPseudoObject.cpp
    cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
    cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp
    cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp
    cfe/branches/tooling/lib/Sema/SemaTemplateInstantiateDecl.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/ASTReaderStmt.cpp
    cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ClangSACheckers.h
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/AnalysisManager.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/CheckerManager.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/CoreEngine.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/RegionStore.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Core/SVals.cpp
    cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
    cfe/branches/tooling/lib/Tooling/CMakeLists.txt
    cfe/branches/tooling/lib/Tooling/Refactoring.cpp
    cfe/branches/tooling/test/Analysis/CFContainers.mm
    cfe/branches/tooling/test/Analysis/CheckNSError.m
    cfe/branches/tooling/test/Analysis/NSPanel.m
    cfe/branches/tooling/test/Analysis/NSString.m
    cfe/branches/tooling/test/Analysis/ObjCProperties.m
    cfe/branches/tooling/test/Analysis/ObjCRetSigs.m
    cfe/branches/tooling/test/Analysis/array-struct-region.c
    cfe/branches/tooling/test/Analysis/dead-stores.c
    cfe/branches/tooling/test/Analysis/dead-stores.m
    cfe/branches/tooling/test/Analysis/inline-plist.c
    cfe/branches/tooling/test/Analysis/inline-unique-reports.c
    cfe/branches/tooling/test/Analysis/malloc-plist.c
    cfe/branches/tooling/test/Analysis/malloc.m
    cfe/branches/tooling/test/Analysis/malloc.mm
    cfe/branches/tooling/test/Analysis/misc-ps-cxx0x.cpp
    cfe/branches/tooling/test/Analysis/misc-ps-region-store.cpp
    cfe/branches/tooling/test/Analysis/misc-ps-region-store.m
    cfe/branches/tooling/test/Analysis/misc-ps.m
    cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.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/plist-output.m
    cfe/branches/tooling/test/Analysis/pr_2542_rdar_6793404.m
    cfe/branches/tooling/test/Analysis/properties.m
    cfe/branches/tooling/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
    cfe/branches/tooling/test/Analysis/retain-release-gc-only.m
    cfe/branches/tooling/test/Analysis/retain-release.m
    cfe/branches/tooling/test/Analysis/unused-ivars.m
    cfe/branches/tooling/test/Analysis/variadic-method-types.m
    cfe/branches/tooling/test/CMakeLists.txt
    cfe/branches/tooling/test/CXX/class.access/class.protected/p1.cpp
    cfe/branches/tooling/test/CXX/class.access/p4.cpp
    cfe/branches/tooling/test/CXX/class/class.nest/p1.cpp
    cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
    cfe/branches/tooling/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.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/expr/expr.prim/expr.prim.lambda/p12.cpp
    cfe/branches/tooling/test/CXX/special/class.free/p1.cpp
    cfe/branches/tooling/test/CXX/special/class.free/p6.cpp
    cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
    cfe/branches/tooling/test/CXX/temp/temp.spec/p5.cpp
    cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
    cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
    cfe/branches/tooling/test/CodeGen/atomic-ops.c
    cfe/branches/tooling/test/CodeGen/switch-dce.c
    cfe/branches/tooling/test/CodeGenCXX/arm.cpp
    cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp
    cfe/branches/tooling/test/CodeGenCXX/global-dtor-no-atexit.cpp
    cfe/branches/tooling/test/CodeGenCXX/global-init.cpp
    cfe/branches/tooling/test/CodeGenCXX/mangle-lambdas.cpp
    cfe/branches/tooling/test/CodeGenCXX/mangle-template.cpp
    cfe/branches/tooling/test/CodeGenCXX/predefined-expr-sizeof.cpp
    cfe/branches/tooling/test/CodeGenCXX/predefined-expr.cpp
    cfe/branches/tooling/test/CodeGenCXX/static-init.cpp
    cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m
    cfe/branches/tooling/test/CodeGenObjC/debug-info-block-helper.m
    cfe/branches/tooling/test/CodeGenObjC/debug-info-property.m
    cfe/branches/tooling/test/CodeGenObjC/debug-info-property3.m
    cfe/branches/tooling/test/CodeGenObjC/debug-info-property4.m
    cfe/branches/tooling/test/CodeGenObjC/debug-info-pubtypes.m
    cfe/branches/tooling/test/CodeGenObjC/debug-info-synthesis.m
    cfe/branches/tooling/test/CodeGenObjCXX/arc.mm
    cfe/branches/tooling/test/CodeGenOpenCL/fpaccuracy.cl
    cfe/branches/tooling/test/Driver/altivec.cpp
    cfe/branches/tooling/test/Driver/apple-kext-i386.cpp
    cfe/branches/tooling/test/Driver/freebsd.c
    cfe/branches/tooling/test/Driver/linux-header-search.cpp
    cfe/branches/tooling/test/Driver/linux-ld.c
    cfe/branches/tooling/test/Driver/mips-float.c
    cfe/branches/tooling/test/Driver/rewrite-objc.m
    cfe/branches/tooling/test/FixIt/fixit-cxx0x.cpp
    cfe/branches/tooling/test/FixIt/fixit-missing-method-return-type.m
    cfe/branches/tooling/test/FixIt/fixit.cpp
    cfe/branches/tooling/test/FixIt/typo-crash.cpp
    cfe/branches/tooling/test/FixIt/typo.m
    cfe/branches/tooling/test/Index/complete-method-decls.m
    cfe/branches/tooling/test/Index/complete-super.cpp
    cfe/branches/tooling/test/Index/complete-synthesized.m
    cfe/branches/tooling/test/Index/fix-its.c
    cfe/branches/tooling/test/Index/overrides.m
    cfe/branches/tooling/test/Index/print-typekind.c
    cfe/branches/tooling/test/Index/print-typekind.m
    cfe/branches/tooling/test/Lexer/has_extension_cxx.cpp
    cfe/branches/tooling/test/Lexer/has_feature_cxx0x.cpp
    cfe/branches/tooling/test/Lexer/newline-eof.c
    cfe/branches/tooling/test/Misc/serialized-diags-single-issue.c
    cfe/branches/tooling/test/Misc/serialized-diags.c
    cfe/branches/tooling/test/Modules/Inputs/module.map
    cfe/branches/tooling/test/Modules/redecl-merge.m
    cfe/branches/tooling/test/PCH/chain-categories2.m
    cfe/branches/tooling/test/PCH/chain-selectors.m
    cfe/branches/tooling/test/PCH/exprs.h
    cfe/branches/tooling/test/PCH/method_pool.m
    cfe/branches/tooling/test/Parser/cxx-template-decl.cpp
    cfe/branches/tooling/test/Parser/cxx-typeof.cpp
    cfe/branches/tooling/test/Parser/cxx0x-attributes.cpp
    cfe/branches/tooling/test/Parser/declarators.c
    cfe/branches/tooling/test/Parser/missing-end-4.m
    cfe/branches/tooling/test/Parser/objc-forcollection-neg-2.m
    cfe/branches/tooling/test/Parser/objc-forcollection-neg.m
    cfe/branches/tooling/test/Parser/objc-foreach-syntax.m
    cfe/branches/tooling/test/Parser/objc-init.m
    cfe/branches/tooling/test/Parser/objc-property-syntax.m
    cfe/branches/tooling/test/Parser/objc-synthesized-recover.m
    cfe/branches/tooling/test/Preprocessor/feature_tests.c
    cfe/branches/tooling/test/Preprocessor/init.c
    cfe/branches/tooling/test/Preprocessor/pic.c
    cfe/branches/tooling/test/Rewriter/rewrite-modern-ivars-2.mm
    cfe/branches/tooling/test/Sema/128bitint.c
    cfe/branches/tooling/test/Sema/array-init.c
    cfe/branches/tooling/test/Sema/atomic-ops.c
    cfe/branches/tooling/test/Sema/c89.c
    cfe/branches/tooling/test/Sema/conditional-expr.c
    cfe/branches/tooling/test/Sema/const-eval.c
    cfe/branches/tooling/test/Sema/conversion-64-32.c
    cfe/branches/tooling/test/Sema/types.c
    cfe/branches/tooling/test/SemaCXX/atomic-type.cxx
    cfe/branches/tooling/test/SemaCXX/class.cpp
    cfe/branches/tooling/test/SemaCXX/constexpr-printing.cpp
    cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-constructor.cpp
    cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
    cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp
    cfe/branches/tooling/test/SemaCXX/default2.cpp
    cfe/branches/tooling/test/SemaCXX/function-redecl.cpp
    cfe/branches/tooling/test/SemaCXX/goto.cpp
    cfe/branches/tooling/test/SemaCXX/namespace-alias.cpp
    cfe/branches/tooling/test/SemaCXX/nested-name-spec.cpp
    cfe/branches/tooling/test/SemaCXX/new-delete.cpp
    cfe/branches/tooling/test/SemaCXX/overload-call.cpp
    cfe/branches/tooling/test/SemaCXX/qual-id-test.cpp
    cfe/branches/tooling/test/SemaCXX/qualified-id-lookup.cpp
    cfe/branches/tooling/test/SemaCXX/static-assert.cpp
    cfe/branches/tooling/test/SemaCXX/this.cpp
    cfe/branches/tooling/test/SemaCXX/typo-correction.cpp
    cfe/branches/tooling/test/SemaCXX/uninitialized.cpp
    cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp
    cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp
    cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp   (props changed)
    cfe/branches/tooling/test/SemaObjC/ClassPropertyNotObject.m
    cfe/branches/tooling/test/SemaObjC/ContClassPropertyLookup.m
    cfe/branches/tooling/test/SemaObjC/DoubleMethod.m
    cfe/branches/tooling/test/SemaObjC/alias-test-2.m
    cfe/branches/tooling/test/SemaObjC/arc-decls.m
    cfe/branches/tooling/test/SemaObjC/arc-jump-block.m
    cfe/branches/tooling/test/SemaObjC/arc-no-runtime.m
    cfe/branches/tooling/test/SemaObjC/arc-objc-lifetime.m
    cfe/branches/tooling/test/SemaObjC/arc-property-lifetime.m
    cfe/branches/tooling/test/SemaObjC/arc-property.m
    cfe/branches/tooling/test/SemaObjC/arc-readonly-property-ivar-1.m
    cfe/branches/tooling/test/SemaObjC/arc-readonly-property-ivar.m
    cfe/branches/tooling/test/SemaObjC/arc-retain-block-property.m
    cfe/branches/tooling/test/SemaObjC/arc-setter-property-match.m
    cfe/branches/tooling/test/SemaObjC/arc-unavailable-for-weakref.m
    cfe/branches/tooling/test/SemaObjC/arc-unsafe-assigns.m
    cfe/branches/tooling/test/SemaObjC/arc.m
    cfe/branches/tooling/test/SemaObjC/assign-rvalue-message.m
    cfe/branches/tooling/test/SemaObjC/atomoic-property-synnthesis-rules.m
    cfe/branches/tooling/test/SemaObjC/attr-deprecated.m
    cfe/branches/tooling/test/SemaObjC/autoreleasepool.m
    cfe/branches/tooling/test/SemaObjC/bad-property-synthesis-crash.m
    cfe/branches/tooling/test/SemaObjC/block-on-method-param.m
    cfe/branches/tooling/test/SemaObjC/block-type-safety.m
    cfe/branches/tooling/test/SemaObjC/category-1.m
    cfe/branches/tooling/test/SemaObjC/category-method-lookup.m
    cfe/branches/tooling/test/SemaObjC/check-dup-objc-decls-1.m
    cfe/branches/tooling/test/SemaObjC/class-extension-after-implementation.m
    cfe/branches/tooling/test/SemaObjC/class-getter-using-dotsyntax.m
    cfe/branches/tooling/test/SemaObjC/class-impl-1.m
    cfe/branches/tooling/test/SemaObjC/class-message-protocol-lookup.m
    cfe/branches/tooling/test/SemaObjC/class-method-self.m
    cfe/branches/tooling/test/SemaObjC/class-protocol-method-match.m
    cfe/branches/tooling/test/SemaObjC/compatible-protocol-qualified-types.m
    cfe/branches/tooling/test/SemaObjC/comptypes-10.m
    cfe/branches/tooling/test/SemaObjC/comptypes-a.m
    cfe/branches/tooling/test/SemaObjC/conditional-expr-5.m
    cfe/branches/tooling/test/SemaObjC/conditional-expr.m
    cfe/branches/tooling/test/SemaObjC/conflict-nonfragile-abi2.m
    cfe/branches/tooling/test/SemaObjC/conflicting-ivar-test-1.m
    cfe/branches/tooling/test/SemaObjC/continuation-class-err.m
    cfe/branches/tooling/test/SemaObjC/custom-atomic-property.m
    cfe/branches/tooling/test/SemaObjC/default-synthesize-1.m
    cfe/branches/tooling/test/SemaObjC/default-synthesize-2.m
    cfe/branches/tooling/test/SemaObjC/default-synthesize-3.m
    cfe/branches/tooling/test/SemaObjC/default-synthesize.m
    cfe/branches/tooling/test/SemaObjC/deref-interface.m
    cfe/branches/tooling/test/SemaObjC/direct-synthesized-ivar-access.m
    cfe/branches/tooling/test/SemaObjC/dist-object-modifiers.m
    cfe/branches/tooling/test/SemaObjC/enhanced-proto-2.m
    cfe/branches/tooling/test/SemaObjC/err-ivar-access-in-class-method.m
    cfe/branches/tooling/test/SemaObjC/error-property-gc-attr.m
    cfe/branches/tooling/test/SemaObjC/format-strings-objc.m
    cfe/branches/tooling/test/SemaObjC/forward-class-1.m
    cfe/branches/tooling/test/SemaObjC/gcc-cast-ext.m
    cfe/branches/tooling/test/SemaObjC/ibaction.m
    cfe/branches/tooling/test/SemaObjC/idiomatic-parentheses.m
    cfe/branches/tooling/test/SemaObjC/incomplete-implementation.m
    cfe/branches/tooling/test/SemaObjC/interface-scope-2.m
    cfe/branches/tooling/test/SemaObjC/invalid-code.m
    cfe/branches/tooling/test/SemaObjC/ivar-access-tests.m
    cfe/branches/tooling/test/SemaObjC/ivar-in-class-extension.m
    cfe/branches/tooling/test/SemaObjC/ivar-in-implementations.m
    cfe/branches/tooling/test/SemaObjC/ivar-lookup-resolution-builtin.m
    cfe/branches/tooling/test/SemaObjC/ivar-lookup.m
    cfe/branches/tooling/test/SemaObjC/ivar-ref-misuse.m
    cfe/branches/tooling/test/SemaObjC/legacy-implementation-1.m
    cfe/branches/tooling/test/SemaObjC/message.m
    cfe/branches/tooling/test/SemaObjC/method-attributes.m
    cfe/branches/tooling/test/SemaObjC/method-bad-param.m
    cfe/branches/tooling/test/SemaObjC/method-conflict-1.m
    cfe/branches/tooling/test/SemaObjC/method-conflict-2.m
    cfe/branches/tooling/test/SemaObjC/method-conflict.m
    cfe/branches/tooling/test/SemaObjC/method-def-1.m
    cfe/branches/tooling/test/SemaObjC/method-lookup.m
    cfe/branches/tooling/test/SemaObjC/method-prototype-scope.m
    cfe/branches/tooling/test/SemaObjC/method-typecheck-1.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/method-undefined-warn-1.m
    cfe/branches/tooling/test/SemaObjC/method-unused-attribute.m
    cfe/branches/tooling/test/SemaObjC/missing-atend-metadata.m
    cfe/branches/tooling/test/SemaObjC/missing-method-return-type.m
    cfe/branches/tooling/test/SemaObjC/nested-typedef-decl.m
    cfe/branches/tooling/test/SemaObjC/newproperty-class-method-1.m
    cfe/branches/tooling/test/SemaObjC/no-gc-weak-test.m
    cfe/branches/tooling/test/SemaObjC/no-ivar-access-control.m
    cfe/branches/tooling/test/SemaObjC/no-protocol-option-tests.m
    cfe/branches/tooling/test/SemaObjC/no-warn-qual-mismatch.m
    cfe/branches/tooling/test/SemaObjC/no-warn-synth-protocol-meth.m
    cfe/branches/tooling/test/SemaObjC/no-warning-unavail-unimp.m
    cfe/branches/tooling/test/SemaObjC/nonnull.m
    cfe/branches/tooling/test/SemaObjC/nsobject-attribute-1.m
    cfe/branches/tooling/test/SemaObjC/nsobject-attribute.m
    cfe/branches/tooling/test/SemaObjC/objc-buffered-methods.m
    cfe/branches/tooling/test/SemaObjC/objc-cstyle-args-in-methods.m
    cfe/branches/tooling/test/SemaObjC/objc-literal-nsnumber.m
    cfe/branches/tooling/test/SemaObjC/objc-qualified-property-lookup.m
    cfe/branches/tooling/test/SemaObjC/pedantic-dynamic-test.m
    cfe/branches/tooling/test/SemaObjC/pragma-pack.m
    cfe/branches/tooling/test/SemaObjC/property-2.m
    cfe/branches/tooling/test/SemaObjC/property-9.m
    cfe/branches/tooling/test/SemaObjC/property-and-ivar-use.m
    cfe/branches/tooling/test/SemaObjC/property-category-1.m
    cfe/branches/tooling/test/SemaObjC/property-category-3.m
    cfe/branches/tooling/test/SemaObjC/property-category-4.m
    cfe/branches/tooling/test/SemaObjC/property-category-impl.m
    cfe/branches/tooling/test/SemaObjC/property-dot-receiver.m
    cfe/branches/tooling/test/SemaObjC/property-expression-error.m
    cfe/branches/tooling/test/SemaObjC/property-impl-misuse.m
    cfe/branches/tooling/test/SemaObjC/property-in-class-extension.m
    cfe/branches/tooling/test/SemaObjC/property-ivar-mismatch.m
    cfe/branches/tooling/test/SemaObjC/property-lookup-in-id.m
    cfe/branches/tooling/test/SemaObjC/property-method-lookup-impl.m
    cfe/branches/tooling/test/SemaObjC/property-not-lvalue.m
    cfe/branches/tooling/test/SemaObjC/property-ns-returns-not-retained-attr.m
    cfe/branches/tooling/test/SemaObjC/property-redundant-decl-accessor.m
    cfe/branches/tooling/test/SemaObjC/property-typecheck-1.m
    cfe/branches/tooling/test/SemaObjC/property-user-setter.m
    cfe/branches/tooling/test/SemaObjC/property.m
    cfe/branches/tooling/test/SemaObjC/protocol-archane.m
    cfe/branches/tooling/test/SemaObjC/protocol-id-test-1.m
    cfe/branches/tooling/test/SemaObjC/protocol-id-test-2.m
    cfe/branches/tooling/test/SemaObjC/provisional-ivar-lookup.m
    cfe/branches/tooling/test/SemaObjC/qualified-protocol-method-conflicts.m
    cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m
    cfe/branches/tooling/test/SemaObjC/return.m
    cfe/branches/tooling/test/SemaObjC/scope-check.m
    cfe/branches/tooling/test/SemaObjC/selector-3.m
    cfe/branches/tooling/test/SemaObjC/selector-error.m
    cfe/branches/tooling/test/SemaObjC/self-assign.m
    cfe/branches/tooling/test/SemaObjC/self-declared-in-block.m
    cfe/branches/tooling/test/SemaObjC/severe-syntax-error.m
    cfe/branches/tooling/test/SemaObjC/sizeof-interface.m
    cfe/branches/tooling/test/SemaObjC/stand-alone-implementation.m
    cfe/branches/tooling/test/SemaObjC/synchronized.m
    cfe/branches/tooling/test/SemaObjC/synth-provisional-ivars-1.m
    cfe/branches/tooling/test/SemaObjC/synth-provisional-ivars.m
    cfe/branches/tooling/test/SemaObjC/synthesize-setter-contclass.m
    cfe/branches/tooling/test/SemaObjC/synthesized-ivar.m
    cfe/branches/tooling/test/SemaObjC/transparent-union.m
    cfe/branches/tooling/test/SemaObjC/undeclared-selector.m
    cfe/branches/tooling/test/SemaObjC/undef-protocol-methods-1.m
    cfe/branches/tooling/test/SemaObjC/undef-superclass-1.m
    cfe/branches/tooling/test/SemaObjC/unimplemented-protocol-prop.m
    cfe/branches/tooling/test/SemaObjC/unused.m
    cfe/branches/tooling/test/SemaObjC/warn-deprecated-implementations.m
    cfe/branches/tooling/test/SemaObjC/warn-forward-class-attr-deprecated.m
    cfe/branches/tooling/test/SemaObjC/warn-implicit-atomic-property.m
    cfe/branches/tooling/test/SemaObjC/warn-missing-super.m
    cfe/branches/tooling/test/SemaObjC/warn-retain-cycle.m
    cfe/branches/tooling/test/SemaObjC/warn-weak-field.m
    cfe/branches/tooling/test/SemaObjC/weak-property.m
    cfe/branches/tooling/test/SemaObjCXX/arc-overloading.mm
    cfe/branches/tooling/test/SemaObjCXX/blocks.mm
    cfe/branches/tooling/test/SemaObjCXX/composite-objc-pointertype.mm
    cfe/branches/tooling/test/SemaObjCXX/cstyle-block-pointer-cast.mm
    cfe/branches/tooling/test/SemaObjCXX/cxxoperator-selector.mm
    cfe/branches/tooling/test/SemaObjCXX/fragile-abi-object-assign.m
    cfe/branches/tooling/test/SemaObjCXX/goto.mm
    cfe/branches/tooling/test/SemaObjCXX/instantiate-method-return.mm
    cfe/branches/tooling/test/SemaObjCXX/ivar-construct.mm
    cfe/branches/tooling/test/SemaObjCXX/ivar-lookup.mm
    cfe/branches/tooling/test/SemaObjCXX/literals.mm
    cfe/branches/tooling/test/SemaObjCXX/message.mm
    cfe/branches/tooling/test/SemaObjCXX/objc-decls-inside-namespace.mm
    cfe/branches/tooling/test/SemaObjCXX/objc-pointer-conv.mm
    cfe/branches/tooling/test/SemaObjCXX/overload.mm
    cfe/branches/tooling/test/SemaObjCXX/propert-dot-error.mm
    cfe/branches/tooling/test/SemaObjCXX/properties.mm
    cfe/branches/tooling/test/SemaObjCXX/property-reference.mm
    cfe/branches/tooling/test/SemaObjCXX/property-synthesis-error.mm
    cfe/branches/tooling/test/SemaObjCXX/void_to_obj.mm
    cfe/branches/tooling/test/SemaTemplate/member-template-access-expr.cpp
    cfe/branches/tooling/test/lit.cfg
    cfe/branches/tooling/tools/arcmt-test/Makefile
    cfe/branches/tooling/tools/c-arcmt-test/Makefile
    cfe/branches/tooling/tools/c-arcmt-test/c-arcmt-test.c
    cfe/branches/tooling/tools/c-index-test/Makefile
    cfe/branches/tooling/tools/c-index-test/c-index-test.c
    cfe/branches/tooling/tools/driver/CMakeLists.txt
    cfe/branches/tooling/tools/driver/Makefile
    cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp
    cfe/branches/tooling/tools/libclang/CIndex.cpp
    cfe/branches/tooling/tools/libclang/CIndexCodeCompletion.cpp
    cfe/branches/tooling/tools/libclang/CIndexDiagnostic.cpp
    cfe/branches/tooling/tools/libclang/CIndexDiagnostic.h
    cfe/branches/tooling/tools/libclang/CIndexer.h
    cfe/branches/tooling/tools/libclang/CMakeLists.txt
    cfe/branches/tooling/tools/libclang/CXCursor.cpp
    cfe/branches/tooling/tools/libclang/CXLoadedDiagnostic.cpp
    cfe/branches/tooling/tools/libclang/CXLoadedDiagnostic.h
    cfe/branches/tooling/tools/libclang/CXStoredDiagnostic.cpp
    cfe/branches/tooling/tools/libclang/CXType.cpp
    cfe/branches/tooling/tools/libclang/Indexing.cpp
    cfe/branches/tooling/tools/libclang/libclang.exports
    cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp
    cfe/branches/tooling/unittests/ASTMatchers/ASTMatchersTest.cpp
    cfe/branches/tooling/unittests/CMakeLists.txt
    cfe/branches/tooling/unittests/Frontend/Makefile
    cfe/branches/tooling/unittests/Tooling/RefactoringTest.cpp
    cfe/branches/tooling/www/cxx_status.html

Propchange: cfe/branches/tooling/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 17 06:08:26 2012
@@ -1,3 +1,3 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:146581-153950
+/cfe/trunk:146581-154675
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/tooling/INPUTS/all-std-headers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/INPUTS/all-std-headers.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/INPUTS/all-std-headers.cpp (original)
+++ cfe/branches/tooling/INPUTS/all-std-headers.cpp Tue Apr 17 06:08:26 2012
@@ -44,13 +44,15 @@
 #include <stdexcept>
 #include <streambuf>
 #include <string>
-#include <strstream> 
+#if __has_include(<strstream>)
+#include <strstream>
+#endif
 #include <typeinfo>
 #include <utility>
 #include <valarray>
 #include <vector>
 
-#if __cplusplus >= 201103
+#if __cplusplus >= 201103 || defined(__GXX_EXPERIMENTAL_CXX0X__)
 #include <array>
 #if __has_include(<atomic>)
 #include <atomic>

Modified: cfe/branches/tooling/docs/LanguageExtensions.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/LanguageExtensions.html?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/docs/LanguageExtensions.html (original)
+++ cfe/branches/tooling/docs/LanguageExtensions.html Tue Apr 17 06:08:26 2012
@@ -30,18 +30,18 @@
 <li><a href="#vectors">Vectors and Extended Vectors</a></li>
 <li><a href="#deprecated">Messages on <tt>deprecated</tt> and <tt>unavailable</tt> attributes</a></li>
 <li><a href="#attributes-on-enumerators">Attributes on enumerators</a></li>
+<li><a href="#user_specified_system_framework">'User-Specified' System Frameworks</a></li>
 <li><a href="#availability">Availability attribute</a></li>
 <li><a href="#checking_language_features">Checks for Standard Language Features</a>
   <ul>
-  <li><a href="#cxx_exceptions">C++ exceptions</a></li>
-  <li><a href="#cxx_rtti">C++ RTTI</a></li>
+  <li><a href="#cxx98">C++98</a>
+    <ul>
+    <li><a href="#cxx_exceptions">C++ exceptions</a></li>
+    <li><a href="#cxx_rtti">C++ RTTI</a></li>
   </ul></li>
-<li><a href="#checking_upcoming_features">Checks for Upcoming Standard Language Features</a>
-  <ul>
-  <li><a href="#cxx0x">C++11</a>
+  <li><a href="#cxx11">C++11</a>
     <ul>
-   <li><a href="#cxx_access_control_sfinae">C++11 SFINAE includes
-   access control</a></li>
+    <li><a href="#cxx_access_control_sfinae">C++11 SFINAE includes access control</a></li>
     <li><a href="#cxx_alias_templates">C++11 alias templates</a></li>
     <li><a href="#cxx_alignas">C++11 alignment specifiers</a></li>
     <li><a href="#cxx_attributes">C++11 attributes</a></li>
@@ -57,6 +57,7 @@
     <li><a href="#cxx_inheriting_constructors">C++11 inheriting constructors</a></li>
     <li><a href="#cxx_inline_namespaces">C++11 inline namespaces</a></li>
     <li><a href="#cxx_lambdas">C++11 lambdas</a></li>
+    <li><a href="#cxx_local_type_template_args">C++11 local and unnamed types as template arguments</a></li>
     <li><a href="#cxx_noexcept">C++11 noexcept specification</a></li>
     <li><a href="#cxx_nonstatic_member_init">C++11 in-class non-static data member initialization</a></li>
     <li><a href="#cxx_nullptr">C++11 nullptr</a></li>
@@ -67,20 +68,21 @@
     <li><a href="#cxx_reference_qualified_functions">C++11 reference-qualified functions</a></li>
     <li><a href="#cxx_static_assert">C++11 <tt>static_assert()</tt></a></li>
     <li><a href="#cxx_auto_type">C++11 type inference</a></li>
-   <li><a href="#cxx_strong_enums">C++11 strongly-typed enumerations</a></li>
+    <li><a href="#cxx_strong_enums">C++11 strongly-typed enumerations</a></li>
     <li><a href="#cxx_trailing_return">C++11 trailing return type</a></li>
     <li><a href="#cxx_unicode_literals">C++11 Unicode string literals</a></li>
     <li><a href="#cxx_unrestricted_unions">C++11 unrestricted unions</a></li>
     <li><a href="#cxx_user_literals">C++11 user-defined literals</a></li>
     <li><a href="#cxx_variadic_templates">C++11 variadic templates</a></li>
-   </ul></li>
+  </ul></li>
   <li><a href="#c11">C11</a>
     <ul>
     <li><a href="#c_alignas">C11 alignment specifiers</a></li>
+    <li><a href="#c_atomic">C11 atomic operations</a></li>
     <li><a href="#c_generic_selections">C11 generic selections</a></li>
     <li><a href="#c_static_assert">C11 <tt>_Static_assert()</tt></a></li>
-    </ul></li>
-  </ul> </li>
+  </ul></li>
+</ul></li>
 <li><a href="#checking_type_traits">Checks for Type Traits</a></li>
 <li><a href="#blocks">Blocks</a></li>
 <li><a href="#objc_features">Objective-C Features</a>
@@ -89,7 +91,7 @@
     <li><a href="#objc_arc">Automatic reference counting</a></li>
     <li><a href="#objc_fixed_enum">Enumerations with a fixed underlying type</a></li>
     <li><a href="#objc_lambdas">Interoperability with C++11 lambdas</a></li>
-    <li><a href="#object-literals-subscripting">Object Literals and Subscripting</a></li>    
+    <li><a href="#object-literals-subscripting">Object Literals and Subscripting</a></li>
   </ul>
 </li>
 <li><a href="#overloading-in-c">Function Overloading in C</a></li>
@@ -625,6 +627,34 @@
 <p>Query for this feature with <tt>__has_extension(enumerator_attributes)</tt>.</p>
 
 <!-- ======================================================================= -->
+<h2 id="user_specified_system_framework">'User-Specified' System Frameworks</h2>
+<!-- ======================================================================= -->
+
+<p>Clang provides a mechanism by which frameworks can be built in such a way
+that they will always be treated as being 'system frameworks', even if they are
+not present in a system framework directory. This can be useful to system
+framework developers who want to be able to test building other applications
+with development builds of their framework, including the manner in which the
+compiler changes warning behavior for system headers.</p>
+
+<p>Framework developers can opt-in to this mechanism by creating a
+'.system_framework' file at the top-level of their framework. That is, the
+framework should have contents like:</p>
+
+<pre>
+ .../TestFramework.framework
+ .../TestFramework.framework/.system_framework
+ .../TestFramework.framework/Headers
+ .../TestFramework.framework/Headers/TestFramework.h
+ ...
+</pre>
+
+<p>Clang will treat the presence of this file as an indicator that the framework
+should be treated as a system framework, regardless of how it was found in the
+framework search path. For consistency, we recommend that such files never be
+included in installed versions of the framework.</p>
+
+<!-- ======================================================================= -->
 <h2 id="availability">Availability attribute</h2
 <!-- ======================================================================= -->
 
@@ -677,33 +707,32 @@
 <h2 id="checking_language_features">Checks for Standard Language Features</h2>
 <!-- ======================================================================= -->
 
-<p>The <tt>__has_feature</tt> macro can be used to query if certain standard language features are
-enabled.  Those features are listed here.</p>
+<p>The <tt>__has_feature</tt> macro can be used to query if certain standard
+language features are enabled.  The <tt>__has_extension</tt> macro can be used
+to query if language features are available as an extension when compiling for
+a standard which does not provide them. The features which can be tested are
+listed here.</p>
+
+<h3 id="cxx98">C++98</h3>
+
+<p>The features listed below are part of the C++98 standard. These features are
+enabled by default when compiling C++ code.</p>
 
-<h3 id="cxx_exceptions">C++ exceptions</h3>
+<h4 id="cxx_exceptions">C++ exceptions</h4>
 
 <p>Use <tt>__has_feature(cxx_exceptions)</tt> to determine if C++ exceptions have been enabled. For
-example, compiling code with <tt>-fexceptions</tt> enables C++ exceptions.</p>
+example, compiling code with <tt>-fno-exceptions</tt> disables C++ exceptions.</p>
 
-<h3 id="cxx_rtti">C++ RTTI</h3>
+<h4 id="cxx_rtti">C++ RTTI</h4>
 
 <p>Use <tt>__has_feature(cxx_rtti)</tt> to determine if C++ RTTI has been enabled. For example,
 compiling code with <tt>-fno-rtti</tt> disables the use of RTTI.</p>
 
-<!-- ======================================================================= -->
-<h2 id="checking_upcoming_features">Checks for Upcoming Standard Language Features</h2>
-<!-- ======================================================================= -->
-
-<p>The <tt>__has_feature</tt> or <tt>__has_extension</tt> macros can be used
-to query if certain upcoming standard language features are enabled.  Those
-features are listed here.  Features that are not yet implemented will be
-noted.</p>
-
-<h3 id="cxx0x">C++11</h3>
+<h3 id="cxx11">C++11</h3>
 
-<p>The features listed below are slated for inclusion in the upcoming
-C++11 standard. As a result, all these features are enabled
-with the <tt>-std=c++11</tt> option when compiling C++ code.</p>
+<p>The features listed below are part of the C++11 standard. As a result, all
+these features are enabled with the <tt>-std=c++11</tt> or <tt>-std=gnu++11</tt>
+option when compiling C++ code.</p>
 
 <h4 id="cxx_access_control_sfinae">C++11 SFINAE includes access control</h4>
 
@@ -737,7 +766,11 @@
 
 <p>Use <tt>__has_feature(cxx_decltype)</tt> or
 <tt>__has_extension(cxx_decltype)</tt> to determine if support for the
-<tt>decltype()</tt> specifier is enabled.</p>
+<tt>decltype()</tt> specifier is enabled. C++11's <tt>decltype</tt>
+does not require type-completeness of a function call expression.
+Use <tt>__has_feature(cxx_decltype_incomplete_return_types)</tt>
+or <tt>__has_extension(cxx_decltype_incomplete_return_types)</tt>
+to determine if support for this feature is enabled.</p>
 
 <h4 id="cxx_default_function_template_args">C++11 default template arguments in function templates</h4>
 
@@ -792,6 +825,12 @@
 <tt>__has_extension(cxx_lambdas)</tt> to determine if support for lambdas
 is enabled. </p>
 
+<h4 id="cxx_local_type_template_args">C++11 local and unnamed types as template arguments</h4>
+
+<p>Use <tt>__has_feature(cxx_local_type_template_args)</tt> or
+<tt>__has_extension(cxx_local_type_template_args)</tt> to determine if
+support for local and unnamed types as template arguments is enabled.</p>
+
 <h4 id="cxx_noexcept">C++11 noexcept</h4>
 
 <p>Use <tt>__has_feature(cxx_noexcept)</tt> or
@@ -882,9 +921,10 @@
 
 <h3 id="c11">C11</h3>
 
-<p>The features listed below are slated for inclusion in the upcoming
-C11 standard. As a result, all these features are enabled
-with the <tt>-std=c11</tt> option when compiling C code.</p>
+<p>The features listed below are part of the C11 standard. As a result, all
+these features are enabled with the <tt>-std=c11</tt> or <tt>-std=gnu11</tt>
+option when compiling C code. Additionally, because these features are all
+backward-compatible, they are available as extensions in all language modes.</p>
 
 <h4 id="c_alignas">C11 alignment specifiers</h4>
 
@@ -892,6 +932,14 @@
 to determine if support for alignment specifiers using <tt>_Alignas</tt>
 is enabled.</p>
 
+<h4 id="c_atomic">C11 atomic operations</h4>
+
+<p>Use <tt>__has_feature(c_atomic)</tt> or <tt>__has_extension(c_atomic)</tt>
+to determine if support for atomic types using <tt>_Atomic</tt> is enabled.
+Clang also provides <a href="#__c11_atomic">a set of builtins</a> which can be
+used to implement the <tt><stdatomic.h></tt> operations on _Atomic
+types.</p>
+
 <h4 id="c_generic_selections">C11 generic selections</h4>
 
 <p>Use <tt>__has_feature(c_generic_selections)</tt> or
@@ -1415,6 +1463,32 @@
 __sync_lock_test_and_set(). The __sync_swap() builtin is a full barrier.
 </p>
 
+<!-- ======================================================================= -->
+<h3><a name="__c11_atomic">__c11_atomic builtins</a></h3>
+<!-- ======================================================================= -->
+
+<p>Clang provides a set of builtins which are intended to be used to implement
+C11's <tt><stdatomic.h></tt> header. These builtins provide the semantics
+of the <tt>_explicit</tt> form of the corresponding C11 operation, and are named
+with a <tt>__c11_</tt> prefix. The supported operations are:</p>
+
+<ul>
+  <li><tt>__c11_atomic_init</tt></li>
+  <li><tt>__c11_atomic_thread_fence</tt></li>
+  <li><tt>__c11_atomic_signal_fence</tt></li>
+  <li><tt>__c11_atomic_is_lock_free</tt></li>
+  <li><tt>__c11_atomic_store</tt></li>
+  <li><tt>__c11_atomic_load</tt></li>
+  <li><tt>__c11_atomic_exchange</tt></li>
+  <li><tt>__c11_atomic_compare_exchange_strong</tt></li>
+  <li><tt>__c11_atomic_compare_exchange_weak</tt></li>
+  <li><tt>__c11_atomic_fetch_add</tt></li>
+  <li><tt>__c11_atomic_fetch_sub</tt></li>
+  <li><tt>__c11_atomic_fetch_and</tt></li>
+  <li><tt>__c11_atomic_fetch_or</tt></li>
+  <li><tt>__c11_atomic_fetch_xor</tt></li>
+</ul>
+
 
 <!-- ======================================================================= -->
 <h2 id="targetspecific">Target-Specific Extensions</h2>

Modified: cfe/branches/tooling/docs/ReleaseNotes.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/ReleaseNotes.html?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/docs/ReleaseNotes.html (original)
+++ cfe/branches/tooling/docs/ReleaseNotes.html Tue Apr 17 06:08:26 2012
@@ -89,7 +89,13 @@
 
 <p>New: <code>-Wdangling-else</code>, <code>-Wstrncat-size</code>, ...</p>
 
-<p>Improved: <code>-Wformat</code>, <code>-Wempty-body</code>, ...</p>
+<p>Improved: <code>-Wformat</code>, <code>-Wempty-body</code>,
+<code>-Wliteral-conversion</code>, ...</p>
+
+<h4 id="tooling">Tooling</h4>
+<!-- FIXME: add a link to the tooling documentation once that's written. -->
+<p>Added an API to enable clang-based standalone tools, including initial build
+system integration.</p>
 
 <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
 <h3 id="cchanges">C Language Changes in Clang</h3>
@@ -126,6 +132,8 @@
   <li>Unrestricted unions</li>
   <li>User-defined literals</li>
   <li>Forward-declared enumerations</li>
+  <li>Atomics (both libc++'s and libstdc++4.7's <tt><atomic></tt> are
+      supported)</li>
 </ul>
 
 <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->

Modified: cfe/branches/tooling/examples/clang-interpreter/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/examples/clang-interpreter/CMakeLists.txt?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/examples/clang-interpreter/CMakeLists.txt (original)
+++ cfe/branches/tooling/examples/clang-interpreter/CMakeLists.txt Tue Apr 17 06:08:26 2012
@@ -7,7 +7,6 @@
     clangStaticAnalyzerFrontend
     clangStaticAnalyzerCheckers
     clangStaticAnalyzerCore
-    clangIndex
     clangAnalysis
     clangRewrite
     clangAST

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang-c/Index.h (original)
+++ cfe/branches/tooling/include/clang-c/Index.h Tue Apr 17 06:08:26 2012
@@ -35,6 +35,16 @@
   #define CINDEX_LINKAGE
 #endif
 
+#ifdef __GNUC__
+  #define CINDEX_DEPRECATED __attribute__((deprecated))
+#else
+  #ifdef _MSC_VER
+    #define CINDEX_DEPRECATED __declspec(deprecated)
+  #else
+    #define CINDEX_DEPRECATED
+  #endif
+#endif
+
 /** \defgroup CINDEX libclang: C Interface to Clang
  *
  * The C Interface to Clang provides a relatively small API that exposes
@@ -830,14 +840,25 @@
 CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
 
 /**
- * \brief Retrieve the name of a particular diagnostic category.
+ * \brief Retrieve the name of a particular diagnostic category.  This
+ *  is now deprecated.  Use clang_getDiagnosticCategoryText()
+ *  instead.
  *
  * \param Category A diagnostic category number, as returned by 
  * \c clang_getDiagnosticCategory().
  *
  * \returns The name of the given diagnostic category.
  */
-CINDEX_LINKAGE CXString clang_getDiagnosticCategoryName(unsigned Category);
+CINDEX_DEPRECATED CINDEX_LINKAGE
+CXString clang_getDiagnosticCategoryName(unsigned Category);
+
+/**
+ * \brief Retrieve the diagnostic category text for a given diagnostic.
+ *
+ *
+ * \returns The text of the given diagnostic category.
+ */
+CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
   
 /**
  * \brief Determine the number of source ranges associated with the given
@@ -1048,7 +1069,16 @@
    * Note: this is a *temporary* option that is available only while
    * we are testing C++ precompiled preamble support. It is deprecated.
    */
-  CXTranslationUnit_CXXChainedPCH = 0x20
+  CXTranslationUnit_CXXChainedPCH = 0x20,
+
+  /**
+   * \brief Used to indicate that function/method bodies should be skipped while
+   * parsing.
+   *
+   * This option can be used to search for declarations/definitions while
+   * ignoring the usages.
+   */
+  CXTranslationUnit_SkipFunctionBodies = 0x40
 };
 
 /**
@@ -2525,6 +2555,22 @@
 CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
 
 /**
+ * \brief Retrieve the number of non-variadic arguments associated with a given
+ * cursor.
+ *
+ * If a cursor that is not a function or method is passed in, -1 is returned.
+ */
+CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
+
+/**
+ * \brief Retrieve the argument cursor of a function or method.
+ *
+ * If a cursor that is not a function or method is passed in or the index
+ * exceeds the number of arguments, an invalid cursor is returned.
+ */
+CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
+
+/**
  * \determine Determine whether two CXTypes represent the same type.
  *
  * \returns non-zero if the CXTypes represent the same type and 
@@ -2598,9 +2644,9 @@
 /**
  * \brief Retrieve the number of non-variadic arguments associated with a function type.
  *
- * If a non-function type is passed in, UINT_MAX is returned.
+ * If a non-function type is passed in, -1 is returned.
  */
-CINDEX_LINKAGE unsigned clang_getNumArgTypes(CXType T);
+CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
 
 /**
  * \brief Retrieve the type of an argument of a function type.

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclBase.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclBase.h Tue Apr 17 06:08:26 2012
@@ -1438,6 +1438,14 @@
   /// replaced with D.
   void makeDeclVisibleInContext(NamedDecl *D);
 
+  /// all_lookups_iterator - An iterator that provides a view over the results
+  /// of looking up every possible name.
+  class all_lookups_iterator;
+
+  all_lookups_iterator lookups_begin() const;
+
+  all_lookups_iterator lookups_end() const;
+
   /// udir_iterator - Iterates through the using-directives stored
   /// within this context.
   typedef UsingDirectiveDecl * const * udir_iterator;

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclCXX.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclCXX.h Tue Apr 17 06:08:26 2012
@@ -621,7 +621,7 @@
            "queried lambda property of non-lambda class");
     return static_cast<LambdaDefinitionData &>(*DefinitionData);
   }
-
+  
   /// \brief The template or declaration that this declaration
   /// describes or was instantiated from, respectively.
   ///
@@ -1503,6 +1503,13 @@
     return getLambdaData().ContextDecl;    
   }
   
+  /// \brief Set the mangling number and context declaration for a lambda
+  /// class.
+  void setLambdaMangling(unsigned ManglingNumber, Decl *ContextDecl) {
+    getLambdaData().ManglingNumber = ManglingNumber;
+    getLambdaData().ContextDecl = ContextDecl;
+  }
+
   /// \brief Determine whether this lambda expression was known to be dependent
   /// at the time it was created, even if its context does not appear to be
   /// dependent.

Modified: cfe/branches/tooling/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/DeclObjC.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclObjC.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclObjC.h Tue Apr 17 06:08:26 2012
@@ -901,14 +901,14 @@
   // Lookup a method. First, we search locally. If a method isn't
   // found, we search referenced protocols and class categories.
   ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance,
-                               bool noCategoryLookup= false) const;
+                               bool shallowCategoryLookup= false) const;
   ObjCMethodDecl *lookupInstanceMethod(Selector Sel,
-                                       bool noCategoryLookup = false) const {
-    return lookupMethod(Sel, true/*isInstance*/, noCategoryLookup);
+                            bool shallowCategoryLookup = false) const {
+    return lookupMethod(Sel, true/*isInstance*/, shallowCategoryLookup);
   }
   ObjCMethodDecl *lookupClassMethod(Selector Sel,
-                                    bool noCategoryLookup = false) const {
-    return lookupMethod(Sel, false/*isInstance*/, noCategoryLookup);
+                     bool shallowCategoryLookup = false) const {
+    return lookupMethod(Sel, false/*isInstance*/, shallowCategoryLookup);
   }
   ObjCInterfaceDecl *lookupInheritedClass(const IdentifierInfo *ICName);
 

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Expr.h (original)
+++ cfe/branches/tooling/include/clang/AST/Expr.h Tue Apr 17 06:08:26 2012
@@ -4470,73 +4470,68 @@
 
 /// AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*,
 /// __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the
-/// similarly-named C++0x instructions.  All of these instructions take one
-/// primary pointer and at least one memory order.
+/// similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>.
+/// All of these instructions take one primary pointer and at least one memory
+/// order.
 class AtomicExpr : public Expr {
 public:
-  enum AtomicOp { Load, Store, CmpXchgStrong, CmpXchgWeak, Xchg,
-                  Add, Sub, And, Or, Xor, Init };
+  enum AtomicOp {
+#define BUILTIN(ID, TYPE, ATTRS)
+#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) AO ## ID,
+#include "clang/Basic/Builtins.def"
+    // Avoid trailing comma
+    BI_First = 0
+  };
+
 private:
-  enum { PTR, ORDER, VAL1, ORDER_FAIL, VAL2, END_EXPR };
+  enum { PTR, ORDER, VAL1, ORDER_FAIL, VAL2, WEAK, END_EXPR };
   Stmt* SubExprs[END_EXPR];
   unsigned NumSubExprs;
   SourceLocation BuiltinLoc, RParenLoc;
   AtomicOp Op;
 
+  friend class ASTStmtReader;
+
 public:
   AtomicExpr(SourceLocation BLoc, Expr **args, unsigned nexpr, QualType t,
              AtomicOp op, SourceLocation RP);
 
+  /// \brief Determine the number of arguments the specified atomic builtin
+  /// should have.
+  static unsigned getNumSubExprs(AtomicOp Op);
+
   /// \brief Build an empty AtomicExpr.
   explicit AtomicExpr(EmptyShell Empty) : Expr(AtomicExprClass, Empty) { }
 
   Expr *getPtr() const {
     return cast<Expr>(SubExprs[PTR]);
   }
-  void setPtr(Expr *E) {
-    SubExprs[PTR] = E;
-  }
   Expr *getOrder() const {
     return cast<Expr>(SubExprs[ORDER]);
   }
-  void setOrder(Expr *E) {
-    SubExprs[ORDER] = E;
-  }
   Expr *getVal1() const {
-    if (Op == Init)
+    if (Op == AO__c11_atomic_init)
       return cast<Expr>(SubExprs[ORDER]);
-    assert(NumSubExprs >= 3);
+    assert(NumSubExprs > VAL1);
     return cast<Expr>(SubExprs[VAL1]);
   }
-  void setVal1(Expr *E) {
-    if (Op == Init) {
-      SubExprs[ORDER] = E;
-      return;
-    }
-    assert(NumSubExprs >= 3);
-    SubExprs[VAL1] = E;
-  }
   Expr *getOrderFail() const {
-    assert(NumSubExprs == 5);
+    assert(NumSubExprs > ORDER_FAIL);
     return cast<Expr>(SubExprs[ORDER_FAIL]);
   }
-  void setOrderFail(Expr *E) {
-    assert(NumSubExprs == 5);
-    SubExprs[ORDER_FAIL] = E;
-  }
   Expr *getVal2() const {
-    assert(NumSubExprs == 5);
+    if (Op == AO__atomic_exchange)
+      return cast<Expr>(SubExprs[ORDER_FAIL]);
+    assert(NumSubExprs > VAL2);
     return cast<Expr>(SubExprs[VAL2]);
   }
-  void setVal2(Expr *E) {
-    assert(NumSubExprs == 5);
-    SubExprs[VAL2] = E;
+  Expr *getWeak() const {
+    assert(NumSubExprs > WEAK);
+    return cast<Expr>(SubExprs[WEAK]);
   }
 
   AtomicOp getOp() const { return Op; }
-  void setOp(AtomicOp op) { Op = op; }
   unsigned getNumSubExprs() { return NumSubExprs; }
-  void setNumSubExprs(unsigned num) { NumSubExprs = num; }
 
   Expr **getSubExprs() { return reinterpret_cast<Expr **>(SubExprs); }
 
@@ -4545,15 +4540,14 @@
   }
 
   bool isCmpXChg() const {
-    return getOp() == AtomicExpr::CmpXchgStrong ||
-           getOp() == AtomicExpr::CmpXchgWeak;
+    return getOp() == AO__c11_atomic_compare_exchange_strong ||
+           getOp() == AO__c11_atomic_compare_exchange_weak ||
+           getOp() == AO__atomic_compare_exchange ||
+           getOp() == AO__atomic_compare_exchange_n;
   }
 
   SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
-  void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
-
   SourceLocation getRParenLoc() const { return RParenLoc; }
-  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
 
   SourceRange getSourceRange() const LLVM_READONLY {
     return SourceRange(BuiltinLoc, RParenLoc);

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ExprCXX.h (original)
+++ cfe/branches/tooling/include/clang/AST/ExprCXX.h Tue Apr 17 06:08:26 2012
@@ -1231,9 +1231,7 @@
              ArrayRef<Expr *> CaptureInits,
              ArrayRef<VarDecl *> ArrayIndexVars,
              ArrayRef<unsigned> ArrayIndexStarts,
-             SourceLocation ClosingBrace,
-             unsigned ManglingNumber,
-             Decl *ContextDecl);
+             SourceLocation ClosingBrace);
 
   /// \brief Construct an empty lambda expression.
   LambdaExpr(EmptyShell Empty, unsigned NumCaptures, bool HasArrayIndexVars)
@@ -1271,9 +1269,7 @@
                             ArrayRef<Expr *> CaptureInits,
                             ArrayRef<VarDecl *> ArrayIndexVars,
                             ArrayRef<unsigned> ArrayIndexStarts,
-                            SourceLocation ClosingBrace,
-                            unsigned ManglingNumber,
-                            Decl *ContextDecl);
+                            SourceLocation ClosingBrace);
 
   /// \brief Construct a new lambda expression that will be deserialized from
   /// an external source.

Modified: cfe/branches/tooling/include/clang/AST/NSAPI.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/NSAPI.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/NSAPI.h (original)
+++ cfe/branches/tooling/include/clang/AST/NSAPI.h Tue Apr 17 06:08:26 2012
@@ -25,6 +25,7 @@
   ASTContext &getASTContext() const { return Ctx; }
 
   enum NSClassIdKindKind {
+    ClassId_NSObject,
     ClassId_NSString,
     ClassId_NSArray,
     ClassId_NSMutableArray,
@@ -32,7 +33,7 @@
     ClassId_NSMutableDictionary,
     ClassId_NSNumber
   };
-  static const unsigned NumClassIds = 6;
+  static const unsigned NumClassIds = 7;
 
   enum NSStringMethodKind {
     NSStr_stringWithString,

Modified: cfe/branches/tooling/include/clang/AST/TemplateBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/TemplateBase.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/TemplateBase.h (original)
+++ cfe/branches/tooling/include/clang/AST/TemplateBase.h Tue Apr 17 06:08:26 2012
@@ -101,7 +101,6 @@
   /// declaration, which is either an external declaration or a
   /// template declaration.
   TemplateArgument(Decl *D) : Kind(Declaration) {
-    // FIXME: Need to be sure we have the "canonical" declaration!
     TypeOrValue = reinterpret_cast<uintptr_t>(D);
   }
 

Modified: cfe/branches/tooling/include/clang/Analysis/CallGraph.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Analysis/CallGraph.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Analysis/CallGraph.h (original)
+++ cfe/branches/tooling/include/clang/Analysis/CallGraph.h Tue Apr 17 06:08:26 2012
@@ -18,6 +18,7 @@
 #define LLVM_CLANG_ANALYSIS_CALLGRAPH
 
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/SetVector.h"
@@ -25,8 +26,14 @@
 namespace clang {
 class CallGraphNode;
 
-class CallGraph {
+/// \class The AST-based call graph.
+///
+/// The call graph extends itself with the given declarations by implementing
+/// the recursive AST visitor, which constructs the graph by visiting the given
+/// declarations.
+class CallGraph : public RecursiveASTVisitor<CallGraph> {
   friend class CallGraphNode;
+
   typedef llvm::DenseMap<const Decl *, CallGraphNode *> FunctionMapTy;
 
   /// FunctionMap owns all CallGraphNodes.
@@ -45,19 +52,23 @@
   CallGraph();
   ~CallGraph();
 
-  /// \brief Add the given declaration to the call graph.
-  void addToCallGraph(Decl *D, bool IsGlobal);
+  /// \brief Populate the call graph with the functions in the given
+  /// declaration.
+  ///
+  /// Recursively walks the declaration to find all the dependent Decls as well.
+  void addToCallGraph(Decl *D) {
+    TraverseDecl(D);
+  }
 
-  /// \brief Populate the call graph with the functions in the given translation
-  /// unit.
-  void addToCallGraph(TranslationUnitDecl *TU);
+  /// \brief Determine if a declaration should be included in the graph.
+  static bool includeInGraph(const Decl *D);
 
   /// \brief Lookup the node for the given declaration.
   CallGraphNode *getNode(const Decl *) const;
 
   /// \brief Lookup the node for the given declaration. If none found, insert
   /// one into the graph.
-  CallGraphNode *getOrInsertFunction(Decl *);
+  CallGraphNode *getOrInsertNode(Decl *);
 
   /// Iterators through all the elements in the graph. Note, this gives
   /// non-deterministic order.
@@ -90,6 +101,32 @@
   void print(raw_ostream &os) const;
   void dump() const;
   void viewGraph() const;
+
+  /// Part of recursive declaration visitation.
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+    // We skip function template definitions, as their semantics is
+    // only determined when they are instantiated.
+    if (includeInGraph(FD))
+      // If this function has external linkage, anything could call it.
+      // Note, we are not precise here. For example, the function could have
+      // its address taken.
+      addNodeForDecl(FD, FD->isGlobal());
+    return true;
+  }
+
+  /// Part of recursive declaration visitation.
+  bool VisitObjCMethodDecl(ObjCMethodDecl *MD) {
+    if (includeInGraph(MD))
+      addNodeForDecl(MD, true);
+    return true;
+  }
+
+private:
+  /// \brief Add the given declaration to the call graph.
+  void addNodeForDecl(Decl *D, bool IsGlobal);
+
+  /// \brief Allocate a new node in the graph.
+  CallGraphNode *allocateNewNode(Decl *);
 };
 
 class CallGraphNode {

Modified: cfe/branches/tooling/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/Attr.td?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/Attr.td (original)
+++ cfe/branches/tooling/include/clang/Basic/Attr.td Tue Apr 17 06:08:26 2012
@@ -452,6 +452,11 @@
   let Subjects = [ObjCMethod];
 }
 
+def ObjCRootClass : Attr {
+  let Spellings = ["objc_root_class"];
+  let Subjects = [ObjCInterface];
+}
+
 def Overloadable : Attr {
   let Spellings = ["overloadable"];
 }
@@ -534,10 +539,12 @@
 
 def ArcWeakrefUnavailable : InheritableAttr {
   let Spellings = ["objc_arc_weak_reference_unavailable"];
+  let Subjects = [ObjCInterface];
 }
 
 def ObjCRequiresPropertyDefs : InheritableAttr {
   let Spellings = ["objc_requires_property_definitions"];
+  let Subjects = [ObjCInterface];
 }
 
 def Unused : InheritableAttr {

Modified: cfe/branches/tooling/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/Builtins.def?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/Builtins.def (original)
+++ cfe/branches/tooling/include/clang/Basic/Builtins.def Tue Apr 17 06:08:26 2012
@@ -594,20 +594,57 @@
 BUILTIN(__sync_swap_8, "LLiLLiD*LLi.", "tn")
 BUILTIN(__sync_swap_16, "LLLiLLLiD*LLLi.", "tn")
 
-BUILTIN(__atomic_load, "v.", "t")
-BUILTIN(__atomic_store, "v.", "t")
-BUILTIN(__atomic_exchange, "v.", "t")
-BUILTIN(__atomic_compare_exchange_strong, "v.", "t")
-BUILTIN(__atomic_compare_exchange_weak, "v.", "t")
-BUILTIN(__atomic_fetch_add, "v.", "t")
-BUILTIN(__atomic_fetch_sub, "v.", "t")
-BUILTIN(__atomic_fetch_and, "v.", "t")
-BUILTIN(__atomic_fetch_or, "v.", "t")
-BUILTIN(__atomic_fetch_xor, "v.", "t")
+// Some of our atomics builtins are handled by AtomicExpr rather than
+// as normal builtin CallExprs. This macro is used for such builtins.
+#ifndef ATOMIC_BUILTIN
+#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
+// C11 _Atomic operations for <stdatomic.h>.
+ATOMIC_BUILTIN(__c11_atomic_init, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_load, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_store, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_exchange, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_compare_exchange_strong, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_compare_exchange_weak, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_fetch_add, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_fetch_sub, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_fetch_and, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_fetch_or, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_fetch_xor, "v.", "t")
+BUILTIN(__c11_atomic_thread_fence, "vi", "n")
+BUILTIN(__c11_atomic_signal_fence, "vi", "n")
+BUILTIN(__c11_atomic_is_lock_free, "iz", "n")
+
+// GNU atomic builtins.
+ATOMIC_BUILTIN(__atomic_load, "v.", "t")
+ATOMIC_BUILTIN(__atomic_load_n, "v.", "t")
+ATOMIC_BUILTIN(__atomic_store, "v.", "t")
+ATOMIC_BUILTIN(__atomic_store_n, "v.", "t")
+ATOMIC_BUILTIN(__atomic_exchange, "v.", "t")
+ATOMIC_BUILTIN(__atomic_exchange_n, "v.", "t")
+ATOMIC_BUILTIN(__atomic_compare_exchange, "v.", "t")
+ATOMIC_BUILTIN(__atomic_compare_exchange_n, "v.", "t")
+ATOMIC_BUILTIN(__atomic_fetch_add, "v.", "t")
+ATOMIC_BUILTIN(__atomic_fetch_sub, "v.", "t")
+ATOMIC_BUILTIN(__atomic_fetch_and, "v.", "t")
+ATOMIC_BUILTIN(__atomic_fetch_or, "v.", "t")
+ATOMIC_BUILTIN(__atomic_fetch_xor, "v.", "t")
+ATOMIC_BUILTIN(__atomic_fetch_nand, "v.", "t")
+ATOMIC_BUILTIN(__atomic_add_fetch, "v.", "t")
+ATOMIC_BUILTIN(__atomic_sub_fetch, "v.", "t")
+ATOMIC_BUILTIN(__atomic_and_fetch, "v.", "t")
+ATOMIC_BUILTIN(__atomic_or_fetch, "v.", "t")
+ATOMIC_BUILTIN(__atomic_xor_fetch, "v.", "t")
+ATOMIC_BUILTIN(__atomic_nand_fetch, "v.", "t")
+BUILTIN(__atomic_test_and_set, "bvD*i", "n")
+BUILTIN(__atomic_clear, "vvD*i", "n")
 BUILTIN(__atomic_thread_fence, "vi", "n")
 BUILTIN(__atomic_signal_fence, "vi", "n")
-BUILTIN(__atomic_init, "v.", "t")
-BUILTIN(__atomic_is_lock_free, "iz", "n")
+BUILTIN(__atomic_always_lock_free, "izvCD*", "n")
+BUILTIN(__atomic_is_lock_free, "izvCD*", "n")
+
+#undef ATOMIC_BUILTIN
 
 // Non-overloaded atomic builtins.
 BUILTIN(__sync_synchronize, "v.", "n")

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td Tue Apr 17 06:08:26 2012
@@ -71,6 +71,8 @@
   "invalid float ABI '%0'">;
 def err_drv_invalid_libcxx_deployment : Error<
   "invalid deployment target for -stdlib=libc++ (requires %0 or later)">;
+def err_drv_invalid_feature : Error<
+  "invalid feature '%0' for CPU '%1'">;
 
 def err_drv_I_dash_not_supported : Error<
   "'%0' not supported, please use -iquote instead">;

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td Tue Apr 17 06:08:26 2012
@@ -148,6 +148,7 @@
 def ObjCMissingSuperCalls : DiagGroup<"objc-missing-super-calls">;
 def ObjCRetainBlockProperty : DiagGroup<"objc-noncopy-retain-block-property">;
 def ObjCReadonlyPropertyHasSetter : DiagGroup<"objc-readonly-with-setter-property">;
+def ObjCRootClass : DiagGroup<"objc-root-class">;
 def Packed : DiagGroup<"packed">;
 def Padded : DiagGroup<"padded">;
 def PointerArith : DiagGroup<"pointer-arith">;

Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td Tue Apr 17 06:08:26 2012
@@ -48,6 +48,11 @@
   InGroup<Comment>;
 def ext_no_newline_eof : Extension<"no newline at end of file">, 
   InGroup<DiagGroup<"newline-eof">>;
+
+def warn_cxx98_compat_no_newline_eof : Warning<
+  "C++98 requires newline at end of file">,
+  InGroup<CXX98CompatPedantic>, DefaultIgnore;
+
 def ext_dollar_in_identifier : Extension<"'$' in identifier">,
   InGroup<DiagGroup<"dollar-in-identifier-extension">>;
 def ext_charize_microsoft : Extension<"@# is a microsoft extension">,
@@ -151,6 +156,9 @@
 def ext_reserved_user_defined_literal : ExtWarn<
   "invalid suffix on literal; C++11 requires a space between literal and "
   "identifier">, InGroup<ReservedUserDefinedLiteral>, DefaultError;
+def ext_ms_reserved_user_defined_literal : ExtWarn<
+  "invalid suffix on literal; C++11 requires a space between literal and "
+  "identifier">, InGroup<ReservedUserDefinedLiteral>;
 def err_unsupported_string_concat : Error<
   "unsupported non-standard concatenation of string literals">;
 def err_string_concat_mixed_suffix : Error<

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td Tue Apr 17 06:08:26 2012
@@ -117,7 +117,6 @@
   InGroup<GNU>;
 
 // Generic errors.
-def err_parse_error : Error<"parse error">;
 def err_expected_expression : Error<"expected expression">;
 def err_expected_type : Error<"expected a type">;
 def err_expected_external_declaration : Error<"expected external declaration">;
@@ -465,11 +464,14 @@
 def warn_cxx98_compat_attribute : Warning<
   "attributes are incompatible with C++98">,
   InGroup<CXX98Compat>, DefaultIgnore;
-def err_cxx0x_attribute_forbids_arguments : Error<
-  "C++11 attribute '%0' cannot have an argument list">;
-def err_cxx0x_attribute_requires_arguments : Error<
-  "C++11 attribute '%0' must have an argument list">;
+def err_cxx11_attribute_forbids_arguments : Error<
+  "attribute '%0' cannot have an argument list">;
+def err_cxx11_attribute_forbids_ellipsis : Error<
+  "attribute '%0' cannot be used as an attribute pack">;
 def err_attributes_not_allowed : Error<"an attribute list cannot appear here">;
+def err_l_square_l_square_not_attribute : Error<
+  "C++11 only allows consecutive left square brackets when "
+  "introducing an attribute">;
 def err_alignas_pack_exp_unsupported : Error<
   "pack expansions in alignment specifiers are not supported yet">;
 
@@ -479,8 +481,8 @@
   "unknown template name %0">;
 def err_expected_comma_greater : Error<
   "expected ',' or '>' in template-parameter-list">;
-def err_expected_class_before : Error<"expected 'class' before '%0'">;
-def err_expected_class_instead : Error<"expected 'class' instead of '%0'">;
+def err_class_on_template_template_param : Error<
+  "template template parameter requires 'class' after the parameter list">;
 def err_template_spec_syntax_non_template : Error<
   "identifier followed by '<' indicates a class template specialization but "
   "%0 %select{does not refer to a template|refers to a function "
@@ -506,6 +508,7 @@
 def err_enum_template : Error<"enumeration cannot be a template">;
 def err_explicit_instantiation_enum : Error<
     "enumerations cannot be explicitly instantiated">;
+def err_expected_template_parameter : Error<"expected template parameter">;
 
 def err_missing_dependent_template_keyword : Error<
   "use 'template' keyword to treat '%0' as a dependent template name">;

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td Tue Apr 17 06:08:26 2012
@@ -444,6 +444,13 @@
   "receiver is treated with 'id' type for purpose of method lookup">;
 def note_suppressed_class_declare : Note<
   "class with specified objc_requires_property_definitions attribute is declared here">;
+def err_objc_root_class_subclass : Error<
+  "objc_root_class attribute may only be specified on a root class declaration">;
+def warn_objc_root_class_missing : Warning<
+	"class %0 defined without specifying a base class">,
+  InGroup<ObjCRootClass>, DefaultIgnore;
+def note_objc_needs_superclass : Note<
+  "add a super class to fix this problem">;
 def warn_dup_category_def : Warning<
   "duplicate definition of category %1 on interface %0">;
 def err_conflicting_super_class : Error<"conflicting super class name %0">;
@@ -652,6 +659,9 @@
   InGroup<DiagGroup<"arc-performSelector-leaks">>;
 def err_gc_weak_property_strong_type : Error<
   "weak attribute declared on a __strong type property in GC mode">;
+def warn_receiver_is_weak : Warning <
+  "weak receiver may be unpredictably null in ARC mode">,
+  InGroup<DiagGroup<"receiver-is-weak">>, DefaultIgnore;
 
 def error_synthesized_ivar_yet_not_supported : Error<
   "instance variable synthesis not yet supported"
@@ -874,8 +884,13 @@
 def note_access_constrained_by_path : Note<
   "constrained by %select{|implicitly }1%select{private|protected}0"
   " inheritance here">;
-def note_access_protected_restricted : Note<
-  "object type %select{|%1 }0must derive from context type %2">;
+def note_access_protected_restricted_noobject : Note<
+  "must name member using the type of the current context %0">;
+def note_access_protected_restricted_ctordtor : Note<
+  "protected %select{constructor|destructor}0 can only be used to "
+  "%select{construct|destroy}0 a base class subobject">;
+def note_access_protected_restricted_object : Note<
+  "can only access this member on an object of type %0">;
 def warn_cxx98_compat_sfinae_access_control : Warning<
   "substitution failure due to access control is incompatible with C++98">,
   InGroup<CXX98Compat>, DefaultIgnore, NoSFINAE;
@@ -1368,9 +1383,9 @@
   "%select{function|constructor}1">;
 def err_constexpr_var_declaration : Error<
   "variables cannot be declared in a constexpr %select{function|constructor}0">;
-def err_constexpr_function_never_constant_expr : Error<
-  "constexpr %select{function|constructor}0 never produces "
-  "a constant expression">;
+def err_constexpr_function_never_constant_expr : ExtWarn<
+  "constexpr %select{function|constructor}0 never produces a "
+  "constant expression">, InGroup<DiagGroup<"invalid-constexpr">>, DefaultError;
 def err_constexpr_body_no_return : Error<
   "no return statement in constexpr function">;
 def err_constexpr_body_multiple_return : Error<
@@ -1532,6 +1547,9 @@
   "using %0 with a literal is redundant">, InGroup<ObjCRedundantLiteralUse>;
 }
 
+def warn_bool_for_boolean_literal : Warning<
+  "BOOL of type %0 is non-intergal and unsuitable for a "
+  "boolean literal - ignored">, InGroup<DiagGroup<"numeric-literals">>;
 def err_only_annotate_after_access_spec : Error<
   "access specifier can only have annotation attributes">;
 def err_attribute_section_invalid_for_target : Error<
@@ -1640,12 +1658,18 @@
   "%plural{0:no parameters to index into|"
   "1:can only be 1, since there is one parameter|"
   ":must be between 1 and %2}2">;
-def err_attribute_argument_not_lockable : Error<
+def warn_attribute_argument_not_lockable : Warning<
   "%0 attribute requires arguments whose type is annotated "
-  "with 'lockable' attribute">;
-def err_attribute_decl_not_lockable : Error<
+  "with 'lockable' attribute; type here is '%1'">,
+  InGroup<ThreadSafety>, DefaultIgnore;
+def warn_attribute_decl_not_lockable : Warning<
   "%0 attribute can only be applied in a context annotated "
-  "with 'lockable' attribute">;
+  "with 'lockable' attribute">,
+  InGroup<ThreadSafety>, DefaultIgnore;
+def warn_attribute_argument_not_class : Warning<
+  "%0 attribute requires arguments that are class type or point to"
+  " class type; type here is '%1'">,
+  InGroup<ThreadSafety>, DefaultIgnore;   
 def warn_unlock_but_no_lock : Warning<
   "unlocking '%0' that was not locked">,
   InGroup<ThreadSafety>, DefaultIgnore;
@@ -1729,7 +1753,7 @@
 def warn_impcast_literal_float_to_integer : Warning<
   "implicit conversion turns literal floating-point number into integer: "
   "%0 to %1">,
-  InGroup<LiteralConversion>, DefaultIgnore;
+  InGroup<LiteralConversion>;
 def warn_impcast_string_literal_to_bool : Warning<
   "implicit conversion turns string literal into bool: %0 to %1">,
   InGroup<StringConversion>, DefaultIgnore;
@@ -2323,6 +2347,13 @@
 def err_template_arg_not_ice : Error<
   "non-type template argument of type %0 is not an integral constant "
   "expression">;
+def err_template_arg_not_address_constant : Error<
+  "non-type template argument of type %0 is not a constant expression">;
+def err_template_arg_untyped_null_constant : Error<
+  "null non-type template argument must be cast to template parameter type %0">;
+def err_template_arg_wrongtype_null_constant : Error<
+ "null non-type template argument of type %0 does not match template parameter "
+ "of type %1">;
 def err_deduced_non_type_template_arg_type_mismatch : Error<
   "deduced non-type template argument does not have the same type as the "
   "its corresponding template parameter (%0 vs %1)">;
@@ -2358,14 +2389,22 @@
   "non-type template argument refers to non-static data member %0">;
 def err_template_arg_method : Error<
   "non-type template argument refers to non-static member function %0">;
-def err_template_arg_function_not_extern : Error<
-  "non-template argument refers to function %0 with internal linkage">;
-def err_template_arg_object_not_extern : Error<
-  "non-template argument refers to object %0 that does not have external "
-  "linkage">;
+def err_template_arg_object_no_linkage : Error<
+  "non-type template argument refers to %select{function|object}0 %1 that "
+  "does not have linkage">;
+def warn_cxx98_compat_template_arg_object_internal : Warning<
+  "non-type template argument referring to %select{function|object}0 %1 with "
+  "internal linkage is incompatible with C++98">,
+  InGroup<CXX98Compat>, DefaultIgnore;
+def ext_template_arg_object_internal : ExtWarn<
+  "non-type template argument referring to %select{function|object}0 %1 with "
+  "internal linkage is a C++11 extension">, InGroup<CXX11>;
+def err_template_arg_thread_local : Error<
+  "non-type template argument refers to thread-local object">;
 def note_template_arg_internal_object : Note<
-  "non-template argument refers to %select{function|object}0 here">;
-def note_template_arg_refers_here : Note<"non-template argument refers here">;
+  "non-type template argument refers to %select{function|object}0 here">;
+def note_template_arg_refers_here : Note<
+  "non-type template argument refers here">;
 def err_template_arg_not_object_or_func : Error<
   "non-type template argument does not refer to an object or function">;
 def err_template_arg_not_pointer_to_member_form : Error<
@@ -3758,7 +3797,7 @@
   InGroup<DiagGroup<"null-arithmetic">>;
 
 def err_invalid_this_use : Error<
-  "invalid use of 'this' outside of a nonstatic member function">;
+  "invalid use of 'this' outside of a non-static member function">;
 def err_invalid_member_use_in_static_method : Error<
   "invalid use of member %0 in static member function">;
 def err_invalid_qualified_function_type : Error<
@@ -3774,7 +3813,10 @@
   "without a ref-qualifier|with ref-qualifier '&'|with ref-qualifier '&&'}1">;
 
 def err_invalid_non_static_member_use : Error<
-  "invalid use of nonstatic data member %0">;
+  "invalid use of non-static data member %0">;
+def err_nested_non_static_member_use : Error<
+  "%select{call to non-static member function|use of non-static data member}0 "
+  "%2 of %1 from nested type %3">;
 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;
@@ -4254,8 +4296,8 @@
 def err_expected_class_or_namespace : Error<"expected a class or namespace">;
 def err_expected_class : Error<"%0 is not a class%select{ or namespace|, "
   "namespace, or scoped enumeration}1">;
-def err_invalid_declarator_scope : Error<
-  "definition or redeclaration of %0 not in a namespace enclosing %1">;
+def err_invalid_declarator_scope : Error<"cannot define or redeclare %0 here "
+  "because namespace %1 does not enclose namespace %2">;
 def err_invalid_declarator_global_scope : Error<
   "definition or redeclaration of %0 cannot name the global scope">;
 def err_invalid_declarator_in_function : Error<
@@ -4328,22 +4370,22 @@
   "%select{assigning to|passing|returning|converting|initializing|sending|casting}2"
   " %0 "
   "%select{from|to parameter of type|from a function with result type|to type|"
-  "with an expression of type|to parameter of type|to type}2 %1; "
-  "%select{|dereference with *|"
-  "take the address with &|"
-  "remove *|"
-  "remove &}3">,
+  "with an expression of type|to parameter of type|to type}2 %1"
+  "%select{|; dereference with *|"
+  "; take the address with &|"
+  "; remove *|"
+  "; remove &}3">,
   InGroup<IntConversion>;
 def ext_typecheck_convert_int_pointer : ExtWarn<
   "incompatible integer to pointer conversion "
   "%select{assigning to|passing|returning|converting|initializing|sending|casting}2"
   " %0 "
   "%select{from|to parameter of type|from a function with result type|to type|"
-  "with an expression of type|to parameter of type|to type}2 %1; "
-  "%select{|dereference with *|"
-  "take the address with &|"
-  "remove *|"
-  "remove &}3">,
+  "with an expression of type|to parameter of type|to type}2 %1"
+  "%select{|; dereference with *|"
+  "; take the address with &|"
+  "; remove *|"
+  "; remove &}3">,
   InGroup<IntConversion>;
 def ext_typecheck_convert_pointer_void_func : Extension<
   "%select{assigning to|passing|returning|converting|initializing|sending|casting}2"
@@ -4364,10 +4406,10 @@
   " %0 "
   "%select{from|to parameter of type|from a function with result type|to type|"
   "with an expression of type|to parameter of type|to type}2 %1"
-  "%select{|dereference with *|"
-  "take the address with &|"
-  "remove *|"
-  "remove &}3">,
+  "%select{|; dereference with *|"
+  "; take the address with &|"
+  "; remove *|"
+  "; remove &}3">,
   InGroup<IncompatiblePointerTypes>;
 def ext_typecheck_convert_discards_qualifiers : ExtWarn<
   "%select{assigning to|passing|returning|converting|initializing|sending|casting}2"
@@ -4483,12 +4525,15 @@
 def err_atomic_op_needs_atomic : Error<
   "first argument to atomic operation must be a pointer to _Atomic "
   "type (%0 invalid)">;
+def err_atomic_op_needs_trivial_copy : Error<
+  "first argument to atomic operation must be a pointer to a trivially-copyable"
+  " type (%0 invalid)">;
 def err_atomic_op_needs_atomic_int_or_ptr : Error<
-  "first argument to atomic operation must be a pointer to atomic "
-  "integer or pointer (%0 invalid)">;
-def err_atomic_op_logical_needs_atomic_int : Error<
-  "first argument to logical atomic operation must be a pointer to atomic "
-  "integer (%0 invalid)">;
+  "first argument to atomic operation must be a pointer to %select{|atomic }0"
+  "integer or pointer (%1 invalid)">;
+def err_atomic_op_bitwise_needs_atomic_int : Error<
+  "first argument to bitwise atomic operation must be a pointer to "
+  "%select{|atomic }0integer (%1 invalid)">;
 
 def err_deleted_function_use : Error<"attempt to use a deleted function">;
 

Modified: cfe/branches/tooling/include/clang/Basic/LangOptions.def
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/LangOptions.def?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/LangOptions.def (original)
+++ cfe/branches/tooling/include/clang/Basic/LangOptions.def Tue Apr 17 06:08:26 2012
@@ -96,7 +96,8 @@
 LANGOPT(Static            , 1, 0, "__STATIC__ predefined macro (as opposed to __DYNAMIC__)")
 VALUE_LANGOPT(PackStruct  , 32, 0, 
               "default struct packing maximum alignment")
-VALUE_LANGOPT(PICLevel          , 2, 0, "__PIC__ level")
+VALUE_LANGOPT(PICLevel    , 2, 0, "__PIC__ level")
+VALUE_LANGOPT(PIELevel    , 2, 0, "__PIE__ level")
 LANGOPT(GNUInline         , 1, 0, "GNU inline semantics")
 LANGOPT(NoInlineDefine    , 1, 0, "__NO_INLINE__ predefined macro")
 LANGOPT(Deprecated        , 1, 0, "__DEPRECATED predefined macro")

Modified: cfe/branches/tooling/include/clang/Basic/Specifiers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/Specifiers.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/Specifiers.h (original)
+++ cfe/branches/tooling/include/clang/Basic/Specifiers.h Tue Apr 17 06:08:26 2012
@@ -40,6 +40,7 @@
     TST_char16,       // C++0x char16_t
     TST_char32,       // C++0x char32_t
     TST_int,
+    TST_int128,
     TST_half,         // OpenCL half, ARM NEON __fp16
     TST_float,
     TST_double,

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/TokenKinds.def (original)
+++ cfe/branches/tooling/include/clang/Basic/TokenKinds.def Tue Apr 17 06:08:26 2012
@@ -332,6 +332,7 @@
 KEYWORD(__builtin_va_arg            , KEYALL)
 KEYWORD(__extension__               , KEYALL)
 KEYWORD(__imag                      , KEYALL)
+KEYWORD(__int128                    , KEYALL)
 KEYWORD(__label__                   , KEYALL)
 KEYWORD(__real                      , KEYALL)
 KEYWORD(__thread                    , KEYALL)

Modified: cfe/branches/tooling/include/clang/Config/config.h.in
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Config/config.h.in?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Config/config.h.in (original)
+++ cfe/branches/tooling/include/clang/Config/config.h.in Tue Apr 17 06:08:26 2012
@@ -15,4 +15,7 @@
 /* Directories clang will search for headers */
 #undef C_INCLUDE_DIRS
 
+/* Linker version detected at compile time. */
+#undef HOST_LINK_VERSION
+
 #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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/CC1Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/CC1Options.td Tue Apr 17 06:08:26 2012
@@ -428,9 +428,6 @@
   HelpText<"Build ASTs and view them with GraphViz">;
 def print_decl_contexts : Flag<"-print-decl-contexts">,
   HelpText<"Print DeclContexts and their Decls">;
-def pubnames_dump : Flag<"-pubnames-dump">, 
-  HelpText<"Print all of the public (global) names in the source, e.g., the "
-           "names of all global declarations and macros">;
 def emit_module : Flag<"-emit-module">,
   HelpText<"Generate pre-compiled module file from a module map">;
 def emit_pth : Flag<"-emit-pth">,
@@ -632,6 +629,8 @@
   HelpText<"Treat signed integer overflow as two's complement">;
 def pic_level : Separate<"-pic-level">,
   HelpText<"Value for __PIC__">;
+def pie_level : Separate<"-pie-level">,
+  HelpText<"Value for __PIE__">;
 def pthread : Flag<"-pthread">,
   HelpText<"Support POSIX threads in generated code">;
 def fpack_struct : Separate<"-fpack-struct">,

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/Options.td Tue Apr 17 06:08:26 2012
@@ -264,8 +264,9 @@
 def exported__symbols__list : Separate<"-exported_symbols_list">;
 def e : JoinedOrSeparate<"-e">;
 def fPIC : Flag<"-fPIC">, Group<f_Group>;
-def fPIE : Flag<"-fPIE">, Group<f_Group>, Flags<[NoArgumentUnused]>;
-def fno_PIE : Flag<"-fno-PIE">, Group<f_Group>, Flags<[NoArgumentUnused]>;
+def fno_PIC : Flag<"-fno-PIC">, Group<f_Group>;
+def fPIE : Flag<"-fPIE">, Group<f_Group>;
+def fno_PIE : Flag<"-fno-PIE">, Group<f_Group>;
 def faccess_control : Flag<"-faccess-control">, Group<f_Group>;
 def fallow_unsupported : Flag<"-fallow-unsupported">, Group<f_Group>;
 def faltivec : Flag<"-faltivec">, Group<f_Group>;
@@ -431,8 +432,6 @@
 def fno_ms_extensions : Flag<"-fno-ms-extensions">, Group<f_Group>;
 def fno_ms_compatibility : Flag<"-fno-ms-compatibility">, Group<f_Group>;
 def fno_delayed_template_parsing : Flag<"-fno-delayed-template-parsing">, Group<f_Group>;
-def fno_objc_default_synthesize_properties 
-  : Flag<"-fno-objc-default-synthesize-properties">, Group<f_Group>;
 def fno_objc_exceptions: Flag<"-fno-objc-exceptions">, Group<f_Group>;
 def fno_objc_legacy_dispatch : Flag<"-fno-objc-legacy-dispatch">, Group<f_Group>;
 def fno_omit_frame_pointer : Flag<"-fno-omit-frame-pointer">, Group<f_Group>;
@@ -461,8 +460,6 @@
 def fno_objc_arc_exceptions : Flag<"-fno-objc-arc-exceptions">, Group<f_Group>;
 def fobjc_atdefs : Flag<"-fobjc-atdefs">, Group<clang_ignored_f_Group>;
 def fobjc_call_cxx_cdtors : Flag<"-fobjc-call-cxx-cdtors">, Group<clang_ignored_f_Group>;
-def fobjc_default_synthesize_properties : 
-  Flag<"-fobjc-default-synthesize-properties">, Group<f_Group>;
 def fobjc_exceptions: Flag<"-fobjc-exceptions">, Group<f_Group>;
 
 def fobjc_gc_only : Flag<"-fobjc-gc-only">, Group<f_Group>;
@@ -497,8 +494,9 @@
 def fpascal_strings : Flag<"-fpascal-strings">, Group<f_Group>;
 def fpch_preprocess : Flag<"-fpch-preprocess">, Group<f_Group>;
 def fpic : Flag<"-fpic">, Group<f_Group>;
-def fpie : Flag<"-fpie">, Group<f_Group>, Flags<[NoArgumentUnused]>;
-def fno_pie : Flag<"-fno-pie">, Group<f_Group>, Flags<[NoArgumentUnused]>;
+def fno_pic : Flag<"-fno-pic">, Group<f_Group>;
+def fpie : Flag<"-fpie">, Group<f_Group>;
+def fno_pie : Flag<"-fno-pie">, Group<f_Group>;
 def fprofile_arcs : Flag<"-fprofile-arcs">, Group<f_Group>;
 def fprofile_generate : Flag<"-fprofile-generate">, Group<f_Group>;
 def framework : Separate<"-framework">, Flags<[LinkerInput]>;
@@ -603,9 +601,10 @@
 def mcmodel_EQ : Joined<"-mcmodel=">, Group<m_Group>;
 def mconstant_cfstrings : Flag<"-mconstant-cfstrings">, Group<clang_ignored_m_Group>;
 def mcpu_EQ : Joined<"-mcpu=">, Group<m_Group>;
-def mdynamic_no_pic : Joined<"-mdynamic-no-pic">, Group<m_Group>, Flags<[NoArgumentUnused]>;
+def mdynamic_no_pic : Joined<"-mdynamic-no-pic">, Group<m_Group>;
 def mfix_and_continue : Flag<"-mfix-and-continue">, Group<clang_ignored_m_Group>;
 def mfloat_abi_EQ : Joined<"-mfloat-abi=">, Group<m_Group>;
+def mfpmath_EQ : Joined<"-mfpmath=">, Group<m_Group>;
 def mfpu_EQ : Joined<"-mfpu=">, Group<m_Group>;
 def mglobal_merge : Flag<"-mglobal-merge">, Group<m_Group>;
 def mhard_float : Flag<"-mhard-float">, Group<m_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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/ASTUnit.h Tue Apr 17 06:08:26 2012
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H
 #define LLVM_CLANG_FRONTEND_ASTUNIT_H
 
-#include "clang/Index/ASTLocation.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
@@ -46,6 +45,7 @@
 class ASTReader;
 class CodeCompleteConsumer;
 class CompilerInvocation;
+class CompilerInstance;
 class Decl;
 class DiagnosticsEngine;
 class FileEntry;
@@ -56,16 +56,6 @@
 class TargetInfo;
 class ASTFrontendAction;
 
-using namespace idx;
-  
-/// \brief Allocator for a cached set of global code completions.
-class GlobalCodeCompletionAllocator 
-  : public CodeCompletionAllocator,
-    public RefCountedBase<GlobalCodeCompletionAllocator>
-{
-
-};
-  
 /// \brief Utility class for loading a ASTContext from an AST file.
 ///
 class ASTUnit : public ModuleLoader {
@@ -141,9 +131,6 @@
   /// The name of the original source file used to generate this ASTUnit.
   std::string OriginalSourceFile;
 
-  // Critical optimization when using clang_getCursor().
-  ASTLocation LastLoc;
-
   /// \brief The set of diagnostics produced when creating the preamble.
   SmallVector<StoredDiagnostic, 4> PreambleDiagnostics;
 
@@ -151,6 +138,10 @@
   /// translation unit.
   SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
 
+  /// \brief The set of diagnostics produced when failing to parse, e.g. due
+  /// to failure to load the PCH.
+  SmallVector<StoredDiagnostic, 4> FailedParseDiagnostics;
+
   /// \brief The number of stored diagnostics that come from the driver
   /// itself.
   ///
@@ -324,25 +315,20 @@
   getCachedCompletionAllocator() {
     return CachedCompletionAllocator;
   }
-  
-  /// \brief Retrieve the allocator used to cache global code completions.
-  /// Creates the allocator if it doesn't already exist.
-  IntrusiveRefCntPtr<GlobalCodeCompletionAllocator>
-  getCursorCompletionAllocator() {
-    if (!CursorCompletionAllocator.getPtr()) {
-      CursorCompletionAllocator = new GlobalCodeCompletionAllocator;
-    }
-    return CursorCompletionAllocator;
+
+  CodeCompletionTUInfo &getCodeCompletionTUInfo() {
+    if (!CCTUInfo)
+      CCTUInfo.reset(new CodeCompletionTUInfo(
+                                            new GlobalCodeCompletionAllocator));
+    return *CCTUInfo;
   }
-  
+
 private:
   /// \brief Allocator used to store cached code completions.
   IntrusiveRefCntPtr<GlobalCodeCompletionAllocator>
     CachedCompletionAllocator;
   
-  /// \brief Allocator used to store code completions for arbitrary cursors.
-  IntrusiveRefCntPtr<GlobalCodeCompletionAllocator>
-    CursorCompletionAllocator;
+  OwningPtr<CodeCompletionTUInfo> CCTUInfo;
 
   /// \brief The set of cached code-completion results.
   std::vector<CachedCodeCompletionResult> CachedCompletionResults;
@@ -397,7 +383,11 @@
                                                      bool AllowRebuild = true,
                                                         unsigned MaxLines = 0);
   void RealizeTopLevelDeclsFromPreamble();
-  
+
+  /// \brief Transfers ownership of the objects (like SourceManager) from
+  /// \param CI to this ASTUnit.
+  void transferASTDataFromCompilerInstance(CompilerInstance &CI);
+
   /// \brief Allows us to assert that ASTUnit is not being used concurrently,
   /// which is not supported.
   ///
@@ -478,10 +468,6 @@
   bool getOwnsRemappedFileBuffers() const { return OwnsRemappedFileBuffers; }
   void setOwnsRemappedFileBuffers(bool val) { OwnsRemappedFileBuffers = val; }
 
-  void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; }
-  ASTLocation getLastASTLocation() const { return LastLoc; }
-
-
   StringRef getMainFileName() const;
 
   typedef std::vector<Decl *>::iterator top_level_iterator;
@@ -676,6 +662,13 @@
   /// \param Persistent - if true the returned ASTUnit will be complete.
   /// false means the caller is only interested in getting info through the
   /// provided \see Action.
+  ///
+  /// \param ErrAST - If non-null and parsing failed without any AST to return
+  /// (e.g. because the PCH could not be loaded), this accepts the ASTUnit
+  /// mainly to allow the caller to see the diagnostics.
+  /// This will only receive an ASTUnit if a new one was created. If an already
+  /// created ASTUnit was passed in \param Unit then the caller can check that.
+  ///
   static ASTUnit *LoadFromCompilerInvocationAction(CompilerInvocation *CI,
                               IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
                                              ASTFrontendAction *Action = 0,
@@ -685,7 +678,8 @@
                                              bool OnlyLocalDecls = false,
                                              bool CaptureDiagnostics = false,
                                              bool PrecompilePreamble = false,
-                                       bool CacheCodeCompletionResults = false);
+                                       bool CacheCodeCompletionResults = false,
+                                       OwningPtr<ASTUnit> *ErrAST = 0);
 
   /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a
   /// CompilerInvocation object.
@@ -717,7 +711,11 @@
   /// lifetime is expected to extend past that of the returned ASTUnit.
   ///
   /// \param ResourceFilesPath - The path to the compiler resource files.
-  //
+  ///
+  /// \param ErrAST - If non-null and parsing failed without any AST to return
+  /// (e.g. because the PCH could not be loaded), this accepts the ASTUnit
+  /// mainly to allow the caller to see the diagnostics.
+  ///
   // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
   // shouldn't need to specify them at construction time.
   static ASTUnit *LoadFromCommandLine(const char **ArgBegin,
@@ -732,7 +730,9 @@
                                       bool PrecompilePreamble = false,
                                       TranslationUnitKind TUKind = TU_Complete,
                                       bool CacheCodeCompletionResults = false,
-                                      bool AllowPCHWithCompilerErrors = false);
+                                      bool AllowPCHWithCompilerErrors = false,
+                                      bool SkipFunctionBodies = false,
+                                      OwningPtr<ASTUnit> *ErrAST = 0);
   
   /// \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/FrontendActions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/FrontendActions.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/FrontendActions.h Tue Apr 17 06:08:26 2012
@@ -173,15 +173,6 @@
   virtual bool usesPreprocessorOnly() const { return true; }
 };
   
-class PubnamesDumpAction : public ASTFrontendAction {
-protected:
-  virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
-                                         StringRef InFile);
-  
-public:
-  virtual bool hasCodeCompletionSupport() const { return false; }
-};
-
 //===----------------------------------------------------------------------===//
 // Preprocessor Actions
 //===----------------------------------------------------------------------===//

Modified: cfe/branches/tooling/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/FrontendOptions.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/FrontendOptions.h Tue Apr 17 06:08:26 2012
@@ -42,7 +42,6 @@
     PrintDeclContext,       ///< Print DeclContext and their Decls.
     PrintPreamble,          ///< Print the "preamble" of the input file
     PrintPreprocessedInput, ///< -E mode.
-    PubnamesDump,           ///< Print all of the "public" names in the source.
     RewriteMacros,          ///< Expand macros but not #includes.
     RewriteObjC,            ///< ObjC->C Rewriter.
     RewriteTest,            ///< Rewriter playground
@@ -112,6 +111,10 @@
   unsigned FixToTemporaries : 1;           ///< Apply fixes to temporary files.
   unsigned ARCMTMigrateEmitARCErrors : 1;  /// Emit ARC errors even if the
                                            /// migrator can fix them
+  unsigned SkipFunctionBodies : 1;         ///< Skip over function bodies to
+                                           /// speed up parsing in cases you do
+                                           /// not need them (e.g. with code
+                                           /// completion).
 
   enum {
     ARCMT_None,
@@ -188,6 +191,7 @@
     ShowVersion = 0;
     ARCMTAction = ARCMT_None;
     ARCMTMigrateEmitARCErrors = 0;
+    SkipFunctionBodies = 0;
     ObjCMTAction = ObjCMT_None;
   }
 

Modified: cfe/branches/tooling/include/clang/Lex/DirectoryLookup.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/DirectoryLookup.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/DirectoryLookup.h (original)
+++ cfe/branches/tooling/include/clang/Lex/DirectoryLookup.h Tue Apr 17 06:08:26 2012
@@ -145,17 +145,23 @@
   /// \param SuggestedModule If non-null, and the file found is semantically
   /// part of a known module, this will be set to the module that should
   /// be imported instead of preprocessing/parsing the file found.
+  ///
+  /// \param InUserSpecifiedSystemHeader [out] If the file is found, set to true
+  /// if the file is located in a framework that has been user-specified to be
+  /// treated as a system framework.
   const FileEntry *LookupFile(StringRef Filename, HeaderSearch &HS,
                               SmallVectorImpl<char> *SearchPath,
                               SmallVectorImpl<char> *RelativePath,
-                              Module **SuggestedModule) const;
+                              Module **SuggestedModule,
+                              bool &InUserSpecifiedSystemHeader) const;
 
 private:
   const FileEntry *DoFrameworkLookup(
       StringRef Filename, HeaderSearch &HS,
       SmallVectorImpl<char> *SearchPath,
       SmallVectorImpl<char> *RelativePath,
-      Module **SuggestedModule) const;
+      Module **SuggestedModule,
+      bool &InUserSpecifiedSystemHeader) const;
 
 };
 

Modified: cfe/branches/tooling/include/clang/Lex/HeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/HeaderSearch.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/branches/tooling/include/clang/Lex/HeaderSearch.h Tue Apr 17 06:08:26 2012
@@ -120,6 +120,17 @@
 /// HeaderSearch - This class encapsulates the information needed to find the
 /// file referenced by a #include or #include_next, (sub-)framework lookup, etc.
 class HeaderSearch {
+  /// This structure is used to record entries in our framework cache.
+  struct FrameworkCacheEntry {
+    /// The directory entry which should be used for the cached framework.
+    const DirectoryEntry *Directory;
+
+    /// Whether this framework has been "user-specified" to be treated as if it
+    /// were a system framework (even if it was found outside a system framework
+    /// directory).
+    bool IsUserSpecifiedSystemFramework;
+  };
+
   FileManager &FileMgr;
   DiagnosticsEngine &Diags;
   /// #include search path information.  Requests for #include "x" search the
@@ -152,8 +163,7 @@
 
   /// FrameworkMap - This is a collection mapping a framework or subframework
   /// name like "Carbon" to the Carbon.framework directory.
-  llvm::StringMap<const DirectoryEntry *, llvm::BumpPtrAllocator>
-    FrameworkMap;
+  llvm::StringMap<FrameworkCacheEntry, llvm::BumpPtrAllocator> FrameworkMap;
 
   /// IncludeAliases - maps include file names (including the quotes or
   /// angle brackets) to other include file names.  This is used to support the
@@ -331,7 +341,7 @@
   /// LookupFrameworkCache - Look up the specified framework name in our
   /// framework cache, returning the DirectoryEntry it is in if we know,
   /// otherwise, return null.
-  const DirectoryEntry *&LookupFrameworkCache(StringRef FWName) {
+  FrameworkCacheEntry &LookupFrameworkCache(StringRef FWName) {
     return FrameworkMap.GetOrCreateValue(FWName).getValue();
   }
 

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/Preprocessor.h (original)
+++ cfe/branches/tooling/include/clang/Lex/Preprocessor.h Tue Apr 17 06:08:26 2012
@@ -124,6 +124,9 @@
   /// \brief Whether we have already loaded macros from the external source.
   mutable bool ReadMacrosFromExternalSource : 1;
 
+  /// \brief True if we are pre-expanding macro arguments.
+  bool InMacroArgPreExpansion;
+
   /// Identifiers - This is mapping/lookup information for all identifiers in
   /// the program, including program keywords.
   mutable IdentifierTable Identifiers;

Modified: cfe/branches/tooling/include/clang/Parse/ParseAST.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Parse/ParseAST.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Parse/ParseAST.h (original)
+++ cfe/branches/tooling/include/clang/Parse/ParseAST.h Tue Apr 17 06:08:26 2012
@@ -36,11 +36,13 @@
   void ParseAST(Preprocessor &pp, ASTConsumer *C,
                 ASTContext &Ctx, bool PrintStats = false,
                 TranslationUnitKind TUKind = TU_Complete,
-                CodeCompleteConsumer *CompletionConsumer = 0);
+                CodeCompleteConsumer *CompletionConsumer = 0,
+                bool SkipFunctionBodies = false);
 
   /// \brief Parse the main file known to the preprocessor, producing an 
   /// abstract syntax tree.
-  void ParseAST(Sema &S, bool PrintStats = false);
+  void ParseAST(Sema &S, bool PrintStats = false,
+                bool SkipFunctionBodies = false);
   
 }  // end namespace clang
 

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Parse/Parser.h (original)
+++ cfe/branches/tooling/include/clang/Parse/Parser.h Tue Apr 17 06:08:26 2012
@@ -198,8 +198,10 @@
 
   IdentifierInfo *getSEHExceptKeyword();
 
+  bool SkipFunctionBodies;
+
 public:
-  Parser(Preprocessor &PP, Sema &Actions);
+  Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies);
   ~Parser();
 
   const LangOptions &getLangOpts() const { return PP.getLangOpts(); }
@@ -725,16 +727,26 @@
   /// returns false.
   bool SkipUntil(tok::TokenKind T, bool StopAtSemi = true,
                  bool DontConsume = false, bool StopAtCodeCompletion = false) {
-    return SkipUntil(&T, 1, StopAtSemi, DontConsume, StopAtCodeCompletion);
+    return SkipUntil(llvm::makeArrayRef(T), StopAtSemi, DontConsume,
+                     StopAtCodeCompletion);
   }
   bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, bool StopAtSemi = true,
                  bool DontConsume = false, bool StopAtCodeCompletion = false) {
     tok::TokenKind TokArray[] = {T1, T2};
-    return SkipUntil(TokArray, 2, StopAtSemi, DontConsume,StopAtCodeCompletion);
+    return SkipUntil(TokArray, StopAtSemi, DontConsume,StopAtCodeCompletion);
   }
-  bool SkipUntil(const tok::TokenKind *Toks, unsigned NumToks,
+  bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3,
                  bool StopAtSemi = true, bool DontConsume = false,
-                 bool StopAtCodeCompletion = false);
+                 bool StopAtCodeCompletion = false) {
+    tok::TokenKind TokArray[] = {T1, T2, T3};
+    return SkipUntil(TokArray, StopAtSemi, DontConsume,StopAtCodeCompletion);
+  }
+  bool SkipUntil(ArrayRef<tok::TokenKind> Toks, bool StopAtSemi = true,
+                 bool DontConsume = false, bool StopAtCodeCompletion = false);
+
+  /// SkipMalformedDecl - Read tokens until we get to some likely good stopping
+  /// point for skipping past a simple-declaration.
+  void SkipMalformedDecl();
 
   //===--------------------------------------------------------------------===//
   // Lexing and parsing of C++ inline methods.
@@ -1661,7 +1673,7 @@
   /// unless the body contains the code-completion point.
   ///
   /// \returns true if the function body was skipped.
-  bool trySkippingFunctionBodyForCodeCompletion();
+  bool trySkippingFunctionBody();
 
   bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
                         const ParsedTemplateInfo &TemplateInfo,
@@ -1858,6 +1870,16 @@
                            Decl **OwnedType = 0);
   void ParseBlockId();
 
+  // Check for the start of a C++11 attribute-specifier-seq in a context where
+  // an attribute is not allowed.
+  bool CheckProhibitedCXX11Attribute() {
+    assert(Tok.is(tok::l_square));
+    if (!getLangOpts().CPlusPlus0x || NextToken().isNot(tok::l_square))
+      return false;
+    return DiagnoseProhibitedCXX11Attribute();
+  }
+  bool DiagnoseProhibitedCXX11Attribute();
+
   void ProhibitAttributes(ParsedAttributesWithRange &attrs) {
     if (!attrs.Range.isValid()) return;
     DiagnoseProhibitedAttributes(attrs);
@@ -1888,31 +1910,34 @@
                              SourceLocation *EndLoc);
 
   void MaybeParseCXX0XAttributes(Declarator &D) {
-    if (getLangOpts().CPlusPlus0x && isCXX0XAttributeSpecifier()) {
+    if (getLangOpts().CPlusPlus0x && isCXX11AttributeSpecifier()) {
       ParsedAttributesWithRange attrs(AttrFactory);
       SourceLocation endLoc;
-      ParseCXX0XAttributes(attrs, &endLoc);
+      ParseCXX11Attributes(attrs, &endLoc);
       D.takeAttributes(attrs, endLoc);
     }
   }
   void MaybeParseCXX0XAttributes(ParsedAttributes &attrs,
                                  SourceLocation *endLoc = 0) {
-    if (getLangOpts().CPlusPlus0x && isCXX0XAttributeSpecifier()) {
+    if (getLangOpts().CPlusPlus0x && isCXX11AttributeSpecifier()) {
       ParsedAttributesWithRange attrsWithRange(AttrFactory);
-      ParseCXX0XAttributes(attrsWithRange, endLoc);
+      ParseCXX11Attributes(attrsWithRange, endLoc);
       attrs.takeAllFrom(attrsWithRange);
     }
   }
   void MaybeParseCXX0XAttributes(ParsedAttributesWithRange &attrs,
-                                 SourceLocation *endLoc = 0) {
-    if (getLangOpts().CPlusPlus0x && isCXX0XAttributeSpecifier())
-      ParseCXX0XAttributes(attrs, endLoc);
+                                 SourceLocation *endLoc = 0,
+                                 bool OuterMightBeMessageSend = false) {
+    if (getLangOpts().CPlusPlus0x &&
+        isCXX11AttributeSpecifier(false, OuterMightBeMessageSend))
+      ParseCXX11Attributes(attrs, endLoc);
   }
 
-  void ParseCXX0XAttributeSpecifier(ParsedAttributes &attrs,
+  void ParseCXX11AttributeSpecifier(ParsedAttributes &attrs,
                                     SourceLocation *EndLoc = 0);
-  void ParseCXX0XAttributes(ParsedAttributesWithRange &attrs,
+  void ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
                             SourceLocation *EndLoc = 0);
+  IdentifierInfo *TryParseCXX11AttributeIdentifier(SourceLocation &Loc);
 
   void MaybeParseMicrosoftAttributes(ParsedAttributes &attrs,
                                      SourceLocation *endLoc = 0) {
@@ -2023,8 +2048,19 @@
   //===--------------------------------------------------------------------===//
   // C++ 7: Declarations [dcl.dcl]
 
-  bool isCXX0XAttributeSpecifier(bool FullLookahead = false,
-                                 tok::TokenKind *After = 0);
+  /// The kind of attribute specifier we have found.
+  enum CXX11AttributeKind {
+    /// This is not an attribute specifier.
+    CAK_NotAttributeSpecifier,
+    /// This should be treated as an attribute-specifier.
+    CAK_AttributeSpecifier,
+    /// The next tokens are '[[', but this is not an attribute-specifier. This
+    /// is ill-formed by C++11 [dcl.attr.grammar]p6.
+    CAK_InvalidAttributeSpecifier
+  };
+  CXX11AttributeKind
+  isCXX11AttributeSpecifier(bool Disambiguate = false,
+                            bool OuterMightBeMessageSend = false);
 
   Decl *ParseNamespace(unsigned Context, SourceLocation &DeclEnd,
                        SourceLocation InlineLoc = SourceLocation());

Modified: cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h Tue Apr 17 06:08:26 2012
@@ -501,8 +501,6 @@
 
 /// \brief An allocator used specifically for the purpose of code completion.
 class CodeCompletionAllocator : public llvm::BumpPtrAllocator {
-  llvm::DenseMap<DeclContext *, StringRef> ParentNames;
-  
 public:
   /// \brief Copy the given string into this allocator.
   const char *CopyString(StringRef String);
@@ -519,12 +517,34 @@
   const char *CopyString(const std::string &String) {
     return CopyString(StringRef(String));
   }
-  
-  /// \brief Retrieve the mapping from known parent declaration contexts to
-  /// the (already copied) strings associated with each context.
-  llvm::DenseMap<DeclContext *, StringRef> &getParentNames() {
-    return ParentNames;
+};
+
+/// \brief Allocator for a cached set of global code completions.
+class GlobalCodeCompletionAllocator 
+  : public CodeCompletionAllocator,
+    public RefCountedBase<GlobalCodeCompletionAllocator>
+{
+
+};
+
+class CodeCompletionTUInfo {
+  llvm::DenseMap<DeclContext *, StringRef> ParentNames;
+  IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> AllocatorRef;
+
+public:
+  explicit CodeCompletionTUInfo(
+                    IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> Allocator)
+    : AllocatorRef(Allocator) { }
+
+  IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> getAllocatorRef() const {
+    return AllocatorRef;
+  }
+  CodeCompletionAllocator &getAllocator() const {
+    assert(AllocatorRef);
+    return *AllocatorRef;
   }
+
+  StringRef getParentName(DeclContext *DC);
 };
 
 } // end namespace clang
@@ -544,6 +564,7 @@
 
 private:
   CodeCompletionAllocator &Allocator;
+  CodeCompletionTUInfo &CCTUInfo;
   unsigned Priority;
   CXAvailabilityKind Availability;
   CXCursorKind ParentKind;
@@ -555,19 +576,25 @@
   SmallVector<const char *, 2> Annotations;
 
 public:
-  CodeCompletionBuilder(CodeCompletionAllocator &Allocator)
-    : Allocator(Allocator), Priority(0), Availability(CXAvailability_Available),
+  CodeCompletionBuilder(CodeCompletionAllocator &Allocator,
+                        CodeCompletionTUInfo &CCTUInfo)
+    : Allocator(Allocator), CCTUInfo(CCTUInfo),
+      Priority(0), Availability(CXAvailability_Available),
       ParentKind(CXCursor_NotImplemented) { }
 
   CodeCompletionBuilder(CodeCompletionAllocator &Allocator,
+                        CodeCompletionTUInfo &CCTUInfo,
                         unsigned Priority, CXAvailabilityKind Availability)
-    : Allocator(Allocator), Priority(Priority), Availability(Availability),
+    : Allocator(Allocator), CCTUInfo(CCTUInfo),
+      Priority(Priority), Availability(Availability),
       ParentKind(CXCursor_NotImplemented) { }
 
   /// \brief Retrieve the allocator into which the code completion
   /// strings should be allocated.
   CodeCompletionAllocator &getAllocator() const { return Allocator; }
 
+  CodeCompletionTUInfo &getCodeCompletionTUInfo() const { return CCTUInfo; }
+
   /// \brief Take the resulting completion string.
   ///
   /// This operation can only be performed once.
@@ -753,10 +780,12 @@
   /// \param Allocator The allocator that will be used to allocate the
   /// string itself.
   CodeCompletionString *CreateCodeCompletionString(Sema &S,
-                                           CodeCompletionAllocator &Allocator);
+                                           CodeCompletionAllocator &Allocator,
+                                           CodeCompletionTUInfo &CCTUInfo);
   CodeCompletionString *CreateCodeCompletionString(ASTContext &Ctx,
                                                    Preprocessor &PP,
-                                           CodeCompletionAllocator &Allocator);
+                                           CodeCompletionAllocator &Allocator,
+                                           CodeCompletionTUInfo &CCTUInfo);
 
   /// \brief Determine a base priority for the given declaration.
   static unsigned getPriorityFromDecl(NamedDecl *ND);
@@ -868,7 +897,8 @@
     /// signature of this overload candidate.
     CodeCompletionString *CreateSignatureString(unsigned CurrentArg,
                                                 Sema &S,
-                                      CodeCompletionAllocator &Allocator) const;
+                                      CodeCompletionAllocator &Allocator,
+                                      CodeCompletionTUInfo &CCTUInfo) const;
   };
 
   CodeCompleteConsumer() : IncludeMacros(false), IncludeCodePatterns(false),
@@ -918,6 +948,8 @@
   /// \brief Retrieve the allocator that will be used to allocate
   /// code completion strings.
   virtual CodeCompletionAllocator &getAllocator() = 0;
+
+  virtual CodeCompletionTUInfo &getCodeCompletionTUInfo() = 0;
 };
 
 /// \brief A simple code-completion consumer that prints the results it
@@ -926,7 +958,7 @@
   /// \brief The raw output stream.
   raw_ostream &OS;
 
-  CodeCompletionAllocator Allocator;
+  CodeCompletionTUInfo CCTUInfo;
 
 public:
   /// \brief Create a new printing code-completion consumer that prints its
@@ -935,7 +967,8 @@
                                bool IncludeGlobals,
                                raw_ostream &OS)
     : CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, IncludeGlobals,
-                           false), OS(OS) {}
+                           false), OS(OS),
+      CCTUInfo(new GlobalCodeCompletionAllocator) {}
 
   /// \brief Prints the finalized code-completion results.
   virtual void ProcessCodeCompleteResults(Sema &S,
@@ -947,7 +980,11 @@
                                          OverloadCandidate *Candidates,
                                          unsigned NumCandidates);
 
-  virtual CodeCompletionAllocator &getAllocator() { return Allocator; }
+  virtual CodeCompletionAllocator &getAllocator() {
+    return CCTUInfo.getAllocator();
+  }
+
+  virtual CodeCompletionTUInfo &getCodeCompletionTUInfo() { return CCTUInfo; }
 };
 
 } // end namespace clang

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/DeclSpec.h (original)
+++ cfe/branches/tooling/include/clang/Sema/DeclSpec.h Tue Apr 17 06:08:26 2012
@@ -245,6 +245,7 @@
   static const TST TST_char16 = clang::TST_char16;
   static const TST TST_char32 = clang::TST_char32;
   static const TST TST_int = clang::TST_int;
+  static const TST TST_int128 = clang::TST_int128;
   static const TST TST_half = clang::TST_half;
   static const TST TST_float = clang::TST_float;
   static const TST TST_double = clang::TST_double;

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Initialization.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Initialization.h Tue Apr 17 06:08:26 2012
@@ -340,7 +340,7 @@
   /// element, sets the element index.
   void setElementIndex(unsigned Index) {
     assert(getKind() == EK_ArrayElement || getKind() == EK_VectorElement ||
-           EK_ComplexElement);
+           getKind() == EK_ComplexElement);
     this->Index = Index;
   }
 
@@ -734,6 +734,9 @@
   /// \brief The candidate set created when initialization failed.
   OverloadCandidateSet FailedCandidateSet;
 
+  /// \brief The incomplete type that caused a failure.
+  QualType FailedIncompleteType;
+  
   /// \brief Prints a follow-up note that highlights the location of
   /// the initialized entity, if it's remote.
   void PrintInitLocationNote(Sema &S, const InitializedEntity &Entity);
@@ -949,6 +952,8 @@
   void SetFailed(FailureKind Failure) {
     SequenceKind = FailedSequence;
     this->Failure = Failure;
+    assert((Failure != FK_Incomplete || !FailedIncompleteType.isNull()) &&
+           "Incomplete type failure requires a type!");
   }
   
   /// \brief Note that this initialization sequence failed due to failed
@@ -967,6 +972,13 @@
     return FailedOverloadResult;
   }
 
+  /// \brief Note that this initialization sequence failed due to an
+  /// incomplete type.
+  void setIncompleteTypeFailure(QualType IncompleteType) {
+    FailedIncompleteType = IncompleteType;
+    SetFailed(FK_Incomplete);
+  }
+
   /// \brief Determine why initialization failed.
   FailureKind getFailureKind() const {
     assert(Failed() && "Not an initialization failure!");

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Sema.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Sema.h Tue Apr 17 06:08:26 2012
@@ -78,6 +78,7 @@
   class ClassTemplateSpecializationDecl;
   class CodeCompleteConsumer;
   class CodeCompletionAllocator;
+  class CodeCompletionTUInfo;
   class CodeCompletionResult;
   class Decl;
   class DeclAccessPair;
@@ -1378,7 +1379,7 @@
 
   /// Push the parameters of D, which must be a function, into scope.
   void ActOnReenterFunctionContext(Scope* S, Decl* D);
-  void ActOnExitFunctionContext() { PopDeclContext(); }
+  void ActOnExitFunctionContext();
 
   DeclContext *getFunctionLevelDeclContext();
 
@@ -2802,8 +2803,10 @@
   ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
                             LabelDecl *TheDecl);
 
+  void ActOnStartStmtExpr();
   ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
                            SourceLocation RPLoc); // "({..})"
+  void ActOnStmtExprError();
 
   // __builtin_offsetof(type, identifier(.identifier|[expr])*)
   struct OffsetOfComponent {
@@ -3698,7 +3701,10 @@
                                        SourceRange IntroducerRange,
                                        TypeSourceInfo *MethodType,
                                        SourceLocation EndLoc,
-                                       llvm::ArrayRef<ParmVarDecl *> Params);
+                                       llvm::ArrayRef<ParmVarDecl *> Params,
+                                       llvm::Optional<unsigned> ManglingNumber 
+                                         = llvm::Optional<unsigned>(),
+                                       Decl *ContextDecl = 0);
   
   /// \brief Introduce the scope for a lambda expression.
   sema::LambdaScopeInfo *enterLambdaScope(CXXMethodDecl *CallOperator,
@@ -3731,9 +3737,6 @@
   /// was successfully completed.
   ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body,
                              Scope *CurScope, 
-                             llvm::Optional<unsigned> ManglingNumber 
-                               = llvm::Optional<unsigned>(),
-                             Decl *ContextDecl = 0,
                              bool IsInstantiation = false);
 
   /// \brief Define the "body" of the conversion from a lambda object to a 
@@ -4103,11 +4106,13 @@
                                       bool IsCopyBindingRefToTemp = false);
   AccessResult CheckConstructorAccess(SourceLocation Loc,
                                       CXXConstructorDecl *D,
+                                      const InitializedEntity &Entity,
                                       AccessSpecifier Access,
-                                      PartialDiagnostic PD);
+                                      const PartialDiagnostic &PDiag);
   AccessResult CheckDestructorAccess(SourceLocation Loc,
                                      CXXDestructorDecl *Dtor,
-                                     const PartialDiagnostic &PDiag);
+                                     const PartialDiagnostic &PDiag,
+                                     QualType objectType = QualType());
   AccessResult CheckDirectMemberAccess(SourceLocation Loc,
                                        NamedDecl *D,
                                        const PartialDiagnostic &PDiag);
@@ -4125,6 +4130,9 @@
                                     bool ForceUnprivileged = false);
   void CheckLookupAccess(const LookupResult &R);
   bool IsSimplyAccessible(NamedDecl *decl, DeclContext *Ctx);
+  bool isSpecialMemberAccessibleForDeletion(CXXMethodDecl *decl,
+                                            AccessSpecifier access,
+                                            QualType objectType);
 
   void HandleDependentAccessCheck(const DependentDiagnostic &DD,
                          const MultiLevelTemplateArgumentList &TemplateArgs);
@@ -4477,8 +4485,6 @@
 
   bool CheckTemplateArgument(TemplateTypeParmDecl *Param,
                              TypeSourceInfo *Arg);
-  bool CheckTemplateArgumentPointerToMember(Expr *Arg,
-                                            TemplateArgument &Converted);
   ExprResult CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
                                    QualType InstantiatedParamType, Expr *Arg,
                                    TemplateArgument &Converted,
@@ -6642,6 +6648,7 @@
                                              unsigned Argument);
   void CodeCompleteNaturalLanguage();
   void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator,
+                                   CodeCompletionTUInfo &CCTUInfo,
                   SmallVectorImpl<CodeCompletionResult> &Results);
   //@}
 

Modified: cfe/branches/tooling/include/clang/Sema/TypoCorrection.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/TypoCorrection.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/TypoCorrection.h (original)
+++ cfe/branches/tooling/include/clang/Sema/TypoCorrection.h Tue Apr 17 06:08:26 2012
@@ -205,7 +205,7 @@
       : WantTypeSpecifiers(true), WantExpressionKeywords(true),
         WantCXXNamedCasts(true), WantRemainingKeywords(true),
         WantObjCSuper(false),
-        IsObjCIvarLookup(false), AllowAddedQualifier(true) {}
+        IsObjCIvarLookup(false) {}
 
   virtual ~CorrectionCandidateCallback() {}
 
@@ -239,10 +239,6 @@
   // Temporary hack for the one case where a CorrectTypoContext enum is used
   // when looking up results.
   bool IsObjCIvarLookup;
-  
-  /// \brief Whether to allow this typo correction to add a 
-  /// nested-name-specifier.
-  bool AllowAddedQualifier;
 };
 
 /// @brief Simple template class for restricting typo correction candidates

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Tue Apr 17 06:08:26 2012
@@ -69,6 +69,7 @@
   friend class BugReportEquivClass;
 
   BugType& BT;
+  const Decl *DeclWithIssue;
   std::string ShortDescription;
   std::string Description;
   PathDiagnosticLocation Location;
@@ -103,16 +104,16 @@
 
 public:
   BugReport(BugType& bt, StringRef desc, const ExplodedNode *errornode)
-    : BT(bt), Description(desc), ErrorNode(errornode),
+    : BT(bt), DeclWithIssue(0), Description(desc), ErrorNode(errornode),
       ConfigurationChangeToken(0) {}
 
   BugReport(BugType& bt, StringRef shortDesc, StringRef desc,
             const ExplodedNode *errornode)
-    : BT(bt), ShortDescription(shortDesc), Description(desc),
+    : BT(bt), DeclWithIssue(0), ShortDescription(shortDesc), Description(desc),
       ErrorNode(errornode), ConfigurationChangeToken(0) {}
 
   BugReport(BugType& bt, StringRef desc, PathDiagnosticLocation l)
-    : BT(bt), Description(desc), Location(l), ErrorNode(0),
+    : BT(bt), DeclWithIssue(0), Description(desc), Location(l), ErrorNode(0),
       ConfigurationChangeToken(0) {}
 
   /// \brief Create a BugReport with a custom uniqueing location.
@@ -124,7 +125,8 @@
   /// 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),
+    : BT(bt), DeclWithIssue(0), Description(desc),
+      UniqueingLocation(LocationToUnique),
       ErrorNode(errornode), ConfigurationChangeToken(0) {}
 
   virtual ~BugReport();
@@ -152,6 +154,16 @@
     return ConfigurationChangeToken;
   }
   
+  /// Return the canonical declaration, be it a method or class, where
+  /// this issue semantically occurred.
+  const Decl *getDeclWithIssue() const;
+  
+  /// Specifically set the Decl where an issue occurred.  This isn't necessary
+  /// for BugReports that cover a path as it will be automatically inferred.
+  void setDeclWithIssue(const Decl *declWithIssue) {
+    DeclWithIssue = declWithIssue;
+  }
+  
   /// \brief This allows for addition of meta data to the diagnostic.
   ///
   /// Currently, only the HTMLDiagnosticClient knows how to display it. 
@@ -345,34 +357,22 @@
   /// reports.
   void EmitReport(BugReport *R);
 
-  void EmitBasicReport(StringRef BugName, StringRef BugStr,
-                       PathDiagnosticLocation Loc,
-                       SourceRange* RangeBeg, unsigned NumRanges);
-
-  void EmitBasicReport(StringRef BugName, StringRef BugCategory,
+  void EmitBasicReport(const Decl *DeclWithIssue,
+                       StringRef BugName, StringRef BugCategory,
                        StringRef BugStr, PathDiagnosticLocation Loc,
                        SourceRange* RangeBeg, unsigned NumRanges);
 
-
-  void EmitBasicReport(StringRef BugName, StringRef BugStr,
-                       PathDiagnosticLocation Loc) {
-    EmitBasicReport(BugName, BugStr, Loc, 0, 0);
-  }
-
-  void EmitBasicReport(StringRef BugName, StringRef BugCategory,
+  void EmitBasicReport(const Decl *DeclWithIssue,
+                       StringRef BugName, StringRef BugCategory,
                        StringRef BugStr, PathDiagnosticLocation Loc) {
-    EmitBasicReport(BugName, BugCategory, BugStr, Loc, 0, 0);
-  }
-
-  void EmitBasicReport(StringRef BugName, StringRef BugStr,
-                       PathDiagnosticLocation Loc, SourceRange R) {
-    EmitBasicReport(BugName, BugStr, Loc, &R, 1);
+    EmitBasicReport(DeclWithIssue, BugName, BugCategory, BugStr, Loc, 0, 0);
   }
 
-  void EmitBasicReport(StringRef BugName, StringRef Category,
+  void EmitBasicReport(const Decl *DeclWithIssue,
+                       StringRef BugName, StringRef Category,
                        StringRef BugStr, PathDiagnosticLocation Loc,
                        SourceRange R) {
-    EmitBasicReport(BugName, Category, BugStr, Loc, &R, 1);
+    EmitBasicReport(DeclWithIssue, BugName, Category, BugStr, Loc, &R, 1);
   }
 
   static bool classof(const BugReporter* R) { return true; }

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h Tue Apr 17 06:08:26 2012
@@ -607,12 +607,15 @@
 ///  diagnostic.  It represents an ordered-collection of PathDiagnosticPieces,
 ///  each which represent the pieces of the path.
 class PathDiagnostic : public llvm::FoldingSetNode {
+  const Decl *DeclWithIssue;
   std::string BugType;
   std::string Desc;
   std::string Category;
   std::deque<std::string> OtherDesc;
   PathPieces pathImpl;
   llvm::SmallVector<PathPieces *, 3> pathStack;
+  
+  PathDiagnostic(); // Do not implement.
 public:
   const PathPieces &path;
 
@@ -635,8 +638,10 @@
   void pushActivePath(PathPieces *p) { pathStack.push_back(p); }
   void popActivePath() { if (!pathStack.empty()) pathStack.pop_back(); }
   
-  PathDiagnostic();
-  PathDiagnostic(StringRef bugtype, StringRef desc,
+  //  PathDiagnostic();
+  PathDiagnostic(const Decl *DeclWithIssue,
+                 StringRef bugtype,
+                 StringRef desc,
                  StringRef category);
 
   ~PathDiagnostic();
@@ -644,7 +649,11 @@
   StringRef getDescription() const { return Desc; }
   StringRef getBugType() const { return BugType; }
   StringRef getCategory() const { return Category; }
-  
+
+  /// Return the semantic context where an issue occurred.  If the
+  /// issue occurs along a path, this represents the "central" area
+  /// where the bug manifests.
+  const Decl *getDeclWithIssue() const { return DeclWithIssue; }
 
   typedef std::deque<std::string>::const_iterator meta_iterator;
   meta_iterator meta_begin() const { return OtherDesc.begin(); }

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/CheckerManager.h Tue Apr 17 06:08:26 2012
@@ -229,8 +229,10 @@
   /// \brief Run checkers for load/store of a location.
   void runCheckersForLocation(ExplodedNodeSet &Dst,
                               const ExplodedNodeSet &Src,
-                              SVal location, bool isLoad,
-                              const Stmt *S,
+                              SVal location,
+                              bool isLoad,
+                              const Stmt *NodeEx,
+                              const Stmt *BoundEx,
                               ExprEngine &Eng);
 
   /// \brief Run checkers for binding of a value to a location.
@@ -343,7 +345,8 @@
   typedef CheckerFn<void (const ObjCMessage &, CheckerContext &)>
       CheckObjCMessageFunc;
   
-  typedef CheckerFn<void (const SVal &location, bool isLoad, const Stmt *S,
+  typedef CheckerFn<void (const SVal &location, bool isLoad,
+                          const Stmt *S,
                           CheckerContext &)>
       CheckLocationFunc;
   

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h Tue Apr 17 06:08:26 2012
@@ -22,11 +22,6 @@
 
 namespace clang {
 
-namespace idx { 
-  class Indexer;
-  class TranslationUnit; 
-}
-
 namespace ento {
   class CheckerManager;
 
@@ -46,11 +41,6 @@
 
   CheckerManager *CheckerMgr;
 
-  /// \brief Provide function definitions in other translation units. This is
-  /// NULL if we don't have multiple translation units. AnalysisManager does
-  /// not own the Indexer.
-  idx::Indexer *Idxer;
-
   enum AnalysisScope { ScopeTU, ScopeDecl } AScope;
 
   /// \brief The maximum number of exploded nodes the analyzer will generate.
@@ -99,7 +89,6 @@
                   StoreManagerCreator storemgr,
                   ConstraintManagerCreator constraintmgr, 
                   CheckerManager *checkerMgr,
-                  idx::Indexer *idxer,
                   unsigned maxnodes, unsigned maxvisit,
                   bool vizdot, bool vizubi, AnalysisPurgeMode purge,
                   bool eager, bool trim,
@@ -137,8 +126,6 @@
 
   CheckerManager *getCheckerManager() const { return CheckerMgr; }
 
-  idx::Indexer *getIndexer() const { return Idxer; }
-
   virtual ASTContext &getASTContext() {
     return Ctx;
   }
@@ -186,10 +173,6 @@
 
   bool shouldInlineCall() const { return (IPAMode == Inlining); }
 
-  bool hasIndexer() const { return Idxer != 0; }
-
-  AnalysisDeclContext *getAnalysisDeclContextInAnotherTU(const Decl *D);
-
   CFG *getCFG(Decl const *D) {
     return AnaCtxMgr.getContext(D)->getCFG();
   }

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h Tue Apr 17 06:08:26 2012
@@ -82,7 +82,7 @@
 
   /// The functions which have been analyzed through inlining. This is owned by
   /// AnalysisConsumer. It can be null.
-  SetOfDecls *AnalyzedCallees;
+  SetOfConstDecls *AnalyzedCallees;
 
   /// The information about functions shared by the whole translation unit.
   /// (This data is owned by AnalysisConsumer.)
@@ -109,7 +109,7 @@
 public:
   /// Construct a CoreEngine object to analyze the provided CFG using
   ///  a DFS exploration of the exploded graph.
-  CoreEngine(SubEngine& subengine, SetOfDecls *VisitedCallees,
+  CoreEngine(SubEngine& subengine, SetOfConstDecls *VisitedCallees,
              FunctionSummariesTy *FS)
     : SubEng(subengine), G(new ExplodedGraph()),
       WList(WorkList::makeBFS()),

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Tue Apr 17 06:08:26 2012
@@ -91,7 +91,8 @@
   GRBugReporter BR;
 
 public:
-  ExprEngine(AnalysisManager &mgr, bool gcEnabled, SetOfDecls *VisitedCallees,
+  ExprEngine(AnalysisManager &mgr, bool gcEnabled,
+             SetOfConstDecls *VisitedCallees,
              FunctionSummariesTy *FS);
 
   ~ExprEngine();
@@ -440,8 +441,13 @@
   // be the same as Pred->state, and when 'location' may not be the
   // same as state->getLValue(Ex).
   /// Simulate a read of the result of Ex.
-  void evalLoad(ExplodedNodeSet &Dst, const Expr *Ex, ExplodedNode *Pred,
-                ProgramStateRef St, SVal location, const ProgramPointTag *tag = 0,
+  void evalLoad(ExplodedNodeSet &Dst,
+                const Expr *NodeEx,  /* Eventually will be a CFGStmt */
+                const Expr *BoundExpr,
+                ExplodedNode *Pred,
+                ProgramStateRef St,
+                SVal location,
+                const ProgramPointTag *tag = 0,
                 QualType LoadTy = QualType());
 
   // FIXME: 'tag' should be removed, and a LocationContext should be used
@@ -450,13 +456,21 @@
                  ExplodedNode *Pred, ProgramStateRef St, SVal TargetLV, SVal Val,
                  const ProgramPointTag *tag = 0);
 private:
-  void evalLoadCommon(ExplodedNodeSet &Dst, const Expr *Ex, ExplodedNode *Pred,
-                      ProgramStateRef St, SVal location, const ProgramPointTag *tag,
+  void evalLoadCommon(ExplodedNodeSet &Dst,
+                      const Expr *NodeEx,  /* Eventually will be a CFGStmt */
+                      const Expr *BoundEx,
+                      ExplodedNode *Pred,
+                      ProgramStateRef St,
+                      SVal location,
+                      const ProgramPointTag *tag,
                       QualType LoadTy);
 
   // FIXME: 'tag' should be removed, and a LocationContext should be used
   // instead.
-  void evalLocation(ExplodedNodeSet &Dst, const Stmt *S, ExplodedNode *Pred,
+  void evalLocation(ExplodedNodeSet &Dst,
+                    const Stmt *NodeEx, /* This will eventually be a CFGStmt */
+                    const Stmt *BoundEx,
+                    ExplodedNode *Pred,
                     ProgramStateRef St, SVal location,
                     const ProgramPointTag *tag, bool isLoad);
 

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h Tue Apr 17 06:08:26 2012
@@ -21,7 +21,8 @@
 
 namespace clang {
 namespace ento {
-typedef llvm::SmallPtrSet<const Decl*,24> SetOfDecls;
+typedef llvm::SmallPtrSet<Decl*, 24> SetOfDecls;
+typedef llvm::SmallPtrSet<const Decl*, 24> SetOfConstDecls;
 
 class FunctionSummariesTy {
   struct FunctionSummary {
@@ -87,8 +88,18 @@
     return 0;
   }
 
+  /// Get the percentage of the reachable blocks.
+  unsigned getPercentBlocksReachable(const Decl *D) {
+    MapTy::const_iterator I = Map.find(D);
+      if (I != Map.end())
+        return ((I->second->VisitedBasicBlocks.count() * 100) /
+                 I->second->TotalBasicBlocks);
+    return 0;
+  }
+
   unsigned getTotalNumBasicBlocks();
   unsigned getTotalNumVisitedBasicBlocks();
+
 };
 
 }} // end clang ento namespaces

Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h Tue Apr 17 06:08:26 2012
@@ -278,6 +278,7 @@
            if (StrInStrNoCase(FName, "InsertValue") != StringRef::npos||
                StrInStrNoCase(FName, "AddValue") != StringRef::npos ||
                StrInStrNoCase(FName, "SetValue") != StringRef::npos ||
+               StrInStrNoCase(FName, "WithData") != StringRef::npos ||
                StrInStrNoCase(FName, "AppendValue") != StringRef::npos||
                StrInStrNoCase(FName, "SetAttribute") != StringRef::npos) {
          return true;

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h Tue Apr 17 06:08:26 2012
@@ -250,11 +250,15 @@
   
   SVal getSValAsScalarOrLoc(const Stmt *Ex, const LocationContext *LCtx) const;
 
+  /// \brief Return the value bound to the specified location.
+  /// Returns UnknownVal() if none found.
   SVal getSVal(Loc LV, QualType T = QualType()) const;
 
   /// Returns the "raw" SVal bound to LV before any value simplfication.
   SVal getRawSVal(Loc LV, QualType T= QualType()) const;
 
+  /// \brief Return the value bound to the specified location.
+  /// Returns UnknownVal() if none found.
   SVal getSVal(const MemRegion* R) const;
 
   SVal getSValAsScalarOrLoc(const MemRegion *R) const;

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h Tue Apr 17 06:08:26 2012
@@ -120,9 +120,18 @@
   virtual SVal ArrayToPointer(Loc Array) = 0;
 
   /// Evaluates DerivedToBase casts.
-  virtual SVal evalDerivedToBase(SVal derived, QualType basePtrType) {
-    return UnknownVal();
-  }
+  virtual SVal evalDerivedToBase(SVal derived, QualType basePtrType) = 0;
+
+  /// \brief Evaluates C++ dynamic_cast cast.
+  /// The callback may result in the following 3 scenarios:
+  ///  - Successful cast (ex: derived is subclass of base).
+  ///  - Failed cast (ex: derived is definitely not a subclass of base).
+  ///  - We don't know (base is a symbolic region and we don't have 
+  ///    enough info to determine if the cast will succeed at run time).
+  /// The function returns an SVal representing the derived class; it's
+  /// valid only if Failed flag is set to false.
+  virtual SVal evalDynamicCast(SVal base, QualType derivedPtrType,
+                                 bool &Failed) = 0;
 
   class CastResult {
     ProgramStateRef state;

Propchange: cfe/branches/tooling/include/clang/Tooling/CompilationDatabase.h
------------------------------------------------------------------------------
    svn:eol-style = LF

Propchange: cfe/branches/tooling/include/clang/Tooling/CompilationDatabase.h
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 17 06:08:26 2012
@@ -0,0 +1,2 @@
+/cfe/branches/type-system-rewrite/include/clang/Tooling/CompilationDatabase.h:134693-134817
+/cfe/trunk/test/SemaTemplate/include/clang/Tooling/CompilationDatabase.h:126920

Modified: cfe/branches/tooling/include/clang/Tooling/Refactoring.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Tooling/Refactoring.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Tooling/Refactoring.h (original)
+++ cfe/branches/tooling/include/clang/Tooling/Refactoring.h Tue Apr 17 06:08:26 2012
@@ -121,7 +121,8 @@
 class RefactoringTool {
 public:
   /// \see ClangTool::ClangTool.
-  RefactoringTool(int argc, char **argv);
+  RefactoringTool(const CompilationDatabase &Compilations,
+                  ArrayRef<std::string> SourcePaths);
 
   /// \brief Returns a set of replacements. All replacements added during the
   /// run of the tool will be applied after all translation units have been

Propchange: cfe/branches/tooling/include/clang/Tooling/Tooling.h
------------------------------------------------------------------------------
    svn:eol-style = LF

Propchange: cfe/branches/tooling/include/clang/Tooling/Tooling.h
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 17 06:08:26 2012
@@ -0,0 +1,2 @@
+/cfe/branches/type-system-rewrite/include/clang/Tooling/Tooling.h:134693-134817
+/cfe/trunk/test/SemaTemplate/include/clang/Tooling/Tooling.h:126920

Modified: cfe/branches/tooling/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTContext.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTContext.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTContext.cpp Tue Apr 17 06:08:26 2012
@@ -3313,8 +3313,11 @@
     case TemplateArgument::Expression:
       return Arg;
 
-    case TemplateArgument::Declaration:
-      return TemplateArgument(Arg.getAsDecl()->getCanonicalDecl());
+    case TemplateArgument::Declaration: {
+      if (Decl *D = Arg.getAsDecl())
+          return TemplateArgument(D->getCanonicalDecl());
+      return TemplateArgument((Decl*)0);
+    }
 
     case TemplateArgument::Template:
       return TemplateArgument(getCanonicalTemplateName(Arg.getAsTemplate()));

Modified: cfe/branches/tooling/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTImporter.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTImporter.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTImporter.cpp Tue Apr 17 06:08:26 2012
@@ -325,6 +325,8 @@
     return IsSameValue(*Arg1.getAsIntegral(), *Arg2.getAsIntegral());
       
   case TemplateArgument::Declaration:
+    if (!Arg1.getAsDecl() || !Arg2.getAsDecl())
+      return !Arg1.getAsDecl() && !Arg2.getAsDecl();
     return Context.IsStructurallyEquivalent(Arg1.getAsDecl(), Arg2.getAsDecl());
       
   case TemplateArgument::Template:

Modified: cfe/branches/tooling/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DeclObjC.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DeclObjC.cpp (original)
+++ cfe/branches/tooling/lib/AST/DeclObjC.cpp Tue Apr 17 06:08:26 2012
@@ -316,9 +316,9 @@
 
 /// lookupMethod - This method returns an instance/class method by looking in
 /// the class, its categories, and its super classes (using a linear search).
-ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
-                                                bool isInstance,
-                                                bool noCategoryLookup) const {
+ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, 
+                                     bool isInstance,
+                                     bool shallowCategoryLookup) const {
   // FIXME: Should make sure no callers ever do this.
   if (!hasDefinition())
     return 0;
@@ -339,13 +339,14 @@
            I != E; ++I)
       if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
         return MethodDecl;
-    if (!noCategoryLookup) {
-      // Didn't find one yet - now look through categories.
-      ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
-      while (CatDecl) {
-        if ((MethodDecl = CatDecl->getMethod(Sel, isInstance)))
-          return MethodDecl;
+    
+    // Didn't find one yet - now look through categories.
+    ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
+    while (CatDecl) {
+      if ((MethodDecl = CatDecl->getMethod(Sel, isInstance)))
+        return MethodDecl;
 
+      if (!shallowCategoryLookup) {
         // Didn't find one yet - look through protocols.
         const ObjCList<ObjCProtocolDecl> &Protocols =
           CatDecl->getReferencedProtocols();
@@ -353,9 +354,10 @@
              E = Protocols.end(); I != E; ++I)
           if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
             return MethodDecl;
-        CatDecl = CatDecl->getNextClassCategory();
       }
+      CatDecl = CatDecl->getNextClassCategory();
     }
+  
     ClassDecl = ClassDecl->getSuperClass();
   }
   return NULL;

Modified: cfe/branches/tooling/lib/AST/DumpXML.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DumpXML.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DumpXML.cpp (original)
+++ cfe/branches/tooling/lib/AST/DumpXML.cpp Tue Apr 17 06:08:26 2012
@@ -320,7 +320,8 @@
       break;
         
     case TemplateArgument::Declaration: {
-      visitDeclRef(A.getAsDecl());
+      if (Decl *D = A.getAsDecl())
+        visitDeclRef(D);
       break;
     }
     case TemplateArgument::Integral: {

Modified: cfe/branches/tooling/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Expr.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Expr.cpp (original)
+++ cfe/branches/tooling/lib/AST/Expr.cpp Tue Apr 17 06:08:26 2012
@@ -399,21 +399,23 @@
     }
 
     PrintingPolicy Policy(Context.getLangOpts());
-
     std::string Proto = FD->getQualifiedNameAsString(Policy);
+    llvm::raw_string_ostream POut(Proto);
 
-    const FunctionType *AFT = FD->getType()->getAs<FunctionType>();
+    const FunctionDecl *Decl = FD;
+    if (const FunctionDecl* Pattern = FD->getTemplateInstantiationPattern())
+      Decl = Pattern;
+    const FunctionType *AFT = Decl->getType()->getAs<FunctionType>();
     const FunctionProtoType *FT = 0;
     if (FD->hasWrittenPrototype())
       FT = dyn_cast<FunctionProtoType>(AFT);
 
-    Proto += "(";
+    POut << "(";
     if (FT) {
-      llvm::raw_string_ostream POut(Proto);
-      for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) {
+      for (unsigned i = 0, e = Decl->getNumParams(); i != e; ++i) {
         if (i) POut << ", ";
         std::string Param;
-        FD->getParamDecl(i)->getType().getAsStringInternal(Param, Policy);
+        Decl->getParamDecl(i)->getType().getAsStringInternal(Param, Policy);
         POut << Param;
       }
 
@@ -422,16 +424,74 @@
         POut << "...";
       }
     }
-    Proto += ")";
+    POut << ")";
 
     if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
       Qualifiers ThisQuals = Qualifiers::fromCVRMask(MD->getTypeQualifiers());
       if (ThisQuals.hasConst())
-        Proto += " const";
+        POut << " const";
       if (ThisQuals.hasVolatile())
-        Proto += " volatile";
+        POut << " volatile";
+      RefQualifierKind Ref = MD->getRefQualifier();
+      if (Ref == RQ_LValue)
+        POut << " &";
+      else if (Ref == RQ_RValue)
+        POut << " &&";
+    }
+
+    typedef SmallVector<const ClassTemplateSpecializationDecl *, 8> SpecsTy;
+    SpecsTy Specs;
+    const DeclContext *Ctx = FD->getDeclContext();
+    while (Ctx && isa<NamedDecl>(Ctx)) {
+      const ClassTemplateSpecializationDecl *Spec
+                               = dyn_cast<ClassTemplateSpecializationDecl>(Ctx);
+      if (Spec && !Spec->isExplicitSpecialization())
+        Specs.push_back(Spec);
+      Ctx = Ctx->getParent();
+    }
+
+    std::string TemplateParams;
+    llvm::raw_string_ostream TOut(TemplateParams);
+    for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend();
+         I != E; ++I) {
+      const TemplateParameterList *Params 
+                  = (*I)->getSpecializedTemplate()->getTemplateParameters();
+      const TemplateArgumentList &Args = (*I)->getTemplateArgs();
+      assert(Params->size() == Args.size());
+      for (unsigned i = 0, numParams = Params->size(); i != numParams; ++i) {
+        StringRef Param = Params->getParam(i)->getName();
+        if (Param.empty()) continue;
+        TOut << Param << " = ";
+        Args.get(i).print(Policy, TOut);
+        TOut << ", ";
+      }
+    }
+
+    FunctionTemplateSpecializationInfo *FSI 
+                                          = FD->getTemplateSpecializationInfo();
+    if (FSI && !FSI->isExplicitSpecialization()) {
+      const TemplateParameterList* Params 
+                                  = FSI->getTemplate()->getTemplateParameters();
+      const TemplateArgumentList* Args = FSI->TemplateArguments;
+      assert(Params->size() == Args->size());
+      for (unsigned i = 0, e = Params->size(); i != e; ++i) {
+        StringRef Param = Params->getParam(i)->getName();
+        if (Param.empty()) continue;
+        TOut << Param << " = ";
+        Args->get(i).print(Policy, TOut);
+        TOut << ", ";
+      }
+    }
+
+    TOut.flush();
+    if (!TemplateParams.empty()) {
+      // remove the trailing comma and space
+      TemplateParams.resize(TemplateParams.size() - 2);
+      POut << " [" << TemplateParams << "]";
     }
 
+    POut.flush();
+
     if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
       AFT->getResultType().getAsStringInternal(Proto, Policy);
 
@@ -3781,6 +3841,7 @@
          false, false, false, false),
     NumSubExprs(nexpr), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)
 {
+  assert(nexpr == getNumSubExprs(op) && "wrong number of subexpressions");
   for (unsigned i = 0; i < nexpr; i++) {
     if (args[i]->isTypeDependent())
       ExprBits.TypeDependent = true;
@@ -3794,3 +3855,49 @@
     SubExprs[i] = args[i];
   }
 }
+
+unsigned AtomicExpr::getNumSubExprs(AtomicOp Op) {
+  switch (Op) {
+  case AO__c11_atomic_init:
+  case AO__c11_atomic_load:
+  case AO__atomic_load_n:
+    return 2;
+
+  case AO__c11_atomic_store:
+  case AO__c11_atomic_exchange:
+  case AO__atomic_load:
+  case AO__atomic_store:
+  case AO__atomic_store_n:
+  case AO__atomic_exchange_n:
+  case AO__c11_atomic_fetch_add:
+  case AO__c11_atomic_fetch_sub:
+  case AO__c11_atomic_fetch_and:
+  case AO__c11_atomic_fetch_or:
+  case AO__c11_atomic_fetch_xor:
+  case AO__atomic_fetch_add:
+  case AO__atomic_fetch_sub:
+  case AO__atomic_fetch_and:
+  case AO__atomic_fetch_or:
+  case AO__atomic_fetch_xor:
+  case AO__atomic_fetch_nand:
+  case AO__atomic_add_fetch:
+  case AO__atomic_sub_fetch:
+  case AO__atomic_and_fetch:
+  case AO__atomic_or_fetch:
+  case AO__atomic_xor_fetch:
+  case AO__atomic_nand_fetch:
+    return 3;
+
+  case AO__atomic_exchange:
+    return 4;
+
+  case AO__c11_atomic_compare_exchange_strong:
+  case AO__c11_atomic_compare_exchange_weak:
+    return 5;
+
+  case AO__atomic_compare_exchange:
+  case AO__atomic_compare_exchange_n:
+    return 6;
+  }
+  llvm_unreachable("unknown atomic op");
+}

Modified: cfe/branches/tooling/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ExprCXX.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/AST/ExprCXX.cpp Tue Apr 17 06:08:26 2012
@@ -796,9 +796,7 @@
                        ArrayRef<Expr *> CaptureInits,
                        ArrayRef<VarDecl *> ArrayIndexVars,
                        ArrayRef<unsigned> ArrayIndexStarts,
-                       SourceLocation ClosingBrace,
-                       unsigned ManglingNumber,
-                       Decl *ContextDecl)
+                       SourceLocation ClosingBrace)
   : Expr(LambdaExprClass, T, VK_RValue, OK_Ordinary,
          T->isDependentType(), T->isDependentType(), T->isDependentType(),
          /*ContainsUnexpandedParameterPack=*/false),
@@ -819,8 +817,6 @@
   ASTContext &Context = Class->getASTContext();
   Data.NumCaptures = NumCaptures;
   Data.NumExplicitCaptures = 0;
-  Data.ManglingNumber = ManglingNumber;
-  Data.ContextDecl = ContextDecl;
   Data.Captures = (Capture *)Context.Allocate(sizeof(Capture) * NumCaptures);
   Capture *ToCapture = Data.Captures;
   for (unsigned I = 0, N = Captures.size(); I != N; ++I) {
@@ -848,9 +844,6 @@
            sizeof(unsigned) * Captures.size());
     getArrayIndexStarts()[Captures.size()] = ArrayIndexVars.size();
   }
-  
-  if (ManglingNumber)
-    Class->ClearLinkageCache();
 }
 
 LambdaExpr *LambdaExpr::Create(ASTContext &Context, 
@@ -863,9 +856,7 @@
                                ArrayRef<Expr *> CaptureInits,
                                ArrayRef<VarDecl *> ArrayIndexVars,
                                ArrayRef<unsigned> ArrayIndexStarts,
-                               SourceLocation ClosingBrace,
-                               unsigned ManglingNumber,
-                               Decl *ContextDecl) {
+                               SourceLocation ClosingBrace) {
   // Determine the type of the expression (i.e., the type of the
   // function object we're creating).
   QualType T = Context.getTypeDeclType(Class);
@@ -878,7 +869,7 @@
   return new (Mem) LambdaExpr(T, IntroducerRange, CaptureDefault, 
                               Captures, ExplicitParams, ExplicitResultType,
                               CaptureInits, ArrayIndexVars, ArrayIndexStarts,
-                              ClosingBrace, ManglingNumber, ContextDecl);
+                              ClosingBrace);
 }
 
 LambdaExpr *LambdaExpr::CreateDeserialized(ASTContext &C, unsigned NumCaptures,

Modified: cfe/branches/tooling/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ExprConstant.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ExprConstant.cpp (original)
+++ cfe/branches/tooling/lib/AST/ExprConstant.cpp Tue Apr 17 06:08:26 2012
@@ -1743,8 +1743,10 @@
     // parameters are constant expressions even if they're non-const.
     // In C, such things can also be folded, although they are not ICEs.
     const VarDecl *VD = dyn_cast<VarDecl>(D);
-    if (const VarDecl *VDef = VD->getDefinition(Info.Ctx))
-      VD = VDef;
+    if (VD) {
+      if (const VarDecl *VDef = VD->getDefinition(Info.Ctx))
+        VD = VDef;
+    }
     if (!VD || VD->isInvalidDecl()) {
       Info.Diag(Conv);
       return false;
@@ -3176,6 +3178,7 @@
     return HandleBaseToDerivedCast(Info, E, Result);
 
   case CK_NullToPointer:
+    VisitIgnoredValue(E->getSubExpr());
     return ZeroInitialization(E);
 
   case CK_IntegralToPointer: {
@@ -3274,6 +3277,7 @@
     return ExprEvaluatorBaseTy::VisitCastExpr(E);
 
   case CK_NullToMemberPointer:
+    VisitIgnoredValue(E->getSubExpr());
     return ZeroInitialization(E);
 
   case CK_BaseToDerivedMemberPointer: {
@@ -4302,7 +4306,7 @@
 }
 
 bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) {
-  switch (E->isBuiltinCall()) {
+  switch (unsigned BuiltinOp = E->isBuiltinCall()) {
   default:
     return ExprEvaluatorBaseTy::VisitCallExpr(E);
 
@@ -4361,7 +4365,9 @@
       
     return Error(E);
 
-  case Builtin::BI__atomic_is_lock_free: {
+  case Builtin::BI__atomic_always_lock_free:
+  case Builtin::BI__atomic_is_lock_free:
+  case Builtin::BI__c11_atomic_is_lock_free: {
     APSInt SizeVal;
     if (!EvaluateInteger(E->getArg(0), SizeVal, Info))
       return false;
@@ -4377,32 +4383,31 @@
 
     // Check power-of-two.
     CharUnits Size = CharUnits::fromQuantity(SizeVal.getZExtValue());
-    if (!Size.isPowerOfTwo())
-#if 0
-      // FIXME: Suppress this folding until the ABI for the promotion width
-      // settles.
-      return Success(0, E);
-#else
-      return Error(E);
-#endif
-
-#if 0
-    // Check against promotion width.
-    // FIXME: Suppress this folding until the ABI for the promotion width
-    // settles.
-    unsigned PromoteWidthBits =
-        Info.Ctx.getTargetInfo().getMaxAtomicPromoteWidth();
-    if (Size > Info.Ctx.toCharUnitsFromBits(PromoteWidthBits))
-      return Success(0, E);
-#endif
-
-    // Check against inlining width.
-    unsigned InlineWidthBits =
-        Info.Ctx.getTargetInfo().getMaxAtomicInlineWidth();
-    if (Size <= Info.Ctx.toCharUnitsFromBits(InlineWidthBits))
-      return Success(1, E);
+    if (Size.isPowerOfTwo()) {
+      // Check against inlining width.
+      unsigned InlineWidthBits =
+          Info.Ctx.getTargetInfo().getMaxAtomicInlineWidth();
+      if (Size <= Info.Ctx.toCharUnitsFromBits(InlineWidthBits)) {
+        if (BuiltinOp == Builtin::BI__c11_atomic_is_lock_free ||
+            Size == CharUnits::One() ||
+            E->getArg(1)->isNullPointerConstant(Info.Ctx,
+                                                Expr::NPC_NeverValueDependent))
+          // OK, we will inline appropriately-aligned operations of this size,
+          // and _Atomic(T) is appropriately-aligned.
+          return Success(1, E);
+
+        QualType PointeeType = E->getArg(1)->IgnoreImpCasts()->getType()->
+          castAs<PointerType>()->getPointeeType();
+        if (!PointeeType->isIncompleteType() &&
+            Info.Ctx.getTypeAlignInChars(PointeeType) >= Size) {
+          // OK, we will inline operations on this object.
+          return Success(1, E);
+        }
+      }
+    }
 
-    return Error(E);
+    return BuiltinOp == Builtin::BI__atomic_always_lock_free ?
+        Success(0, E) : Error(E);
   }
   }
 }

Modified: cfe/branches/tooling/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ItaniumMangle.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/branches/tooling/lib/AST/ItaniumMangle.cpp Tue Apr 17 06:08:26 2012
@@ -535,6 +535,14 @@
   return 0;
 }
 
+static bool isLambda(const NamedDecl *ND) {
+  const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(ND);
+  if (!Record)
+    return false;
+  
+  return Record->isLambda();
+}
+
 void CXXNameMangler::mangleName(const NamedDecl *ND) {
   //  <name> ::= <nested-name>
   //         ::= <unscoped-name>
@@ -545,7 +553,9 @@
 
   // If this is an extern variable declared locally, the relevant DeclContext
   // is that of the containing namespace, or the translation unit.
-  if (isa<FunctionDecl>(DC) && ND->hasLinkage())
+  // FIXME: This is a hack; extern variables declared locally should have
+  // a proper semantic declaration context!
+  if (isa<FunctionDecl>(DC) && ND->hasLinkage() && !isLambda(ND))
     while (!DC->isNamespace() && !DC->isTranslationUnit())
       DC = getEffectiveParentContext(DC);
   else if (GetLocalClassDecl(ND)) {
@@ -3108,12 +3118,22 @@
   case TemplateArgument::Declaration: {
     assert(P && "Missing template parameter for declaration argument");
     //  <expr-primary> ::= L <mangled-name> E # external name
-
+    //  <expr-primary> ::= L <type> 0 E
     // Clang produces AST's where pointer-to-member-function expressions
     // and pointer-to-function expressions are represented as a declaration not
     // an expression. We compensate for it here to produce the correct mangling.
-    NamedDecl *D = cast<NamedDecl>(A.getAsDecl());
     const NonTypeTemplateParmDecl *Parameter = cast<NonTypeTemplateParmDecl>(P);
+
+    // Handle NULL pointer arguments.
+    if (!A.getAsDecl()) {
+      Out << "L";
+      mangleType(Parameter->getType());
+      Out << "0E";
+      break;
+    }
+    
+
+    NamedDecl *D = cast<NamedDecl>(A.getAsDecl());
     bool compensateMangling = !Parameter->getType()->isReferenceType();
     if (compensateMangling) {
       Out << 'X';

Modified: cfe/branches/tooling/lib/AST/NSAPI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/NSAPI.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/NSAPI.cpp (original)
+++ cfe/branches/tooling/lib/AST/NSAPI.cpp Tue Apr 17 06:08:26 2012
@@ -18,6 +18,7 @@
 
 IdentifierInfo *NSAPI::getNSClassId(NSClassIdKindKind K) const {
   static const char *ClassName[NumClassIds] = {
+    "NSObject",
     "NSString",
     "NSArray",
     "NSMutableArray",

Modified: cfe/branches/tooling/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/StmtPrinter.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/StmtPrinter.cpp (original)
+++ cfe/branches/tooling/lib/AST/StmtPrinter.cpp Tue Apr 17 06:08:26 2012
@@ -727,12 +727,40 @@
   OS << '"';
   static char Hex[] = "0123456789ABCDEF";
 
+  unsigned LastSlashX = Str->getLength();
   for (unsigned I = 0, N = Str->getLength(); I != N; ++I) {
     switch (uint32_t Char = Str->getCodeUnit(I)) {
     default:
-      // FIXME: Is this the best way to print wchar_t?
+      // FIXME: Convert UTF-8 back to codepoints before rendering.
+
+      // Convert UTF-16 surrogate pairs back to codepoints before rendering.
+      // Leave invalid surrogates alone; we'll use \x for those.
+      if (Str->getKind() == StringLiteral::UTF16 && I != N - 1 &&
+          Char >= 0xd800 && Char <= 0xdbff) {
+        uint32_t Trail = Str->getCodeUnit(I + 1);
+        if (Trail >= 0xdc00 && Trail <= 0xdfff) {
+          Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
+          ++I;
+        }
+      }
+
       if (Char > 0xff) {
-        assert(Char <= 0x10ffff && "invalid unicode codepoint");
+        // If this is a wide string, output characters over 0xff using \x
+        // escapes. Otherwise, this is a UTF-16 or UTF-32 string, and Char is a
+        // codepoint: use \x escapes for invalid codepoints.
+        if (Str->getKind() == StringLiteral::Wide ||
+            (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
+          // FIXME: Is this the best way to print wchar_t?
+          OS << "\\x";
+          int Shift = 28;
+          while ((Char >> Shift) == 0)
+            Shift -= 4;
+          for (/**/; Shift >= 0; Shift -= 4)
+            OS << Hex[(Char >> Shift) & 15];
+          LastSlashX = I;
+          break;
+        }
+
         if (Char > 0xffff)
           OS << "\\U00"
              << Hex[(Char >> 20) & 15]
@@ -745,13 +773,26 @@
            << Hex[(Char >>  0) & 15];
         break;
       }
+
+      // If we used \x... for the previous character, and this character is a
+      // hexadecimal digit, prevent it being slurped as part of the \x.
+      if (LastSlashX + 1 == I) {
+        switch (Char) {
+          case '0': case '1': case '2': case '3': case '4':
+          case '5': case '6': case '7': case '8': case '9':
+          case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+          case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+            OS << "\"\"";
+        }
+      }
+
       if (Char <= 0xff && isprint(Char))
         OS << (char)Char;
       else  // Output anything hard as an octal escape.
         OS << '\\'
-        << (char)('0'+ ((Char >> 6) & 7))
-        << (char)('0'+ ((Char >> 3) & 7))
-        << (char)('0'+ ((Char >> 0) & 7));
+           << (char)('0' + ((Char >> 6) & 7))
+           << (char)('0' + ((Char >> 3) & 7))
+           << (char)('0' + ((Char >> 0) & 7));
       break;
     // Handle some common non-printable cases to make dumps prettier.
     case '\\': OS << "\\\\"; break;
@@ -1067,52 +1108,34 @@
 void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
   const char *Name = 0;
   switch (Node->getOp()) {
-    case AtomicExpr::Init:
-      Name = "__atomic_init(";
-      break;
-    case AtomicExpr::Load:
-      Name = "__atomic_load(";
-      break;
-    case AtomicExpr::Store:
-      Name = "__atomic_store(";
-      break;
-    case AtomicExpr::CmpXchgStrong:
-      Name = "__atomic_compare_exchange_strong(";
-      break;
-    case AtomicExpr::CmpXchgWeak:
-      Name = "__atomic_compare_exchange_weak(";
-      break;
-    case AtomicExpr::Xchg:
-      Name = "__atomic_exchange(";
-      break;
-    case AtomicExpr::Add:
-      Name = "__atomic_fetch_add(";
-      break;
-    case AtomicExpr::Sub:
-      Name = "__atomic_fetch_sub(";
-      break;
-    case AtomicExpr::And:
-      Name = "__atomic_fetch_and(";
-      break;
-    case AtomicExpr::Or:
-      Name = "__atomic_fetch_or(";
-      break;
-    case AtomicExpr::Xor:
-      Name = "__atomic_fetch_xor(";
-      break;
+#define BUILTIN(ID, TYPE, ATTRS)
+#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
+  case AtomicExpr::AO ## ID: \
+    Name = #ID "("; \
+    break;
+#include "clang/Basic/Builtins.def"
   }
   OS << Name;
+
+  // AtomicExpr stores its subexpressions in a permuted order.
   PrintExpr(Node->getPtr());
   OS << ", ";
-  if (Node->getOp() != AtomicExpr::Load) {
+  if (Node->getOp() != AtomicExpr::AO__c11_atomic_load &&
+      Node->getOp() != AtomicExpr::AO__atomic_load_n) {
     PrintExpr(Node->getVal1());
     OS << ", ";
   }
-  if (Node->isCmpXChg()) {
+  if (Node->getOp() == AtomicExpr::AO__atomic_exchange ||
+      Node->isCmpXChg()) {
     PrintExpr(Node->getVal2());
     OS << ", ";
   }
-  if (Node->getOp() != AtomicExpr::Init)
+  if (Node->getOp() == AtomicExpr::AO__atomic_compare_exchange ||
+      Node->getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
+    PrintExpr(Node->getWeak());
+    OS << ", ";
+  }
+  if (Node->getOp() != AtomicExpr::AO__c11_atomic_init)
     PrintExpr(Node->getOrder());
   if (Node->isCmpXChg()) {
     OS << ", ";

Modified: cfe/branches/tooling/lib/AST/TemplateBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/TemplateBase.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/TemplateBase.cpp (original)
+++ cfe/branches/tooling/lib/AST/TemplateBase.cpp Tue Apr 17 06:08:26 2012
@@ -80,9 +80,13 @@
     return true;
 
   case Declaration:
-    if (DeclContext *DC = dyn_cast<DeclContext>(getAsDecl()))
-      return DC->isDependentContext();
-    return getAsDecl()->getDeclContext()->isDependentContext();
+    if (Decl *D = getAsDecl()) {
+      if (DeclContext *DC = dyn_cast<DeclContext>(D))
+        return DC->isDependentContext();
+      return D->getDeclContext()->isDependentContext();
+    }
+      
+    return false;
 
   case Integral:
     // Never dependent
@@ -118,10 +122,13 @@
     return true;
     
   case Declaration:
-    if (DeclContext *DC = dyn_cast<DeclContext>(getAsDecl()))
-      return DC->isDependentContext();
-    return getAsDecl()->getDeclContext()->isDependentContext();
-    
+    if (Decl *D = getAsDecl()) {
+      if (DeclContext *DC = dyn_cast<DeclContext>(D))
+        return DC->isDependentContext();
+      return D->getDeclContext()->isDependentContext();
+    }
+    return false;
+      
   case Integral:
     // Never dependent
     return false;
@@ -322,16 +329,14 @@
   }
     
   case Declaration: {
-    bool Unnamed = true;
     if (NamedDecl *ND = dyn_cast_or_null<NamedDecl>(getAsDecl())) {
       if (ND->getDeclName()) {
-        Unnamed = false;
         Out << *ND;
+      } else {
+        Out << "<anonymous>";
       }
-    }
-    
-    if (Unnamed) {
-      Out << "<anonymous>";
+    } else {
+      Out << "nullptr";
     }
     break;
   }
@@ -488,7 +493,9 @@
     return DB << Arg.getAsType();
       
   case TemplateArgument::Declaration:
-    return DB << Arg.getAsDecl();
+    if (Decl *D = Arg.getAsDecl())
+      return DB << D;
+    return DB << "nullptr";
       
   case TemplateArgument::Integral:
     return DB << Arg.getAsIntegral()->toString(10);

Modified: cfe/branches/tooling/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Type.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Type.cpp (original)
+++ cfe/branches/tooling/lib/AST/Type.cpp Tue Apr 17 06:08:26 2012
@@ -1428,13 +1428,13 @@
   case Int:               return "int";
   case Long:              return "long";
   case LongLong:          return "long long";
-  case Int128:            return "__int128_t";
+  case Int128:            return "__int128";
   case UChar:             return "unsigned char";
   case UShort:            return "unsigned short";
   case UInt:              return "unsigned int";
   case ULong:             return "unsigned long";
   case ULongLong:         return "unsigned long long";
-  case UInt128:           return "__uint128_t";
+  case UInt128:           return "unsigned __int128";
   case Half:              return "half";
   case Float:             return "float";
   case Double:            return "double";

Modified: cfe/branches/tooling/lib/AST/TypePrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/TypePrinter.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/TypePrinter.cpp (original)
+++ cfe/branches/tooling/lib/AST/TypePrinter.cpp Tue Apr 17 06:08:26 2012
@@ -264,8 +264,9 @@
 
 void TypePrinter::printMemberPointer(const MemberPointerType *T, 
                                      std::string &S) { 
-  std::string C;
-  print(QualType(T->getClass(), 0), C);
+  PrintingPolicy InnerPolicy(Policy);
+  Policy.SuppressTag = true;
+  std::string C = QualType(T->getClass(), 0).getAsString(InnerPolicy);
   C += "::*";
   S = C + S;
   

Modified: cfe/branches/tooling/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/CFG.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/CFG.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/CFG.cpp Tue Apr 17 06:08:26 2012
@@ -310,7 +310,6 @@
   // Visitors to walk an AST and construct the CFG.
   CFGBlock *VisitAddrLabelExpr(AddrLabelExpr *A, AddStmtChoice asc);
   CFGBlock *VisitBinaryOperator(BinaryOperator *B, AddStmtChoice asc);
-  CFGBlock *VisitBlockExpr(BlockExpr *E, AddStmtChoice asc);
   CFGBlock *VisitBreakStmt(BreakStmt *B);
   CFGBlock *VisitCXXCatchStmt(CXXCatchStmt *S);
   CFGBlock *VisitExprWithCleanups(ExprWithCleanups *E,
@@ -336,12 +335,14 @@
   CFGBlock *VisitDeclSubExpr(DeclStmt *DS);
   CFGBlock *VisitDefaultStmt(DefaultStmt *D);
   CFGBlock *VisitDoStmt(DoStmt *D);
+  CFGBlock *VisitLambdaExpr(LambdaExpr *E, AddStmtChoice asc);
   CFGBlock *VisitForStmt(ForStmt *F);
   CFGBlock *VisitGotoStmt(GotoStmt *G);
   CFGBlock *VisitIfStmt(IfStmt *I);
   CFGBlock *VisitImplicitCastExpr(ImplicitCastExpr *E, AddStmtChoice asc);
   CFGBlock *VisitIndirectGotoStmt(IndirectGotoStmt *I);
   CFGBlock *VisitLabelStmt(LabelStmt *L);
+  CFGBlock *VisitLambdaExpr(LambdaExpr *L);
   CFGBlock *VisitMemberExpr(MemberExpr *M, AddStmtChoice asc);
   CFGBlock *VisitObjCAtCatchStmt(ObjCAtCatchStmt *S);
   CFGBlock *VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S);
@@ -361,6 +362,7 @@
   CFGBlock *Visit(Stmt *S, AddStmtChoice asc = AddStmtChoice::NotAlwaysAdd);
   CFGBlock *VisitStmt(Stmt *S, AddStmtChoice asc);
   CFGBlock *VisitChildren(Stmt *S);
+  CFGBlock *VisitNoRecurse(Expr *E, AddStmtChoice asc);
 
   // Visitors to walk an AST and generate destructors of temporaries in
   // full expression.
@@ -984,7 +986,7 @@
       return VisitBinaryOperator(cast<BinaryOperator>(S), asc);
 
     case Stmt::BlockExprClass:
-      return VisitBlockExpr(cast<BlockExpr>(S), asc);
+      return VisitNoRecurse(cast<Expr>(S), asc);
 
     case Stmt::BreakStmtClass:
       return VisitBreakStmt(cast<BreakStmt>(S));
@@ -1064,6 +1066,9 @@
     case Stmt::LabelStmtClass:
       return VisitLabelStmt(cast<LabelStmt>(S));
 
+    case Stmt::LambdaExprClass:
+      return VisitLambdaExpr(cast<LambdaExpr>(S), asc);
+
     case Stmt::MemberExprClass:
       return VisitMemberExpr(cast<MemberExpr>(S), asc);
 
@@ -1235,7 +1240,7 @@
   return (LBlock ? LBlock : RBlock);
 }
 
-CFGBlock *CFGBuilder::VisitBlockExpr(BlockExpr *E, AddStmtChoice asc) {
+CFGBlock *CFGBuilder::VisitNoRecurse(Expr *E, AddStmtChoice asc) {
   if (asc.alwaysAdd(*this, E)) {
     autoCreateBlock();
     appendStmt(Block, E);
@@ -1716,6 +1721,19 @@
   return LabelBlock;
 }
 
+CFGBlock *CFGBuilder::VisitLambdaExpr(LambdaExpr *E, AddStmtChoice asc) {
+  CFGBlock *LastBlock = VisitNoRecurse(E, asc);
+  for (LambdaExpr::capture_init_iterator it = E->capture_init_begin(),
+       et = E->capture_init_end(); it != et; ++it) {
+    if (Expr *Init = *it) {
+      CFGBlock *Tmp = Visit(Init);
+      if (Tmp != 0)
+        LastBlock = Tmp;
+    }
+  }
+  return LastBlock;
+}
+  
 CFGBlock *CFGBuilder::VisitGotoStmt(GotoStmt *G) {
   // Goto is a control-flow statement.  Thus we stop processing the current
   // block and create a new one.

Modified: cfe/branches/tooling/lib/Analysis/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/CMakeLists.txt?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/Analysis/CMakeLists.txt Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-set(LLVM_USED_LIBS clangBasic clangAST clangIndex)
+set(LLVM_USED_LIBS clangBasic clangAST)
 
 add_clang_library(clangAnalysis
   AnalysisDeclContext.cpp

Modified: cfe/branches/tooling/lib/Analysis/CallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/CallGraph.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/CallGraph.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/CallGraph.cpp Tue Apr 17 06:08:26 2012
@@ -14,35 +14,12 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
-#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/StmtVisitor.h"
 
 #include "llvm/Support/GraphWriter.h"
 
 using namespace clang;
 
-/// Determine if a declaration should be included in the graph.
-static bool includeInGraph(const Decl *D) {
-  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
-    // We skip function template definitions, as their semantics is
-    // only determined when they are instantiated.
-    if (!FD->isThisDeclarationADefinition() ||
-        FD->isDependentContext())
-      return false;
-
-    IdentifierInfo *II = FD->getIdentifier();
-    if (II && II->getName().startswith("__inline"))
-      return false;
-  }
-
-  if (const ObjCMethodDecl *ID = dyn_cast<ObjCMethodDecl>(D)) {
-    if (!ID->isThisDeclarationADefinition())
-      return false;
-  }
-
-  return true;
-}
-
 namespace {
 /// A helper class, which walks the AST and locates all the call sites in the
 /// given function body.
@@ -60,8 +37,8 @@
   void VisitCallExpr(CallExpr *CE) {
     // TODO: We need to handle ObjC method calls as well.
     if (FunctionDecl *CalleeDecl = CE->getDirectCallee())
-      if (includeInGraph(CalleeDecl)) {
-        CallGraphNode *CalleeNode = G->getOrInsertFunction(CalleeDecl);
+      if (G->includeInGraph(CalleeDecl)) {
+        CallGraphNode *CalleeNode = G->getOrInsertNode(CalleeDecl);
         CallerNode->addCallee(CalleeNode, G);
       }
   }
@@ -73,38 +50,10 @@
   }
 };
 
-/// A helper class which walks the AST declarations.
-// TODO: We might want to specialize the visitor to shrink the call graph.
-// For example, we might not want to include the inline methods from header
-// files.
-class CGDeclVisitor : public RecursiveASTVisitor<CGDeclVisitor> {
-  CallGraph *CG;
-
-public:
-  CGDeclVisitor(CallGraph * InCG) : CG(InCG) {}
-
-  bool VisitFunctionDecl(FunctionDecl *FD) {
-    // We skip function template definitions, as their semantics is
-    // only determined when they are instantiated.
-    if (includeInGraph(FD))
-      // If this function has external linkage, anything could call it.
-      // Note, we are not precise here. For example, the function could have
-      // its address taken.
-      CG->addToCallGraph(FD, FD->isGlobal());
-    return true;
-  }
-
-  bool VisitObjCMethodDecl(ObjCMethodDecl *MD) {
-    if (includeInGraph(MD))
-      CG->addToCallGraph(MD, true);
-    return true;
-  }
-};
-
 } // end anonymous namespace
 
 CallGraph::CallGraph() {
-  Root = getOrInsertFunction(0);
+  Root = getOrInsertNode(0);
 }
 
 CallGraph::~CallGraph() {
@@ -116,20 +65,43 @@
   }
 }
 
-void CallGraph::addToCallGraph(Decl* D, bool IsGlobal) {
+bool CallGraph::includeInGraph(const Decl *D) {
+  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+    // We skip function template definitions, as their semantics is
+    // only determined when they are instantiated.
+    if (!FD->isThisDeclarationADefinition() ||
+        FD->isDependentContext())
+      return false;
+
+    IdentifierInfo *II = FD->getIdentifier();
+    if (II && II->getName().startswith("__inline"))
+      return false;
+  }
+
+  if (const ObjCMethodDecl *ID = dyn_cast<ObjCMethodDecl>(D)) {
+    if (!ID->isThisDeclarationADefinition())
+      return false;
+  }
+
+  return true;
+}
+
+void CallGraph::addNodeForDecl(Decl* D, bool IsGlobal) {
   assert(D);
-  CallGraphNode *Node = getOrInsertFunction(D);
 
+  // Do nothing if the node already exists.
+  if (FunctionMap.find(D) != FunctionMap.end())
+    return;
+
+  // Allocate a new node, mark it as root, and process it's calls.
+  CallGraphNode *Node = getOrInsertNode(D);
   if (IsGlobal)
     Root->addCallee(Node, this);
 
   // Process all the calls by this function as well.
   CGBuilder builder(this, D, Node);
-  builder.Visit(D->getBody());
-}
-
-void CallGraph::addToCallGraph(TranslationUnitDecl *TU) {
-  CGDeclVisitor(this).TraverseDecl(TU);
+  if (Stmt *Body = D->getBody())
+    builder.Visit(Body);
 }
 
 CallGraphNode *CallGraph::getNode(const Decl *F) const {
@@ -138,7 +110,7 @@
   return I->second;
 }
 
-CallGraphNode *CallGraph::getOrInsertFunction(Decl *F) {
+CallGraphNode *CallGraph::getOrInsertNode(Decl *F) {
   CallGraphNode *&Node = FunctionMap[F];
   if (Node)
     return Node;

Modified: cfe/branches/tooling/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/SourceManager.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/SourceManager.cpp (original)
+++ cfe/branches/tooling/lib/Basic/SourceManager.cpp Tue Apr 17 06:08:26 2012
@@ -1037,6 +1037,10 @@
   return getPresumedLoc(Loc).getColumn();
 }
 
+#ifdef __SSE2__
+#include <emmintrin.h>
+#endif
+
 static LLVM_ATTRIBUTE_NOINLINE void
 ComputeLineNumbers(DiagnosticsEngine &Diag, ContentCache *FI,
                    llvm::BumpPtrAllocator &Alloc,
@@ -1062,11 +1066,44 @@
   unsigned Offs = 0;
   while (1) {
     // Skip over the contents of the line.
-    // TODO: Vectorize this?  This is very performance sensitive for programs
-    // with lots of diagnostics and in -E mode.
     const unsigned char *NextBuf = (const unsigned char *)Buf;
+
+#ifdef __SSE2__
+    // Try to skip to the next newline using SSE instructions. This is very
+    // performance sensitive for programs with lots of diagnostics and in -E
+    // mode.
+    __m128i CRs = _mm_set1_epi8('\r');
+    __m128i LFs = _mm_set1_epi8('\n');
+
+    // First fix up the alignment to 16 bytes.
+    while (((uintptr_t)NextBuf & 0xF) != 0) {
+      if (*NextBuf == '\n' || *NextBuf == '\r' || *NextBuf == '\0')
+        goto FoundSpecialChar;
+      ++NextBuf;
+    }
+
+    // Scan 16 byte chunks for '\r' and '\n'. Ignore '\0'.
+    while (NextBuf+16 <= End) {
+      __m128i Chunk = *(__m128i*)NextBuf;
+      __m128i Cmp = _mm_or_si128(_mm_cmpeq_epi8(Chunk, CRs),
+                                 _mm_cmpeq_epi8(Chunk, LFs));
+      unsigned Mask = _mm_movemask_epi8(Cmp);
+
+      // If we found a newline, adjust the pointer and jump to the handling code.
+      if (Mask != 0) {
+        NextBuf += llvm::CountTrailingZeros_32(Mask);
+        goto FoundSpecialChar;
+      }
+      NextBuf += 16;
+    }
+#endif
+
     while (*NextBuf != '\n' && *NextBuf != '\r' && *NextBuf != '\0')
       ++NextBuf;
+
+#ifdef __SSE2__
+FoundSpecialChar:
+#endif
     Offs += NextBuf-Buf;
     Buf = NextBuf;
 

Modified: cfe/branches/tooling/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/Targets.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/Targets.cpp (original)
+++ cfe/branches/tooling/lib/Basic/Targets.cpp Tue Apr 17 06:08:26 2012
@@ -2730,7 +2730,8 @@
                                  StringRef Name,
                                  bool Enabled) const {
     if (Name == "soft-float" || Name == "soft-float-abi" ||
-        Name == "vfp2" || Name == "vfp3" || Name == "neon" || Name == "d16") {
+        Name == "vfp2" || Name == "vfp3" || Name == "neon" || Name == "d16" ||
+        Name == "neonfp") {
       Features[Name] = Enabled;
     } else
       return false;
@@ -3448,8 +3449,11 @@
   std::string ABI;
 
 public:
-  MipsTargetInfoBase(const std::string& triple, const std::string& ABIStr)
+  MipsTargetInfoBase(const std::string& triple,
+                     const std::string& ABIStr,
+                     const std::string& CPUStr)
     : TargetInfo(triple),
+      CPU(CPUStr),
       SoftFloat(false), SingleFloat(false),
       ABI(ABIStr)
   {}
@@ -3475,6 +3479,10 @@
       Builder.defineMacro("__mips_hard_float", Twine(1));
     else
       llvm_unreachable("Invalid float ABI for Mips.");
+
+    Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
+    Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
+    Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
   }
 
   virtual void getTargetDefines(const LangOptions &Opts,
@@ -3570,7 +3578,7 @@
 class Mips32TargetInfoBase : public MipsTargetInfoBase {
 public:
   Mips32TargetInfoBase(const std::string& triple) :
-    MipsTargetInfoBase(triple, "o32") {
+    MipsTargetInfoBase(triple, "o32", "mips32") {
     SizeType = UnsignedInt;
     PtrDiffType = SignedInt;
   }
@@ -3585,10 +3593,6 @@
                               MacroBuilder &Builder) const {
     MipsTargetInfoBase::getArchDefines(Opts, Builder);
 
-    Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
-    Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
-    Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
-
     if (ABI == "o32") {
       Builder.defineMacro("__mips_o32");
       Builder.defineMacro("_ABIO32", "1");
@@ -3678,7 +3682,7 @@
   virtual void SetDescriptionString(const std::string &Name) = 0;
 public:
   Mips64TargetInfoBase(const std::string& triple) :
-    MipsTargetInfoBase(triple, "n64") {
+    MipsTargetInfoBase(triple, "n64", "mips64") {
     LongWidth = LongAlign = 64;
     PointerWidth = PointerAlign = 64;
     LongDoubleWidth = LongDoubleAlign = 128;

Modified: cfe/branches/tooling/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CMakeLists.txt?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/CMakeLists.txt Tue Apr 17 06:08:26 2012
@@ -15,5 +15,4 @@
 add_subdirectory(Frontend)
 add_subdirectory(FrontendTool)
 add_subdirectory(Tooling)
-add_subdirectory(Index)
 add_subdirectory(StaticAnalyzer)

Modified: cfe/branches/tooling/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/BackendUtil.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/BackendUtil.cpp Tue Apr 17 06:08:26 2012
@@ -344,6 +344,7 @@
   Options.RealignStack = CodeGenOpts.StackRealignment;
   Options.DisableTailCalls = CodeGenOpts.DisableTailCalls;
   Options.TrapFuncName = CodeGenOpts.TrapFuncName;
+  Options.PositionIndependentExecutable = LangOpts.PIELevel != 0;
 
   TargetMachine *TM = TheTarget->createTargetMachine(Triple, TargetOpts.CPU,
                                                      FeaturesStr, Options,
@@ -382,7 +383,8 @@
   // Add ObjC ARC final-cleanup optimizations. This is done as part of the
   // "codegen" passes so that it isn't run multiple times when there is
   // inlining happening.
-  if (LangOpts.ObjCAutoRefCount)
+  if (LangOpts.ObjCAutoRefCount &&
+      CodeGenOpts.OptimizationLevel > 0)
     PM->add(createObjCARCContractPass());
 
   if (TM->addPassesToEmitFile(*PM, OS, CGFT,

Modified: cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp Tue Apr 17 06:08:26 2012
@@ -1208,7 +1208,7 @@
                                           SC_Static,
                                           SC_None,
                                           false,
-                                          true);
+                                          false);
   StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation());
 
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
@@ -1323,7 +1323,7 @@
                                           SourceLocation(), II, C.VoidTy, 0,
                                           SC_Static,
                                           SC_None,
-                                          false, true);
+                                          false, false);
   StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation());
 
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
@@ -1601,7 +1601,7 @@
                                           SourceLocation(), II, R, 0,
                                           SC_Static,
                                           SC_None,
-                                          false, true);
+                                          false, false);
 
   CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation());
 
@@ -1672,7 +1672,7 @@
                                           SourceLocation(), II, R, 0,
                                           SC_Static,
                                           SC_None,
-                                          false, true);
+                                          false, false);
   CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation());
 
   if (byrefInfo.needsDispose()) {
@@ -1850,7 +1850,8 @@
   // int32_t __size;
   types.push_back(Int32Ty);
 
-  bool HasCopyAndDispose = getContext().BlockRequiresCopying(Ty);
+  bool HasCopyAndDispose =
+       (Ty->isObjCRetainableType()) || getContext().getBlockVarCopyInits(D);
   if (HasCopyAndDispose) {
     /// void *__copy_helper;
     types.push_back(Int8PtrTy);

Modified: cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGBuiltin.cpp Tue Apr 17 06:08:26 2012
@@ -966,10 +966,186 @@
     return RValue::get(0);
   }
 
+  case Builtin::BI__c11_atomic_is_lock_free:
+  case Builtin::BI__atomic_is_lock_free: {
+    // Call "bool __atomic_is_lock_free(size_t size, void *ptr)". For the
+    // __c11 builtin, ptr is 0 (indicating a properly-aligned object), since
+    // _Atomic(T) is always properly-aligned.
+    const char *LibCallName = "__atomic_is_lock_free";
+    CallArgList Args;
+    Args.add(RValue::get(EmitScalarExpr(E->getArg(0))),
+             getContext().getSizeType());
+    if (BuiltinID == Builtin::BI__atomic_is_lock_free)
+      Args.add(RValue::get(EmitScalarExpr(E->getArg(1))),
+               getContext().VoidPtrTy);
+    else
+      Args.add(RValue::get(llvm::Constant::getNullValue(VoidPtrTy)),
+               getContext().VoidPtrTy);
+    const CGFunctionInfo &FuncInfo =
+        CGM.getTypes().arrangeFunctionCall(E->getType(), Args,
+                                           FunctionType::ExtInfo(),
+                                           RequiredArgs::All);
+    llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(FuncInfo);
+    llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, LibCallName);
+    return EmitCall(FuncInfo, Func, ReturnValueSlot(), Args);
+  }
+
+  case Builtin::BI__atomic_test_and_set: {
+    // Look at the argument type to determine whether this is a volatile
+    // operation. The parameter type is always volatile.
+    QualType PtrTy = E->getArg(0)->IgnoreImpCasts()->getType();
+    bool Volatile =
+        PtrTy->castAs<PointerType>()->getPointeeType().isVolatileQualified();
+
+    Value *Ptr = EmitScalarExpr(E->getArg(0));
+    unsigned AddrSpace =
+        cast<llvm::PointerType>(Ptr->getType())->getAddressSpace();
+    Ptr = Builder.CreateBitCast(Ptr, Int8Ty->getPointerTo(AddrSpace));
+    Value *NewVal = Builder.getInt8(1);
+    Value *Order = EmitScalarExpr(E->getArg(1));
+    if (isa<llvm::ConstantInt>(Order)) {
+      int ord = cast<llvm::ConstantInt>(Order)->getZExtValue();
+      AtomicRMWInst *Result = 0;
+      switch (ord) {
+      case 0:  // memory_order_relaxed
+      default: // invalid order
+        Result = Builder.CreateAtomicRMW(llvm::AtomicRMWInst::Xchg,
+                                         Ptr, NewVal,
+                                         llvm::Monotonic);
+        break;
+      case 1:  // memory_order_consume
+      case 2:  // memory_order_acquire
+        Result = Builder.CreateAtomicRMW(llvm::AtomicRMWInst::Xchg,
+                                         Ptr, NewVal,
+                                         llvm::Acquire);
+        break;
+      case 3:  // memory_order_release
+        Result = Builder.CreateAtomicRMW(llvm::AtomicRMWInst::Xchg,
+                                         Ptr, NewVal,
+                                         llvm::Release);
+        break;
+      case 4:  // memory_order_acq_rel
+        Result = Builder.CreateAtomicRMW(llvm::AtomicRMWInst::Xchg,
+                                         Ptr, NewVal,
+                                         llvm::AcquireRelease);
+        break;
+      case 5:  // memory_order_seq_cst
+        Result = Builder.CreateAtomicRMW(llvm::AtomicRMWInst::Xchg,
+                                         Ptr, NewVal,
+                                         llvm::SequentiallyConsistent);
+        break;
+      }
+      Result->setVolatile(Volatile);
+      return RValue::get(Builder.CreateIsNotNull(Result, "tobool"));
+    }
+
+    llvm::BasicBlock *ContBB = createBasicBlock("atomic.continue", CurFn);
+
+    llvm::BasicBlock *BBs[5] = {
+      createBasicBlock("monotonic", CurFn),
+      createBasicBlock("acquire", CurFn),
+      createBasicBlock("release", CurFn),
+      createBasicBlock("acqrel", CurFn),
+      createBasicBlock("seqcst", CurFn)
+    };
+    llvm::AtomicOrdering Orders[5] = {
+      llvm::Monotonic, llvm::Acquire, llvm::Release,
+      llvm::AcquireRelease, llvm::SequentiallyConsistent
+    };
+
+    Order = Builder.CreateIntCast(Order, Builder.getInt32Ty(), false);
+    llvm::SwitchInst *SI = Builder.CreateSwitch(Order, BBs[0]);
+
+    Builder.SetInsertPoint(ContBB);
+    PHINode *Result = Builder.CreatePHI(Int8Ty, 5, "was_set");
+
+    for (unsigned i = 0; i < 5; ++i) {
+      Builder.SetInsertPoint(BBs[i]);
+      AtomicRMWInst *RMW = Builder.CreateAtomicRMW(llvm::AtomicRMWInst::Xchg,
+                                                   Ptr, NewVal, Orders[i]);
+      RMW->setVolatile(Volatile);
+      Result->addIncoming(RMW, BBs[i]);
+      Builder.CreateBr(ContBB);
+    }
+
+    SI->addCase(Builder.getInt32(0), BBs[0]);
+    SI->addCase(Builder.getInt32(1), BBs[1]);
+    SI->addCase(Builder.getInt32(2), BBs[1]);
+    SI->addCase(Builder.getInt32(3), BBs[2]);
+    SI->addCase(Builder.getInt32(4), BBs[3]);
+    SI->addCase(Builder.getInt32(5), BBs[4]);
+
+    Builder.SetInsertPoint(ContBB);
+    return RValue::get(Builder.CreateIsNotNull(Result, "tobool"));
+  }
+
+  case Builtin::BI__atomic_clear: {
+    QualType PtrTy = E->getArg(0)->IgnoreImpCasts()->getType();
+    bool Volatile =
+        PtrTy->castAs<PointerType>()->getPointeeType().isVolatileQualified();
+
+    Value *Ptr = EmitScalarExpr(E->getArg(0));
+    unsigned AddrSpace =
+        cast<llvm::PointerType>(Ptr->getType())->getAddressSpace();
+    Ptr = Builder.CreateBitCast(Ptr, Int8Ty->getPointerTo(AddrSpace));
+    Value *NewVal = Builder.getInt8(0);
+    Value *Order = EmitScalarExpr(E->getArg(1));
+    if (isa<llvm::ConstantInt>(Order)) {
+      int ord = cast<llvm::ConstantInt>(Order)->getZExtValue();
+      StoreInst *Store = Builder.CreateStore(NewVal, Ptr, Volatile);
+      Store->setAlignment(1);
+      switch (ord) {
+      case 0:  // memory_order_relaxed
+      default: // invalid order
+        Store->setOrdering(llvm::Monotonic);
+        break;
+      case 3:  // memory_order_release
+        Store->setOrdering(llvm::Release);
+        break;
+      case 5:  // memory_order_seq_cst
+        Store->setOrdering(llvm::SequentiallyConsistent);
+        break;
+      }
+      return RValue::get(0);
+    }
+
+    llvm::BasicBlock *ContBB = createBasicBlock("atomic.continue", CurFn);
+
+    llvm::BasicBlock *BBs[3] = {
+      createBasicBlock("monotonic", CurFn),
+      createBasicBlock("release", CurFn),
+      createBasicBlock("seqcst", CurFn)
+    };
+    llvm::AtomicOrdering Orders[3] = {
+      llvm::Monotonic, llvm::Release, llvm::SequentiallyConsistent
+    };
+
+    Order = Builder.CreateIntCast(Order, Builder.getInt32Ty(), false);
+    llvm::SwitchInst *SI = Builder.CreateSwitch(Order, BBs[0]);
+
+    for (unsigned i = 0; i < 3; ++i) {
+      Builder.SetInsertPoint(BBs[i]);
+      StoreInst *Store = Builder.CreateStore(NewVal, Ptr, Volatile);
+      Store->setAlignment(1);
+      Store->setOrdering(Orders[i]);
+      Builder.CreateBr(ContBB);
+    }
+
+    SI->addCase(Builder.getInt32(0), BBs[0]);
+    SI->addCase(Builder.getInt32(3), BBs[1]);
+    SI->addCase(Builder.getInt32(5), BBs[2]);
+
+    Builder.SetInsertPoint(ContBB);
+    return RValue::get(0);
+  }
+
   case Builtin::BI__atomic_thread_fence:
-  case Builtin::BI__atomic_signal_fence: {
+  case Builtin::BI__atomic_signal_fence:
+  case Builtin::BI__c11_atomic_thread_fence:
+  case Builtin::BI__c11_atomic_signal_fence: {
     llvm::SynchronizationScope Scope;
-    if (BuiltinID == Builtin::BI__atomic_signal_fence)
+    if (BuiltinID == Builtin::BI__atomic_signal_fence ||
+        BuiltinID == Builtin::BI__c11_atomic_signal_fence)
       Scope = llvm::SingleThread;
     else
       Scope = llvm::CrossThread;

Modified: cfe/branches/tooling/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGCall.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGCall.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGCall.cpp Tue Apr 17 06:08:26 2012
@@ -419,16 +419,37 @@
     uint64_t NumElts = AT->getSize().getZExtValue();
     for (uint64_t Elt = 0; Elt < NumElts; ++Elt)
       GetExpandedTypes(AT->getElementType(), expandedTypes);
-  } else if (const RecordType *RT = type->getAsStructureType()) {
+  } else if (const RecordType *RT = type->getAs<RecordType>()) {
     const RecordDecl *RD = RT->getDecl();
     assert(!RD->hasFlexibleArrayMember() &&
            "Cannot expand structure with flexible array.");
-    for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
-         i != e; ++i) {
-      const FieldDecl *FD = *i;
-      assert(!FD->isBitField() &&
-             "Cannot expand structure with bit-field members.");
-      GetExpandedTypes(FD->getType(), expandedTypes);
+    if (RD->isUnion()) {
+      // Unions can be here only in degenerative cases - all the fields are same
+      // after flattening. Thus we have to use the "largest" field.
+      const FieldDecl *LargestFD = 0;
+      CharUnits UnionSize = CharUnits::Zero();
+
+      for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
+           i != e; ++i) {
+        const FieldDecl *FD = *i;
+        assert(!FD->isBitField() &&
+               "Cannot expand structure with bit-field members.");
+        CharUnits FieldSize = getContext().getTypeSizeInChars(FD->getType());
+        if (UnionSize < FieldSize) {
+          UnionSize = FieldSize;
+          LargestFD = FD;
+        }
+      }
+      if (LargestFD)
+        GetExpandedTypes(LargestFD->getType(), expandedTypes);
+    } else {
+      for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
+           i != e; ++i) {
+        const FieldDecl *FD = *i;
+        assert(!FD->isBitField() &&
+               "Cannot expand structure with bit-field members.");
+        GetExpandedTypes(FD->getType(), expandedTypes);
+      }
     }
   } else if (const ComplexType *CT = type->getAs<ComplexType>()) {
     llvm::Type *EltTy = ConvertType(CT->getElementType());
@@ -453,16 +474,40 @@
       LValue LV = MakeAddrLValue(EltAddr, EltTy);
       AI = ExpandTypeFromArgs(EltTy, LV, AI);
     }
-  } else if (const RecordType *RT = Ty->getAsStructureType()) {
+  } else if (const RecordType *RT = Ty->getAs<RecordType>()) {
     RecordDecl *RD = RT->getDecl();
-    for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
-         i != e; ++i) {
-      FieldDecl *FD = *i;
-      QualType FT = FD->getType();
-
-      // FIXME: What are the right qualifiers here?
-      LValue LV = EmitLValueForField(Addr, FD, 0);
-      AI = ExpandTypeFromArgs(FT, LV, AI);
+    if (RD->isUnion()) {
+      // Unions can be here only in degenerative cases - all the fields are same
+      // after flattening. Thus we have to use the "largest" field.
+      const FieldDecl *LargestFD = 0;
+      CharUnits UnionSize = CharUnits::Zero();
+
+      for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
+           i != e; ++i) {
+        const FieldDecl *FD = *i;
+        assert(!FD->isBitField() &&
+               "Cannot expand structure with bit-field members.");
+        CharUnits FieldSize = getContext().getTypeSizeInChars(FD->getType());
+        if (UnionSize < FieldSize) {
+          UnionSize = FieldSize;
+          LargestFD = FD;
+        }
+      }
+      if (LargestFD) {
+        // FIXME: What are the right qualifiers here?
+        LValue LV = EmitLValueForField(Addr, LargestFD, 0);
+        AI = ExpandTypeFromArgs(LargestFD->getType(), LV, AI);
+      }
+    } else {
+      for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
+           i != e; ++i) {
+        FieldDecl *FD = *i;
+        QualType FT = FD->getType();
+
+        // FIXME: What are the right qualifiers here?
+        LValue LV = EmitLValueForField(Addr, FD, 0);
+        AI = ExpandTypeFromArgs(FT, LV, AI);
+      }
     }
   } else if (const ComplexType *CT = Ty->getAs<ComplexType>()) {
     QualType EltTy = CT->getElementType();
@@ -1760,26 +1805,38 @@
         EltRV = EmitLoadOfLValue(LV);
       ExpandTypeToArgs(EltTy, EltRV, Args, IRFuncTy);
     }
-  } else if (const RecordType *RT = Ty->getAsStructureType()) {
+  } else if (const RecordType *RT = Ty->getAs<RecordType>()) {
     RecordDecl *RD = RT->getDecl();
     assert(RV.isAggregate() && "Unexpected rvalue during struct expansion");
     llvm::Value *Addr = RV.getAggregateAddr();
-    for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
-         i != e; ++i) {
-      FieldDecl *FD = *i;
-      QualType FT = FD->getType();
-    
-      // FIXME: What are the right qualifiers here?
-      LValue LV = EmitLValueForField(Addr, FD, 0);
-      RValue FldRV;
-      if (FT->isAnyComplexType())
-        // FIXME: Volatile?
-        FldRV = RValue::getComplex(LoadComplexFromAddr(LV.getAddress(), false));
-      else if (CodeGenFunction::hasAggregateLLVMType(FT))
-        FldRV = LV.asAggregateRValue();
-      else
-        FldRV = EmitLoadOfLValue(LV);
-      ExpandTypeToArgs(FT, FldRV, Args, IRFuncTy);
+
+    if (RD->isUnion()) {
+      const FieldDecl *LargestFD = 0;
+      CharUnits UnionSize = CharUnits::Zero();
+
+      for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
+           i != e; ++i) {
+        const FieldDecl *FD = *i;
+        assert(!FD->isBitField() &&
+               "Cannot expand structure with bit-field members.");
+        CharUnits FieldSize = getContext().getTypeSizeInChars(FD->getType());
+        if (UnionSize < FieldSize) {
+          UnionSize = FieldSize;
+          LargestFD = FD;
+        }
+      }
+      if (LargestFD) {
+        RValue FldRV = EmitRValueForField(Addr, LargestFD);
+        ExpandTypeToArgs(LargestFD->getType(), FldRV, Args, IRFuncTy);
+      }
+    } else {
+      for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
+           i != e; ++i) {
+        FieldDecl *FD = *i;
+
+        RValue FldRV = EmitRValueForField(Addr, FD);
+        ExpandTypeToArgs(FD->getType(), FldRV, Args, IRFuncTy);
+      }
     }
   } else if (Ty->isAnyComplexType()) {
     ComplexPairTy CV = RV.getComplexVal();

Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp Tue Apr 17 06:08:26 2012
@@ -1181,6 +1181,15 @@
   return T;
 }
 
+/// getOrCreateInterfaceType - Emit an objective c interface type standalone
+/// debug info.
+llvm::DIType CGDebugInfo::getOrCreateInterfaceType(QualType D,
+						   SourceLocation Loc) {
+  llvm::DIType T = getOrCreateType(D, getOrCreateFile(Loc));
+  DBuilder.retainType(T);
+  return T;
+}
+
 /// CreateType - get structure or union type.
 llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty) {
   RecordDecl *RD = Ty->getDecl();
@@ -1282,6 +1291,7 @@
 				 RuntimeLang);
     return FwdDecl;
   }
+
   ID = Def;
 
   // Bit size, align and offset of the type.
@@ -1296,7 +1306,7 @@
     DBuilder.createStructType(Unit, ID->getName(), DefUnit,
                               Line, Size, Align, Flags,
                               llvm::DIArray(), RuntimeLang);
-  
+
   // 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;
@@ -1327,10 +1337,14 @@
     SourceLocation Loc = PD->getLocation();
     llvm::DIFile PUnit = getOrCreateFile(Loc);
     unsigned PLine = getLineNumber(Loc);
+    ObjCMethodDecl *Getter = PD->getGetterMethodDecl();
+    ObjCMethodDecl *Setter = PD->getSetterMethodDecl();
     llvm::MDNode *PropertyNode =
       DBuilder.createObjCProperty(PD->getName(),
 				  PUnit, PLine,
+                                  (Getter && Getter->isImplicit()) ? "" :
                                   getSelectorName(PD->getGetterName()),
+                                  (Setter && Setter->isImplicit()) ? "" :
                                   getSelectorName(PD->getSetterName()),
                                   PD->getPropertyAttributes(),
 				  getOrCreateType(PD->getType(), PUnit));
@@ -1388,13 +1402,17 @@
 	  SourceLocation Loc = PD->getLocation();
 	  llvm::DIFile PUnit = getOrCreateFile(Loc);
 	  unsigned PLine = getLineNumber(Loc);
-	  PropertyNode =
-	    DBuilder.createObjCProperty(PD->getName(),
-					PUnit, PLine,
+          ObjCMethodDecl *Getter = PD->getGetterMethodDecl();
+          ObjCMethodDecl *Setter = PD->getSetterMethodDecl();
+          PropertyNode =
+            DBuilder.createObjCProperty(PD->getName(),
+                                        PUnit, PLine,
+                                        (Getter && Getter->isImplicit()) ? "" :
                                         getSelectorName(PD->getGetterName()),
+                                        (Setter && Setter->isImplicit()) ? "" :
                                         getSelectorName(PD->getSetterName()),
-					PD->getPropertyAttributes(),
-					getOrCreateType(PD->getType(),PUnit));
+                                        PD->getPropertyAttributes(),
+                                        getOrCreateType(PD->getType(), PUnit));
         }
       }
     }
@@ -1991,12 +2009,13 @@
     }
     Name = getFunctionName(FD);
     // Use mangled name as linkage name for c/c++ functions.
-    if (!Fn->hasInternalLinkage())
+    if (FD->hasPrototype()) {
       LinkageName = CGM.getMangledName(GD);
+      Flags |= llvm::DIDescriptor::FlagPrototyped;
+    }
     if (LinkageName == Name)
       LinkageName = StringRef();
-    if (FD->hasPrototype())
-      Flags |= llvm::DIDescriptor::FlagPrototyped;
+
     if (const NamespaceDecl *NSDecl =
         dyn_cast_or_null<NamespaceDecl>(FD->getDeclContext()))
       FDContext = getOrCreateNameSpace(NSDecl);

Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h Tue Apr 17 06:08:26 2012
@@ -226,6 +226,12 @@
 
   /// getOrCreateRecordType - Emit record type's standalone debug info. 
   llvm::DIType getOrCreateRecordType(QualType Ty, SourceLocation L);
+
+  /// getOrCreateInterfaceType - Emit an objective c interface type standalone
+  /// debug info.
+  llvm::DIType getOrCreateInterfaceType(QualType Ty,
+					SourceLocation Loc);
+
 private:
   /// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
   void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,

Modified: cfe/branches/tooling/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDeclCXX.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDeclCXX.cpp Tue Apr 17 06:08:26 2012
@@ -145,37 +145,110 @@
   EmitStoreOfScalar(RV.getScalarVal(), DeclPtr, false, Alignment, T);
 }
 
-void
-CodeGenFunction::EmitCXXGlobalDtorRegistration(llvm::Constant *DtorFn,
-                                               llvm::Constant *DeclPtr) {
-  // Generate a global destructor entry if not using __cxa_atexit.
-  if (!CGM.getCodeGenOpts().CXAAtExit) {
-    CGM.AddCXXDtorEntry(DtorFn, DeclPtr);
+/// Register a global destructor using __cxa_atexit.
+static void emitGlobalDtorWithCXAAtExit(CodeGenFunction &CGF,
+                                        llvm::Constant *dtor,
+                                        llvm::Constant *addr) {
+  // We're assuming that the destructor function is something we can
+  // reasonably call with the default CC.  Go ahead and cast it to the
+  // right prototype.
+  llvm::Type *dtorTy =
+    llvm::FunctionType::get(CGF.VoidTy, CGF.Int8PtrTy, false)->getPointerTo();
+
+  // extern "C" int __cxa_atexit(void (*f)(void *), void *p, void *d);
+  llvm::Type *paramTys[] = { dtorTy, CGF.Int8PtrTy, CGF.Int8PtrTy };
+  llvm::FunctionType *atexitTy =
+    llvm::FunctionType::get(CGF.IntTy, paramTys, false);
+
+  // Fetch the actual function.
+  llvm::Constant *atexit =
+    CGF.CGM.CreateRuntimeFunction(atexitTy, "__cxa_atexit");
+  if (llvm::Function *fn = dyn_cast<llvm::Function>(atexit))
+    fn->setDoesNotThrow();
+
+  // Create a variable that binds the atexit to this shared object.
+  llvm::Constant *handle =
+    CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+
+  llvm::Value *args[] = {
+    llvm::ConstantExpr::getBitCast(dtor, dtorTy),
+    llvm::ConstantExpr::getBitCast(addr, CGF.Int8PtrTy),
+    handle
+  };
+  CGF.Builder.CreateCall(atexit, args);
+}
+
+static llvm::Function *
+CreateGlobalInitOrDestructFunction(CodeGenModule &CGM,
+                                   llvm::FunctionType *ty,
+                                   const Twine &name);
+
+/// Create a stub function, suitable for being passed to atexit,
+/// which passes the given address to the given destructor function.
+static llvm::Constant *createAtExitStub(CodeGenModule &CGM,
+                                        llvm::Constant *dtor,
+                                        llvm::Constant *addr) {
+  // Get the destructor function type, void(*)(void).
+  llvm::FunctionType *ty = llvm::FunctionType::get(CGM.VoidTy, false);
+  llvm::Function *fn =
+    CreateGlobalInitOrDestructFunction(CGM, ty,
+                                       Twine("__dtor_", addr->getName()));
+
+  CodeGenFunction CGF(CGM);
+
+  CGF.StartFunction(GlobalDecl(), CGM.getContext().VoidTy, fn,
+                    CGM.getTypes().arrangeNullaryFunction(),
+                    FunctionArgList(), SourceLocation());
+
+  llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
+ 
+ // Make sure the call and the callee agree on calling convention.
+  if (llvm::Function *dtorFn =
+        dyn_cast<llvm::Function>(dtor->stripPointerCasts()))
+    call->setCallingConv(dtorFn->getCallingConv());
+
+  CGF.FinishFunction();
+
+  return fn;
+}
+
+/// Register a global destructor using atexit.
+static void emitGlobalDtorWithAtExit(CodeGenFunction &CGF,
+                                     llvm::Constant *dtor,
+                                     llvm::Constant *addr) {
+  // Create a function which calls the destructor.
+  llvm::Constant *dtorStub = createAtExitStub(CGF.CGM, dtor, addr);
+
+  // extern "C" int atexit(void (*f)(void));
+  llvm::FunctionType *atexitTy =
+    llvm::FunctionType::get(CGF.IntTy, dtorStub->getType(), false);
+
+  llvm::Constant *atexit =
+    CGF.CGM.CreateRuntimeFunction(atexitTy, "atexit");
+  if (llvm::Function *atexitFn = dyn_cast<llvm::Function>(atexit))
+    atexitFn->setDoesNotThrow();
+
+  CGF.Builder.CreateCall(atexit, dtorStub);
+}
+
+void CodeGenFunction::EmitCXXGlobalDtorRegistration(llvm::Constant *dtor,
+                                                    llvm::Constant *addr) {
+  // Use __cxa_atexit if available.
+  if (CGM.getCodeGenOpts().CXAAtExit) {
+    emitGlobalDtorWithCXAAtExit(*this, dtor, addr);
     return;
   }
 
-  // Get the destructor function type
-  llvm::Type *DtorFnTy = llvm::FunctionType::get(VoidTy, Int8PtrTy, false);
-  DtorFnTy = llvm::PointerType::getUnqual(DtorFnTy);
-
-  llvm::Type *Params[] = { DtorFnTy, Int8PtrTy, Int8PtrTy };
-
-  // Get the __cxa_atexit function type
-  // extern "C" int __cxa_atexit ( void (*f)(void *), void *p, void *d );
-  llvm::FunctionType *AtExitFnTy =
-    llvm::FunctionType::get(ConvertType(getContext().IntTy), Params, false);
-
-  llvm::Constant *AtExitFn = CGM.CreateRuntimeFunction(AtExitFnTy,
-                                                       "__cxa_atexit");
-  if (llvm::Function *Fn = dyn_cast<llvm::Function>(AtExitFn))
-    Fn->setDoesNotThrow();
+  // In Apple kexts, we want to add a global destructor entry.
+  // FIXME: shouldn't this be guarded by some variable?
+  if (CGM.getContext().getLangOpts().AppleKext) {
+    // Generate a global destructor entry.
+    CGM.AddCXXDtorEntry(dtor, addr);
+    return;
+  }
 
-  llvm::Constant *Handle = CGM.CreateRuntimeVariable(Int8PtrTy,
-                                                     "__dso_handle");
-  llvm::Value *Args[3] = { llvm::ConstantExpr::getBitCast(DtorFn, DtorFnTy),
-                           llvm::ConstantExpr::getBitCast(DeclPtr, Int8PtrTy),
-                           llvm::ConstantExpr::getBitCast(Handle, Int8PtrTy) };
-  Builder.CreateCall(AtExitFn, Args);
+  // Otherwise, we just use atexit.
+  emitGlobalDtorWithAtExit(*this, dtor, addr);
 }
 
 void CodeGenFunction::EmitCXXGuardedInit(const VarDecl &D,
@@ -290,7 +363,7 @@
   llvm::Function *Fn =
     CreateGlobalInitOrDestructFunction(*this, FTy, "_GLOBAL__D_a");
 
-  CodeGenFunction(*this).GenerateCXXGlobalDtorFunc(Fn, CXXGlobalDtors);
+  CodeGenFunction(*this).GenerateCXXGlobalDtorsFunc(Fn, CXXGlobalDtors);
   AddGlobalDtor(Fn);
 }
 
@@ -341,7 +414,7 @@
   FinishFunction();
 }
 
-void CodeGenFunction::GenerateCXXGlobalDtorFunc(llvm::Function *Fn,
+void CodeGenFunction::GenerateCXXGlobalDtorsFunc(llvm::Function *Fn,
                   const std::vector<std::pair<llvm::WeakVH, llvm::Constant*> >
                                                 &DtorsAndObjects) {
   StartFunction(GlobalDecl(), getContext().VoidTy, Fn,

Modified: cfe/branches/tooling/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExpr.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExpr.cpp Tue Apr 17 06:08:26 2012
@@ -867,6 +867,9 @@
   if (const EnumType *ET = Ty->getAs<EnumType>())
     return ET->getDecl()->getIntegerType()->isBooleanType();
 
+  if (const AtomicType *AT = Ty->getAs<AtomicType>())
+    return hasBooleanRepresentation(AT->getValueType());
+
   return false;
 }
 
@@ -1227,7 +1230,7 @@
   // Get the source value, truncated to the width of the bit-field.
   llvm::Value *SrcVal = Src.getScalarVal();
 
-  if (Dst.getType()->isBooleanType())
+  if (hasBooleanRepresentation(Dst.getType()))
     SrcVal = Builder.CreateIntCast(SrcVal, ResLTy, /*IsSigned=*/false);
 
   SrcVal = Builder.CreateAnd(SrcVal, llvm::APInt::getLowBitsSet(ResSizeInBits,
@@ -2375,6 +2378,19 @@
   return MakeAddrLValue(RV.getScalarVal(), E->getType());
 }
 
+RValue CodeGenFunction::EmitRValueForField(llvm::Value *Addr,
+                                           const FieldDecl *FD) {
+  QualType FT = FD->getType();
+  // FIXME: What are the right qualifiers here?
+  LValue LV = EmitLValueForField(Addr, FD, 0);
+  if (FT->isAnyComplexType())
+    // FIXME: Volatile?
+    return RValue::getComplex(LoadComplexFromAddr(LV.getAddress(), false));
+  else if (CodeGenFunction::hasAggregateLLVMType(FT))
+    return LV.asAggregateRValue();
+
+  return EmitLoadOfLValue(LV);
+}
 
 //===--------------------------------------------------------------------===//
 //                             Expression Emission
@@ -2688,7 +2704,17 @@
 EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, llvm::Value *Dest,
              llvm::Value *Ptr, llvm::Value *Val1, llvm::Value *Val2,
              uint64_t Size, unsigned Align, llvm::AtomicOrdering Order) {
-  if (E->isCmpXChg()) {
+  llvm::AtomicRMWInst::BinOp Op = llvm::AtomicRMWInst::Add;
+  llvm::Instruction::BinaryOps PostOp = (llvm::Instruction::BinaryOps)0;
+
+  switch (E->getOp()) {
+  case AtomicExpr::AO__c11_atomic_init:
+    llvm_unreachable("Already handled!");
+
+  case AtomicExpr::AO__c11_atomic_compare_exchange_strong:
+  case AtomicExpr::AO__c11_atomic_compare_exchange_weak:
+  case AtomicExpr::AO__atomic_compare_exchange:
+  case AtomicExpr::AO__atomic_compare_exchange_n: {
     // Note that cmpxchg only supports specifying one ordering and
     // doesn't support weak cmpxchg, at least at the moment.
     llvm::LoadInst *LoadVal1 = CGF.Builder.CreateLoad(Val1);
@@ -2705,7 +2731,9 @@
     return;
   }
 
-  if (E->getOp() == AtomicExpr::Load) {
+  case AtomicExpr::AO__c11_atomic_load:
+  case AtomicExpr::AO__atomic_load_n:
+  case AtomicExpr::AO__atomic_load: {
     llvm::LoadInst *Load = CGF.Builder.CreateLoad(Ptr);
     Load->setAtomic(Order);
     Load->setAlignment(Size);
@@ -2715,7 +2743,9 @@
     return;
   }
 
-  if (E->getOp() == AtomicExpr::Store) {
+  case AtomicExpr::AO__c11_atomic_store:
+  case AtomicExpr::AO__atomic_store:
+  case AtomicExpr::AO__atomic_store_n: {
     assert(!Dest && "Store does not return a value");
     llvm::LoadInst *LoadVal1 = CGF.Builder.CreateLoad(Val1);
     LoadVal1->setAlignment(Align);
@@ -2726,26 +2756,74 @@
     return;
   }
 
-  llvm::AtomicRMWInst::BinOp Op = llvm::AtomicRMWInst::Add;
-  switch (E->getOp()) {
-    case AtomicExpr::CmpXchgWeak:
-    case AtomicExpr::CmpXchgStrong:
-    case AtomicExpr::Store:
-    case AtomicExpr::Init:
-    case AtomicExpr::Load:  assert(0 && "Already handled!");
-    case AtomicExpr::Add:   Op = llvm::AtomicRMWInst::Add;  break;
-    case AtomicExpr::Sub:   Op = llvm::AtomicRMWInst::Sub;  break;
-    case AtomicExpr::And:   Op = llvm::AtomicRMWInst::And;  break;
-    case AtomicExpr::Or:    Op = llvm::AtomicRMWInst::Or;   break;
-    case AtomicExpr::Xor:   Op = llvm::AtomicRMWInst::Xor;  break;
-    case AtomicExpr::Xchg:  Op = llvm::AtomicRMWInst::Xchg; break;
+  case AtomicExpr::AO__c11_atomic_exchange:
+  case AtomicExpr::AO__atomic_exchange_n:
+  case AtomicExpr::AO__atomic_exchange:
+    Op = llvm::AtomicRMWInst::Xchg;
+    break;
+
+  case AtomicExpr::AO__atomic_add_fetch:
+    PostOp = llvm::Instruction::Add;
+    // Fall through.
+  case AtomicExpr::AO__c11_atomic_fetch_add:
+  case AtomicExpr::AO__atomic_fetch_add:
+    Op = llvm::AtomicRMWInst::Add;
+    break;
+
+  case AtomicExpr::AO__atomic_sub_fetch:
+    PostOp = llvm::Instruction::Sub;
+    // Fall through.
+  case AtomicExpr::AO__c11_atomic_fetch_sub:
+  case AtomicExpr::AO__atomic_fetch_sub:
+    Op = llvm::AtomicRMWInst::Sub;
+    break;
+
+  case AtomicExpr::AO__atomic_and_fetch:
+    PostOp = llvm::Instruction::And;
+    // Fall through.
+  case AtomicExpr::AO__c11_atomic_fetch_and:
+  case AtomicExpr::AO__atomic_fetch_and:
+    Op = llvm::AtomicRMWInst::And;
+    break;
+
+  case AtomicExpr::AO__atomic_or_fetch:
+    PostOp = llvm::Instruction::Or;
+    // Fall through.
+  case AtomicExpr::AO__c11_atomic_fetch_or:
+  case AtomicExpr::AO__atomic_fetch_or:
+    Op = llvm::AtomicRMWInst::Or;
+    break;
+
+  case AtomicExpr::AO__atomic_xor_fetch:
+    PostOp = llvm::Instruction::Xor;
+    // Fall through.
+  case AtomicExpr::AO__c11_atomic_fetch_xor:
+  case AtomicExpr::AO__atomic_fetch_xor:
+    Op = llvm::AtomicRMWInst::Xor;
+    break;
+
+  case AtomicExpr::AO__atomic_nand_fetch:
+    PostOp = llvm::Instruction::And;
+    // Fall through.
+  case AtomicExpr::AO__atomic_fetch_nand:
+    Op = llvm::AtomicRMWInst::Nand;
+    break;
   }
+
   llvm::LoadInst *LoadVal1 = CGF.Builder.CreateLoad(Val1);
   LoadVal1->setAlignment(Align);
   llvm::AtomicRMWInst *RMWI =
       CGF.Builder.CreateAtomicRMW(Op, Ptr, LoadVal1, Order);
   RMWI->setVolatile(E->isVolatile());
-  llvm::StoreInst *StoreDest = CGF.Builder.CreateStore(RMWI, Dest);
+
+  // For __atomic_*_fetch operations, perform the operation again to
+  // determine the value which was written.
+  llvm::Value *Result = RMWI;
+  if (PostOp)
+    Result = CGF.Builder.CreateBinOp(PostOp, RMWI, LoadVal1);
+  if (E->getOp() == AtomicExpr::AO__atomic_nand_fetch)
+    Result = CGF.Builder.CreateNot(Result);
+  llvm::StoreInst *StoreDest = CGF.Builder.CreateStore(Result, Dest);
   StoreDest->setAlignment(Align);
 }
 
@@ -2770,7 +2848,9 @@
 
 RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) {
   QualType AtomicTy = E->getPtr()->getType()->getPointeeType();
-  QualType MemTy = AtomicTy->getAs<AtomicType>()->getValueType();
+  QualType MemTy = AtomicTy;
+  if (const AtomicType *AT = AtomicTy->getAs<AtomicType>())
+    MemTy = AT->getValueType();
   CharUnits sizeChars = getContext().getTypeSizeInChars(AtomicTy);
   uint64_t Size = sizeChars.getQuantity();
   CharUnits alignChars = getContext().getTypeAlignInChars(AtomicTy);
@@ -2784,36 +2864,106 @@
   llvm::Value *Ptr, *Order, *OrderFail = 0, *Val1 = 0, *Val2 = 0;
   Ptr = EmitScalarExpr(E->getPtr());
 
-  if (E->getOp() == AtomicExpr::Init) {
+  if (E->getOp() == AtomicExpr::AO__c11_atomic_init) {
     assert(!Dest && "Init does not return a value");
-    Val1 = EmitScalarExpr(E->getVal1());
-    llvm::StoreInst *Store = Builder.CreateStore(Val1, Ptr);
-    Store->setAlignment(Size);
-    Store->setVolatile(E->isVolatile());
+    if (!hasAggregateLLVMType(E->getVal1()->getType())) {
+      QualType PointeeType
+        = E->getPtr()->getType()->getAs<PointerType>()->getPointeeType();
+      EmitScalarInit(EmitScalarExpr(E->getVal1()),
+                     LValue::MakeAddr(Ptr, PointeeType, alignChars,
+                                      getContext()));
+    } else if (E->getType()->isAnyComplexType()) {
+      EmitComplexExprIntoAddr(E->getVal1(), Ptr, E->isVolatile());
+    } else {
+      AggValueSlot Slot = AggValueSlot::forAddr(Ptr, alignChars,
+                                        AtomicTy.getQualifiers(),
+                                        AggValueSlot::IsNotDestructed,
+                                        AggValueSlot::DoesNotNeedGCBarriers,
+                                        AggValueSlot::IsNotAliased);
+      EmitAggExpr(E->getVal1(), Slot);
+    }
     return RValue::get(0);
   }
 
   Order = EmitScalarExpr(E->getOrder());
-  if (E->isCmpXChg()) {
+
+  switch (E->getOp()) {
+  case AtomicExpr::AO__c11_atomic_init:
+    llvm_unreachable("Already handled!");
+
+  case AtomicExpr::AO__c11_atomic_load:
+  case AtomicExpr::AO__atomic_load_n:
+    break;
+
+  case AtomicExpr::AO__atomic_load:
+    Dest = EmitScalarExpr(E->getVal1());
+    break;
+
+  case AtomicExpr::AO__atomic_store:
+    Val1 = EmitScalarExpr(E->getVal1());
+    break;
+
+  case AtomicExpr::AO__atomic_exchange:
     Val1 = EmitScalarExpr(E->getVal1());
-    Val2 = EmitValToTemp(*this, E->getVal2());
+    Dest = EmitScalarExpr(E->getVal2());
+    break;
+
+  case AtomicExpr::AO__c11_atomic_compare_exchange_strong:
+  case AtomicExpr::AO__c11_atomic_compare_exchange_weak:
+  case AtomicExpr::AO__atomic_compare_exchange_n:
+  case AtomicExpr::AO__atomic_compare_exchange:
+    Val1 = EmitScalarExpr(E->getVal1());
+    if (E->getOp() == AtomicExpr::AO__atomic_compare_exchange)
+      Val2 = EmitScalarExpr(E->getVal2());
+    else
+      Val2 = EmitValToTemp(*this, E->getVal2());
     OrderFail = EmitScalarExpr(E->getOrderFail());
-  } else if ((E->getOp() == AtomicExpr::Add || E->getOp() == AtomicExpr::Sub) &&
-             MemTy->isPointerType()) {
-    // For pointers, we're required to do a bit of math: adding 1 to an int*
-    // is not the same as adding 1 to a uintptr_t.
-    QualType Val1Ty = E->getVal1()->getType();
-    llvm::Value *Val1Scalar = EmitScalarExpr(E->getVal1());
-    CharUnits PointeeIncAmt =
-        getContext().getTypeSizeInChars(MemTy->getPointeeType());
-    Val1Scalar = Builder.CreateMul(Val1Scalar, CGM.getSize(PointeeIncAmt));
-    Val1 = CreateMemTemp(Val1Ty, ".atomictmp");
-    EmitStoreOfScalar(Val1Scalar, MakeAddrLValue(Val1, Val1Ty));
-  } else if (E->getOp() != AtomicExpr::Load) {
+    // Evaluate and discard the 'weak' argument.
+    if (E->getNumSubExprs() == 6)
+      EmitScalarExpr(E->getWeak());
+    break;
+
+  case AtomicExpr::AO__c11_atomic_fetch_add:
+  case AtomicExpr::AO__c11_atomic_fetch_sub:
+    if (MemTy->isPointerType()) {
+      // For pointer arithmetic, we're required to do a bit of math:
+      // adding 1 to an int* is not the same as adding 1 to a uintptr_t.
+      // ... but only for the C11 builtins. The GNU builtins expect the
+      // user to multiply by sizeof(T).
+      QualType Val1Ty = E->getVal1()->getType();
+      llvm::Value *Val1Scalar = EmitScalarExpr(E->getVal1());
+      CharUnits PointeeIncAmt =
+          getContext().getTypeSizeInChars(MemTy->getPointeeType());
+      Val1Scalar = Builder.CreateMul(Val1Scalar, CGM.getSize(PointeeIncAmt));
+      Val1 = CreateMemTemp(Val1Ty, ".atomictmp");
+      EmitStoreOfScalar(Val1Scalar, MakeAddrLValue(Val1, Val1Ty));
+      break;
+    }
+    // Fall through.
+  case AtomicExpr::AO__atomic_fetch_add:
+  case AtomicExpr::AO__atomic_fetch_sub:
+  case AtomicExpr::AO__atomic_add_fetch:
+  case AtomicExpr::AO__atomic_sub_fetch:
+  case AtomicExpr::AO__c11_atomic_store:
+  case AtomicExpr::AO__c11_atomic_exchange:
+  case AtomicExpr::AO__atomic_store_n:
+  case AtomicExpr::AO__atomic_exchange_n:
+  case AtomicExpr::AO__c11_atomic_fetch_and:
+  case AtomicExpr::AO__c11_atomic_fetch_or:
+  case AtomicExpr::AO__c11_atomic_fetch_xor:
+  case AtomicExpr::AO__atomic_fetch_and:
+  case AtomicExpr::AO__atomic_fetch_or:
+  case AtomicExpr::AO__atomic_fetch_xor:
+  case AtomicExpr::AO__atomic_fetch_nand:
+  case AtomicExpr::AO__atomic_and_fetch:
+  case AtomicExpr::AO__atomic_or_fetch:
+  case AtomicExpr::AO__atomic_xor_fetch:
+  case AtomicExpr::AO__atomic_nand_fetch:
     Val1 = EmitValToTemp(*this, E->getVal1());
+    break;
   }
 
-  if (E->getOp() != AtomicExpr::Store && !Dest)
+  if (!E->getType()->isVoidType() && !Dest)
     Dest = CreateMemTemp(E->getType(), ".atomicdst");
 
   // Use a library call.  See: http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary .
@@ -2835,9 +2985,11 @@
     // optimisation benefit possible from a libcall version of a weak compare
     // and exchange.
     // bool __atomic_compare_exchange(size_t size, void *obj, void *expected,
-     //                               void *desired, int success, int failure)
-    case AtomicExpr::CmpXchgWeak:
-    case AtomicExpr::CmpXchgStrong:
+    //                                void *desired, int success, int failure)
+    case AtomicExpr::AO__c11_atomic_compare_exchange_weak:
+    case AtomicExpr::AO__c11_atomic_compare_exchange_strong:
+    case AtomicExpr::AO__atomic_compare_exchange:
+    case AtomicExpr::AO__atomic_compare_exchange_n:
       LibCallName = "__atomic_compare_exchange";
       RetTy = getContext().BoolTy;
       Args.add(RValue::get(EmitCastToVoidPtr(Val1)),
@@ -2850,7 +3002,9 @@
       break;
     // void __atomic_exchange(size_t size, void *mem, void *val, void *return,
     //                        int order)
-    case AtomicExpr::Xchg:
+    case AtomicExpr::AO__c11_atomic_exchange:
+    case AtomicExpr::AO__atomic_exchange_n:
+    case AtomicExpr::AO__atomic_exchange:
       LibCallName = "__atomic_exchange";
       Args.add(RValue::get(EmitCastToVoidPtr(Val1)),
                getContext().VoidPtrTy);
@@ -2858,13 +3012,17 @@
                getContext().VoidPtrTy);
       break;
     // void __atomic_store(size_t size, void *mem, void *val, int order)
-    case AtomicExpr::Store:
+    case AtomicExpr::AO__c11_atomic_store:
+    case AtomicExpr::AO__atomic_store:
+    case AtomicExpr::AO__atomic_store_n:
       LibCallName = "__atomic_store";
       Args.add(RValue::get(EmitCastToVoidPtr(Val1)),
                getContext().VoidPtrTy);
       break;
     // void __atomic_load(size_t size, void *mem, void *return, int order)
-    case AtomicExpr::Load:
+    case AtomicExpr::AO__c11_atomic_load:
+    case AtomicExpr::AO__atomic_load:
+    case AtomicExpr::AO__atomic_load_n:
       LibCallName = "__atomic_load";
       Args.add(RValue::get(EmitCastToVoidPtr(Dest)),
                getContext().VoidPtrTy);
@@ -2892,7 +3050,7 @@
     RValue Res = EmitCall(FuncInfo, Func, ReturnValueSlot(), Args);
     if (E->isCmpXChg())
       return Res;
-    if (E->getOp() == AtomicExpr::Store)
+    if (E->getType()->isVoidType())
       return RValue::get(0);
     return ConvertTempToRValue(*this, E->getType(), Dest);
   }
@@ -2932,24 +3090,31 @@
     default: // invalid order
       // We should not ever get here normally, but it's hard to
       // enforce that in general.
-      break; 
+      break;
     }
-    if (E->getOp() == AtomicExpr::Store || E->getOp() == AtomicExpr::Init)
+    if (E->getType()->isVoidType())
       return RValue::get(0);
     return ConvertTempToRValue(*this, E->getType(), OrigDest);
   }
 
   // Long case, when Order isn't obviously constant.
 
+  bool IsStore = E->getOp() == AtomicExpr::AO__c11_atomic_store ||
+                 E->getOp() == AtomicExpr::AO__atomic_store ||
+                 E->getOp() == AtomicExpr::AO__atomic_store_n;
+  bool IsLoad = E->getOp() == AtomicExpr::AO__c11_atomic_load ||
+                E->getOp() == AtomicExpr::AO__atomic_load ||
+                E->getOp() == AtomicExpr::AO__atomic_load_n;
+
   // Create all the relevant BB's
   llvm::BasicBlock *MonotonicBB = 0, *AcquireBB = 0, *ReleaseBB = 0,
                    *AcqRelBB = 0, *SeqCstBB = 0;
   MonotonicBB = createBasicBlock("monotonic", CurFn);
-  if (E->getOp() != AtomicExpr::Store)
+  if (!IsStore)
     AcquireBB = createBasicBlock("acquire", CurFn);
-  if (E->getOp() != AtomicExpr::Load)
+  if (!IsLoad)
     ReleaseBB = createBasicBlock("release", CurFn);
-  if (E->getOp() != AtomicExpr::Load && E->getOp() != AtomicExpr::Store)
+  if (!IsLoad && !IsStore)
     AcqRelBB = createBasicBlock("acqrel", CurFn);
   SeqCstBB = createBasicBlock("seqcst", CurFn);
   llvm::BasicBlock *ContBB = createBasicBlock("atomic.continue", CurFn);
@@ -2966,7 +3131,7 @@
   EmitAtomicOp(*this, E, Dest, Ptr, Val1, Val2, Size, Align,
                llvm::Monotonic);
   Builder.CreateBr(ContBB);
-  if (E->getOp() != AtomicExpr::Store) {
+  if (!IsStore) {
     Builder.SetInsertPoint(AcquireBB);
     EmitAtomicOp(*this, E, Dest, Ptr, Val1, Val2, Size, Align,
                  llvm::Acquire);
@@ -2974,14 +3139,14 @@
     SI->addCase(Builder.getInt32(1), AcquireBB);
     SI->addCase(Builder.getInt32(2), AcquireBB);
   }
-  if (E->getOp() != AtomicExpr::Load) {
+  if (!IsLoad) {
     Builder.SetInsertPoint(ReleaseBB);
     EmitAtomicOp(*this, E, Dest, Ptr, Val1, Val2, Size, Align,
                  llvm::Release);
     Builder.CreateBr(ContBB);
     SI->addCase(Builder.getInt32(3), ReleaseBB);
   }
-  if (E->getOp() != AtomicExpr::Load && E->getOp() != AtomicExpr::Store) {
+  if (!IsLoad && !IsStore) {
     Builder.SetInsertPoint(AcqRelBB);
     EmitAtomicOp(*this, E, Dest, Ptr, Val1, Val2, Size, Align,
                  llvm::AcquireRelease);
@@ -2996,21 +3161,18 @@
 
   // Cleanup and return
   Builder.SetInsertPoint(ContBB);
-  if (E->getOp() == AtomicExpr::Store)
+  if (E->getType()->isVoidType())
     return RValue::get(0);
   return ConvertTempToRValue(*this, E->getType(), OrigDest);
 }
 
-void CodeGenFunction::SetFPAccuracy(llvm::Value *Val, unsigned AccuracyN,
-                                    unsigned AccuracyD) {
+void CodeGenFunction::SetFPAccuracy(llvm::Value *Val, float Accuracy) {
   assert(Val->getType()->isFPOrFPVectorTy());
-  if (!AccuracyN || !isa<llvm::Instruction>(Val))
+  if (Accuracy == 0.0 || !isa<llvm::Instruction>(Val))
     return;
 
-  llvm::Value *Vals[2];
-  Vals[0] = llvm::ConstantInt::get(Int32Ty, AccuracyN);
-  Vals[1] = llvm::ConstantInt::get(Int32Ty, AccuracyD);
-  llvm::MDNode *Node = llvm::MDNode::get(getLLVMContext(), Vals);
+  llvm::Value *ULPs = llvm::ConstantFP::get(Builder.getFloatTy(), Accuracy);
+  llvm::MDNode *Node = llvm::MDNode::get(getLLVMContext(), ULPs);
 
   cast<llvm::Instruction>(Val)->setMetadata(llvm::LLVMContext::MD_fpaccuracy,
                                             Node);

Modified: cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp Tue Apr 17 06:08:26 2012
@@ -754,8 +754,8 @@
                                                         MTy->getNumElements());
     Value* NewV = llvm::UndefValue::get(RTy);
     for (unsigned i = 0, e = MTy->getNumElements(); i != e; ++i) {
-      Value *Indx = Builder.getInt32(i);
-      Indx = Builder.CreateExtractElement(Mask, Indx, "shuf_idx");
+      Value *IIndx = Builder.getInt32(i);
+      Value *Indx = Builder.CreateExtractElement(Mask, IIndx, "shuf_idx");
       Indx = Builder.CreateZExt(Indx, CGF.Int32Ty, "idx_zext");
       
       // Handle vec3 special since the index will be off by one for the RHS.
@@ -767,7 +767,7 @@
         Indx = Builder.CreateSelect(cmpIndx, newIndx, Indx, "sel_shuf_idx");
       }
       Value *VExt = Builder.CreateExtractElement(LHS, Indx, "shuf_elt");
-      NewV = Builder.CreateInsertElement(NewV, VExt, Indx, "shuf_ins");
+      NewV = Builder.CreateInsertElement(NewV, VExt, IIndx, "shuf_ins");
     }
     return NewV;
   }
@@ -1807,7 +1807,7 @@
       if (ValTy->isFloatTy() ||
           (isa<llvm::VectorType>(ValTy) &&
            cast<llvm::VectorType>(ValTy)->getElementType()->isFloatTy()))
-        CGF.SetFPAccuracy(Val, 5, 2);
+        CGF.SetFPAccuracy(Val, 2.5);
     }
     return Val;
   }

Modified: cfe/branches/tooling/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjC.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjC.cpp Tue Apr 17 06:08:26 2012
@@ -2782,7 +2782,7 @@
                                           SC_Static,
                                           SC_None,
                                           false,
-                                          true);
+                                          false);
   
   QualType DestTy = C.getPointerType(Ty);
   QualType SrcTy = Ty;
@@ -2868,7 +2868,7 @@
                                           SC_Static,
                                           SC_None,
                                           false,
-                                          true);
+                                          false);
   
   QualType DestTy = C.getPointerType(Ty);
   QualType SrcTy = Ty;

Modified: cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp Tue Apr 17 06:08:26 2012
@@ -2121,15 +2121,16 @@
       // Get the existing variable, if one exists.
       llvm::GlobalVariable *offset = TheModule.getNamedGlobal(Name);
       if (offset) {
-          offset->setInitializer(offsetValue);
-          // If this is the real definition, change its linkage type so that
-          // different modules will use this one, rather than their private
-          // copy.
-          offset->setLinkage(llvm::GlobalValue::ExternalLinkage);
+        offset->setInitializer(offsetValue);
+        // If this is the real definition, change its linkage type so that
+        // different modules will use this one, rather than their private
+        // copy.
+        offset->setLinkage(llvm::GlobalValue::ExternalLinkage);
       } else {
-          // Add a new alias if there isn't one already.
-          offset = new llvm::GlobalVariable(TheModule, offsetValue->getType(),
-                  false, llvm::GlobalValue::ExternalLinkage, offsetValue, Name);
+        // Add a new alias if there isn't one already.
+        offset = new llvm::GlobalVariable(TheModule, offsetValue->getType(),
+                false, llvm::GlobalValue::ExternalLinkage, offsetValue, Name);
+        (void) offset; // Silence dead store warning.
       }
       ++ivarIndex;
   }
@@ -2593,7 +2594,7 @@
     // to replace it with the real version for a library.  In non-PIC code you
     // must compile with the fragile ABI if you want to use ivars from a
     // GCC-compiled class.
-    if (CGM.getLangOpts().PICLevel) {
+    if (CGM.getLangOpts().PICLevel || CGM.getLangOpts().PIELevel) {
       llvm::GlobalVariable *IvarOffsetGV = new llvm::GlobalVariable(TheModule,
             Int32Ty, false,
             llvm::GlobalValue::PrivateLinkage, OffsetGuess, Name+".guess");
@@ -2653,7 +2654,10 @@
       Offset = new llvm::GlobalVariable(TheModule, IntTy,
           false, llvm::GlobalValue::LinkOnceAnyLinkage,
           llvm::Constant::getNullValue(IntTy), name);
-    return CGF.Builder.CreateLoad(Offset);
+    Offset = CGF.Builder.CreateLoad(Offset);
+    if (Offset->getType() != PtrDiffTy)
+      Offset = CGF.Builder.CreateZExtOrBitCast(Offset, PtrDiffTy);
+    return Offset;
   }
   uint64_t Offset = ComputeIvarBaseOffset(CGF.CGM, Interface, Ivar);
   return llvm::ConstantInt::get(PtrDiffTy, Offset, /*isSigned*/true);

Modified: cfe/branches/tooling/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGStmt.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGStmt.cpp Tue Apr 17 06:08:26 2012
@@ -778,7 +778,7 @@
 void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) {
   // As long as debug info is modeled with instructions, we have to ensure we
   // have a place to insert here and write the stop point here.
-  if (getDebugInfo() && HaveInsertPoint())
+  if (HaveInsertPoint())
     EmitStopPoint(&S);
 
   for (DeclStmt::const_decl_iterator I = S.decl_begin(), E = S.decl_end();
@@ -892,7 +892,7 @@
 
   // If the body of the case is just a 'break', and if there was no fallthrough,
   // try to not emit an empty block.
-  if (isa<BreakStmt>(S.getSubStmt())) {
+  if ((CGM.getCodeGenOpts().OptimizationLevel > 0) && isa<BreakStmt>(S.getSubStmt())) {
     JumpDest Block = BreakContinueStack.back().BreakBlock;
     
     // Only do this optimization if there are no cleanups that need emitting.
@@ -1178,8 +1178,8 @@
       for (unsigned i = 0, e = CaseStmts.size(); i != e; ++i)
         EmitStmt(CaseStmts[i]);
 
-      // Now we want to restore the saved switch instance so that nested switches
-      // continue to function properly
+      // Now we want to restore the saved switch instance so that nested
+      // switches continue to function properly
       SwitchInsn = SavedSwitchInsn;
 
       return;

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h Tue Apr 17 06:08:26 2012
@@ -2104,6 +2104,8 @@
   LValue EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
   LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e);
 
+  RValue EmitRValueForField(llvm::Value *Addr, const FieldDecl *FD);
+
   class ConstantEmission {
     llvm::PointerIntPair<llvm::Constant*, 1, bool> ValueAndIsReference;
     ConstantEmission(llvm::Constant *C, bool isReference)
@@ -2429,11 +2431,11 @@
                                  llvm::Constant **Decls,
                                  unsigned NumDecls);
 
-  /// GenerateCXXGlobalDtorFunc - Generates code for destroying global
+  /// GenerateCXXGlobalDtorsFunc - Generates code for destroying global
   /// variables.
-  void GenerateCXXGlobalDtorFunc(llvm::Function *Fn,
-                                 const std::vector<std::pair<llvm::WeakVH,
-                                   llvm::Constant*> > &DtorsAndObjects);
+  void GenerateCXXGlobalDtorsFunc(llvm::Function *Fn,
+                                  const std::vector<std::pair<llvm::WeakVH,
+                                  llvm::Constant*> > &DtorsAndObjects);
 
   void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
                                         const VarDecl *D,
@@ -2518,8 +2520,7 @@
 
   /// SetFPAccuracy - Set the minimum required accuracy of the given floating
   /// point operation, expressed as the maximum relative error in ulp.
-  void SetFPAccuracy(llvm::Value *Val, unsigned AccuracyN,
-                     unsigned AccuracyD = 1);
+  void SetFPAccuracy(llvm::Value *Val, float Accuracy);
 
 private:
   llvm::MDNode *getRangeForLoadFromType(QualType Ty);

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp Tue Apr 17 06:08:26 2012
@@ -2535,6 +2535,11 @@
     EmitObjCPropertyImplementations(OMD);
     EmitObjCIvarInitializations(OMD);
     ObjCRuntime->GenerateClass(OMD);
+    // Emit global variable debug information.
+    if (CGDebugInfo *DI = getModuleDebugInfo())
+      DI->getOrCreateInterfaceType(getContext().getObjCInterfaceType(OMD->getClassInterface()),
+				   OMD->getLocation());
+    
     break;
   }
   case Decl::ObjCMethod: {

Modified: cfe/branches/tooling/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenTypes.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenTypes.cpp Tue Apr 17 06:08:26 2012
@@ -556,7 +556,7 @@
   }
 
   case Type::Atomic: {
-    ResultType = ConvertTypeForMem(cast<AtomicType>(Ty)->getValueType());
+    ResultType = ConvertType(cast<AtomicType>(Ty)->getValueType());
     break;
   }
   }

Modified: cfe/branches/tooling/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/MicrosoftCXXABI.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/MicrosoftCXXABI.cpp Tue Apr 17 06:08:26 2012
@@ -78,6 +78,13 @@
   //     delete[] p;
   //   }
   // Whereas it prints "104" and "104" if you give A a destructor.
+  void ReadArrayCookie(CodeGenFunction &CGF, llvm::Value *Ptr,
+                       const CXXDeleteExpr *expr,
+                       QualType ElementType, llvm::Value *&NumElements,
+                       llvm::Value *&AllocPtr, CharUnits &CookieSize) {
+    CGF.CGM.ErrorUnsupported(expr, "don't know how to handle array cookies "
+                                   "in the Microsoft C++ ABI");
+  }
 };
 
 }

Modified: cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp Tue Apr 17 06:08:26 2012
@@ -2527,19 +2527,16 @@
 static bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
                                    ASTContext &Context,
                                    uint64_t *HAMembers = 0) {
-  uint64_t Members;
+  uint64_t Members = 0;
   if (const ConstantArrayType *AT = Context.getAsConstantArrayType(Ty)) {
     if (!isHomogeneousAggregate(AT->getElementType(), Base, Context, &Members))
       return false;
     Members *= AT->getSize().getZExtValue();
   } else if (const RecordType *RT = Ty->getAs<RecordType>()) {
     const RecordDecl *RD = RT->getDecl();
-    if (RD->isUnion() || RD->hasFlexibleArrayMember())
+    if (RD->hasFlexibleArrayMember())
       return false;
-    if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
-      if (!CXXRD->isAggregate())
-        return false;
-    }
+
     Members = 0;
     for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
          i != e; ++i) {
@@ -2547,7 +2544,9 @@
       uint64_t FldMembers;
       if (!isHomogeneousAggregate(FD->getType(), Base, Context, &FldMembers))
         return false;
-      Members += FldMembers;
+
+      Members = (RD->isUnion() ?
+                 std::max(Members, FldMembers) : Members + FldMembers);
     }
   } else {
     Members = 1;
@@ -2584,7 +2583,8 @@
   // Homogeneous Aggregates can have at most 4 members of the base type.
   if (HAMembers)
     *HAMembers = Members;
-  return (Members <= 4);
+
+  return (Members > 0 && Members <= 4);
 }
 
 ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty) const {
@@ -2609,8 +2609,10 @@
   if (getABIKind() == ARMABIInfo::AAPCS_VFP) {
     // Homogeneous Aggregates need to be expanded.
     const Type *Base = 0;
-    if (isHomogeneousAggregate(Ty, Base, getContext()))
+    if (isHomogeneousAggregate(Ty, Base, getContext())) {
+      assert(Base && "Base class should be set for homogeneous aggregate");
       return ABIArgInfo::getExpand();
+    }
   }
 
   // Otherwise, pass by coercing to a structure of the appropriate size.
@@ -2776,9 +2778,11 @@
   // Check for homogeneous aggregates with AAPCS-VFP.
   if (getABIKind() == AAPCS_VFP) {
     const Type *Base = 0;
-    if (isHomogeneousAggregate(RetTy, Base, getContext()))
+    if (isHomogeneousAggregate(RetTy, Base, getContext())) {
+      assert(Base && "Base class should be set for homogeneous aggregate");
       // Homogeneous Aggregates are returned directly.
       return ABIArgInfo::getDirect();
+    }
   }
 
   // Aggregates <= 4 bytes are returned in r0; other aggregates

Modified: cfe/branches/tooling/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Driver.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Driver.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Driver.cpp Tue Apr 17 06:08:26 2012
@@ -1003,6 +1003,7 @@
     } else if (A->getOption().matches(options::OPT_x)) {
       InputTypeArg = A;
       InputType = types::lookupTypeForTypeSpecifier(A->getValue(Args));
+      A->claim();
 
       // Follow gcc behavior and treat as linker input for invalid -x
       // options. Its not clear why we shouldn't just revert to unknown; but

Modified: cfe/branches/tooling/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChains.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChains.cpp (original)
+++ cfe/branches/tooling/lib/Driver/ToolChains.cpp Tue Apr 17 06:08:26 2012
@@ -2059,10 +2059,20 @@
     addPathIfExists((GCCInstallation.getInstallPath() +
                      GCCInstallation.getMultiarchSuffix()),
                     Paths);
-    addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib/../" + Multilib,
-                    Paths);
-    addPathIfExists(LibPath + "/" + MultiarchTriple, Paths);
-    addPathIfExists(LibPath + "/../" + Multilib, Paths);
+
+    // If the GCC installation we found is inside of the sysroot, we want to
+    // prefer libraries installed in the parent prefix of the GCC installation.
+    // It is important to *not* use these paths when the GCC installation is
+    // outside of the system root as that can pick up un-intented libraries.
+    // This usually happens when there is an external cross compiler on the
+    // host system, and a more minimal sysroot available that is the target of
+    // the cross.
+    if (StringRef(LibPath).startswith(SysRoot)) {
+      addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib/../" + Multilib,
+                      Paths);
+      addPathIfExists(LibPath + "/" + MultiarchTriple, Paths);
+      addPathIfExists(LibPath + "/../" + Multilib, Paths);
+    }
   }
   addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths);
   addPathIfExists(SysRoot + "/lib/../" + Multilib, Paths);
@@ -2081,8 +2091,11 @@
     const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
     if (!GCCInstallation.getMultiarchSuffix().empty())
       addPathIfExists(GCCInstallation.getInstallPath(), Paths);
-    addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib", Paths);
-    addPathIfExists(LibPath, Paths);
+
+    if (StringRef(LibPath).startswith(SysRoot)) {
+      addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib", Paths);
+      addPathIfExists(LibPath, Paths);
+    }
   }
   addPathIfExists(SysRoot + "/lib", Paths);
   addPathIfExists(SysRoot + "/usr/lib", Paths);

Modified: cfe/branches/tooling/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChains.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChains.h (original)
+++ cfe/branches/tooling/lib/Driver/ToolChains.h Tue Apr 17 06:08:26 2012
@@ -459,6 +459,16 @@
 public:
   OpenBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args);
 
+  virtual bool IsObjCNonFragileABIDefault() const { return true; }
+  virtual bool IsObjCLegacyDispatchDefault() const {
+    llvm::Triple::ArchType Arch = getTriple().getArch();
+    if (Arch == llvm::Triple::arm ||
+        Arch == llvm::Triple::x86 ||
+        Arch == llvm::Triple::x86_64)
+     return false;
+    return true;
+  }
+
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
 };
@@ -467,6 +477,16 @@
 public:
   FreeBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args);
 
+  virtual bool IsObjCNonFragileABIDefault() const { return true; }
+  virtual bool IsObjCLegacyDispatchDefault() const {
+    llvm::Triple::ArchType Arch = getTriple().getArch();
+    if (Arch == llvm::Triple::arm ||
+        Arch == llvm::Triple::x86 ||
+        Arch == llvm::Triple::x86_64)
+     return false;
+    return true;
+  }
+
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
 };
@@ -475,6 +495,16 @@
 public:
   NetBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args);
 
+  virtual bool IsObjCNonFragileABIDefault() const { return true; }
+  virtual bool IsObjCLegacyDispatchDefault() const {
+    llvm::Triple::ArchType Arch = getTriple().getArch();
+    if (Arch == llvm::Triple::arm ||
+        Arch == llvm::Triple::x86 ||
+        Arch == llvm::Triple::x86_64)
+     return false;
+    return true;
+  }
+
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
 };

Modified: cfe/branches/tooling/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Tools.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Tools.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Tools.cpp Tue Apr 17 06:08:26 2012
@@ -504,41 +504,75 @@
   }
 }
 
-void Clang::AddARMTargetArgs(const ArgList &Args,
-                             ArgStringList &CmdArgs,
-                             bool KernelOrKext) const {
-  const Driver &D = getToolChain().getDriver();
-  llvm::Triple Triple = getToolChain().getTriple();
+// Handle -mfpu=.
+//
+// FIXME: Centralize feature selection, defaulting shouldn't be also in the
+// frontend target.
+static void addFPUArgs(const Driver &D, const Arg *A, const ArgList &Args,
+                       ArgStringList &CmdArgs) {
+  StringRef FPU = A->getValue(Args);
+
+  // Set the target features based on the FPU.
+  if (FPU == "fpa" || FPU == "fpe2" || FPU == "fpe3" || FPU == "maverick") {
+    // Disable any default FPU support.
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("-vfp2");
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("-vfp3");
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("-neon");
+  } else if (FPU == "vfp3-d16" || FPU == "vfpv3-d16") {
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("+vfp3");
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("+d16");
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("-neon");
+  } else if (FPU == "vfp") {
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("+vfp2");
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("-neon");
+  } else if (FPU == "vfp3" || FPU == "vfpv3") {
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("+vfp3");
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("-neon");
+  } else if (FPU == "neon") {
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("+neon");
+  } else
+    D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
+}
 
-  // Select the ABI to use.
-  //
-  // FIXME: Support -meabi.
-  const char *ABIName = 0;
-  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
-    ABIName = A->getValue(Args);
-  } else {
-    // Select the default based on the platform.
-    switch(Triple.getEnvironment()) {
-    case llvm::Triple::ANDROIDEABI:
-    case llvm::Triple::GNUEABI:
-      ABIName = "aapcs-linux";
-      break;
-    case llvm::Triple::EABI:
-      ABIName = "aapcs";
-      break;
-    default:
-      ABIName = "apcs-gnu";
-    }
-  }
-  CmdArgs.push_back("-target-abi");
-  CmdArgs.push_back(ABIName);
+// Handle -mfpmath=.
+static void addFPMathArgs(const Driver &D, const Arg *A, const ArgList &Args,
+                          ArgStringList &CmdArgs, StringRef CPU) {
+  StringRef FPMath = A->getValue(Args);
+  
+  // Set the target features based on the FPMath.
+  if (FPMath == "neon") {
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("+neonfp");
+    
+    if (CPU != "cortex-a8" && CPU != "cortex-a9" && CPU != "cortex-a9-mp")    
+      D.Diag(diag::err_drv_invalid_feature) << "-mfpmath=neon" << CPU;
+    
+  } else if (FPMath == "vfp" || FPMath == "vfp2" || FPMath == "vfp3" ||
+             FPMath == "vfp4") {
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("-neonfp");
 
-  // Set the CPU based on -march= and -mcpu=.
-  CmdArgs.push_back("-target-cpu");
-  CmdArgs.push_back(getARMTargetCPU(Args, Triple));
+    // FIXME: Add warnings when disabling a feature not present for a given CPU.    
+  } else
+    D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
+}
 
-  // Select the float ABI as determined by -msoft-float, -mhard-float, and
-  // -mfloat-abi=.
+// Select the float ABI as determined by -msoft-float, -mhard-float, and
+// -mfloat-abi=.
+static StringRef getARMFloatABI(const Driver &D,
+                                const ArgList &Args,
+                                const llvm::Triple &Triple) {
   StringRef FloatABI;
   if (Arg *A = Args.getLastArg(options::OPT_msoft_float,
                                options::OPT_mhard_float,
@@ -610,6 +644,45 @@
     }
   }
 
+  return FloatABI;
+}
+
+
+void Clang::AddARMTargetArgs(const ArgList &Args,
+                             ArgStringList &CmdArgs,
+                             bool KernelOrKext) const {
+  const Driver &D = getToolChain().getDriver();
+  llvm::Triple Triple = getToolChain().getTriple();
+
+  // Select the ABI to use.
+  //
+  // FIXME: Support -meabi.
+  const char *ABIName = 0;
+  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
+    ABIName = A->getValue(Args);
+  } else {
+    // Select the default based on the platform.
+    switch(Triple.getEnvironment()) {
+    case llvm::Triple::ANDROIDEABI:
+    case llvm::Triple::GNUEABI:
+      ABIName = "aapcs-linux";
+      break;
+    case llvm::Triple::EABI:
+      ABIName = "aapcs";
+      break;
+    default:
+      ABIName = "apcs-gnu";
+    }
+  }
+  CmdArgs.push_back("-target-abi");
+  CmdArgs.push_back(ABIName);
+
+  // Set the CPU based on -march= and -mcpu=.
+  CmdArgs.push_back("-target-cpu");
+  CmdArgs.push_back(getARMTargetCPU(Args, Triple));
+
+  // Determine floating point ABI from the options & target defaults.
+  StringRef FloatABI = getARMFloatABI(D, Args, Triple);
   if (FloatABI == "soft") {
     // Floating point operations and argument passing are soft.
     //
@@ -647,44 +720,12 @@
   }
 
   // Honor -mfpu=.
-  //
-  // FIXME: Centralize feature selection, defaulting shouldn't be also in the
-  // frontend target.
-  if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ)) {
-    StringRef FPU = A->getValue(Args);
-
-    // Set the target features based on the FPU.
-    if (FPU == "fpa" || FPU == "fpe2" || FPU == "fpe3" || FPU == "maverick") {
-      // Disable any default FPU support.
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-vfp2");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-vfp3");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-neon");
-    } else if (FPU == "vfp3-d16" || FPU == "vfpv3-d16") {
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("+vfp3");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("+d16");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-neon");
-    } else if (FPU == "vfp") {
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("+vfp2");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-neon");
-    } else if (FPU == "vfp3" || FPU == "vfpv3") {
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("+vfp3");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-neon");
-    } else if (FPU == "neon") {
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("+neon");
-    } else
-      D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
-  }
+  if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ))
+    addFPUArgs(D, A, Args, CmdArgs);
+
+  // Honor -mfpmath=.
+  if (const Arg *A = Args.getLastArg(options::OPT_mfpmath_EQ))
+    addFPMathArgs(D, A, Args, CmdArgs, getARMTargetCPU(Args, Triple));
 
   // Setting -msoft-float effectively disables NEON because of the GCC
   // implementation, although the same isn't true of VFP or VFP3.
@@ -755,38 +796,46 @@
     return "n64";
 }
 
-void Clang::AddMIPSTargetArgs(const ArgList &Args,
-                             ArgStringList &CmdArgs) const {
-  const Driver &D = getToolChain().getDriver();
-
+// Get CPU and ABI names. They are not independent
+// so we have to calculate them together.
+static void getMipsCPUAndABI(const ArgList &Args,
+                             const ToolChain &TC,
+                             StringRef &CPUName,
+                             StringRef &ABIName) {
   StringRef ArchName;
-  const char *CPUName;
 
-  // Set target cpu and architecture.
+  // Select target cpu and architecture.
   if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
     CPUName = A->getValue(Args);
     ArchName = getMipsArchFromCPU(CPUName);
   }
   else {
-    ArchName = Args.MakeArgString(getToolChain().getArchName());
+    ArchName = Args.MakeArgString(TC.getArchName());
     if (!checkMipsArchName(ArchName))
-      D.Diag(diag::err_drv_invalid_arch_name) << ArchName;
+      TC.getDriver().Diag(diag::err_drv_invalid_arch_name) << ArchName;
     else
       CPUName = getMipsCPUFromArch(ArchName);
   }
-
-  CmdArgs.push_back("-target-cpu");
-  CmdArgs.push_back(CPUName);
  
   // Select the ABI to use.
-  const char *ABIName = 0;
   if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
     ABIName = A->getValue(Args);
   else 
     ABIName = getMipsABIFromArch(ArchName);
+}
+
+void Clang::AddMIPSTargetArgs(const ArgList &Args,
+                             ArgStringList &CmdArgs) const {
+  const Driver &D = getToolChain().getDriver();
+  StringRef CPUName;
+  StringRef ABIName;
+  getMipsCPUAndABI(Args, getToolChain(), CPUName, ABIName);
+
+  CmdArgs.push_back("-target-cpu");
+  CmdArgs.push_back(CPUName.data());
 
   CmdArgs.push_back("-target-abi");
-  CmdArgs.push_back(ABIName);
+  CmdArgs.push_back(ABIName.data());
 
   // Select the float ABI as determined by -msoft-float, -mhard-float,
   // and -mfloat-abi=.
@@ -1079,7 +1128,7 @@
 /// Objective-C exceptions.
 static void addExceptionArgs(const ArgList &Args, types::ID InputType,
                              const llvm::Triple &Triple,
-                             bool KernelOrKext, bool IsRewriter,
+                             bool KernelOrKext,
                              unsigned objcABIVersion,
                              ArgStringList &CmdArgs) {
   if (KernelOrKext) {
@@ -1279,6 +1328,8 @@
 
   // Select the appropriate action.
   bool IsRewriter = false;
+  bool IsModernRewriter = false;
+  
   if (isa<AnalyzeJobAction>(JA)) {
     assert(JA.getType() == types::TY_Plist && "Invalid output type.");
     CmdArgs.push_back("-analyze");
@@ -1349,6 +1400,7 @@
       CmdArgs.push_back("-emit-pch");
     } else if (JA.getType() == types::TY_RewrittenObjC) {
       CmdArgs.push_back("-rewrite-objc");
+      IsModernRewriter = true;
     } else if (JA.getType() == types::TY_RewrittenLegacyObjC) {
       CmdArgs.push_back("-rewrite-objc");
       IsRewriter = true;
@@ -1437,15 +1489,43 @@
   // would do to enable flag_pic.
   //
   // FIXME: Centralize this code.
-  bool PICEnabled = (Args.hasArg(options::OPT_fPIC) ||
-                     Args.hasArg(options::OPT_fpic) ||
-                     Args.hasArg(options::OPT_fPIE) ||
-                     Args.hasArg(options::OPT_fpie));
-  bool PICDisabled = (Args.hasArg(options::OPT_mkernel) ||
-                      Args.hasArg(options::OPT_static));
+  Arg *LastPICArg = 0;
+  for (ArgList::const_iterator I = Args.begin(), E = Args.end(); I != E; ++I) {
+    if ((*I)->getOption().matches(options::OPT_fPIC) ||
+        (*I)->getOption().matches(options::OPT_fno_PIC) ||
+        (*I)->getOption().matches(options::OPT_fpic) ||
+        (*I)->getOption().matches(options::OPT_fno_pic) ||
+        (*I)->getOption().matches(options::OPT_fPIE) ||
+        (*I)->getOption().matches(options::OPT_fno_PIE) ||
+        (*I)->getOption().matches(options::OPT_fpie) ||
+        (*I)->getOption().matches(options::OPT_fno_pie)) {
+      LastPICArg = *I;
+      (*I)->claim();
+    }
+  }
+  bool PICDisabled = false;
+  bool PICEnabled = false;
+  bool PICForPIE = false;
+  if (LastPICArg) {
+    PICForPIE = (LastPICArg->getOption().matches(options::OPT_fPIE) ||
+                 LastPICArg->getOption().matches(options::OPT_fpie));
+    PICEnabled = (PICForPIE ||
+                  LastPICArg->getOption().matches(options::OPT_fPIC) ||
+                  LastPICArg->getOption().matches(options::OPT_fpic));
+    PICDisabled = !PICEnabled;
+  }
+  // Note that these flags are trump-cards. Regardless of the order w.r.t. the
+  // PIC or PIE options above, if these show up, PIC is disabled.
+  if (Args.hasArg(options::OPT_mkernel))
+    PICDisabled = true;
+  if (Args.hasArg(options::OPT_static))
+    PICDisabled = true;
+  bool DynamicNoPIC = Args.hasArg(options::OPT_mdynamic_no_pic);
+
+  // Select the relocation model.
   const char *Model = getToolChain().GetForcedPicModel();
   if (!Model) {
-    if (Args.hasArg(options::OPT_mdynamic_no_pic))
+    if (DynamicNoPIC)
       Model = "dynamic-no-pic";
     else if (PICDisabled)
       Model = "static";
@@ -1454,19 +1534,25 @@
     else
       Model = getToolChain().GetDefaultRelocationModel();
   }
-  if (StringRef(Model) != "pic") {
+  StringRef ModelStr = Model ? Model : "";
+  if (Model && ModelStr != "pic") {
     CmdArgs.push_back("-mrelocation-model");
     CmdArgs.push_back(Model);
   }
 
-  // Infer the __PIC__ value.
-  //
-  // FIXME:  This isn't quite right on Darwin, which always sets
-  // __PIC__=2.
-  if (strcmp(Model, "pic") == 0 || strcmp(Model, "dynamic-no-pic") == 0) {
+  // Infer the __PIC__ and __PIE__ values.
+  if (ModelStr == "pic" && PICForPIE) {
+    CmdArgs.push_back("-pie-level");
+    CmdArgs.push_back((LastPICArg &&
+                       LastPICArg->getOption().matches(options::OPT_fPIE)) ?
+                      "2" : "1");
+  } else if (ModelStr == "pic" || ModelStr == "dynamic-no-pic") {
     CmdArgs.push_back("-pic-level");
-    CmdArgs.push_back(Args.hasArg(options::OPT_fPIC) ? "2" : "1");
+    CmdArgs.push_back(((ModelStr != "dynamic-no-pic" && LastPICArg &&
+                        LastPICArg->getOption().matches(options::OPT_fPIC)) ||
+                       getToolChain().getTriple().isOSDarwin()) ? "2" : "1");
   }
+
   if (!Args.hasFlag(options::OPT_fmerge_all_constants,
                     options::OPT_fno_merge_all_constants))
     CmdArgs.push_back("-fno-merge-all-constants");
@@ -2226,7 +2312,8 @@
   ObjCRuntime objCRuntime;
   unsigned objcABIVersion = 0;
   bool NeXTRuntimeIsDefault
-    = (IsRewriter || getToolChain().getTriple().isOSDarwin());
+    = (IsRewriter || IsModernRewriter ||
+       getToolChain().getTriple().isOSDarwin());
   if (Args.hasFlag(options::OPT_fnext_runtime, options::OPT_fgnu_runtime,
                    NeXTRuntimeIsDefault)) {
     objCRuntime.setKind(ObjCRuntime::NeXT);
@@ -2260,8 +2347,9 @@
       D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
   } else {
     // Otherwise, determine if we are using the non-fragile ABI.
-    bool NonFragileABIIsDefault
-      = (!IsRewriter && getToolChain().IsObjCNonFragileABIDefault());
+    bool NonFragileABIIsDefault = 
+      (IsModernRewriter || 
+       (!IsRewriter && getToolChain().IsObjCNonFragileABIDefault()));
     if (Args.hasFlag(options::OPT_fobjc_nonfragile_abi,
                      options::OPT_fno_objc_nonfragile_abi,
                      NonFragileABIIsDefault)) {
@@ -2306,9 +2394,7 @@
 
   // -fobjc-default-synthesize-properties=1 is default. This only has an effect
   // if the nonfragile objc abi is used.
-  if (Args.hasFlag(options::OPT_fobjc_default_synthesize_properties,
-                   options::OPT_fno_objc_default_synthesize_properties,
-                   getToolChain().IsObjCDefaultSynthPropertiesDefault())) {
+  if (getToolChain().IsObjCDefaultSynthPropertiesDefault()) {
     CmdArgs.push_back("-fobjc-default-synthesize-properties");
   }
 
@@ -2341,7 +2427,7 @@
 
   // -fobjc-infer-related-result-type is the default, except in the Objective-C
   // rewriter.
-  if (IsRewriter)
+  if (IsRewriter || IsModernRewriter)
     CmdArgs.push_back("-fno-objc-infer-related-result-type");
 
   // Handle -fobjc-gc and -fobjc-gc-only. They are exclusive, and -fobjc-gc-only
@@ -2364,7 +2450,7 @@
 
   // Add exception args.
   addExceptionArgs(Args, InputType, getToolChain().getTriple(),
-                   KernelOrKext, IsRewriter, objcABIVersion, CmdArgs);
+                   KernelOrKext, objcABIVersion, CmdArgs);
 
   if (getToolChain().UseSjLjExceptions())
     CmdArgs.push_back("-fsjlj-exceptions");
@@ -2645,44 +2731,12 @@
   CmdArgs.push_back(getARMTargetCPU(Args, Triple));
 
   // Honor -mfpu=.
-  //
-  // FIXME: Centralize feature selection, defaulting shouldn't be also in the
-  // frontend target.
-  if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ)) {
-    StringRef FPU = A->getValue(Args);
-
-    // Set the target features based on the FPU.
-    if (FPU == "fpa" || FPU == "fpe2" || FPU == "fpe3" || FPU == "maverick") {
-      // Disable any default FPU support.
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-vfp2");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-vfp3");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-neon");
-    } else if (FPU == "vfp3-d16" || FPU == "vfpv3-d16") {
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("+vfp3");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("+d16");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-neon");
-    } else if (FPU == "vfp") {
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("+vfp2");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-neon");
-    } else if (FPU == "vfp3" || FPU == "vfpv3") {
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("+vfp3");
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("-neon");
-    } else if (FPU == "neon") {
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back("+neon");
-    } else
-      D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
-  }
+  if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ))
+    addFPUArgs(D, A, Args, CmdArgs);
+
+  // Honor -mfpmath=.
+  if (const Arg *A = Args.getLastArg(options::OPT_mfpmath_EQ))
+    addFPMathArgs(D, A, Args, CmdArgs, getARMTargetCPU(Args, Triple));
 }
 
 void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
@@ -3625,8 +3679,7 @@
   Args.ClaimAllArgs(options::OPT__serialize_diags);
 
   types::ID InputType = Inputs[0].getType();
-  const Arg *A;
-  if ((A = Args.getLastArg(options::OPT_traditional)))
+  if (const Arg *A = Args.getLastArg(options::OPT_traditional))
     D.Diag(diag::err_drv_argument_only_allowed_with)
       << A->getAsString(Args) << "-E";
 
@@ -4376,11 +4429,11 @@
   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)) {
+    if (getToolChain().getDriver().CCCIsCXX)
+      getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
     CmdArgs.push_back("-lgcc_s");
     if (!Args.hasArg(options::OPT_shared)) {
       CmdArgs.push_back("-lgcc");
@@ -4847,7 +4900,6 @@
   if (getToolChain().getArch() == llvm::Triple::x86)
     CmdArgs.push_back("--32");
 
-
   // Set byte order explicitly
   if (getToolChain().getArchName() == "mips")
     CmdArgs.push_back("-EB");
@@ -5014,19 +5066,33 @@
              getToolChain().getArch() == llvm::Triple::mipsel ||
              getToolChain().getArch() == llvm::Triple::mips64 ||
              getToolChain().getArch() == llvm::Triple::mips64el) {
-    // Get Mips CPU name and pass it to 'as'.
-    const char *CPUName;
-    if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
-      CPUName = A->getValue(Args);
+    StringRef CPUName;
+    StringRef ABIName;
+    getMipsCPUAndABI(Args, getToolChain(), CPUName, ABIName);
+
+    CmdArgs.push_back("-march");
+    CmdArgs.push_back(CPUName.data());
+
+    // Convert ABI name to the GNU tools acceptable variant.
+    if (ABIName == "o32")
+      ABIName = "32";
+    else if (ABIName == "n64")
+      ABIName = "64";
+
+    CmdArgs.push_back("-mabi");
+    CmdArgs.push_back(ABIName.data());
+
+    if (getToolChain().getArch() == llvm::Triple::mips ||
+        getToolChain().getArch() == llvm::Triple::mips64)
+      CmdArgs.push_back("-EB");
     else
-      CPUName = getMipsCPUFromArch(getToolChain().getArchName());
-
-    if (CPUName) {
-      CmdArgs.push_back("-march");
-      CmdArgs.push_back(CPUName);
-    }
+      CmdArgs.push_back("-EL");
   }
 
+  Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
+
   Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
                        options::OPT_Xassembler);
 
@@ -5151,6 +5217,9 @@
     else if (ToolChain.getArch() == llvm::Triple::mips ||
              ToolChain.getArch() == llvm::Triple::mipsel)
       CmdArgs.push_back("/lib/ld.so.1");
+    else if (ToolChain.getArch() == llvm::Triple::mips64 ||
+             ToolChain.getArch() == llvm::Triple::mips64el)
+      CmdArgs.push_back("/lib64/ld.so.1");
     else if (ToolChain.getArch() == llvm::Triple::ppc)
       CmdArgs.push_back("/lib/ld.so.1");
     else if (ToolChain.getArch() == llvm::Triple::ppc64)
@@ -5194,6 +5263,15 @@
        i != e; ++i)
     CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + *i));
 
+  // Tell the linker to load the plugin. This has to come before AddLinkerInputs
+  // as gold requires -plugin to come before any -plugin-opt that -Wl might
+  // forward.
+  if (D.IsUsingLTO(Args) || Args.hasArg(options::OPT_use_gold_plugin)) {
+    CmdArgs.push_back("-plugin");
+    std::string Plugin = ToolChain.getDriver().Dir + "/../lib/LLVMgold.so";
+    CmdArgs.push_back(Args.MakeArgString(Plugin));
+  }
+
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
 
   if (D.CCCIsCXX && !Args.hasArg(options::OPT_nostdlib)) {
@@ -5242,12 +5320,6 @@
 
   addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
 
-  if (D.IsUsingLTO(Args) || Args.hasArg(options::OPT_use_gold_plugin)) {
-    CmdArgs.push_back("-plugin");
-    std::string Plugin = ToolChain.getDriver().Dir + "/../lib/LLVMgold.so";
-    CmdArgs.push_back(Args.MakeArgString(Plugin));
-  }
-
   C.addCommand(new Command(JA, *this, ToolChain.Linker.c_str(), CmdArgs));
 }
 

Modified: cfe/branches/tooling/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/ASTUnit.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/ASTUnit.cpp Tue Apr 17 06:08:26 2012
@@ -351,7 +351,8 @@
   typedef CodeCompletionResult Result;
   SmallVector<Result, 8> Results;
   CachedCompletionAllocator = new GlobalCodeCompletionAllocator;
-  TheSema->GatherGlobalCodeCompletions(*CachedCompletionAllocator, Results);
+  TheSema->GatherGlobalCodeCompletions(*CachedCompletionAllocator,
+                                       getCodeCompletionTUInfo(), Results);
   
   // Translate global code completions into cached completions.
   llvm::DenseMap<CanQualType, unsigned> CompletionTypes;
@@ -362,7 +363,8 @@
       bool IsNestedNameSpecifier = false;
       CachedCodeCompletionResult CachedResult;
       CachedResult.Completion = Results[I].CreateCodeCompletionString(*TheSema,
-                                                    *CachedCompletionAllocator);
+                                                    *CachedCompletionAllocator,
+                                                    getCodeCompletionTUInfo());
       CachedResult.ShowInContexts = getDeclShowContexts(Results[I].Declaration,
                                                         Ctx->getLangOpts(),
                                                         IsNestedNameSpecifier);
@@ -426,7 +428,8 @@
           Results[I].StartsNestedNameSpecifier = true;
           CachedResult.Completion 
             = Results[I].CreateCodeCompletionString(*TheSema,
-                                                    *CachedCompletionAllocator);
+                                                    *CachedCompletionAllocator,
+                                                    getCodeCompletionTUInfo());
           CachedResult.ShowInContexts = RemainingContexts;
           CachedResult.Priority = CCP_NestedNameSpecifier;
           CachedResult.TypeClass = STC_Void;
@@ -447,7 +450,8 @@
       CachedCodeCompletionResult CachedResult;
       CachedResult.Completion 
         = Results[I].CreateCodeCompletionString(*TheSema,
-                                                *CachedCompletionAllocator);
+                                                *CachedCompletionAllocator,
+                                                getCodeCompletionTUInfo());
       CachedResult.ShowInContexts
         = (1 << (CodeCompletionContext::CCC_TopLevel - 1))
         | (1 << (CodeCompletionContext::CCC_ObjCInterface - 1))
@@ -1134,19 +1138,13 @@
   }
 
   Act->Execute();
-  
-  // Steal the created target, context, and preprocessor.
-  TheSema.reset(Clang->takeSema());
-  Consumer.reset(Clang->takeASTConsumer());
-  Ctx = &Clang->getASTContext();
-  PP = &Clang->getPreprocessor();
-  Clang->setSourceManager(0);
-  Clang->setFileManager(0);
-  Target = &Clang->getTarget();
-  Reader = Clang->getModuleManager();
+
+  transferASTDataFromCompilerInstance(*Clang);
   
   Act->EndSourceFile();
 
+  FailedParseDiagnostics.clear();
+
   return false;
 
 error:
@@ -1155,7 +1153,11 @@
     delete OverrideMainBuffer;
     SavedMainFileBuffer = 0;
   }
-  
+
+  // Keep the ownership of the data in the ASTUnit because the client may
+  // want to see the diagnostics.
+  transferASTDataFromCompilerInstance(*Clang);
+  FailedParseDiagnostics.swap(StoredDiagnostics);
   StoredDiagnostics.clear();
   NumStoredDiagnosticsFromDriver = 0;
   return true;
@@ -1643,6 +1645,18 @@
   TopLevelDecls.insert(TopLevelDecls.begin(), Resolved.begin(), Resolved.end());
 }
 
+void ASTUnit::transferASTDataFromCompilerInstance(CompilerInstance &CI) {
+  // Steal the created target, context, and preprocessor.
+  TheSema.reset(CI.takeSema());
+  Consumer.reset(CI.takeASTConsumer());
+  Ctx = &CI.getASTContext();
+  PP = &CI.getPreprocessor();
+  CI.setSourceManager(0);
+  CI.setFileManager(0);
+  Target = &CI.getTarget();
+  Reader = CI.getModuleManager();
+}
+
 StringRef ASTUnit::getMainFileName() const {
   return Invocation->getFrontendOpts().Inputs[0].File;
 }
@@ -1671,7 +1685,8 @@
                                              bool OnlyLocalDecls,
                                              bool CaptureDiagnostics,
                                              bool PrecompilePreamble,
-                                             bool CacheCodeCompletionResults) {
+                                             bool CacheCodeCompletionResults,
+                                             OwningPtr<ASTUnit> *ErrAST) {
   assert(CI && "A CompilerInvocation is required");
 
   OwningPtr<ASTUnit> OwnAST;
@@ -1766,8 +1781,13 @@
   llvm::CrashRecoveryContextCleanupRegistrar<TopLevelDeclTrackerAction>
     ActCleanup(TrackerAct.get());
 
-  if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
+  if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) {
+    AST->transferASTDataFromCompilerInstance(*Clang);
+    if (OwnAST && ErrAST)
+      ErrAST->swap(OwnAST);
+
     return 0;
+  }
 
   if (Persistent && !TrackerAct) {
     Clang->getPreprocessor().addPPCallbacks(
@@ -1780,16 +1800,9 @@
     Clang->setASTConsumer(new MultiplexConsumer(Consumers));
   }
   Act->Execute();
-  
+
   // Steal the created target, context, and preprocessor.
-  AST->TheSema.reset(Clang->takeSema());
-  AST->Consumer.reset(Clang->takeASTConsumer());
-  AST->Ctx = &Clang->getASTContext();
-  AST->PP = &Clang->getPreprocessor();
-  Clang->setSourceManager(0);
-  Clang->setFileManager(0);
-  AST->Target = &Clang->getTarget();
-  AST->Reader = Clang->getModuleManager();
+  AST->transferASTDataFromCompilerInstance(*Clang);
   
   Act->EndSourceFile();
 
@@ -1868,7 +1881,9 @@
                                       bool PrecompilePreamble,
                                       TranslationUnitKind TUKind,
                                       bool CacheCodeCompletionResults,
-                                      bool AllowPCHWithCompilerErrors) {
+                                      bool AllowPCHWithCompilerErrors,
+                                      bool SkipFunctionBodies,
+                                      OwningPtr<ASTUnit> *ErrAST) {
   if (!Diags.getPtr()) {
     // No diagnostics engine was provided, so create our own diagnostics object
     // with the default options.
@@ -1911,6 +1926,8 @@
   // Override the resources path.
   CI->getHeaderSearchOpts().ResourceDir = ResourceFilesPath;
 
+  CI->getFrontendOpts().SkipFunctionBodies = SkipFunctionBodies;
+
   // Create the AST unit.
   OwningPtr<ASTUnit> AST;
   AST.reset(new ASTUnit(false));
@@ -1932,7 +1949,17 @@
   llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit>
     ASTUnitCleanup(AST.get());
 
-  return AST->LoadFromCompilerInvocation(PrecompilePreamble) ? 0 : AST.take();
+  if (AST->LoadFromCompilerInvocation(PrecompilePreamble)) {
+    // Some error occurred, if caller wants to examine diagnostics, pass it the
+    // ASTUnit.
+    if (ErrAST) {
+      AST->StoredDiagnostics.swap(AST->FailedParseDiagnostics);
+      ErrAST->swap(AST);
+    }
+    return 0;
+  }
+
+  return AST.take();
 }
 
 bool ASTUnit::Reparse(RemappedFile *RemappedFiles, unsigned NumRemappedFiles) {
@@ -1989,9 +2016,9 @@
       CurrentTopLevelHashValue != CompletionCacheTopLevelHashValue)
     CacheCodeCompletionResults();
 
-  // We now need to clear out the completion allocator for
-  // clang_getCursorCompletionString; it'll be recreated if necessary.
-  CursorCompletionAllocator = 0;
+  // We now need to clear out the completion info related to this translation
+  // unit; it'll be recreated if necessary.
+  CCTUInfo.reset();
   
   return Result;
 }
@@ -2053,6 +2080,10 @@
     virtual CodeCompletionAllocator &getAllocator() {
       return Next.getAllocator();
     }
+
+    virtual CodeCompletionTUInfo &getCodeCompletionTUInfo() {
+      return Next.getCodeCompletionTUInfo();
+    }
   };
 }
 
@@ -2210,8 +2241,8 @@
         Context.getKind() == CodeCompletionContext::CCC_MacroNameUse) {
       // Create a new code-completion string that just contains the
       // macro name, without its arguments.
-      CodeCompletionBuilder Builder(getAllocator(), CCP_CodePattern,
-                                    C->Availability);
+      CodeCompletionBuilder Builder(getAllocator(), getCodeCompletionTUInfo(),
+                                    CCP_CodePattern, C->Availability);
       Builder.AddTypedTextChunk(C->Completion->getTypedText());
       CursorKind = CXCursor_NotImplemented;
       Priority = CCP_CodePattern;
@@ -2337,6 +2368,8 @@
                                 FrontendOpts.ShowGlobalSymbolsInCodeCompletion);
   Clang->setCodeCompletionConsumer(AugmentedConsumer);
 
+  Clang->getFrontendOpts().SkipFunctionBodies = true;
+
   // If we have a precompiled preamble, try to use it. We only allow
   // the use of the precompiled preamble if we're if the completion
   // point is within the main file, after the end of the precompiled

Modified: cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp Tue Apr 17 06:08:26 2012
@@ -88,6 +88,7 @@
 
 void CompilerInstance::setCodeCompletionConsumer(CodeCompleteConsumer *Value) {
   CompletionConsumer.reset(Value);
+  getFrontendOpts().SkipFunctionBodies = Value != 0;
 }
 
 // Diagnostics
@@ -383,7 +384,7 @@
 void CompilerInstance::createCodeCompletionConsumer() {
   const ParsedSourceLocation &Loc = getFrontendOpts().CodeCompletionAt;
   if (!CompletionConsumer) {
-    CompletionConsumer.reset(
+    setCodeCompletionConsumer(
       createCodeCompletionConsumer(getPreprocessor(),
                                    Loc.FileName, Loc.Line, Loc.Column,
                                    getFrontendOpts().ShowMacrosInCodeCompletion,
@@ -394,14 +395,14 @@
       return;
   } else if (EnableCodeCompletion(getPreprocessor(), Loc.FileName,
                                   Loc.Line, Loc.Column)) {
-    CompletionConsumer.reset();
+    setCodeCompletionConsumer(0);
     return;
   }
 
   if (CompletionConsumer->isOutputBinary() &&
       llvm::sys::Program::ChangeStdoutToBinary()) {
     getPreprocessor().getDiagnostics().Report(diag::err_fe_stdout_binary);
-    CompletionConsumer.reset();
+    setCodeCompletionConsumer(0);
   }
 }
 

Modified: cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp Tue Apr 17 06:08:26 2012
@@ -429,7 +429,6 @@
   case frontend::PrintDeclContext:       return "-print-decl-contexts";
   case frontend::PrintPreamble:          return "-print-preamble";
   case frontend::PrintPreprocessedInput: return "-E";
-  case frontend::PubnamesDump:           return "-pubnames-dump";
   case frontend::RewriteMacros:          return "-rewrite-macros";
   case frontend::RewriteObjC:            return "-rewrite-objc";
   case frontend::RewriteTest:            return "-rewrite-test";
@@ -740,6 +739,8 @@
     Res.push_back("-fno-bitfield-type-alignment");
   if (Opts.PICLevel)
     Res.push_back("-pic-level", llvm::utostr(Opts.PICLevel));
+  if (Opts.PIELevel)
+    Res.push_back("-pie-level", llvm::utostr(Opts.PIELevel));
   if (Opts.ObjCGCBitmapPrint)
     Res.push_back("-print-ivar-layout");
   if (Opts.NoConstantCFStrings)
@@ -1367,8 +1368,6 @@
       Opts.ProgramAction = frontend::PrintPreamble; break;
     case OPT_E:
       Opts.ProgramAction = frontend::PrintPreprocessedInput; break;
-    case OPT_pubnames_dump:
-      Opts.ProgramAction = frontend::PubnamesDump; break;
     case OPT_rewrite_macros:
       Opts.ProgramAction = frontend::RewriteMacros; break;
     case OPT_rewrite_objc:
@@ -1897,6 +1896,7 @@
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
   Opts.PackStruct = Args.getLastArgIntValue(OPT_fpack_struct, 0, Diags);
   Opts.PICLevel = Args.getLastArgIntValue(OPT_pic_level, 0, Diags);
+  Opts.PIELevel = Args.getLastArgIntValue(OPT_pie_level, 0, Diags);
   Opts.Static = Args.hasArg(OPT_static_define);
   Opts.DumpRecordLayoutsSimple = Args.hasArg(OPT_fdump_record_layouts_simple);
   Opts.DumpRecordLayouts = Opts.DumpRecordLayoutsSimple 

Modified: cfe/branches/tooling/lib/Frontend/FrontendAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/FrontendAction.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/FrontendAction.cpp Tue Apr 17 06:08:26 2012
@@ -412,7 +412,8 @@
   if (!CI.hasSema())
     CI.createSema(getTranslationUnitKind(), CompletionConsumer);
 
-  ParseAST(CI.getSema(), CI.getFrontendOpts().ShowStats);
+  ParseAST(CI.getSema(), CI.getFrontendOpts().ShowStats,
+           CI.getFrontendOpts().SkipFunctionBodies);
 }
 
 void PluginASTAction::anchor() { }

Modified: cfe/branches/tooling/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/FrontendActions.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/FrontendActions.cpp Tue Apr 17 06:08:26 2012
@@ -25,7 +25,6 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/system_error.h"
-#include <set>
 
 using namespace clang;
 
@@ -355,77 +354,6 @@
   return new ASTConsumer();
 }
 
-namespace {
-  class PubnamesDumpConsumer : public ASTConsumer {
-    Preprocessor &PP;
-    
-    /// \brief Determine whether the given identifier provides a 'public' name.
-    bool isPublicName(IdentifierInfo *II) {
-      // If there are any top-level declarations associated with this
-      // identifier, it is a public name.
-      if (II->getFETokenInfo<void>())
-        return true;
-
-      // If this identifier is the name of a non-builtin macro that isn't
-      // defined on the command line or implicitly by the front end, it is a
-      // public name.
-      if (II->hasMacroDefinition()) {
-        if (MacroInfo *M = PP.getMacroInfo(II))
-          if (!M->isBuiltinMacro()) {
-            SourceLocation Loc = M->getDefinitionLoc();
-            FileID File = PP.getSourceManager().getFileID(Loc);
-            if (PP.getSourceManager().getFileEntryForID(File))
-              return true;
-          }
-      }
-      
-      return false;
-    }
-      
-  public:
-    PubnamesDumpConsumer(Preprocessor &PP) : PP(PP) { }
-        
-    virtual void HandleTranslationUnit(ASTContext &Ctx) {
-      std::set<StringRef> Pubnames;
-      
-      // Add the names of any non-builtin macros.
-      for (IdentifierTable::iterator I = Ctx.Idents.begin(),
-                                  IEnd = Ctx.Idents.end();
-           I != IEnd; ++I) {
-        if (isPublicName(I->second))
-          Pubnames.insert(I->first());
-      }
-      
-      // If there is an external identifier lookup source, consider those
-      // identifiers as well.
-      if (IdentifierInfoLookup *External
-            = Ctx.Idents.getExternalIdentifierLookup()) {
-        OwningPtr<IdentifierIterator> Iter(External->getIdentifiers());
-        do {
-          StringRef Name = Iter->Next();
-          if (Name.empty())
-            break;
-          
-          if (isPublicName(PP.getIdentifierInfo(Name)))
-            Pubnames.insert(Name);
-        } while (true);
-      }
-
-      // Print the names, in lexicographical order.
-      for (std::set<StringRef>::iterator N = Pubnames.begin(),
-                                      NEnd = Pubnames.end();
-           N != NEnd; ++N) {
-        llvm::outs() << *N << '\n';
-      }
-    }
-  };
-}
-
-ASTConsumer *PubnamesDumpAction::CreateASTConsumer(CompilerInstance &CI,
-                                                   StringRef InFile) {
-  return new PubnamesDumpConsumer(CI.getPreprocessor());
-}
-
 //===----------------------------------------------------------------------===//
 // Preprocessor Actions
 //===----------------------------------------------------------------------===//

Modified: cfe/branches/tooling/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/InitPreprocessor.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/InitPreprocessor.cpp Tue Apr 17 06:08:26 2012
@@ -202,6 +202,20 @@
                         ConstSuffix);
 }
 
+/// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
+/// the specified properties.
+static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
+                                    unsigned InlineWidth) {
+  // Fully-aligned, power-of-2 sizes no larger than the inline
+  // width will be inlined as lock-free operations.
+  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
+      TypeWidth <= InlineWidth)
+    return "2"; // "always lock free"
+  // We cannot be certain what operations the lib calls might be
+  // able to implement as lock-free on future processors.
+  return "1"; // "sometimes lock free"
+}
+
 /// \brief Add definitions required for a smooth interaction between
 /// Objective-C++ automated reference counting and libstdc++ (4.2).
 static void AddObjCXXARCLibstdcxxDefines(const LangOptions &LangOpts, 
@@ -521,6 +535,32 @@
   else
     Builder.defineMacro("__GNUC_STDC_INLINE__");
 
+  // The value written by __atomic_test_and_set.
+  // FIXME: This is target-dependent.
+  Builder.defineMacro("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", "1");
+
+  // Used by libstdc++ to implement ATOMIC_<foo>_LOCK_FREE.
+  unsigned InlineWidthBits = TI.getMaxAtomicInlineWidth();
+#define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \
+  Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \
+                      getLockFreeValue(TI.get##Type##Width(), \
+                                       TI.get##Type##Align(), \
+                                       InlineWidthBits));
+  DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
+  DEFINE_LOCK_FREE_MACRO(CHAR, Char);
+  DEFINE_LOCK_FREE_MACRO(CHAR16_T, Char16);
+  DEFINE_LOCK_FREE_MACRO(CHAR32_T, Char32);
+  DEFINE_LOCK_FREE_MACRO(WCHAR_T, WChar);
+  DEFINE_LOCK_FREE_MACRO(SHORT, Short);
+  DEFINE_LOCK_FREE_MACRO(INT, Int);
+  DEFINE_LOCK_FREE_MACRO(LONG, Long);
+  DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
+  Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE",
+                      getLockFreeValue(TI.getPointerWidth(0),
+                                       TI.getPointerAlign(0),
+                                       InlineWidthBits));
+#undef DEFINE_LOCK_FREE_MACRO
+
   if (LangOpts.NoInlineDefine)
     Builder.defineMacro("__NO_INLINE__");
 
@@ -528,6 +568,10 @@
     Builder.defineMacro("__PIC__", Twine(PICLevel));
     Builder.defineMacro("__pic__", Twine(PICLevel));
   }
+  if (unsigned PIELevel = LangOpts.PIELevel) {
+    Builder.defineMacro("__PIE__", Twine(PIELevel));
+    Builder.defineMacro("__pie__", Twine(PIELevel));
+  }
 
   // Macros to control C99 numerics and <float.h>
   Builder.defineMacro("__FLT_EVAL_METHOD__", Twine(TI.getFloatEvalMethod()));

Modified: cfe/branches/tooling/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/branches/tooling/lib/FrontendTool/ExecuteCompilerInvocation.cpp Tue Apr 17 06:08:26 2012
@@ -72,7 +72,6 @@
   case PrintDeclContext:       return new DeclContextPrintAction();
   case PrintPreamble:          return new PrintPreambleAction();
   case PrintPreprocessedInput: return new PrintPreprocessedAction();
-  case PubnamesDump:           return new PubnamesDumpAction();
   case RewriteMacros:          return new RewriteMacrosAction();
   case RewriteObjC:            return new RewriteObjCAction();
   case RewriteTest:            return new RewriteTestAction();

Modified: cfe/branches/tooling/lib/Headers/avxintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Headers/avxintrin.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Headers/avxintrin.h (original)
+++ cfe/branches/tooling/lib/Headers/avxintrin.h Tue Apr 17 06:08:26 2012
@@ -1202,7 +1202,7 @@
 
 /* SIMD store ops (unaligned) */
 static __inline void __attribute__((__always_inline__, __nodebug__))
-_mm256_storeu2_m128(float const *addr_hi, float const *addr_lo, __m256 a)
+_mm256_storeu2_m128(float *addr_hi, float *addr_lo, __m256 a)
 {
   __m128 v128;
 
@@ -1213,7 +1213,7 @@
 }
 
 static __inline void __attribute__((__always_inline__, __nodebug__))
-_mm256_storeu2_m128d(double const *addr_hi, double const *addr_lo, __m256d a)
+_mm256_storeu2_m128d(double *addr_hi, double *addr_lo, __m256d a)
 {
   __m128d v128;
 
@@ -1224,7 +1224,7 @@
 }
 
 static __inline void __attribute__((__always_inline__, __nodebug__))
-_mm256_storeu2_m128i(__m128i const *addr_hi, __m128i const *addr_lo, __m256i a)
+_mm256_storeu2_m128i(__m128i *addr_hi, __m128i *addr_lo, __m256i a)
 {
   __m128i v128;
 

Modified: cfe/branches/tooling/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/HeaderSearch.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/branches/tooling/lib/Lex/HeaderSearch.cpp Tue Apr 17 06:08:26 2012
@@ -204,7 +204,10 @@
     HeaderSearch &HS,
     SmallVectorImpl<char> *SearchPath,
     SmallVectorImpl<char> *RelativePath,
-    Module **SuggestedModule) const {
+    Module **SuggestedModule,
+    bool &InUserSpecifiedSystemFramework) const {
+  InUserSpecifiedSystemFramework = false;
+
   SmallString<1024> TmpDir;
   if (isNormalDir()) {
     // Concatenate the requested file onto the directory.
@@ -239,7 +242,7 @@
 
   if (isFramework())
     return DoFrameworkLookup(Filename, HS, SearchPath, RelativePath,
-                             SuggestedModule);
+                             SuggestedModule, InUserSpecifiedSystemFramework);
 
   assert(isHeaderMap() && "Unknown directory lookup");
   const FileEntry * const Result = getHeaderMap()->LookupFile(
@@ -266,7 +269,8 @@
     HeaderSearch &HS,
     SmallVectorImpl<char> *SearchPath,
     SmallVectorImpl<char> *RelativePath,
-    Module **SuggestedModule) const 
+    Module **SuggestedModule,
+    bool &InUserSpecifiedSystemFramework) const
 {
   FileManager &FileMgr = HS.getFileMgr();
 
@@ -275,12 +279,12 @@
   if (SlashPos == StringRef::npos) return 0;
 
   // Find out if this is the home for the specified framework, by checking
-  // HeaderSearch.  Possible answer are yes/no and unknown.
-  const DirectoryEntry *&FrameworkDirCache =
+  // HeaderSearch.  Possible answers are yes/no and unknown.
+  HeaderSearch::FrameworkCacheEntry &CacheEntry =
     HS.LookupFrameworkCache(Filename.substr(0, SlashPos));
 
   // If it is known and in some other directory, fail.
-  if (FrameworkDirCache && FrameworkDirCache != getFrameworkDir())
+  if (CacheEntry.Directory && CacheEntry.Directory != getFrameworkDir())
     return 0;
 
   // Otherwise, construct the path to this framework dir.
@@ -298,22 +302,32 @@
   // FrameworkName = "/System/Library/Frameworks/Cocoa.framework/"
   FrameworkName += ".framework/";
 
-  // If the cache entry is still unresolved, query to see if the cache entry is
-  // still unresolved.  If so, check its existence now.
-  if (FrameworkDirCache == 0) {
+  // If the cache entry was unresolved, populate it now.
+  if (CacheEntry.Directory == 0) {
     HS.IncrementFrameworkLookupCount();
 
     // If the framework dir doesn't exist, we fail.
-    // FIXME: It's probably more efficient to query this with FileMgr.getDir.
-    bool Exists;
-    if (llvm::sys::fs::exists(FrameworkName.str(), Exists) || !Exists)
-      return 0;
+    const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkName.str());
+    if (Dir == 0) return 0;
 
     // Otherwise, if it does, remember that this is the right direntry for this
     // framework.
-    FrameworkDirCache = getFrameworkDir();
+    CacheEntry.Directory = getFrameworkDir();
+
+    // If this is a user search directory, check if the framework has been
+    // user-specified as a system framework.
+    if (getDirCharacteristic() == SrcMgr::C_User) {
+      SmallString<1024> SystemFrameworkMarker(FrameworkName);
+      SystemFrameworkMarker += ".system_framework";
+      if (llvm::sys::fs::exists(SystemFrameworkMarker.str())) {
+        CacheEntry.IsUserSpecifiedSystemFramework = true;
+      }
+    }
   }
 
+  // Set the 'user-specified system framework' flag.
+  InUserSpecifiedSystemFramework = CacheEntry.IsUserSpecifiedSystemFramework;
+
   if (RelativePath != NULL) {
     RelativePath->clear();
     RelativePath->append(Filename.begin()+SlashPos+1, Filename.end());
@@ -478,9 +492,10 @@
 
   // Check each directory in sequence to see if it contains this file.
   for (; i != SearchDirs.size(); ++i) {
+    bool InUserSpecifiedSystemFramework = false;
     const FileEntry *FE =
       SearchDirs[i].LookupFile(Filename, *this, SearchPath, RelativePath,
-                               SuggestedModule);
+                               SuggestedModule, InUserSpecifiedSystemFramework);
     if (!FE) continue;
 
     CurDir = &SearchDirs[i];
@@ -489,6 +504,12 @@
     HeaderFileInfo &HFI = getFileInfo(FE);
     HFI.DirInfo = CurDir->getDirCharacteristic();
 
+    // If the directory characteristic is User but this framework was
+    // user-specified to be treated as a system framework, promote the
+    // characteristic.
+    if (HFI.DirInfo == SrcMgr::C_User && InUserSpecifiedSystemFramework)
+      HFI.DirInfo = SrcMgr::C_System;
+
     // If this file is found in a header map and uses the framework style of
     // includes, then this header is part of a framework we're building.
     if (CurDir->isIndexHeaderMap()) {
@@ -562,26 +583,25 @@
        FrameworkPos[DotFrameworkLen] != '\\'))
     return 0;
 
-  SmallString<1024> FrameworkName(ContextName,
-                                        FrameworkPos+DotFrameworkLen+1);
+  SmallString<1024> FrameworkName(ContextName, FrameworkPos+DotFrameworkLen+1);
 
   // Append Frameworks/HIToolbox.framework/
   FrameworkName += "Frameworks/";
   FrameworkName.append(Filename.begin(), Filename.begin()+SlashPos);
   FrameworkName += ".framework/";
 
-  llvm::StringMapEntry<const DirectoryEntry *> &CacheLookup =
+  llvm::StringMapEntry<FrameworkCacheEntry> &CacheLookup =
     FrameworkMap.GetOrCreateValue(Filename.substr(0, SlashPos));
 
   // Some other location?
-  if (CacheLookup.getValue() &&
+  if (CacheLookup.getValue().Directory &&
       CacheLookup.getKeyLength() == FrameworkName.size() &&
       memcmp(CacheLookup.getKeyData(), &FrameworkName[0],
              CacheLookup.getKeyLength()) != 0)
     return 0;
 
   // Cache subframework.
-  if (CacheLookup.getValue() == 0) {
+  if (CacheLookup.getValue().Directory == 0) {
     ++NumSubFrameworkLookups;
 
     // If the framework dir doesn't exist, we fail.
@@ -590,7 +610,7 @@
 
     // Otherwise, if it does, remember that this is the right direntry for this
     // framework.
-    CacheLookup.setValue(Dir);
+    CacheLookup.getValue().Directory = Dir;
   }
 
   const FileEntry *FE = 0;

Modified: cfe/branches/tooling/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Lexer.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Lexer.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Lexer.cpp Tue Apr 17 06:08:26 2012
@@ -1597,7 +1597,9 @@
     // them.
     if (C != '_') {
       if (!isLexingRawMode())
-        Diag(CurPtr, diag::ext_reserved_user_defined_literal)
+        Diag(CurPtr, getLangOpts().MicrosoftMode ? 
+            diag::ext_ms_reserved_user_defined_literal :
+            diag::ext_reserved_user_defined_literal)
           << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
       return CurPtr;
     }
@@ -2374,8 +2376,9 @@
   // C99 5.1.1.2p2: If the file is non-empty and didn't end in a newline, issue
   // a pedwarn.
   if (CurPtr != BufferStart && (CurPtr[-1] != '\n' && CurPtr[-1] != '\r'))
-    Diag(BufferEnd, diag::ext_no_newline_eof)
-      << FixItHint::CreateInsertion(getSourceLocation(BufferEnd), "\n");
+    Diag(BufferEnd, LangOpts.CPlusPlus0x ? // C++11 [lex.phases] 2.2 p2
+         diag::warn_cxx98_compat_no_newline_eof : diag::ext_no_newline_eof)
+    << FixItHint::CreateInsertion(getSourceLocation(BufferEnd), "\n");
 
   BufferPtr = CurPtr;
 

Modified: cfe/branches/tooling/lib/Lex/MacroArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/MacroArgs.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/MacroArgs.cpp (original)
+++ cfe/branches/tooling/lib/Lex/MacroArgs.cpp Tue Apr 17 06:08:26 2012
@@ -16,6 +16,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/LexDiagnostic.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/Support/SaveAndRestore.h"
 #include <algorithm>
 
 using namespace clang;
@@ -155,6 +156,8 @@
   std::vector<Token> &Result = PreExpArgTokens[Arg];
   if (!Result.empty()) return Result;
 
+  SaveAndRestore<bool> PreExpandingMacroArgs(PP.InMacroArgPreExpansion, true);
+
   const Token *AT = getUnexpArgument(Arg);
   unsigned NumToks = getArgLength(AT)+1;  // Include the EOF.
 
@@ -177,6 +180,8 @@
   // will not otherwise be popped until the next token is lexed.  The problem is
   // that the token may be lexed sometime after the vector of tokens itself is
   // destroyed, which would be badness.
+  if (PP.InCachingLexMode())
+    PP.ExitCachingLexMode();
   PP.RemoveTopOfLexerStack();
   return Result;
 }

Modified: cfe/branches/tooling/lib/Lex/PPCaching.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PPCaching.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PPCaching.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PPCaching.cpp Tue Apr 17 06:08:26 2012
@@ -57,17 +57,21 @@
   ExitCachingLexMode();
   Lex(Result);
 
-  if (!isBacktrackEnabled()) {
+  if (isBacktrackEnabled()) {
+    // Cache the lexed token.
+    EnterCachingLexMode();
+    CachedTokens.push_back(Result);
+    ++CachedLexPos;
+    return;
+  }
+
+  if (CachedLexPos < CachedTokens.size()) {
+    EnterCachingLexMode();
+  } else {
     // All cached tokens were consumed.
     CachedTokens.clear();
     CachedLexPos = 0;
-    return;
   }
-
-  // Cache the lexed token.
-  EnterCachingLexMode();
-  CachedTokens.push_back(Result);
-  ++CachedLexPos;
 }
 
 void Preprocessor::EnterCachingLexMode() {

Modified: cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp Tue Apr 17 06:08:26 2012
@@ -649,6 +649,7 @@
            .Case("cxx_auto_type", LangOpts.CPlusPlus0x)
            .Case("cxx_constexpr", LangOpts.CPlusPlus0x)
            .Case("cxx_decltype", LangOpts.CPlusPlus0x)
+           .Case("cxx_decltype_incomplete_return_types", LangOpts.CPlusPlus0x)
            .Case("cxx_default_function_template_args", LangOpts.CPlusPlus0x)
            .Case("cxx_defaulted_functions", LangOpts.CPlusPlus0x)
            .Case("cxx_delegating_constructors", LangOpts.CPlusPlus0x)
@@ -659,6 +660,7 @@
          //.Case("cxx_inheriting_constructors", false)
            .Case("cxx_inline_namespaces", LangOpts.CPlusPlus0x)
            .Case("cxx_lambdas", LangOpts.CPlusPlus0x)
+           .Case("cxx_local_type_template_args", LangOpts.CPlusPlus0x)
            .Case("cxx_nonstatic_member_init", LangOpts.CPlusPlus0x)
            .Case("cxx_noexcept", LangOpts.CPlusPlus0x)
            .Case("cxx_nullptr", LangOpts.CPlusPlus0x)
@@ -753,6 +755,7 @@
            .Case("cxx_deleted_functions", LangOpts.CPlusPlus)
            .Case("cxx_explicit_conversions", LangOpts.CPlusPlus)
            .Case("cxx_inline_namespaces", LangOpts.CPlusPlus)
+           .Case("cxx_local_type_template_args", LangOpts.CPlusPlus)
            .Case("cxx_nonstatic_member_init", LangOpts.CPlusPlus)
            .Case("cxx_override_control", LangOpts.CPlusPlus)
            .Case("cxx_range_for", LangOpts.CPlusPlus)

Modified: cfe/branches/tooling/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Pragma.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Pragma.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Pragma.cpp Tue Apr 17 06:08:26 2012
@@ -115,10 +115,61 @@
     DiscardUntilEndOfDirective();
 }
 
+namespace {
+/// \brief Helper class for \see Preprocessor::Handle_Pragma.
+class LexingFor_PragmaRAII {
+  Preprocessor &PP;
+  bool InMacroArgPreExpansion;
+  bool Failed;
+  Token &OutTok;
+  Token PragmaTok;
+
+public:
+  LexingFor_PragmaRAII(Preprocessor &PP, bool InMacroArgPreExpansion,
+                       Token &Tok)
+    : PP(PP), InMacroArgPreExpansion(InMacroArgPreExpansion),
+      Failed(false), OutTok(Tok) {
+    if (InMacroArgPreExpansion) {
+      PragmaTok = OutTok;
+      PP.EnableBacktrackAtThisPos();
+    }
+  }
+
+  ~LexingFor_PragmaRAII() {
+    if (InMacroArgPreExpansion) {
+      if (Failed) {
+        PP.CommitBacktrackedTokens();
+      } else {
+        PP.Backtrack();
+        OutTok = PragmaTok;
+      }
+    }
+  }
+
+  void failed() {
+    Failed = true;
+  }
+};
+}
+
 /// Handle_Pragma - Read a _Pragma directive, slice it up, process it, then
 /// return the first token after the directive.  The _Pragma token has just
 /// been read into 'Tok'.
 void Preprocessor::Handle_Pragma(Token &Tok) {
+
+  // This works differently if we are pre-expanding a macro argument.
+  // In that case we don't actually "activate" the pragma now, we only lex it
+  // until we are sure it is lexically correct and then we backtrack so that
+  // we activate the pragma whenever we encounter the tokens again in the token
+  // stream. This ensures that we will activate it in the correct location
+  // or that we will ignore it if it never enters the token stream, e.g:
+  //
+  //     #define EMPTY(x)
+  //     #define INACTIVE(x) EMPTY(x)
+  //     INACTIVE(_Pragma("clang diagnostic ignored \"-Wconversion\""))
+
+  LexingFor_PragmaRAII _PragmaLexing(*this, InMacroArgPreExpansion, Tok);
+
   // Remember the pragma token location.
   SourceLocation PragmaLoc = Tok.getLocation();
 
@@ -126,7 +177,7 @@
   Lex(Tok);
   if (Tok.isNot(tok::l_paren)) {
     Diag(PragmaLoc, diag::err__Pragma_malformed);
-    return;
+    return _PragmaLexing.failed();
   }
 
   // Read the '"..."'.
@@ -138,7 +189,7 @@
       Lex(Tok);
     if (Tok.is(tok::r_paren))
       Lex(Tok);
-    return;
+    return _PragmaLexing.failed();
   }
 
   if (Tok.hasUDSuffix()) {
@@ -147,20 +198,24 @@
     Lex(Tok);
     if (Tok.is(tok::r_paren))
       Lex(Tok);
-    return;
+    return _PragmaLexing.failed();
   }
 
   // Remember the string.
-  std::string StrVal = getSpelling(Tok);
+  Token StrTok = Tok;
 
   // Read the ')'.
   Lex(Tok);
   if (Tok.isNot(tok::r_paren)) {
     Diag(PragmaLoc, diag::err__Pragma_malformed);
-    return;
+    return _PragmaLexing.failed();
   }
 
+  if (InMacroArgPreExpansion)
+    return;
+
   SourceLocation RParenLoc = Tok.getLocation();
+  std::string StrVal = getSpelling(StrTok);
 
   // The _Pragma is lexically sound.  Destringize according to C99 6.10.9.1:
   // "The string literal is destringized by deleting the L prefix, if present,

Modified: cfe/branches/tooling/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Preprocessor.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Preprocessor.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Preprocessor.cpp Tue Apr 17 06:08:26 2012
@@ -135,6 +135,7 @@
   // Macro expansion is enabled.
   DisableMacroExpansion = false;
   InMacroArgs = false;
+  InMacroArgPreExpansion = false;
   NumCachedTokenLexers = 0;
   
   CachedLexPos = 0;

Modified: cfe/branches/tooling/lib/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Makefile?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Makefile (original)
+++ cfe/branches/tooling/lib/Makefile Tue Apr 17 06:08:26 2012
@@ -10,7 +10,7 @@
 
 PARALLEL_DIRS = Headers Basic Lex Parse AST ASTMatchers Sema CodeGen Analysis \
                 StaticAnalyzer Edit Rewrite ARCMigrate Serialization Frontend \
-                FrontendTool Tooling Index Driver
+                FrontendTool Tooling Driver
 
 include $(CLANG_LEVEL)/Makefile
 

Modified: cfe/branches/tooling/lib/Parse/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseAST.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseAST.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseAST.cpp Tue Apr 17 06:08:26 2012
@@ -38,19 +38,20 @@
 void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
                      ASTContext &Ctx, bool PrintStats,
                      TranslationUnitKind TUKind,
-                     CodeCompleteConsumer *CompletionConsumer) {
+                     CodeCompleteConsumer *CompletionConsumer,
+                     bool SkipFunctionBodies) {
 
   OwningPtr<Sema> S(new Sema(PP, Ctx, *Consumer,
                                    TUKind,
                                    CompletionConsumer));
 
   // Recover resources if we crash before exiting this method.
-  llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleaupSema(S.get());
+  llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(S.get());
   
-  ParseAST(*S.get(), PrintStats);
+  ParseAST(*S.get(), PrintStats, SkipFunctionBodies);
 }
 
-void clang::ParseAST(Sema &S, bool PrintStats) {
+void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) {
   // Collect global stats on Decls/Stmts (until we have a module streamer).
   if (PrintStats) {
     Decl::EnableStatistics();
@@ -63,14 +64,15 @@
 
   ASTConsumer *Consumer = &S.getASTConsumer();
 
-  OwningPtr<Parser> ParseOP(new Parser(S.getPreprocessor(), S));
+  OwningPtr<Parser> ParseOP(new Parser(S.getPreprocessor(), S,
+                                       SkipFunctionBodies));
   Parser &P = *ParseOP.get();
 
   PrettyStackTraceParserEntry CrashInfo(P);
 
   // Recover resources if we crash before exiting this method.
   llvm::CrashRecoveryContextCleanupRegistrar<Parser>
-    CleaupParser(ParseOP.get());
+    CleanupParser(ParseOP.get());
 
   S.getPreprocessor().EnterMainSourceFile();
   P.Initialize();

Modified: cfe/branches/tooling/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseDecl.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseDecl.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseDecl.cpp Tue Apr 17 06:08:26 2012
@@ -207,6 +207,7 @@
   case tok::kw_int:
   case tok::kw_long:
   case tok::kw___int64:
+  case tok::kw___int128:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw_float:
@@ -734,9 +735,18 @@
   ParseScope ClassScope(this, ScopeFlags, !AlreadyHasClassScope);
   ParseScopeFlags ClassScopeFlags(this, ScopeFlags, AlreadyHasClassScope);
 
+  // Enter the scope of nested classes
+  if (!AlreadyHasClassScope)
+    Actions.ActOnStartDelayedMemberDeclarations(getCurScope(),
+                                                Class.TagOrTemplate);
+
   for (unsigned i = 0, ni = Class.LateParsedDeclarations.size(); i < ni; ++i) {
     Class.LateParsedDeclarations[i]->ParseLexedAttributes();
   }
+
+  if (!AlreadyHasClassScope)
+    Actions.ActOnFinishDelayedMemberDeclarations(getCurScope(),
+                                                 Class.TagOrTemplate);
 }
 
 
@@ -896,6 +906,40 @@
     *EndLoc = T.getCloseLocation();
 }
 
+/// DiagnoseProhibitedCXX11Attribute - We have found the opening square brackets
+/// of a C++11 attribute-specifier in a location where an attribute is not
+/// permitted. By C++11 [dcl.attr.grammar]p6, this is ill-formed. Diagnose this
+/// situation.
+///
+/// \return \c true if we skipped an attribute-like chunk of tokens, \c false if
+/// this doesn't appear to actually be an attribute-specifier, and the caller
+/// should try to parse it.
+bool Parser::DiagnoseProhibitedCXX11Attribute() {
+  assert(Tok.is(tok::l_square) && NextToken().is(tok::l_square));
+
+  switch (isCXX11AttributeSpecifier(/*Disambiguate*/true)) {
+  case CAK_NotAttributeSpecifier:
+    // No diagnostic: we're in Obj-C++11 and this is not actually an attribute.
+    return false;
+
+  case CAK_InvalidAttributeSpecifier:
+    Diag(Tok.getLocation(), diag::err_l_square_l_square_not_attribute);
+    return false;
+
+  case CAK_AttributeSpecifier:
+    // Parse and discard the attributes.
+    SourceLocation BeginLoc = ConsumeBracket();
+    ConsumeBracket();
+    SkipUntil(tok::r_square, /*StopAtSemi*/ false);
+    assert(Tok.is(tok::r_square) && "isCXX11AttributeSpecifier lied");
+    SourceLocation EndLoc = ConsumeBracket();
+    Diag(BeginLoc, diag::err_attributes_not_allowed)
+      << SourceRange(BeginLoc, EndLoc);
+    return true;
+  }
+  llvm_unreachable("All cases handled above.");
+}
+
 void Parser::DiagnoseProhibitedAttributes(ParsedAttributesWithRange &attrs) {
   Diag(attrs.Range.getBegin(), diag::err_attributes_not_allowed)
     << attrs.Range;
@@ -1073,6 +1117,67 @@
   }
 }
 
+/// Skip until we reach something which seems like a sensible place to pick
+/// up parsing after a malformed declaration. This will sometimes stop sooner
+/// than SkipUntil(tok::r_brace) would, but will never stop later.
+void Parser::SkipMalformedDecl() {
+  while (true) {
+    switch (Tok.getKind()) {
+    case tok::l_brace:
+      // Skip until matching }, then stop. We've probably skipped over
+      // a malformed class or function definition or similar.
+      ConsumeBrace();
+      SkipUntil(tok::r_brace, /*StopAtSemi*/false);
+      if (Tok.is(tok::comma) || Tok.is(tok::l_brace) || Tok.is(tok::kw_try)) {
+        // This declaration isn't over yet. Keep skipping.
+        continue;
+      }
+      if (Tok.is(tok::semi))
+        ConsumeToken();
+      return;
+
+    case tok::l_square:
+      ConsumeBracket();
+      SkipUntil(tok::r_square, /*StopAtSemi*/false);
+      continue;
+
+    case tok::l_paren:
+      ConsumeParen();
+      SkipUntil(tok::r_paren, /*StopAtSemi*/false);
+      continue;
+
+    case tok::r_brace:
+      return;
+
+    case tok::semi:
+      ConsumeToken();
+      return;
+
+    case tok::kw_inline:
+      // 'inline namespace' at the start of a line is almost certainly
+      // a good place to pick back up parsing.
+      if (Tok.isAtStartOfLine() && NextToken().is(tok::kw_namespace))
+        return;
+      break;
+
+    case tok::kw_namespace:
+      // 'namespace' at the start of a line is almost certainly a good
+      // place to pick back up parsing.
+      if (Tok.isAtStartOfLine())
+        return;
+      break;
+
+    case tok::eof:
+      return;
+
+    default:
+      break;
+    }
+
+    ConsumeAnyToken();
+  }
+}
+
 /// ParseDeclGroup - Having concluded that this is either a function
 /// definition or a group of object declarations, actually parse the
 /// result.
@@ -1087,10 +1192,7 @@
 
   // Bail out if the first declarator didn't seem well-formed.
   if (!D.hasName() && !D.mayOmitIdentifier()) {
-    // Skip until ; or }.
-    SkipUntil(tok::r_brace, true, true);
-    if (Tok.is(tok::semi))
-      ConsumeToken();
+    SkipMalformedDecl();
     return DeclGroupPtrTy();
   }
 
@@ -2228,10 +2330,14 @@
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec,
                                      DiagID);
       break;
-     case tok::kw_half:
-       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_half, Loc, PrevSpec,
-                                      DiagID);
-       break;
+    case tok::kw___int128:
+      isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec,
+                                     DiagID);
+      break;
+    case tok::kw_half:
+      isInvalid = DS.SetTypeSpecType(DeclSpec::TST_half, Loc, PrevSpec,
+                                     DiagID);
+      break;
     case tok::kw_float:
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_float, Loc, PrevSpec,
                                      DiagID);
@@ -3039,6 +3145,7 @@
   case tok::kw_short:
   case tok::kw_long:
   case tok::kw___int64:
+  case tok::kw___int128:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw__Complex:
@@ -3109,6 +3216,7 @@
   case tok::kw_short:
   case tok::kw_long:
   case tok::kw___int64:
+  case tok::kw___int128:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw__Complex:
@@ -3244,6 +3352,7 @@
   case tok::kw_short:
   case tok::kw_long:
   case tok::kw___int64:
+  case tok::kw___int128:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw__Complex:
@@ -3436,15 +3545,12 @@
 ///
 void Parser::ParseTypeQualifierListOpt(DeclSpec &DS,
                                        bool VendorAttributesAllowed,
-                                       bool CXX0XAttributesAllowed) {
-  if (getLangOpts().CPlusPlus0x && isCXX0XAttributeSpecifier()) {
-    SourceLocation Loc = Tok.getLocation();
+                                       bool CXX11AttributesAllowed) {
+  if (getLangOpts().CPlusPlus0x && CXX11AttributesAllowed &&
+      isCXX11AttributeSpecifier()) {
     ParsedAttributesWithRange attrs(AttrFactory);
-    ParseCXX0XAttributes(attrs);
-    if (CXX0XAttributesAllowed)
-      DS.takeAttributesFrom(attrs);
-    else
-      Diag(Loc, diag::err_attributes_not_allowed);
+    ParseCXX11Attributes(attrs);
+    DS.takeAttributesFrom(attrs);
   }
 
   SourceLocation EndLoc;
@@ -3637,6 +3743,7 @@
     // Is a pointer.
     DeclSpec DS(AttrFactory);
 
+    // FIXME: GNU attributes are not allowed here in a new-type-id.
     ParseTypeQualifierListOpt(DS);
     D.ExtendWithDeclSpec(DS);
 
@@ -3667,16 +3774,13 @@
            diag::warn_cxx98_compat_rvalue_reference :
            diag::ext_rvalue_reference);
 
+    // GNU-style and C++11 attributes are allowed here, as is restrict.
+    ParseTypeQualifierListOpt(DS);
+    D.ExtendWithDeclSpec(DS);
+
     // C++ 8.3.2p1: cv-qualified references are ill-formed except when the
     // cv-qualifiers are introduced through the use of a typedef or of a
     // template type argument, in which case the cv-qualifiers are ignored.
-    //
-    // [GNU] Retricted references are allowed.
-    // [GNU] Attributes on references are allowed.
-    // [C++0x] Attributes on references are not allowed.
-    ParseTypeQualifierListOpt(DS, true, false);
-    D.ExtendWithDeclSpec(DS);
-
     if (DS.getTypeQualifiers() != DeclSpec::TQ_unspecified) {
       if (DS.getTypeQualifiers() & DeclSpec::TQ_const)
         Diag(DS.getConstSpecLoc(),
@@ -3737,13 +3841,19 @@
 /// [C99]   direct-declarator '[' 'static' type-qual-list[opt] assign-expr ']'
 /// [C99]   direct-declarator '[' type-qual-list 'static' assignment-expr ']'
 /// [C99]   direct-declarator '[' type-qual-list[opt] '*' ']'
+/// [C++11] direct-declarator '[' constant-expression[opt] ']'
+///                    attribute-specifier-seq[opt]
 ///         direct-declarator '(' parameter-type-list ')'
 ///         direct-declarator '(' identifier-list[opt] ')'
 /// [GNU]   direct-declarator '(' parameter-forward-declarations
 ///                    parameter-type-list[opt] ')'
 /// [C++]   direct-declarator '(' parameter-declaration-clause ')'
 ///                    cv-qualifier-seq[opt] exception-specification[opt]
+/// [C++11] direct-declarator '(' parameter-declaration-clause ')'
+///                    attribute-specifier-seq[opt] cv-qualifier-seq[opt]
+///                    ref-qualifier[opt] exception-specification[opt]
 /// [C++]   declarator-id
+/// [C++11] declarator-id attribute-specifier-seq[opt]
 ///
 ///       declarator-id: [C++ 8]
 ///         '...'[opt] id-expression
@@ -3891,8 +4001,8 @@
   assert(D.isPastIdentifier() &&
          "Haven't past the location of the identifier yet?");
 
-  // Don't parse attributes unless we have an identifier.
-  if (D.getIdentifier())
+  // Don't parse attributes unless we have parsed an unparenthesized name.
+  if (D.hasName() && !D.getNumTypeObjects())
     MaybeParseCXX0XAttributes(D);
 
   while (1) {
@@ -3986,7 +4096,8 @@
   } else if (Tok.is(tok::r_paren) ||           // 'int()' is a function.
              (getLangOpts().CPlusPlus && Tok.is(tok::ellipsis) &&
               NextToken().is(tok::r_paren)) || // C++ int(...)
-             isDeclarationSpecifier()) {       // 'int(int)' is a function.
+             isDeclarationSpecifier() ||       // 'int(int)' is a function.
+             isCXX11AttributeSpecifier()) {    // 'int([[]]int)' is a function.
     // This handles C99 6.7.5.3p11: in "typedef int X; void foo(X)", X is
     // considered to be a type, not a K&R identifier-list.
     isGrouping = false;
@@ -4038,22 +4149,23 @@
 /// declarator D up to a paren, which indicates that we are parsing function
 /// arguments.
 ///
-/// If attrs is non-null, then the caller parsed those arguments immediately
-/// after the open paren - they should be considered to be the first argument of
-/// a parameter.  If RequiresArg is true, then the first argument of the
-/// function is required to be present and required to not be an identifier
-/// list.
-///
-/// For C++, after the parameter-list, it also parses cv-qualifier-seq[opt],
-/// (C++0x) ref-qualifier[opt], exception-specification[opt], and
-/// (C++0x) trailing-return-type[opt].
+/// If FirstArgAttrs is non-null, then the caller parsed those arguments
+/// immediately after the open paren - they should be considered to be the
+/// first argument of a parameter.
+///
+/// If RequiresArg is true, then the first argument of the function is required
+/// to be present and required to not be an identifier list.
+///
+/// For C++, after the parameter-list, it also parses the cv-qualifier-seq[opt],
+/// (C++11) ref-qualifier[opt], exception-specification[opt],
+/// (C++11) attribute-specifier-seq[opt], and (C++11) trailing-return-type[opt].
 ///
-/// [C++0x] exception-specification:
+/// [C++11] exception-specification:
 ///           dynamic-exception-specification
 ///           noexcept-specification
 ///
 void Parser::ParseFunctionDeclarator(Declarator &D,
-                                     ParsedAttributes &attrs,
+                                     ParsedAttributes &FirstArgAttrs,
                                      BalancedDelimiterTracker &Tracker,
                                      bool RequiresArg) {
   assert(getCurScope()->isFunctionPrototypeScope() && 
@@ -4079,8 +4191,9 @@
   SmallVector<ParsedType, 2> DynamicExceptions;
   SmallVector<SourceRange, 2> DynamicExceptionRanges;
   ExprResult NoexceptExpr;
+  ParsedAttributes FnAttrs(AttrFactory);
   ParsedType TrailingReturnType;
-  
+
   Actions.ActOnStartFunctionDeclarator();
 
   SourceLocation EndLoc;
@@ -4094,7 +4207,7 @@
     EndLoc = Tracker.getCloseLocation();
   } else {
     if (Tok.isNot(tok::r_paren))
-      ParseParameterDeclarationClause(D, attrs, ParamInfo, EllipsisLoc);
+      ParseParameterDeclarationClause(D, FirstArgAttrs, ParamInfo, EllipsisLoc);
     else if (RequiresArg)
       Diag(Tok, diag::err_argument_required_after_attribute);
 
@@ -4105,22 +4218,24 @@
     EndLoc = Tracker.getCloseLocation();
 
     if (getLangOpts().CPlusPlus) {
-      MaybeParseCXX0XAttributes(attrs);
+      // FIXME: Accept these components in any order, and produce fixits to
+      // correct the order if the user gets it wrong. Ideally we should deal
+      // with the virt-specifier-seq and pure-specifier in the same way.
 
       // Parse cv-qualifier-seq[opt].
-      ParseTypeQualifierListOpt(DS, false /*no attributes*/);
-        if (!DS.getSourceRange().getEnd().isInvalid()) {
-          EndLoc = DS.getSourceRange().getEnd();
-          ConstQualifierLoc = DS.getConstSpecLoc();
-          VolatileQualifierLoc = DS.getVolatileSpecLoc();
-        }
+      ParseTypeQualifierListOpt(DS, false /*no attributes*/, false);
+      if (!DS.getSourceRange().getEnd().isInvalid()) {
+        EndLoc = DS.getSourceRange().getEnd();
+        ConstQualifierLoc = DS.getConstSpecLoc();
+        VolatileQualifierLoc = DS.getVolatileSpecLoc();
+      }
 
       // Parse ref-qualifier[opt].
       if (Tok.is(tok::amp) || Tok.is(tok::ampamp)) {
         Diag(Tok, getLangOpts().CPlusPlus0x ?
              diag::warn_cxx98_compat_ref_qualifier :
              diag::ext_ref_qualifier);
-        
+
         RefQualifierIsLValueRef = Tok.is(tok::amp);
         RefQualifierLoc = ConsumeToken();
         EndLoc = RefQualifierLoc;
@@ -4134,6 +4249,10 @@
       if (ESpecType != EST_None)
         EndLoc = ESpecRange.getEnd();
 
+      // Parse attribute-specifier-seq[opt]. Per DR 979 and DR 1297, this goes
+      // after the exception-specification.
+      MaybeParseCXX0XAttributes(FnAttrs);
+
       // Parse trailing-return-type[opt].
       if (getLangOpts().CPlusPlus0x && Tok.is(tok::arrow)) {
         Diag(Tok, diag::warn_cxx98_compat_trailing_return_type);
@@ -4164,7 +4283,7 @@
                                              Tracker.getOpenLocation(), 
                                              EndLoc, D,
                                              TrailingReturnType),
-                attrs, EndLoc);
+                FnAttrs, EndLoc);
 
   Actions.ActOnEndFunctionDeclarator();
 }
@@ -4258,9 +4377,9 @@
 /// after the opening parenthesis. This function will not parse a K&R-style
 /// identifier list.
 ///
-/// D is the declarator being parsed.  If attrs is non-null, then the caller
-/// parsed those arguments immediately after the open paren - they should be
-/// considered to be the first argument of a parameter.
+/// D is the declarator being parsed.  If FirstArgAttrs is non-null, then the
+/// caller parsed those arguments immediately after the open paren - they should
+/// be considered to be part of the first parameter.
 ///
 /// After returning, ParamInfo will hold the parsed parameters. EllipsisLoc will
 /// be the location of the ellipsis, if any was parsed.
@@ -4283,15 +4402,18 @@
 /// [C++]   declaration-specifiers abstract-declarator[opt]
 ///           '=' assignment-expression
 /// [GNU]   declaration-specifiers abstract-declarator[opt] attributes
+/// [C++11] attribute-specifier-seq parameter-declaration
 ///
 void Parser::ParseParameterDeclarationClause(
        Declarator &D,
-       ParsedAttributes &attrs,
+       ParsedAttributes &FirstArgAttrs,
        SmallVector<DeclaratorChunk::ParamInfo, 16> &ParamInfo,
        SourceLocation &EllipsisLoc) {
 
   while (1) {
     if (Tok.is(tok::ellipsis)) {
+      // FIXME: Issue a diagnostic if we parsed an attribute-specifier-seq
+      // before deciding this was a parameter-declaration-clause.
       EllipsisLoc = ConsumeToken();     // Consume the ellipsis.
       break;
     }
@@ -4300,6 +4422,9 @@
     // Just use the ParsingDeclaration "scope" of the declarator.
     DeclSpec DS(AttrFactory);
 
+    // Parse any C++11 attributes.
+    MaybeParseCXX0XAttributes(DS.getAttributes());
+
     // Skip any Microsoft attributes before a param.
     if (getLangOpts().MicrosoftExt && Tok.is(tok::l_square))
       ParseMicrosoftAttributes(DS.getAttributes());
@@ -4308,12 +4433,10 @@
 
     // If the caller parsed attributes for the first argument, add them now.
     // Take them so that we only apply the attributes to the first parameter.
-    // FIXME: If we saw an ellipsis first, this code is not reached. Are the
-    // attributes lost? Should they even be allowed?
     // FIXME: If we can leave the attributes in the token stream somehow, we can
-    // get rid of a parameter (attrs) and this statement. It might be too much
-    // hassle.
-    DS.takeAttributesFrom(attrs);
+    // get rid of a parameter (FirstArgAttrs) and this statement. It might be
+    // too much hassle.
+    DS.takeAttributesFrom(FirstArgAttrs);
 
     ParseDeclarationSpecifiers(DS);
 
@@ -4438,7 +4561,12 @@
 /// [C99]   direct-declarator '[' 'static' type-qual-list[opt] assign-expr ']'
 /// [C99]   direct-declarator '[' type-qual-list 'static' assignment-expr ']'
 /// [C99]   direct-declarator '[' type-qual-list[opt] '*' ']'
+/// [C++11] direct-declarator '[' constant-expression[opt] ']'
+///                           attribute-specifier-seq[opt]
 void Parser::ParseBracketDeclarator(Declarator &D) {
+  if (CheckProhibitedCXX11Attribute())
+    return;
+
   BalancedDelimiterTracker T(*this, tok::l_square);
   T.consumeOpen();
 

Modified: cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp Tue Apr 17 06:08:26 2012
@@ -2736,43 +2736,87 @@
   Victim->TemplateScope = getCurScope()->getParent()->isTemplateParamScope();
 }
 
-/// ParseCXX0XAttributeSpecifier - Parse a C++0x attribute-specifier. Currently
+/// \brief Try to parse an 'identifier' which appears within an attribute-token.
+///
+/// \return the parsed identifier on success, and 0 if the next token is not an
+/// attribute-token.
+///
+/// C++11 [dcl.attr.grammar]p3:
+///   If a keyword or an alternative token that satisfies the syntactic
+///   requirements of an identifier is contained in an attribute-token,
+///   it is considered an identifier.
+IdentifierInfo *Parser::TryParseCXX11AttributeIdentifier(SourceLocation &Loc) {
+  switch (Tok.getKind()) {
+  default:
+    // Identifiers and keywords have identifier info attached.
+    if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
+      Loc = ConsumeToken();
+      return II;
+    }
+    return 0;
+
+  case tok::ampamp:       // 'and'
+  case tok::pipe:         // 'bitor'
+  case tok::pipepipe:     // 'or'
+  case tok::caret:        // 'xor'
+  case tok::tilde:        // 'compl'
+  case tok::amp:          // 'bitand'
+  case tok::ampequal:     // 'and_eq'
+  case tok::pipeequal:    // 'or_eq'
+  case tok::caretequal:   // 'xor_eq'
+  case tok::exclaim:      // 'not'
+  case tok::exclaimequal: // 'not_eq'
+    // Alternative tokens do not have identifier info, but their spelling
+    // starts with an alphabetical character.
+    llvm::SmallString<8> SpellingBuf;
+    StringRef Spelling = PP.getSpelling(Tok.getLocation(), SpellingBuf);
+    if (std::isalpha(Spelling[0])) {
+      Loc = ConsumeToken();
+      return &PP.getIdentifierTable().get(Spelling.data());
+    }
+    return 0;
+  }
+}
+
+/// ParseCXX11AttributeSpecifier - Parse a C++11 attribute-specifier. Currently
 /// only parses standard attributes.
 ///
-/// [C++0x] attribute-specifier:
+/// [C++11] attribute-specifier:
 ///         '[' '[' attribute-list ']' ']'
 ///         alignment-specifier
 ///
-/// [C++0x] attribute-list:
+/// [C++11] attribute-list:
 ///         attribute[opt]
 ///         attribute-list ',' attribute[opt]
+///         attribute '...'
+///         attribute-list ',' attribute '...'
 ///
-/// [C++0x] attribute:
+/// [C++11] attribute:
 ///         attribute-token attribute-argument-clause[opt]
 ///
-/// [C++0x] attribute-token:
+/// [C++11] attribute-token:
 ///         identifier
 ///         attribute-scoped-token
 ///
-/// [C++0x] attribute-scoped-token:
+/// [C++11] attribute-scoped-token:
 ///         attribute-namespace '::' identifier
 ///
-/// [C++0x] attribute-namespace:
+/// [C++11] attribute-namespace:
 ///         identifier
 ///
-/// [C++0x] attribute-argument-clause:
+/// [C++11] attribute-argument-clause:
 ///         '(' balanced-token-seq ')'
 ///
-/// [C++0x] balanced-token-seq:
+/// [C++11] balanced-token-seq:
 ///         balanced-token
 ///         balanced-token-seq balanced-token
 ///
-/// [C++0x] balanced-token:
+/// [C++11] balanced-token:
 ///         '(' balanced-token-seq ')'
 ///         '[' balanced-token-seq ']'
 ///         '{' balanced-token-seq '}'
 ///         any token but '(', ')', '[', ']', '{', or '}'
-void Parser::ParseCXX0XAttributeSpecifier(ParsedAttributes &attrs,
+void Parser::ParseCXX11AttributeSpecifier(ParsedAttributes &attrs,
                                           SourceLocation *endLoc) {
   if (Tok.is(tok::kw_alignas)) {
     Diag(Tok.getLocation(), diag::warn_cxx98_compat_alignas);
@@ -2781,56 +2825,53 @@
   }
 
   assert(Tok.is(tok::l_square) && NextToken().is(tok::l_square)
-      && "Not a C++0x attribute list");
+      && "Not a C++11 attribute list");
 
   Diag(Tok.getLocation(), diag::warn_cxx98_compat_attribute);
 
   ConsumeBracket();
   ConsumeBracket();
 
-  if (Tok.is(tok::comma)) {
-    Diag(Tok.getLocation(), diag::err_expected_ident);
-    ConsumeToken();
-  }
-
-  while (Tok.is(tok::identifier) || Tok.is(tok::comma)) {
+  while (Tok.isNot(tok::r_square)) {
     // attribute not present
     if (Tok.is(tok::comma)) {
       ConsumeToken();
       continue;
     }
 
-    IdentifierInfo *ScopeName = 0, *AttrName = Tok.getIdentifierInfo();
-    SourceLocation ScopeLoc, AttrLoc = ConsumeToken();
+    SourceLocation ScopeLoc, AttrLoc;
+    IdentifierInfo *ScopeName = 0, *AttrName = 0;
+
+    AttrName = TryParseCXX11AttributeIdentifier(AttrLoc);
+    if (!AttrName)
+      // Break out to the "expected ']'" diagnostic.
+      break;
 
     // scoped attribute
     if (Tok.is(tok::coloncolon)) {
       ConsumeToken();
 
-      if (!Tok.is(tok::identifier)) {
+      ScopeName = AttrName;
+      ScopeLoc = AttrLoc;
+
+      AttrName = TryParseCXX11AttributeIdentifier(AttrLoc);
+      if (!AttrName) {
         Diag(Tok.getLocation(), diag::err_expected_ident);
         SkipUntil(tok::r_square, tok::comma, true, true);
         continue;
       }
-
-      ScopeName = AttrName;
-      ScopeLoc = AttrLoc;
-
-      AttrName = Tok.getIdentifierInfo();
-      AttrLoc = ConsumeToken();
     }
 
     bool AttrParsed = false;
     // No scoped names are supported; ideally we could put all non-standard
     // attributes into namespaces.
     if (!ScopeName) {
-      switch(AttributeList::getKind(AttrName))
-      {
+      switch (AttributeList::getKind(AttrName)) {
       // No arguments
       case AttributeList::AT_carries_dependency:
       case AttributeList::AT_noreturn: {
         if (Tok.is(tok::l_paren)) {
-          Diag(Tok.getLocation(), diag::err_cxx0x_attribute_forbids_arguments)
+          Diag(Tok.getLocation(), diag::err_cxx11_attribute_forbids_arguments)
             << AttrName->getName();
           break;
         }
@@ -2852,6 +2893,13 @@
       // SkipUntil maintains the balancedness of tokens.
       SkipUntil(tok::r_paren, false);
     }
+
+    if (Tok.is(tok::ellipsis)) {
+      if (AttrParsed)
+        Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis)
+          << AttrName->getName();
+      ConsumeToken();
+    }
   }
 
   if (ExpectAndConsume(tok::r_square, diag::err_expected_rsquare))
@@ -2862,19 +2910,19 @@
     SkipUntil(tok::r_square, false);
 }
 
-/// ParseCXX0XAttributes - Parse a C++0x attribute-specifier-seq.
+/// ParseCXX11Attributes - Parse a C++0x attribute-specifier-seq.
 ///
 /// attribute-specifier-seq:
 ///       attribute-specifier-seq[opt] attribute-specifier
-void Parser::ParseCXX0XAttributes(ParsedAttributesWithRange &attrs,
+void Parser::ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
                                   SourceLocation *endLoc) {
   SourceLocation StartLoc = Tok.getLocation(), Loc;
   if (!endLoc)
     endLoc = &Loc;
 
   do {
-    ParseCXX0XAttributeSpecifier(attrs, endLoc);
-  } while (isCXX0XAttributeSpecifier());
+    ParseCXX11AttributeSpecifier(attrs, endLoc);
+  } while (isCXX11AttributeSpecifier());
 
   attrs.Range = SourceRange(StartLoc, *endLoc);
 }
@@ -2892,6 +2940,7 @@
   assert(Tok.is(tok::l_square) && "Not a Microsoft attribute list");
 
   while (Tok.is(tok::l_square)) {
+    // FIXME: If this is actually a C++11 attribute, parse it as one.
     ConsumeBracket();
     SkipUntil(tok::r_square, true, true);
     if (endLoc) *endLoc = Tok.getLocation();

Modified: cfe/branches/tooling/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseExpr.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseExpr.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseExpr.cpp Tue Apr 17 06:08:26 2012
@@ -987,6 +987,7 @@
   case tok::kw_int:
   case tok::kw_long:
   case tok::kw___int64:
+  case tok::kw___int128:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw_half:
@@ -1286,7 +1287,12 @@
       if (getLangOpts().ObjC1 && Tok.isAtStartOfLine() &&
           isSimpleObjCMessageExpression())
         return move(LHS);
-       
+
+      // Reject array indices starting with a lambda-expression. '[[' is
+      // reserved for attributes.
+      if (CheckProhibitedCXX11Attribute())
+        return ExprError();
+
       BalancedDelimiterTracker T(*this, tok::l_square);
       T.consumeOpen();
       Loc = T.getOpenLocation();
@@ -1755,6 +1761,9 @@
         Comps.back().LocEnd = ConsumeToken();
 
       } else if (Tok.is(tok::l_square)) {
+        if (CheckProhibitedCXX11Attribute())
+          return ExprError();
+
         // offsetof-member-designator: offsetof-member-design '[' expression ']'
         Comps.push_back(Sema::OffsetOfComponent());
         Comps.back().isBrackets = true;
@@ -1917,13 +1926,19 @@
   // unless they've already reported an error.
   if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) {
     Diag(Tok, diag::ext_gnu_statement_expr);
+
+    Actions.ActOnStartStmtExpr();
+
     ParsedAttributes attrs(AttrFactory);
     StmtResult Stmt(ParseCompoundStatement(attrs, true));
     ExprType = CompoundStmt;
 
     // If the substmt parsed correctly, build the AST node.
-    if (!Stmt.isInvalid())
+    if (!Stmt.isInvalid()) {
       Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.take(), Tok.getLocation());
+    } else {
+      Actions.ActOnStmtExprError();
+    }
   } else if (ExprType >= CompoundLiteral && BridgeCast) {
     tok::TokenKind tokenKind = Tok.getKind();
     SourceLocation BridgeKeywordLoc = ConsumeToken();

Modified: cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp Tue Apr 17 06:08:26 2012
@@ -1389,6 +1389,7 @@
   case tok::kw_short:
   case tok::kw_long:
   case tok::kw___int64:
+  case tok::kw___int128:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw_void:
@@ -1499,6 +1500,9 @@
   case tok::kw_int:
     DS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec, DiagID);
     break;
+  case tok::kw___int128:
+    DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec, DiagID);
+    break;
   case tok::kw_half:
     DS.SetTypeSpecType(DeclSpec::TST_half, Loc, PrevSpec, DiagID);
     break;
@@ -1813,7 +1817,9 @@
       bool isNew = Tok.getKind() == tok::kw_new;
       // Consume the 'new' or 'delete'.
       SymbolLocations[SymbolIdx++] = ConsumeToken();
-      if (Tok.is(tok::l_square)) {
+      // Check for array new/delete.
+      if (Tok.is(tok::l_square) &&
+          (!getLangOpts().CPlusPlus0x || NextToken().isNot(tok::l_square))) {
         // Consume the '[' and ']'.
         BalancedDelimiterTracker T(*this, tok::l_square);
         T.consumeOpen();
@@ -2342,6 +2348,10 @@
   // Parse the array dimensions.
   bool first = true;
   while (Tok.is(tok::l_square)) {
+    // An array-size expression can't start with a lambda.
+    if (CheckProhibitedCXX11Attribute())
+      continue;
+
     BalancedDelimiterTracker T(*this, tok::l_square);
     T.consumeOpen();
 
@@ -2356,13 +2366,16 @@
 
     T.consumeClose();
 
-    ParsedAttributes attrs(AttrFactory);
+    // Attributes here appertain to the array type. C++11 [expr.new]p5.
+    ParsedAttributes Attrs(AttrFactory);
+    MaybeParseCXX0XAttributes(Attrs);
+
     D.AddTypeInfo(DeclaratorChunk::getArray(0,
                                             /*static=*/false, /*star=*/false,
                                             Size.release(),
                                             T.getOpenLocation(),
                                             T.getCloseLocation()),
-                  attrs, T.getCloseLocation());
+                  Attrs, T.getCloseLocation());
 
     if (T.getCloseLocation().isInvalid())
       return;
@@ -2414,7 +2427,11 @@
 
   // Array delete?
   bool ArrayDelete = false;
-  if (Tok.is(tok::l_square)) {
+  if (Tok.is(tok::l_square) && NextToken().is(tok::r_square)) {
+    // FIXME: This could be the start of a lambda-expression. We should
+    // disambiguate this, but that will require arbitrary lookahead if
+    // the next token is '(':
+    //   delete [](int*){ /* ... */
     ArrayDelete = true;
     BalancedDelimiterTracker T(*this, tok::l_square);
 

Modified: cfe/branches/tooling/lib/Parse/ParseInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseInit.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseInit.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseInit.cpp Tue Apr 17 06:08:26 2012
@@ -211,6 +211,11 @@
     //   [foo ... bar]     -> array designator
     //   [4][foo bar]      -> obsolete GNU designation with objc message send.
     //
+    // We do not need to check for an expression starting with [[ here. If it
+    // contains an Objective-C message send, then it is not an ill-formed
+    // attribute. If it is a lambda-expression within an array-designator, then
+    // it will be rejected because a constant-expression cannot begin with a
+    // lambda-expression.
     InMessageExpressionRAIIObject InMessage(*this, true);
     
     BalancedDelimiterTracker T(*this, tok::l_square);

Modified: cfe/branches/tooling/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseObjc.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseObjc.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseObjc.cpp Tue Apr 17 06:08:26 2012
@@ -161,6 +161,7 @@
 ///     __attribute__((deprecated))
 ///     __attribute__((unavailable))
 ///     __attribute__((objc_exception)) - used by NSException on 64-bit
+///     __attribute__((objc_root_class))
 ///
 Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
                                               ParsedAttributes &attrs) {
@@ -2810,11 +2811,9 @@
   // specified Declarator for the method.
   Actions.ActOnStartOfObjCMethodDef(getCurScope(), MDecl);
     
-  if (PP.isCodeCompletionEnabled()) {
-      if (trySkippingFunctionBodyForCodeCompletion()) {
-          BodyScope.Exit();
-          return Actions.ActOnFinishFunctionBody(MDecl, 0);
-      }
+  if (SkipFunctionBodies && trySkippingFunctionBody()) {
+    BodyScope.Exit();
+    return Actions.ActOnFinishFunctionBody(MDecl, 0);
   }
     
   StmtResult FnBody(ParseCompoundStatementBody());

Modified: cfe/branches/tooling/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseStmt.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseStmt.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseStmt.cpp Tue Apr 17 06:08:26 2012
@@ -84,7 +84,7 @@
   ParenBraceBracketBalancer BalancerRAIIObj(*this);
 
   ParsedAttributesWithRange attrs(AttrFactory);
-  MaybeParseCXX0XAttributes(attrs);
+  MaybeParseCXX0XAttributes(attrs, 0, /*MightBeObjCMessageSend*/ true);
 
   // Cases in this switch statement should fall through if the parser expects
   // the token to end in a semicolon (in which case SemiError should be set),
@@ -789,7 +789,7 @@
         ConsumeToken();
 
       ParsedAttributesWithRange attrs(AttrFactory);
-      MaybeParseCXX0XAttributes(attrs);
+      MaybeParseCXX0XAttributes(attrs, 0, /*MightBeObjCMessageSend*/ true);
 
       // If this is the start of a declaration, parse it as such.
       if (isDeclarationStatement()) {
@@ -1958,11 +1958,9 @@
   assert(Tok.is(tok::l_brace));
   SourceLocation LBraceLoc = Tok.getLocation();
 
-  if (PP.isCodeCompletionEnabled()) {
-    if (trySkippingFunctionBodyForCodeCompletion()) {
-      BodyScope.Exit();
-      return Actions.ActOnFinishFunctionBody(Decl, 0);
-    }
+  if (SkipFunctionBodies && trySkippingFunctionBody()) {
+    BodyScope.Exit();
+    return Actions.ActOnFinishFunctionBody(Decl, 0);
   }
 
   PrettyDeclStackTraceEntry CrashInfo(Actions, Decl, LBraceLoc,
@@ -2002,11 +2000,9 @@
   else
     Actions.ActOnDefaultCtorInitializers(Decl);
 
-  if (PP.isCodeCompletionEnabled()) {
-    if (trySkippingFunctionBodyForCodeCompletion()) {
-      BodyScope.Exit();
-      return Actions.ActOnFinishFunctionBody(Decl, 0);
-    }
+  if (SkipFunctionBodies && trySkippingFunctionBody()) {
+    BodyScope.Exit();
+    return Actions.ActOnFinishFunctionBody(Decl, 0);
   }
 
   SourceLocation LBraceLoc = Tok.getLocation();
@@ -2023,17 +2019,17 @@
   return Actions.ActOnFinishFunctionBody(Decl, FnBody.take());
 }
 
-bool Parser::trySkippingFunctionBodyForCodeCompletion() {
+bool Parser::trySkippingFunctionBody() {
   assert(Tok.is(tok::l_brace));
-  assert(PP.isCodeCompletionEnabled() &&
-         "Should only be called when in code-completion mode");
+  assert(SkipFunctionBodies &&
+         "Should only be called when SkipFunctionBodies is enabled");
 
   // We're in code-completion mode. Skip parsing for all function bodies unless
   // the body contains the code-completion point.
   TentativeParsingAction PA(*this);
   ConsumeBrace();
   if (SkipUntil(tok::r_brace, /*StopAtSemi=*/false, /*DontConsume=*/false,
-                /*StopAtCodeCompletion=*/true)) {
+                /*StopAtCodeCompletion=*/PP.isCodeCompletionEnabled())) {
     PA.Commit();
     return true;
   }

Modified: cfe/branches/tooling/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseTemplate.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseTemplate.cpp Tue Apr 17 06:08:26 2012
@@ -309,14 +309,19 @@
   LAngleLoc = ConsumeToken();
 
   // Try to parse the template parameter list.
-  if (Tok.is(tok::greater))
-    RAngleLoc = ConsumeToken();
-  else if (ParseTemplateParameterList(Depth, TemplateParams)) {
-    if (!Tok.is(tok::greater)) {
-      Diag(Tok.getLocation(), diag::err_expected_greater);
-      return true;
-    }
+  bool Failed = false;
+  if (!Tok.is(tok::greater) && !Tok.is(tok::greatergreater))
+    Failed = ParseTemplateParameterList(Depth, TemplateParams);
+
+  if (Tok.is(tok::greatergreater)) {
+    Tok.setKind(tok::greater);
+    RAngleLoc = Tok.getLocation();
+    Tok.setLocation(Tok.getLocation().getLocWithOffset(1));
+  } else if (Tok.is(tok::greater))
     RAngleLoc = ConsumeToken();
+  else if (Failed) {
+    Diag(Tok.getLocation(), diag::err_expected_greater);
+    return true;
   }
   return false;
 }
@@ -339,23 +344,21 @@
     } else {
       // If we failed to parse a template parameter, skip until we find
       // a comma or closing brace.
-      SkipUntil(tok::comma, tok::greater, true, true);
+      SkipUntil(tok::comma, tok::greater, tok::greatergreater, true, true);
     }
 
     // Did we find a comma or the end of the template parmeter list?
     if (Tok.is(tok::comma)) {
       ConsumeToken();
-    } else if (Tok.is(tok::greater)) {
+    } else if (Tok.is(tok::greater) || Tok.is(tok::greatergreater)) {
       // Don't consume this... that's done by template parser.
       break;
     } else {
       // Somebody probably forgot to close the template. Skip ahead and
       // try to get out of the expression. This error is currently
       // subsumed by whatever goes on in ParseTemplateParameter.
-      // TODO: This could match >>, and it would be nice to avoid those
-      // silly errors with template <vec<T>>.
       Diag(Tok.getLocation(), diag::err_expected_comma_greater);
-      SkipUntil(tok::greater, true, true);
+      SkipUntil(tok::comma, tok::greater, tok::greatergreater, true, true);
       return false;
     }
   }
@@ -490,7 +493,7 @@
     ParamName = Tok.getIdentifierInfo();
     NameLoc = ConsumeToken();
   } else if (Tok.is(tok::equal) || Tok.is(tok::comma) ||
-            Tok.is(tok::greater)) {
+             Tok.is(tok::greater) || Tok.is(tok::greatergreater)) {
     // Unnamed template parameter. Don't have to do anything here, just
     // don't consume this token.
   } else {
@@ -539,17 +542,24 @@
   }
 
   // Generate a meaningful error if the user forgot to put class before the
-  // identifier, comma, or greater.
-  if (Tok.is(tok::kw_typename) || Tok.is(tok::kw_struct)) {
-    Diag(Tok.getLocation(), diag::err_expected_class_instead)
-      << PP.getSpelling(Tok)
-      << FixItHint::CreateReplacement(Tok.getLocation(), "class");
-    ConsumeToken();
-  } else if (!Tok.is(tok::kw_class))
-      Diag(Tok.getLocation(), diag::err_expected_class_before)
-        << PP.getSpelling(Tok)
-        << FixItHint::CreateInsertion(Tok.getLocation(), "class ");
-  else 
+  // identifier, comma, or greater. Provide a fixit if the identifier, comma,
+  // or greater appear immediately or after 'typename' or 'struct'. In the
+  // latter case, replace the keyword with 'class'.
+  if (!Tok.is(tok::kw_class)) {
+    bool Replace = Tok.is(tok::kw_typename) || Tok.is(tok::kw_struct);
+    const Token& Next = Replace ? NextToken() : Tok;
+    if (Next.is(tok::identifier) || Next.is(tok::comma) ||
+        Next.is(tok::greater) || Next.is(tok::greatergreater) ||
+        Next.is(tok::ellipsis))
+      Diag(Tok.getLocation(), diag::err_class_on_template_template_param)
+        << (Replace ? FixItHint::CreateReplacement(Tok.getLocation(), "class")
+                    : FixItHint::CreateInsertion(Tok.getLocation(), "class "));
+    else
+      Diag(Tok.getLocation(), diag::err_class_on_template_template_param);
+
+    if (Replace)
+      ConsumeToken();
+  } else
     ConsumeToken();
 
   // Parse the ellipsis, if given.
@@ -569,7 +579,8 @@
   if (Tok.is(tok::identifier)) {
     ParamName = Tok.getIdentifierInfo();
     NameLoc = ConsumeToken();
-  } else if (Tok.is(tok::equal) || Tok.is(tok::comma) || Tok.is(tok::greater)) {
+  } else if (Tok.is(tok::equal) || Tok.is(tok::comma) ||
+             Tok.is(tok::greater) || Tok.is(tok::greatergreater)) {
     // Unnamed template parameter. Don't have to do anything here, just
     // don't consume this token.
   } else {
@@ -595,10 +606,7 @@
     if (DefaultArg.isInvalid()) {
       Diag(Tok.getLocation(), 
            diag::err_default_template_template_parameter_not_template);
-      static const tok::TokenKind EndToks[] = { 
-        tok::comma, tok::greater, tok::greatergreater
-      };
-      SkipUntil(EndToks, 3, true, true);
+      SkipUntil(tok::comma, tok::greater, tok::greatergreater, true, true);
     }
   }
   
@@ -626,12 +634,7 @@
   Declarator ParamDecl(DS, Declarator::TemplateParamContext);
   ParseDeclarator(ParamDecl);
   if (DS.getTypeSpecType() == DeclSpec::TST_unspecified) {
-    // This probably shouldn't happen - and it's more of a Sema thing, but
-    // basically we didn't parse the type name because we couldn't associate
-    // it with an AST node. we should just skip to the comma or greater.
-    // TODO: This is currently a placeholder for some kind of Sema Error.
-    Diag(Tok.getLocation(), diag::err_parse_error);
-    SkipUntil(tok::comma, tok::greater, true, true);
+    Diag(Tok.getLocation(), diag::err_expected_template_parameter);
     return 0;
   }
 

Modified: cfe/branches/tooling/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseTentative.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseTentative.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseTentative.cpp Tue Apr 17 06:08:26 2012
@@ -374,91 +374,166 @@
   return TPR == TPResult::True();
 }
 
-/// isCXX0XAttributeSpecifier - returns true if this is a C++0x
-/// attribute-specifier. By default, unless in Obj-C++, only a cursory check is
-/// performed that will simply return true if a [[ is seen. Currently C++ has no
-/// syntactical ambiguities from this check, but it may inhibit error recovery.
-/// If CheckClosing is true, a check is made for closing ]] brackets.
-///
-/// If given, After is set to the token after the attribute-specifier so that
-/// appropriate parsing decisions can be made; it is left untouched if false is
-/// returned.
-///
-/// FIXME: If an error is in the closing ]] brackets, the program assumes
-/// the absence of an attribute-specifier, which can cause very yucky errors
-/// to occur.
+/// \brief Returns true if this is a C++11 attribute-specifier. Per
+/// C++11 [dcl.attr.grammar]p6, two consecutive left square bracket tokens
+/// always introduce an attribute. In Objective-C++11, this rule does not
+/// apply if either '[' begins a message-send.
 ///
-/// [C++0x] attribute-specifier:
+/// If Disambiguate is true, we try harder to determine whether a '[[' starts
+/// an attribute-specifier, and return CAK_InvalidAttributeSpecifier if not.
+///
+/// If OuterMightBeMessageSend is true, we assume the outer '[' is either an
+/// Obj-C message send or the start of an attribute. Otherwise, we assume it
+/// is not an Obj-C message send.
+///
+/// C++11 [dcl.attr.grammar]:
+///
+///     attribute-specifier:
 ///         '[' '[' attribute-list ']' ']'
 ///         alignment-specifier
 ///
-/// [C++0x] attribute-list:
+///     attribute-list:
 ///         attribute[opt]
 ///         attribute-list ',' attribute[opt]
+///         attribute '...'
+///         attribute-list ',' attribute '...'
 ///
-/// [C++0x] attribute:
+///     attribute:
 ///         attribute-token attribute-argument-clause[opt]
 ///
-/// [C++0x] attribute-token:
-///         identifier
-///         attribute-scoped-token
-///
-/// [C++0x] attribute-scoped-token:
-///         attribute-namespace '::' identifier
-///
-/// [C++0x] attribute-namespace:
+///     attribute-token:
 ///         identifier
+///         identifier '::' identifier
 ///
-/// [C++0x] attribute-argument-clause:
-///         '(' balanced-token-seq ')'
-///
-/// [C++0x] balanced-token-seq:
-///         balanced-token
-///         balanced-token-seq balanced-token
-///
-/// [C++0x] balanced-token:
+///     attribute-argument-clause:
 ///         '(' balanced-token-seq ')'
-///         '[' balanced-token-seq ']'
-///         '{' balanced-token-seq '}'
-///         any token but '(', ')', '[', ']', '{', or '}'
-bool Parser::isCXX0XAttributeSpecifier (bool CheckClosing,
-                                        tok::TokenKind *After) {
+Parser::CXX11AttributeKind
+Parser::isCXX11AttributeSpecifier(bool Disambiguate,
+                                  bool OuterMightBeMessageSend) {
   if (Tok.is(tok::kw_alignas))
-    return true;
+    return CAK_AttributeSpecifier;
 
   if (Tok.isNot(tok::l_square) || NextToken().isNot(tok::l_square))
-    return false;
-  
-  // No tentative parsing if we don't need to look for ]]
-  if (!CheckClosing && !getLangOpts().ObjC1)
-    return true;
-  
-  struct TentativeReverter {
-    TentativeParsingAction PA;
+    return CAK_NotAttributeSpecifier;
 
-    TentativeReverter (Parser& P)
-      : PA(P)
-    {}
-    ~TentativeReverter () {
-      PA.Revert();
-    }
-  } R(*this);
+  // No tentative parsing if we don't need to look for ']]' or a lambda.
+  if (!Disambiguate && !getLangOpts().ObjC1)
+    return CAK_AttributeSpecifier;
+
+  TentativeParsingAction PA(*this);
 
   // Opening brackets were checked for above.
   ConsumeBracket();
-  ConsumeBracket();
 
-  // SkipUntil will handle balanced tokens, which are guaranteed in attributes.
-  SkipUntil(tok::r_square, false);
+  // Outside Obj-C++11, treat anything with a matching ']]' as an attribute.
+  if (!getLangOpts().ObjC1) {
+    ConsumeBracket();
+
+    bool IsAttribute = SkipUntil(tok::r_square, false);
+    IsAttribute &= Tok.is(tok::r_square);
+
+    PA.Revert();
+
+    return IsAttribute ? CAK_AttributeSpecifier : CAK_InvalidAttributeSpecifier;
+  }
+
+  // In Obj-C++11, we need to distinguish four situations:
+  //  1a) int x[[attr]];                     C++11 attribute.
+  //  1b) [[attr]];                          C++11 statement attribute.
+  //   2) int x[[obj](){ return 1; }()];     Lambda in array size/index.
+  //  3a) int x[[obj get]];                  Message send in array size/index.
+  //  3b) [[Class alloc] init];              Message send in message send.
+  //   4) [[obj]{ return self; }() doStuff]; Lambda in message send.
+  // (1) is an attribute, (2) is ill-formed, and (3) and (4) are accepted.
+
+  // If we have a lambda-introducer, then this is definitely not a message send.
+  // FIXME: If this disambiguation is too slow, fold the tentative lambda parse
+  // into the tentative attribute parse below.
+  LambdaIntroducer Intro;
+  if (!TryParseLambdaIntroducer(Intro)) {
+    // A lambda cannot end with ']]', and an attribute must.
+    bool IsAttribute = Tok.is(tok::r_square);
+
+    PA.Revert();
+
+    if (IsAttribute)
+      // Case 1: C++11 attribute.
+      return CAK_AttributeSpecifier;
+
+    if (OuterMightBeMessageSend)
+      // Case 4: Lambda in message send.
+      return CAK_NotAttributeSpecifier;
+
+    // Case 2: Lambda in array size / index.
+    return CAK_InvalidAttributeSpecifier;
+  }
 
-  if (Tok.isNot(tok::r_square))
-    return false;
   ConsumeBracket();
 
-  if (After)
-    *After = Tok.getKind();
+  // If we don't have a lambda-introducer, then we have an attribute or a
+  // message-send.
+  bool IsAttribute = true;
+  while (Tok.isNot(tok::r_square)) {
+    if (Tok.is(tok::comma)) {
+      // Case 1: Stray commas can only occur in attributes.
+      PA.Revert();
+      return CAK_AttributeSpecifier;
+    }
 
-  return true;
+    // Parse the attribute-token, if present.
+    // C++11 [dcl.attr.grammar]:
+    //   If a keyword or an alternative token that satisfies the syntactic
+    //   requirements of an identifier is contained in an attribute-token,
+    //   it is considered an identifier.
+    SourceLocation Loc;
+    if (!TryParseCXX11AttributeIdentifier(Loc)) {
+      IsAttribute = false;
+      break;
+    }
+    if (Tok.is(tok::coloncolon)) {
+      ConsumeToken();
+      if (!TryParseCXX11AttributeIdentifier(Loc)) {
+        IsAttribute = false;
+        break;
+      }
+    }
+
+    // Parse the attribute-argument-clause, if present.
+    if (Tok.is(tok::l_paren)) {
+      ConsumeParen();
+      if (!SkipUntil(tok::r_paren, false)) {
+        IsAttribute = false;
+        break;
+      }
+    }
+
+    if (Tok.is(tok::ellipsis))
+      ConsumeToken();
+
+    if (Tok.isNot(tok::comma))
+      break;
+
+    ConsumeToken();
+  }
+
+  // An attribute must end ']]'.
+  if (IsAttribute) {
+    if (Tok.is(tok::r_square)) {
+      ConsumeBracket();
+      IsAttribute = Tok.is(tok::r_square);
+    } else {
+      IsAttribute = false;
+    }
+  }
+
+  PA.Revert();
+
+  if (IsAttribute)
+    // Case 1: C++11 statement attribute.
+    return CAK_AttributeSpecifier;
+
+  // Case 3: Message send.
+  return CAK_NotAttributeSpecifier;
 }
 
 ///         declarator:
@@ -707,6 +782,7 @@
   case tok::kw_int:
   case tok::kw_long:
   case tok::kw___int64:
+  case tok::kw___int128:
   case tok::kw_restrict:
   case tok::kw_short:
   case tok::kw_signed:
@@ -1038,6 +1114,7 @@
   case tok::kw_int:
   case tok::kw_long:
   case tok::kw___int64:
+  case tok::kw___int128:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw_half:
@@ -1215,11 +1292,13 @@
 ///   parameter-declaration-list ',' parameter-declaration
 ///
 /// parameter-declaration:
-///   decl-specifier-seq declarator attributes[opt]
-///   decl-specifier-seq declarator attributes[opt] '=' assignment-expression
-///   decl-specifier-seq abstract-declarator[opt] attributes[opt]
-///   decl-specifier-seq abstract-declarator[opt] attributes[opt]
+///   attribute-specifier-seq[opt] decl-specifier-seq declarator attributes[opt]
+///   attribute-specifier-seq[opt] decl-specifier-seq declarator attributes[opt]
 ///     '=' assignment-expression
+///   attribute-specifier-seq[opt] decl-specifier-seq abstract-declarator[opt]
+///     attributes[opt]
+///   attribute-specifier-seq[opt] decl-specifier-seq abstract-declarator[opt]
+///     attributes[opt] '=' assignment-expression
 ///
 Parser::TPResult Parser::TryParseParameterDeclarationClause() {
 
@@ -1243,6 +1322,11 @@
         return TPResult::False();
     }
 
+    // An attribute-specifier-seq here is a sign of a function declarator.
+    if (isCXX11AttributeSpecifier(/*Disambiguate*/false,
+                                  /*OuterMightBeMessageSend*/true))
+      return TPResult::True();
+
     ParsedAttributes attrs(AttrFactory);
     MaybeParseMicrosoftAttributes(attrs);
 
@@ -1266,8 +1350,8 @@
     if (Tok.is(tok::equal)) {
       // '=' assignment-expression
       // Parse through assignment-expression.
-      tok::TokenKind StopToks[2] ={ tok::comma, tok::r_paren };
-      if (!SkipUntil(StopToks, 2, true/*StopAtSemi*/, true/*DontConsume*/))
+      if (!SkipUntil(tok::comma, tok::r_paren, true/*StopAtSemi*/,
+                     true/*DontConsume*/))
         return TPResult::Error();
     }
 

Modified: cfe/branches/tooling/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/Parser.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/Parser.cpp (original)
+++ cfe/branches/tooling/lib/Parse/Parser.cpp Tue Apr 17 06:08:26 2012
@@ -31,10 +31,11 @@
   return Ident__except;
 }
 
-Parser::Parser(Preprocessor &pp, Sema &actions)
+Parser::Parser(Preprocessor &pp, Sema &actions, bool SkipFunctionBodies)
   : PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
     GreaterThanIsOperator(true), ColonIsSacred(false), 
-    InMessageExpression(false), TemplateParameterDepth(0) {
+    InMessageExpression(false), TemplateParameterDepth(0),
+    SkipFunctionBodies(SkipFunctionBodies) {
   Tok.setKind(tok::eof);
   Actions.CurScope = 0;
   NumCachedScopes = 0;
@@ -213,15 +214,14 @@
 ///
 /// If SkipUntil finds the specified token, it returns true, otherwise it
 /// returns false.
-bool Parser::SkipUntil(const tok::TokenKind *Toks, unsigned NumToks,
-                       bool StopAtSemi, bool DontConsume,
-                       bool StopAtCodeCompletion) {
+bool Parser::SkipUntil(ArrayRef<tok::TokenKind> Toks, bool StopAtSemi,
+                       bool DontConsume, bool StopAtCodeCompletion) {
   // We always want this function to skip at least one token if the first token
   // isn't T and if not at EOF.
   bool isFirstTokenSkipped = true;
   while (1) {
     // If we found one of the tokens, stop and return true.
-    for (unsigned i = 0; i != NumToks; ++i) {
+    for (unsigned i = 0, NumToks = Toks.size(); i != NumToks; ++i) {
       if (Tok.is(Toks[i])) {
         if (DontConsume) {
           // Noop, don't consume the token.
@@ -1111,7 +1111,7 @@
     if (Tok.is(tok::semi)) {
       ConsumeToken();
     } else {
-      Diag(Tok, diag::err_parse_error);
+      Diag(Tok, diag::err_expected_semi_declaration);
       // Skip to end of block or statement
       SkipUntil(tok::semi, true);
       if (Tok.is(tok::semi))
@@ -1681,9 +1681,9 @@
   assert(!P.Tok.is(Close) && "Should have consumed closing delimiter");
   
   const char *LHSName = "unknown";
-  diag::kind DID = diag::err_parse_error;
+  diag::kind DID;
   switch (Close) {
-  default: break;
+  default: llvm_unreachable("Unexpected balanced token");
   case tok::r_paren : LHSName = "("; DID = diag::err_expected_rparen; break;
   case tok::r_brace : LHSName = "{"; DID = diag::err_expected_rbrace; break;
   case tok::r_square: LHSName = "["; DID = diag::err_expected_rsquare; break;

Modified: cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp Tue Apr 17 06:08:26 2012
@@ -320,6 +320,7 @@
     Stmt *RewriteObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Exp);
     Stmt *RewriteObjCNumericLiteralExpr(ObjCNumericLiteral *Exp);
     Stmt *RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp);
+    Stmt *RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral *Exp);
     Stmt *RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp);
     Stmt *RewriteObjCTryStmt(ObjCAtTryStmt *S);
     Stmt *RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S);
@@ -329,6 +330,8 @@
     Stmt *RewriteBreakStmt(BreakStmt *S);
     Stmt *RewriteContinueStmt(ContinueStmt *S);
     void RewriteCastExpr(CStyleCastExpr *CE);
+    void RewriteImplicitCastObjCExpr(CastExpr *IE);
+    void RewriteLinkageSpec(LinkageSpecDecl *LSD);
     
     // Block rewriting.
     void RewriteBlocksInFunctionProtoType(QualType funcType, NamedDecl *D);
@@ -463,8 +466,11 @@
     bool BufferContainsPPDirectives(const char *startBuf, const char *endBuf);
     
     void convertToUnqualifiedObjCType(QualType &T) {
-      if (T->isObjCQualifiedIdType())
-        T = Context->getObjCIdType();
+      if (T->isObjCQualifiedIdType()) {
+        bool isConst = T.isConstQualified();
+        T = isConst ? Context->getObjCIdType().withConst() 
+                    : Context->getObjCIdType();
+      }
       else if (T->isObjCQualifiedClassType())
         T = Context->getObjCClassType();
       else if (T->isObjCObjectPointerType() &&
@@ -672,6 +678,10 @@
     if (PD->isThisDeclarationADefinition())
       RewriteProtocolDecl(PD);
   } else if (LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(D)) {
+    // FIXME. This will not work in all situations and leaving it out
+    // is harmless.
+    // RewriteLinkageSpec(LSD);
+    
     // Recurse into linkage specifications
     for (DeclContext::decl_iterator DI = LSD->decls_begin(),
                                  DIEnd = LSD->decls_end();
@@ -693,6 +703,12 @@
           RewriteForwardClassDecl(DG);
           continue;
         }
+        else {
+          // Keep track of all interface declarations seen.
+          ObjCInterfacesSeen.push_back(IFace);
+          ++DI;
+          continue;
+        }
       }
 
       if (ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>((*DI))) {
@@ -1058,6 +1074,22 @@
   ReplaceText(LocStart, 0, "// ");
 }
 
+void 
+RewriteModernObjC::RewriteLinkageSpec(LinkageSpecDecl *LSD) {
+  SourceLocation LocStart = LSD->getExternLoc();
+  if (LocStart.isInvalid())
+    llvm_unreachable("Invalid extern SourceLocation");
+  
+  ReplaceText(LocStart, 0, "// ");
+  if (!LSD->hasBraces())
+    return;
+  // FIXME. We don't rewrite well if '{' is not on same line as 'extern'.
+  SourceLocation LocRBrace = LSD->getRBraceLoc();
+  if (LocRBrace.isInvalid())
+    llvm_unreachable("Invalid rbrace SourceLocation");
+  ReplaceText(LocRBrace, 0, "// ");
+}
+
 void RewriteModernObjC::RewriteTypeIntoString(QualType T, std::string &ResultStr,
                                         const FunctionType *&FPRetType) {
   if (T->isObjCQualifiedIdType())
@@ -1293,7 +1325,8 @@
 
   // Because the rewriter doesn't allow us to rewrite rewritten code,
   // we need to suppress rewriting the sub-statements.
-  Expr *Base, *RHS;
+  Expr *Base;
+  SmallVector<Expr*, 2> Args;
   {
     DisableReplaceStmtScope S(*this);
 
@@ -1304,11 +1337,15 @@
       Base = cast<OpaqueValueExpr>(Base)->getSourceExpr();
       Base = cast<Expr>(RewriteFunctionBodyOrGlobalInitializer(Base));
     }
-
-    // Rebuild the RHS.
-    RHS = cast<BinaryOperator>(PseudoOp->getSyntacticForm())->getRHS();
-    RHS = cast<OpaqueValueExpr>(RHS)->getSourceExpr();
-    RHS = cast<Expr>(RewriteFunctionBodyOrGlobalInitializer(RHS));
+  
+    unsigned numArgs = OldMsg->getNumArgs();
+    for (unsigned i = 0; i < numArgs; i++) {
+      Expr *Arg = OldMsg->getArg(i);
+      if (isa<OpaqueValueExpr>(Arg))
+        Arg = cast<OpaqueValueExpr>(Arg)->getSourceExpr();
+      Arg = cast<Expr>(RewriteFunctionBodyOrGlobalInitializer(Arg));
+      Args.push_back(Arg);
+    }
   }
 
   // TODO: avoid this copy.
@@ -1325,7 +1362,7 @@
                                      OldMsg->getSelector(),
                                      SelLocs,
                                      OldMsg->getMethodDecl(),
-                                     RHS,
+                                     Args,
                                      OldMsg->getRightLoc(),
                                      OldMsg->isImplicit());
     break;
@@ -1338,7 +1375,7 @@
                                      OldMsg->getSelector(),
                                      SelLocs,
                                      OldMsg->getMethodDecl(),
-                                     RHS,
+                                     Args,
                                      OldMsg->getRightLoc(),
                                      OldMsg->isImplicit());
     break;
@@ -1354,7 +1391,7 @@
                                      OldMsg->getSelector(),
                                      SelLocs,
                                      OldMsg->getMethodDecl(),
-                                     RHS,
+                                     Args,
                                      OldMsg->getRightLoc(),
                                      OldMsg->isImplicit());
     break;
@@ -1376,20 +1413,27 @@
   // Because the rewriter doesn't allow us to rewrite rewritten code,
   // we need to suppress rewriting the sub-statements.
   Expr *Base = 0;
+  SmallVector<Expr*, 1> Args;
   {
     DisableReplaceStmtScope S(*this);
-
     // Rebuild the base expression if we have one.
     if (OldMsg->getReceiverKind() == ObjCMessageExpr::Instance) {
       Base = OldMsg->getInstanceReceiver();
       Base = cast<OpaqueValueExpr>(Base)->getSourceExpr();
       Base = cast<Expr>(RewriteFunctionBodyOrGlobalInitializer(Base));
     }
+    unsigned numArgs = OldMsg->getNumArgs();
+    for (unsigned i = 0; i < numArgs; i++) {
+      Expr *Arg = OldMsg->getArg(i);
+      if (isa<OpaqueValueExpr>(Arg))
+        Arg = cast<OpaqueValueExpr>(Arg)->getSourceExpr();
+      Arg = cast<Expr>(RewriteFunctionBodyOrGlobalInitializer(Arg));
+      Args.push_back(Arg);
+    }
   }
 
   // Intentionally empty.
   SmallVector<SourceLocation, 1> SelLocs;
-  SmallVector<Expr*, 1> Args;
 
   ObjCMessageExpr *NewMsg = 0;
   switch (OldMsg->getReceiverKind()) {
@@ -2226,7 +2270,7 @@
   CurFunctionDeclToDeclareForBlock = 0;
 }
 
-// SynthSuperContructorFunctionDecl - id objc_super(id obj, id super);
+// SynthSuperContructorFunctionDecl - id __rw_objc_super(id obj, id super);
 void RewriteModernObjC::SynthSuperContructorFunctionDecl() {
   if (SuperContructorFunctionDecl)
     return;
@@ -2267,21 +2311,13 @@
                                          SC_None, false);
 }
 
-// SynthMsgSendSuperFunctionDecl - id objc_msgSendSuper(struct objc_super *, SEL op, ...);
+// SynthMsgSendSuperFunctionDecl - id objc_msgSendSuper(void);
 void RewriteModernObjC::SynthMsgSendSuperFunctionDecl() {
   IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper");
-  SmallVector<QualType, 16> ArgTys;
-  RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
-                                      SourceLocation(), SourceLocation(),
-                                      &Context->Idents.get("objc_super"));
-  QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
-  assert(!argT.isNull() && "Can't build 'struct objc_super *' type");
-  ArgTys.push_back(argT);
-  argT = Context->getObjCSelType();
-  assert(!argT.isNull() && "Can't find 'SEL' type");
-  ArgTys.push_back(argT);
+  SmallVector<QualType, 2> ArgTys;
+  ArgTys.push_back(Context->VoidTy);
   QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
-                                               &ArgTys[0], ArgTys.size(),
+                                               &ArgTys[0], 1,
                                                true /*isVariadic*/);
   MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
                                               SourceLocation(),
@@ -2313,22 +2349,14 @@
 }
 
 // SynthMsgSendSuperStretFunctionDecl -
-// id objc_msgSendSuper_stret(struct objc_super *, SEL op, ...);
+// id objc_msgSendSuper_stret(void);
 void RewriteModernObjC::SynthMsgSendSuperStretFunctionDecl() {
   IdentifierInfo *msgSendIdent =
     &Context->Idents.get("objc_msgSendSuper_stret");
-  SmallVector<QualType, 16> ArgTys;
-  RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
-                                      SourceLocation(), SourceLocation(),
-                                      &Context->Idents.get("objc_super"));
-  QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
-  assert(!argT.isNull() && "Can't build 'struct objc_super *' type");
-  ArgTys.push_back(argT);
-  argT = Context->getObjCSelType();
-  assert(!argT.isNull() && "Can't find 'SEL' type");
-  ArgTys.push_back(argT);
+  SmallVector<QualType, 2> ArgTys;
+  ArgTys.push_back(Context->VoidTy);
   QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
-                                               &ArgTys[0], ArgTys.size(),
+                                               &ArgTys[0], 1,
                                                true /*isVariadic*/);
   MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
                                                        SourceLocation(),
@@ -2581,6 +2609,48 @@
   SourceLocation StartLoc = Exp->getLocStart();
   SourceLocation EndLoc = Exp->getLocEnd();
   
+  // Build the expression: __NSContainer_literal(int, ...).arr
+  QualType IntQT = Context->IntTy;
+  QualType NSArrayFType =
+    getSimpleFunctionType(Context->VoidTy, &IntQT, 1, true);
+  std::string NSArrayFName("__NSContainer_literal");
+  FunctionDecl *NSArrayFD = SynthBlockInitFunctionDecl(NSArrayFName);
+  DeclRefExpr *NSArrayDRE = 
+    new (Context) DeclRefExpr(NSArrayFD, false, NSArrayFType, VK_RValue,
+                              SourceLocation());
+
+  SmallVector<Expr*, 16> InitExprs;
+  unsigned NumElements = Exp->getNumElements();
+  unsigned UnsignedIntSize = 
+    static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
+  Expr *count = IntegerLiteral::Create(*Context,
+                                       llvm::APInt(UnsignedIntSize, NumElements),
+                                       Context->UnsignedIntTy, SourceLocation());
+  InitExprs.push_back(count);
+  for (unsigned i = 0; i < NumElements; i++)
+    InitExprs.push_back(Exp->getElement(i));
+  Expr *NSArrayCallExpr = 
+    new (Context) CallExpr(*Context, NSArrayDRE, &InitExprs[0], InitExprs.size(),
+                           NSArrayFType, VK_LValue, SourceLocation());
+  
+  FieldDecl *ARRFD = FieldDecl::Create(*Context, 0, SourceLocation(),
+                                    SourceLocation(),
+                                    &Context->Idents.get("arr"),
+                                    Context->getPointerType(Context->VoidPtrTy), 0,
+                                    /*BitWidth=*/0, /*Mutable=*/true,
+                                    /*HasInit=*/false);
+  MemberExpr *ArrayLiteralME = 
+    new (Context) MemberExpr(NSArrayCallExpr, false, ARRFD, 
+                             SourceLocation(),
+                             ARRFD->getType(), VK_LValue,
+                             OK_Ordinary);
+  QualType ConstIdT = Context->getObjCIdType().withConst();
+  CStyleCastExpr * ArrayLiteralObjects = 
+    NoTypeInfoCStyleCastExpr(Context, 
+                             Context->getPointerType(ConstIdT),
+                             CK_BitCast,
+                             ArrayLiteralME);
+  
   // Synthesize a call to objc_msgSend().
   SmallVector<Expr*, 32> MsgExprs;
   SmallVector<Expr*, 4> ClsExprs;
@@ -2615,22 +2685,14 @@
                                                   StartLoc, EndLoc);
   MsgExprs.push_back(SelExp);
   
-  unsigned NumElements = Exp->getNumElements();
+  // (const id [])objects
+  MsgExprs.push_back(ArrayLiteralObjects);
   
-  // FIXME. Incomplete.
-  InitListExpr *ILE =
-    new (Context) InitListExpr(*Context, SourceLocation(),
-                               Exp->getElements(), NumElements,
-                               SourceLocation());
-  MsgExprs.push_back(ILE);
-  unsigned UnsignedIntSize = 
-    static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
-  
-  Expr *count = IntegerLiteral::Create(*Context,
-                                       llvm::APInt(UnsignedIntSize, NumElements),
-                                       Context->UnsignedIntTy,
-                                       SourceLocation());
-  MsgExprs.push_back(count);
+  // (NSUInteger)cnt
+  Expr *cnt = IntegerLiteral::Create(*Context,
+                                     llvm::APInt(UnsignedIntSize, NumElements),
+                                     Context->UnsignedIntTy, SourceLocation());
+  MsgExprs.push_back(cnt);
   
   
   SmallVector<QualType, 4> ArgTypes;
@@ -2672,18 +2734,195 @@
   return CE;
 }
 
-// struct objc_super { struct objc_object *receiver; struct objc_class *super; };
+Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral *Exp) {
+  // synthesize declaration of helper functions needed in this routine.
+  if (!SelGetUidFunctionDecl)
+    SynthSelGetUidFunctionDecl();
+  // use objc_msgSend() for all.
+  if (!MsgSendFunctionDecl)
+    SynthMsgSendFunctionDecl();
+  if (!GetClassFunctionDecl)
+    SynthGetClassFunctionDecl();
+  
+  FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
+  SourceLocation StartLoc = Exp->getLocStart();
+  SourceLocation EndLoc = Exp->getLocEnd();
+  
+  // Build the expression: __NSContainer_literal(int, ...).arr
+  QualType IntQT = Context->IntTy;
+  QualType NSDictFType =
+    getSimpleFunctionType(Context->VoidTy, &IntQT, 1, true);
+  std::string NSDictFName("__NSContainer_literal");
+  FunctionDecl *NSDictFD = SynthBlockInitFunctionDecl(NSDictFName);
+  DeclRefExpr *NSDictDRE = 
+    new (Context) DeclRefExpr(NSDictFD, false, NSDictFType, VK_RValue,
+                              SourceLocation());
+  
+  SmallVector<Expr*, 16> KeyExprs;
+  SmallVector<Expr*, 16> ValueExprs;
+  
+  unsigned NumElements = Exp->getNumElements();
+  unsigned UnsignedIntSize = 
+    static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
+  Expr *count = IntegerLiteral::Create(*Context,
+                                       llvm::APInt(UnsignedIntSize, NumElements),
+                                       Context->UnsignedIntTy, SourceLocation());
+  KeyExprs.push_back(count);
+  ValueExprs.push_back(count);
+  for (unsigned i = 0; i < NumElements; i++) {
+    ObjCDictionaryElement Element = Exp->getKeyValueElement(i);
+    KeyExprs.push_back(Element.Key);
+    ValueExprs.push_back(Element.Value);
+  }
+  
+  // (const id [])objects
+  Expr *NSValueCallExpr = 
+    new (Context) CallExpr(*Context, NSDictDRE, &ValueExprs[0], ValueExprs.size(),
+                           NSDictFType, VK_LValue, SourceLocation());
+  
+  FieldDecl *ARRFD = FieldDecl::Create(*Context, 0, SourceLocation(),
+                                       SourceLocation(),
+                                       &Context->Idents.get("arr"),
+                                       Context->getPointerType(Context->VoidPtrTy), 0,
+                                       /*BitWidth=*/0, /*Mutable=*/true,
+                                       /*HasInit=*/false);
+  MemberExpr *DictLiteralValueME = 
+    new (Context) MemberExpr(NSValueCallExpr, false, ARRFD, 
+                             SourceLocation(),
+                             ARRFD->getType(), VK_LValue,
+                             OK_Ordinary);
+  QualType ConstIdT = Context->getObjCIdType().withConst();
+  CStyleCastExpr * DictValueObjects = 
+    NoTypeInfoCStyleCastExpr(Context, 
+                             Context->getPointerType(ConstIdT),
+                             CK_BitCast,
+                             DictLiteralValueME);
+  // (const id <NSCopying> [])keys
+  Expr *NSKeyCallExpr = 
+    new (Context) CallExpr(*Context, NSDictDRE, &KeyExprs[0], KeyExprs.size(),
+                           NSDictFType, VK_LValue, SourceLocation());
+  
+  MemberExpr *DictLiteralKeyME = 
+    new (Context) MemberExpr(NSKeyCallExpr, false, ARRFD, 
+                             SourceLocation(),
+                             ARRFD->getType(), VK_LValue,
+                             OK_Ordinary);
+  
+  CStyleCastExpr * DictKeyObjects = 
+    NoTypeInfoCStyleCastExpr(Context, 
+                             Context->getPointerType(ConstIdT),
+                             CK_BitCast,
+                             DictLiteralKeyME);
+  
+  
+  
+  // Synthesize a call to objc_msgSend().
+  SmallVector<Expr*, 32> MsgExprs;
+  SmallVector<Expr*, 4> ClsExprs;
+  QualType argType = Context->getPointerType(Context->CharTy);
+  QualType expType = Exp->getType();
+  
+  // Create a call to objc_getClass("NSArray"). It will be th 1st argument.
+  ObjCInterfaceDecl *Class = 
+  expType->getPointeeType()->getAs<ObjCObjectType>()->getInterface();
+  
+  IdentifierInfo *clsName = Class->getIdentifier();
+  ClsExprs.push_back(StringLiteral::Create(*Context,
+                                           clsName->getName(),
+                                           StringLiteral::Ascii, false,
+                                           argType, SourceLocation()));
+  CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
+                                               &ClsExprs[0],
+                                               ClsExprs.size(), 
+                                               StartLoc, EndLoc);
+  MsgExprs.push_back(Cls);
+  
+  // Create a call to sel_registerName("arrayWithObjects:count:").
+  // it will be the 2nd argument.
+  SmallVector<Expr*, 4> SelExprs;
+  ObjCMethodDecl *DictMethod = Exp->getDictWithObjectsMethod();
+  SelExprs.push_back(StringLiteral::Create(*Context,
+                                           DictMethod->getSelector().getAsString(),
+                                           StringLiteral::Ascii, false,
+                                           argType, SourceLocation()));
+  CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
+                                                  &SelExprs[0], SelExprs.size(),
+                                                  StartLoc, EndLoc);
+  MsgExprs.push_back(SelExp);
+  
+  // (const id [])objects
+  MsgExprs.push_back(DictValueObjects);
+  
+  // (const id <NSCopying> [])keys
+  MsgExprs.push_back(DictKeyObjects);
+  
+  // (NSUInteger)cnt
+  Expr *cnt = IntegerLiteral::Create(*Context,
+                                     llvm::APInt(UnsignedIntSize, NumElements),
+                                     Context->UnsignedIntTy, SourceLocation());
+  MsgExprs.push_back(cnt);
+  
+  
+  SmallVector<QualType, 8> ArgTypes;
+  ArgTypes.push_back(Context->getObjCIdType());
+  ArgTypes.push_back(Context->getObjCSelType());
+  for (ObjCMethodDecl::param_iterator PI = DictMethod->param_begin(),
+       E = DictMethod->param_end(); PI != E; ++PI) {
+    QualType T = (*PI)->getType();
+    if (const PointerType* PT = T->getAs<PointerType>()) {
+      QualType PointeeTy = PT->getPointeeType();
+      convertToUnqualifiedObjCType(PointeeTy);
+      T = Context->getPointerType(PointeeTy);
+    }
+    ArgTypes.push_back(T);
+  }
+  
+  QualType returnType = Exp->getType();
+  // Get the type, we will need to reference it in a couple spots.
+  QualType msgSendType = MsgSendFlavor->getType();
+  
+  // Create a reference to the objc_msgSend() declaration.
+  DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, false, msgSendType,
+                                               VK_LValue, SourceLocation());
+  
+  CastExpr *cast = NoTypeInfoCStyleCastExpr(Context,
+                                            Context->getPointerType(Context->VoidTy),
+                                            CK_BitCast, DRE);
+  
+  // Now do the "normal" pointer to function cast.
+  QualType castType =
+  getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(),
+                        DictMethod->isVariadic());
+  castType = Context->getPointerType(castType);
+  cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
+                                  cast);
+  
+  // Don't forget the parens to enforce the proper binding.
+  ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast);
+  
+  const FunctionType *FT = msgSendType->getAs<FunctionType>();
+  CallExpr *CE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
+                                        MsgExprs.size(),
+                                        FT->getResultType(), VK_RValue,
+                                        EndLoc);
+  ReplaceStmt(Exp, CE);
+  return CE;
+}
+
+// struct __rw_objc_super { 
+//   struct objc_object *object; struct objc_object *superClass; 
+// };
 QualType RewriteModernObjC::getSuperStructType() {
   if (!SuperStructDecl) {
     SuperStructDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
                                          SourceLocation(), SourceLocation(),
-                                         &Context->Idents.get("objc_super"));
+                                         &Context->Idents.get("__rw_objc_super"));
     QualType FieldTypes[2];
 
-    // struct objc_object *receiver;
+    // struct objc_object *object;
     FieldTypes[0] = Context->getObjCIdType();
-    // struct objc_class *super;
-    FieldTypes[1] = Context->getObjCClassType();
+    // struct objc_object *superClass;
+    FieldTypes[1] = Context->getObjCIdType();
 
     // Create fields
     for (unsigned i = 0; i < 2; ++i) {
@@ -2820,7 +3059,7 @@
                         NoTypeInfoCStyleCastExpr(Context,
                                                  Context->getObjCIdType(),
                                                  CK_BitCast, Cls));
-    // struct objc_super
+    // struct __rw_objc_super
     QualType superType = getSuperStructType();
     Expr *SuperRep;
 
@@ -2838,7 +3077,7 @@
       // the structure definition in the header. The rewriter has it's own
       // internal definition (__rw_objc_super) that is uses. This is why
       // we need the cast below. For example:
-      // (struct objc_super *)&__rw_objc_super((id)self, (id)objc_getClass("SUPER"))
+      // (struct __rw_objc_super *)&__rw_objc_super((id)self, (id)objc_getClass("SUPER"))
       //
       SuperRep = new (Context) UnaryOperator(SuperRep, UO_AddrOf,
                                Context->getPointerType(SuperRep->getType()),
@@ -2848,7 +3087,7 @@
                                           Context->getPointerType(superType),
                                           CK_BitCast, SuperRep);
     } else {
-      // (struct objc_super) { <exprs from above> }
+      // (struct __rw_objc_super) { <exprs from above> }
       InitListExpr *ILE =
         new (Context) InitListExpr(*Context, SourceLocation(),
                                    &InitExprs[0], InitExprs.size(),
@@ -2858,7 +3097,7 @@
       SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superTInfo,
                                                    superType, VK_LValue,
                                                    ILE, false);
-      // struct objc_super *
+      // struct __rw_objc_super *
       SuperRep = new (Context) UnaryOperator(SuperRep, UO_AddrOf,
                                Context->getPointerType(SuperRep->getType()),
                                              VK_RValue, OK_Ordinary,
@@ -2930,7 +3169,7 @@
       // set 'super class', using class_getSuperclass().
       NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
                                CK_BitCast, Cls));
-    // struct objc_super
+    // struct __rw_objc_super
     QualType superType = getSuperStructType();
     Expr *SuperRep;
 
@@ -2947,7 +3186,7 @@
       // the structure definition in the header. The rewriter has it's own
       // internal definition (__rw_objc_super) that is uses. This is why
       // we need the cast below. For example:
-      // (struct objc_super *)&__rw_objc_super((id)self, (id)objc_getClass("SUPER"))
+      // (struct __rw_objc_super *)&__rw_objc_super((id)self, (id)objc_getClass("SUPER"))
       //
       SuperRep = new (Context) UnaryOperator(SuperRep, UO_AddrOf,
                                Context->getPointerType(SuperRep->getType()),
@@ -2957,7 +3196,7 @@
                                Context->getPointerType(superType),
                                CK_BitCast, SuperRep);
     } else {
-      // (struct objc_super) { <exprs from above> }
+      // (struct __rw_objc_super) { <exprs from above> }
       InitListExpr *ILE =
         new (Context) InitListExpr(*Context, SourceLocation(),
                                    &InitExprs[0], InitExprs.size(),
@@ -4219,6 +4458,24 @@
   return;
 }
 
+void RewriteModernObjC::RewriteImplicitCastObjCExpr(CastExpr *IC) {
+  CastKind CastKind = IC->getCastKind();
+  
+  if (CastKind == CK_BlockPointerToObjCPointerCast) {
+    CStyleCastExpr * CastExpr = 
+      NoTypeInfoCStyleCastExpr(Context, IC->getType(), CK_BitCast, IC);
+    ReplaceStmt(IC, CastExpr);
+  }
+  else if (CastKind == CK_AnyPointerToBlockPointerCast) {
+    QualType BlockT = IC->getType();
+    (void)convertBlockPointerToFunctionPointer(BlockT);
+    CStyleCastExpr * CastExpr = 
+      NoTypeInfoCStyleCastExpr(Context, BlockT, CK_BitCast, IC);
+    ReplaceStmt(IC, CastExpr);
+  }
+  return;
+}
+
 void RewriteModernObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) {
   SourceLocation DeclLoc = FD->getLocation();
   unsigned parenCount = 0;
@@ -4541,6 +4798,10 @@
   // {0, &ND, some_flag, __size=sizeof(struct __Block_byref_ND), 
   //  initializer-if-any};
   bool hasInit = (ND->getInit() != 0);
+  // FIXME. rewriter does not support __block c++ objects which
+  // require construction.
+  if (hasInit && dyn_cast<CXXConstructExpr>(ND->getInit()))
+    hasInit = false;
   unsigned flags = 0;
   if (HasCopyAndDispose)
     flags |= BLOCK_HAS_COPY_DISPOSE;
@@ -4970,6 +5231,10 @@
   
   if (ObjCArrayLiteral *ArrayLitExpr = dyn_cast<ObjCArrayLiteral>(S))
     return RewriteObjCArrayLiteralExpr(ArrayLitExpr);
+  
+  if (ObjCDictionaryLiteral *DictionaryLitExpr = 
+        dyn_cast<ObjCDictionaryLiteral>(S))
+    return RewriteObjCDictionaryLiteralExpr(DictionaryLitExpr);
 
   if (ObjCMessageExpr *MessExpr = dyn_cast<ObjCMessageExpr>(S)) {
 #if 0
@@ -5092,6 +5357,9 @@
   if (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(S)) {
     RewriteCastExpr(CE);
   }
+  if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(S)) {
+    RewriteImplicitCastObjCExpr(ICE);
+  }
 #if 0
   if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(S)) {
     CastExpr *Replacement = new (Context) CastExpr(ICE->getType(),
@@ -5333,8 +5601,13 @@
   if (IsHeader)
     Preamble = "#pragma once\n";
   Preamble += "struct objc_selector; struct objc_class;\n";
-  Preamble += "struct __rw_objc_super { struct objc_object *object; ";
-  Preamble += "struct objc_object *superClass; ";
+  Preamble += "struct __rw_objc_super { \n\tstruct objc_object *object; ";
+  Preamble += "\n\tstruct objc_object *superClass; ";
+  // Add a constructor for creating temporary objects.
+  Preamble += "\n\t__rw_objc_super(struct objc_object *o, struct objc_object *s) ";
+  Preamble += ": object(o), superClass(s) {} ";
+  Preamble += "\n};\n";
+  
   if (LangOpts.MicrosoftExt) {
     // Define all sections using syntax that makes sense.
     // These are currently generated.
@@ -5358,12 +5631,7 @@
     Preamble += "#pragma section(\".objc_classrefs$B\", long, read, write)\n";
     Preamble += "#pragma section(\".objc_superrefs$B\", long, read, write)\n";
     
-    // Add a constructor for creating temporary objects.
-    Preamble += "__rw_objc_super(struct objc_object *o, struct objc_object *s) "
-    ": ";
-    Preamble += "object(o), superClass(s) {} ";
   }
-  Preamble += "};\n";
   Preamble += "#ifndef _REWRITER_typedef_Protocol\n";
   Preamble += "typedef struct objc_object Protocol;\n";
   Preamble += "#define _REWRITER_typedef_Protocol\n";
@@ -5444,12 +5712,35 @@
     Preamble += "#ifndef KEEP_ATTRIBUTES\n";  // We use this for clang tests.
     Preamble += "#define __attribute__(X)\n";
     Preamble += "#endif\n";
+    Preamble += "#ifndef __weak\n";
     Preamble += "#define __weak\n";
+    Preamble += "#endif\n";
+    Preamble += "#ifndef __block\n";
+    Preamble += "#define __block\n";
+    Preamble += "#endif\n";
   }
   else {
     Preamble += "#define __block\n";
     Preamble += "#define __weak\n";
   }
+  
+  // Declarations required for modern objective-c array and dictionary literals.
+  Preamble += "\n#include <stdarg.h>\n";
+  Preamble += "struct __NSContainer_literal {\n";
+  Preamble += "  void * *arr;\n";
+  Preamble += "  __NSContainer_literal (unsigned int count, ...) {\n";
+  Preamble += "\tva_list marker;\n";
+  Preamble += "\tva_start(marker, count);\n";
+  Preamble += "\tarr = new void *[count];\n";
+  Preamble += "\tfor (unsigned i = 0; i < count; i++)\n";
+  Preamble += "\t  arr[i] = va_arg(marker, void *);\n";
+  Preamble += "\tva_end( marker );\n";
+  Preamble += "  };\n";
+  Preamble += "  __NSContainer_literal() {\n";
+  Preamble += "\tdelete[] arr;\n";
+  Preamble += "  }\n";
+  Preamble += "};\n";
+  
   // NOTE! Windows uses LLP64 for 64bit mode. So, cast pointer to long long
   // as this avoids warning in any 64bit/32bit compilation model.
   Preamble += "\n#define __OFFSETOFIVAR__(TYPE, MEMBER) ((long long) &((TYPE *)0)->MEMBER)\n";
@@ -6120,7 +6411,8 @@
   }
 }
 
-static void Write_IvarOffsetVar(ASTContext *Context,
+static void Write_IvarOffsetVar(RewriteModernObjC &RewriteObj,
+                                ASTContext *Context,
                                 std::string &Result, 
                                 ArrayRef<ObjCIvarDecl *> Ivars, 
                                 ObjCInterfaceDecl *CDecl) {
@@ -6150,17 +6442,8 @@
     WriteInternalIvarName(CDecl, IvarDecl, Result);
     Result += " __attribute__ ((used, section (\"__DATA,__objc_ivar\")))";
     Result += " = ";
-    if (IvarDecl->isBitField()) {
-      // FIXME: The hack below doesn't work for bitfields. For now, we simply
-      // place all bitfields at offset 0.
-      Result += "0;\n";
-    }
-    else {
-      Result += "__OFFSETOFIVAR__(struct ";
-      Result += CDecl->getNameAsString();
-      Result += "_IMPL, "; 
-      Result += IvarDecl->getName(); Result += ");\n";
-    }
+    RewriteObj.RewriteIvarOffsetComputation(IvarDecl, Result);
+    Result += ";\n";
   }
 }
 
@@ -6170,7 +6453,7 @@
                                            StringRef VarName,
                                            ObjCInterfaceDecl *CDecl) {
   if (Ivars.size() > 0) {
-    Write_IvarOffsetVar(Context, Result, Ivars, CDecl);
+    Write_IvarOffsetVar(RewriteObj, Context, Result, Ivars, CDecl);
     
     Result += "\nstatic ";
     Write__ivar_list_t_TypeDecl(Result, Ivars.size());
@@ -6579,11 +6862,7 @@
     
     ObjCIvarDecl *IVD = CDecl->all_declared_ivar_begin();
     if (IVD) {
-      InstanceStart += "__OFFSETOFIVAR__(struct ";
-      InstanceStart += CDecl->getNameAsString();
-      InstanceStart += "_IMPL, ";
-      InstanceStart += IVD->getNameAsString();
-      InstanceStart += ")";
+      RewriteIvarOffsetComputation(IVD, InstanceStart);
     }
     else 
       InstanceStart = InstanceSize;

Modified: cfe/branches/tooling/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/CodeCompleteConsumer.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/branches/tooling/lib/Sema/CodeCompleteConsumer.cpp Tue Apr 17 06:08:26 2012
@@ -267,8 +267,70 @@
   return CopyString(String.toStringRef(Data));
 }
 
+StringRef CodeCompletionTUInfo::getParentName(DeclContext *DC) {
+  NamedDecl *ND = dyn_cast<NamedDecl>(DC);
+  if (!ND)
+    return StringRef();
+  
+  // Check whether we've already cached the parent name.
+  StringRef &CachedParentName = ParentNames[DC];
+  if (!CachedParentName.empty())
+    return CachedParentName;
+
+  // If we already processed this DeclContext and assigned empty to it, the
+  // data pointer will be non-null.
+  if (CachedParentName.data() != 0)
+    return StringRef();
+
+  // Find the interesting names.
+  llvm::SmallVector<DeclContext *, 2> Contexts;
+  while (DC && !DC->isFunctionOrMethod()) {
+    if (NamedDecl *ND = dyn_cast<NamedDecl>(DC)) {
+      if (ND->getIdentifier())
+        Contexts.push_back(DC);
+    }
+    
+    DC = DC->getParent();
+  }
+
+  {
+    llvm::SmallString<128> S;
+    llvm::raw_svector_ostream OS(S);
+    bool First = true;
+    for (unsigned I = Contexts.size(); I != 0; --I) {
+      if (First)
+        First = false;
+      else {
+        OS << "::";
+      }
+      
+      DeclContext *CurDC = Contexts[I-1];
+      if (ObjCCategoryImplDecl *CatImpl = dyn_cast<ObjCCategoryImplDecl>(CurDC))
+        CurDC = CatImpl->getCategoryDecl();
+      
+      if (ObjCCategoryDecl *Cat = dyn_cast<ObjCCategoryDecl>(CurDC)) {
+        ObjCInterfaceDecl *Interface = Cat->getClassInterface();
+        if (!Interface) {
+          // Assign an empty StringRef but with non-null data to distinguish
+          // between empty because we didn't process the DeclContext yet.
+          CachedParentName = StringRef((const char *)~0U, 0);
+          return StringRef();
+        }
+        
+        OS << Interface->getName() << '(' << Cat->getName() << ')';
+      } else {
+        OS << cast<NamedDecl>(CurDC)->getName();
+      }
+    }
+    
+    CachedParentName = AllocatorRef->CopyString(OS.str());
+  }
+
+  return CachedParentName;
+}
+
 CodeCompletionString *CodeCompletionBuilder::TakeString() {
-  void *Mem = Allocator.Allocate(
+  void *Mem = getAllocator().Allocate(
                   sizeof(CodeCompletionString) + sizeof(Chunk) * Chunks.size()
                                     + sizeof(const char *) * Annotations.size(),
                                  llvm::alignOf<CodeCompletionString>());
@@ -329,54 +391,7 @@
     return;
   
   ParentKind = getCursorKindForDecl(ND);
-  
-  // Check whether we've already cached the parent name.
-  StringRef &CachedParentName = Allocator.getParentNames()[DC];
-  if (!CachedParentName.empty()) {
-    ParentName = CachedParentName;
-    return;
-  }
-
-  // Find the interesting names.
-  llvm::SmallVector<DeclContext *, 2> Contexts;
-  while (DC && !DC->isFunctionOrMethod()) {
-    if (NamedDecl *ND = dyn_cast<NamedDecl>(DC)) {
-      if (ND->getIdentifier())
-        Contexts.push_back(DC);
-    }
-    
-    DC = DC->getParent();
-  }
-
-  {
-    llvm::SmallString<128> S;
-    llvm::raw_svector_ostream OS(S);
-    bool First = true;
-    for (unsigned I = Contexts.size(); I != 0; --I) {
-      if (First)
-        First = false;
-      else {
-        OS << "::";
-      }
-      
-      DeclContext *CurDC = Contexts[I-1];
-      if (ObjCCategoryImplDecl *CatImpl = dyn_cast<ObjCCategoryImplDecl>(CurDC))
-        CurDC = CatImpl->getCategoryDecl();
-      
-      if (ObjCCategoryDecl *Cat = dyn_cast<ObjCCategoryDecl>(CurDC)) {
-        ObjCInterfaceDecl *Interface = Cat->getClassInterface();
-        if (!Interface)
-          return;
-        
-        OS << Interface->getName() << '(' << Cat->getName() << ')';
-      } else {
-        OS << cast<NamedDecl>(CurDC)->getName();
-      }
-    }
-    
-    ParentName = Allocator.CopyString(OS.str());
-    CachedParentName = ParentName;
-  }
+  ParentName = getCodeCompletionTUInfo().getParentName(DC);
 }
 
 unsigned CodeCompletionResult::getPriorityFromDecl(NamedDecl *ND) {
@@ -458,7 +473,8 @@
       if (Results[I].Hidden)
         OS << " (Hidden)";
       if (CodeCompletionString *CCS 
-            = Results[I].CreateCodeCompletionString(SemaRef, Allocator)) {
+            = Results[I].CreateCodeCompletionString(SemaRef, getAllocator(),
+                                                    CCTUInfo)) {
         OS << " : " << CCS->getAsString();
       }
         
@@ -472,7 +488,8 @@
     case CodeCompletionResult::RK_Macro: {
       OS << Results[I].Macro->getName();
       if (CodeCompletionString *CCS 
-            = Results[I].CreateCodeCompletionString(SemaRef, Allocator)) {
+            = Results[I].CreateCodeCompletionString(SemaRef, getAllocator(),
+                                                    CCTUInfo)) {
         OS << " : " << CCS->getAsString();
       }
       OS << '\n';
@@ -496,7 +513,7 @@
   for (unsigned I = 0; I != NumCandidates; ++I) {
     if (CodeCompletionString *CCS
           = Candidates[I].CreateSignatureString(CurrentArg, SemaRef,
-                                                Allocator)) {
+                                                getAllocator(), CCTUInfo)) {
       OS << "OVERLOAD: " << CCS->getAsString() << "\n";
     }
   }

Modified: cfe/branches/tooling/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/DeclSpec.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/DeclSpec.cpp (original)
+++ cfe/branches/tooling/lib/Sema/DeclSpec.cpp Tue Apr 17 06:08:26 2012
@@ -264,6 +264,7 @@
     case TST_float:
     case TST_half:
     case TST_int:
+    case TST_int128:
     case TST_struct:
     case TST_union:
     case TST_unknown_anytype:
@@ -379,6 +380,7 @@
   case DeclSpec::TST_char16:      return "char16_t";
   case DeclSpec::TST_char32:      return "char32_t";
   case DeclSpec::TST_int:         return "int";
+  case DeclSpec::TST_int128:      return "__int128";
   case DeclSpec::TST_half:        return "half";
   case DeclSpec::TST_float:       return "float";
   case DeclSpec::TST_double:      return "double";
@@ -818,7 +820,7 @@
   if (TypeSpecSign != TSS_unspecified) {
     if (TypeSpecType == TST_unspecified)
       TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int.
-    else if (TypeSpecType != TST_int  &&
+    else if (TypeSpecType != TST_int  && TypeSpecType != TST_int128 &&
              TypeSpecType != TST_char && TypeSpecType != TST_wchar) {
       Diag(D, TSSLoc, diag::err_invalid_sign_spec)
         << getSpecifierName((TST)TypeSpecType);

Modified: cfe/branches/tooling/lib/Sema/SemaAccess.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaAccess.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaAccess.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaAccess.cpp Tue Apr 17 06:08:26 2012
@@ -165,6 +165,10 @@
     initialize();
   }
 
+  bool isInstanceMember() const {
+    return (isMemberAccess() && getTargetDecl()->isCXXInstanceMember());
+  }
+
   bool hasInstanceContext() const {
     return HasInstanceContext;
   }
@@ -671,18 +675,25 @@
 }
 
 /// Search for a class P that EC is a friend of, under the constraint
-///   InstanceContext <= P <= NamingClass
+///   InstanceContext <= P
+/// if InstanceContext exists, or else
+///   NamingClass <= P
 /// and with the additional restriction that a protected member of
-/// NamingClass would have some natural access in P.
+/// NamingClass would have some natural access in P, which implicitly
+/// imposes the constraint that P <= NamingClass.
 ///
-/// That second condition isn't actually quite right: the condition in
-/// the standard is whether the target would have some natural access
-/// in P.  The difference is that the target might be more accessible
-/// along some path not passing through NamingClass.  Allowing that
+/// This isn't quite the condition laid out in the standard.
+/// Instead of saying that a notional protected member of NamingClass
+/// would have to have some natural access in P, it says the actual
+/// target has to have some natural access in P, which opens up the
+/// possibility that the target (which is not necessarily a member
+/// of NamingClass) might be more accessible along some path not
+/// passing through it.  That's really a bad idea, though, because it
 /// introduces two problems:
-///   - It breaks encapsulation because you can suddenly access a
-///     forbidden base class's members by subclassing it elsewhere.
-///   - It makes access substantially harder to compute because it
+///   - Most importantly, it breaks encapsulation because you can
+///     access a forbidden base class's members by directly subclassing
+///     it elsewhere.
+///   - It also makes access substantially harder to compute because it
 ///     breaks the hill-climbing algorithm: knowing that the target is
 ///     accessible in some base class would no longer let you change
 ///     the question solely to whether the base class is accessible,
@@ -692,9 +703,15 @@
 static AccessResult GetProtectedFriendKind(Sema &S, const EffectiveContext &EC,
                                            const CXXRecordDecl *InstanceContext,
                                            const CXXRecordDecl *NamingClass) {
-  assert(InstanceContext->getCanonicalDecl() == InstanceContext);
+  assert(InstanceContext == 0 ||
+         InstanceContext->getCanonicalDecl() == InstanceContext);
   assert(NamingClass->getCanonicalDecl() == NamingClass);
 
+  // If we don't have an instance context, our constraints give us
+  // that NamingClass <= P <= NamingClass, i.e. P == NamingClass.
+  // This is just the usual friendship check.
+  if (!InstanceContext) return GetFriendKind(S, EC, NamingClass);
+
   ProtectedFriendContext PRC(S, EC, InstanceContext, NamingClass);
   if (PRC.findFriendship(InstanceContext)) return AR_accessible;
   if (PRC.EverDependent) return AR_dependent;
@@ -737,15 +754,6 @@
       case AR_dependent: OnFailure = AR_dependent; continue;
       }
 
-      if (!Target.hasInstanceContext())
-        return AR_accessible;
-
-      const CXXRecordDecl *InstanceContext = Target.resolveInstanceContext(S);
-      if (!InstanceContext) {
-        OnFailure = AR_dependent;
-        continue;
-      }
-
       // C++ [class.protected]p1:
       //   An additional access check beyond those described earlier in
       //   [class.access] is applied when a non-static data member or
@@ -758,8 +766,49 @@
       //   expression. In this case, the class of the object expression
       //   shall be C or a class derived from C.
       //
-      // We interpret this as a restriction on [M3].  Most of the
-      // conditions are encoded by not having any instance context.
+      // We interpret this as a restriction on [M3].
+
+      // In this part of the code, 'C' is just our context class ECRecord.
+      
+      // These rules are different if we don't have an instance context.
+      if (!Target.hasInstanceContext()) {
+        // If it's not an instance member, these restrictions don't apply.
+        if (!Target.isInstanceMember()) return AR_accessible;
+
+        // If it's an instance member, use the pointer-to-member rule
+        // that the naming class has to be derived from the effective
+        // context.
+
+        // Despite the standard's confident wording, there is a case
+        // where you can have an instance member that's neither in a
+        // pointer-to-member expression nor in a member access:  when
+        // it names a field in an unevaluated context that can't be an
+        // implicit member.  Pending clarification, we just apply the
+        // same naming-class restriction here.
+        //   FIXME: we're probably not correctly adding the
+        //   protected-member restriction when we retroactively convert
+        //   an expression to being evaluated.
+
+        // We know that ECRecord derives from NamingClass.  The
+        // restriction says to check whether NamingClass derives from
+        // ECRecord, but that's not really necessary: two distinct
+        // classes can't be recursively derived from each other.  So
+        // along this path, we just need to check whether the classes
+        // are equal.
+        if (NamingClass == ECRecord) return AR_accessible;
+
+        // Otherwise, this context class tells us nothing;  on to the next.
+        continue;
+      }
+
+      assert(Target.isInstanceMember());
+
+      const CXXRecordDecl *InstanceContext = Target.resolveInstanceContext(S);
+      if (!InstanceContext) {
+        OnFailure = AR_dependent;
+        continue;
+      }
+
       switch (IsDerivedFromInclusive(InstanceContext, ECRecord)) {
       case AR_accessible: return AR_accessible;
       case AR_inaccessible: continue;
@@ -778,9 +827,14 @@
   // *unless* the [class.protected] restriction applies.  If it does,
   // however, we should ignore whether the naming class is a friend,
   // and instead rely on whether any potential P is a friend.
-  if (Access == AS_protected && Target.hasInstanceContext()) {
-    const CXXRecordDecl *InstanceContext = Target.resolveInstanceContext(S);
-    if (!InstanceContext) return AR_dependent;
+  if (Access == AS_protected && Target.isInstanceMember()) {
+    // Compute the instance context if possible.
+    const CXXRecordDecl *InstanceContext = 0;
+    if (Target.hasInstanceContext()) {
+      InstanceContext = Target.resolveInstanceContext(S);
+      if (!InstanceContext) return AR_dependent;
+    }
+
     switch (GetProtectedFriendKind(S, EC, InstanceContext, NamingClass)) {
     case AR_accessible: return AR_accessible;
     case AR_inaccessible: return OnFailure;
@@ -950,31 +1004,46 @@
 static bool TryDiagnoseProtectedAccess(Sema &S, const EffectiveContext &EC,
                                        AccessTarget &Target) {
   // Only applies to instance accesses.
-  if (!Target.hasInstanceContext())
+  if (!Target.isInstanceMember())
     return false;
+
   assert(Target.isMemberAccess());
-  NamedDecl *D = Target.getTargetDecl();
 
-  const CXXRecordDecl *DeclaringClass = Target.getDeclaringClass();
-  DeclaringClass = DeclaringClass->getCanonicalDecl();
+  const CXXRecordDecl *NamingClass = Target.getNamingClass();
+  NamingClass = NamingClass->getCanonicalDecl();
 
   for (EffectiveContext::record_iterator
          I = EC.Records.begin(), E = EC.Records.end(); I != E; ++I) {
     const CXXRecordDecl *ECRecord = *I;
-    switch (IsDerivedFromInclusive(ECRecord, DeclaringClass)) {
+    switch (IsDerivedFromInclusive(ECRecord, NamingClass)) {
     case AR_accessible: break;
     case AR_inaccessible: continue;
     case AR_dependent: continue;
     }
 
     // The effective context is a subclass of the declaring class.
-    // If that class isn't a superclass of the instance context,
-    // then the [class.protected] restriction applies.
+    // Check whether the [class.protected] restriction is limiting
+    // access.
 
     // To get this exactly right, this might need to be checked more
     // holistically;  it's not necessarily the case that gaining
     // access here would grant us access overall.
 
+    NamedDecl *D = Target.getTargetDecl();
+
+    // If we don't have an instance context, [class.protected] says the
+    // naming class has to equal the context class.
+    if (!Target.hasInstanceContext()) {
+      // If it does, the restriction doesn't apply.
+      if (NamingClass == ECRecord) continue;
+
+      // TODO: it would be great to have a fixit here, since this is
+      // such an obvious error.
+      S.Diag(D->getLocation(), diag::note_access_protected_restricted_noobject)
+        << S.Context.getTypeDeclType(ECRecord);
+      return true;
+    }
+
     const CXXRecordDecl *InstanceContext = Target.resolveInstanceContext(S);
     assert(InstanceContext && "diagnosing dependent access");
 
@@ -982,12 +1051,25 @@
     case AR_accessible: continue;
     case AR_dependent: continue;
     case AR_inaccessible:
-      S.Diag(D->getLocation(), diag::note_access_protected_restricted)
-        << (InstanceContext != Target.getNamingClass()->getCanonicalDecl())
-        << S.Context.getTypeDeclType(InstanceContext)
-        << S.Context.getTypeDeclType(ECRecord);
+      break;
+    }
+
+    // Okay, the restriction seems to be what's limiting us.
+
+    // Use a special diagnostic for constructors and destructors.
+    if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D) ||
+        (isa<FunctionTemplateDecl>(D) &&
+         isa<CXXConstructorDecl>(
+                cast<FunctionTemplateDecl>(D)->getTemplatedDecl()))) {
+      S.Diag(D->getLocation(), diag::note_access_protected_restricted_ctordtor)
+        << isa<CXXDestructorDecl>(D);
       return true;
     }
+
+    // Otherwise, use the generic diagnostic.
+    S.Diag(D->getLocation(), diag::note_access_protected_restricted_object)
+      << S.Context.getTypeDeclType(ECRecord);
+    return true;
   }
 
   return false;
@@ -1425,9 +1507,33 @@
   return CheckAccess(*this, E->getMemberLoc(), Entity);
 }
 
+/// Is the given special member function accessible for the purposes of
+/// deciding whether to define a special member function as deleted?
+bool Sema::isSpecialMemberAccessibleForDeletion(CXXMethodDecl *decl,
+                                                AccessSpecifier access,
+                                                QualType objectType) {
+  // Fast path.
+  if (access == AS_public || !getLangOpts().AccessControl) return true;
+
+  AccessTarget entity(Context, AccessTarget::Member, decl->getParent(),
+                      DeclAccessPair::make(decl, access), objectType);
+
+  // Suppress diagnostics.
+  entity.setDiag(PDiag());
+
+  switch (CheckAccess(*this, SourceLocation(), entity)) {
+  case AR_accessible: return true;
+  case AR_inaccessible: return false;
+  case AR_dependent: llvm_unreachable("dependent for =delete computation");
+  case AR_delayed: llvm_unreachable("cannot delay =delete computation");
+  }
+  llvm_unreachable("bad access result");
+}
+
 Sema::AccessResult Sema::CheckDestructorAccess(SourceLocation Loc,
                                                CXXDestructorDecl *Dtor,
-                                               const PartialDiagnostic &PDiag) {
+                                               const PartialDiagnostic &PDiag,
+                                               QualType ObjectTy) {
   if (!getLangOpts().AccessControl)
     return AR_accessible;
 
@@ -1437,9 +1543,11 @@
     return AR_accessible;
 
   CXXRecordDecl *NamingClass = Dtor->getParent();
+  if (ObjectTy.isNull()) ObjectTy = Context.getTypeDeclType(NamingClass);
+
   AccessTarget Entity(Context, AccessTarget::Member, NamingClass,
                       DeclAccessPair::make(Dtor, Access),
-                      QualType());
+                      ObjectTy);
   Entity.setDiag(PDiag); // TODO: avoid copy
 
   return CheckAccess(*this, Loc, Entity);
@@ -1451,14 +1559,9 @@
                                                 const InitializedEntity &Entity,
                                                 AccessSpecifier Access,
                                                 bool IsCopyBindingRefToTemp) {
-  if (!getLangOpts().AccessControl ||
-      Access == AS_public)
+  if (!getLangOpts().AccessControl || Access == AS_public)
     return AR_accessible;
 
-  CXXRecordDecl *NamingClass = Constructor->getParent();
-  AccessTarget AccessEntity(Context, AccessTarget::Member, NamingClass,
-                            DeclAccessPair::make(Constructor, Access),
-                            QualType());
   PartialDiagnostic PD(PDiag());
   switch (Entity.getKind()) {
   default:
@@ -1490,26 +1593,38 @@
 
   }
 
-  return CheckConstructorAccess(UseLoc, Constructor, Access, PD);
+  return CheckConstructorAccess(UseLoc, Constructor, Entity, Access, PD);
 }
 
 /// Checks access to a constructor.
 Sema::AccessResult Sema::CheckConstructorAccess(SourceLocation UseLoc,
                                                 CXXConstructorDecl *Constructor,
+                                                const InitializedEntity &Entity,
                                                 AccessSpecifier Access,
-                                                PartialDiagnostic PD) {
+                                                const PartialDiagnostic &PD) {
   if (!getLangOpts().AccessControl ||
       Access == AS_public)
     return AR_accessible;
 
   CXXRecordDecl *NamingClass = Constructor->getParent();
+
+  // Initializing a base sub-object is an instance method call on an
+  // object of the derived class.  Otherwise, we have an instance method
+  // call on an object of the constructed type.
+  CXXRecordDecl *ObjectClass;
+  if (Entity.getKind() == InitializedEntity::EK_Base) {
+    ObjectClass = cast<CXXConstructorDecl>(CurContext)->getParent();
+  } else {
+    ObjectClass = NamingClass;
+  }
+
   AccessTarget AccessEntity(Context, AccessTarget::Member, NamingClass,
                             DeclAccessPair::make(Constructor, Access),
-                            QualType());
+                            Context.getTypeDeclType(ObjectClass));
   AccessEntity.setDiag(PD);
 
   return CheckAccess(*this, UseLoc, AccessEntity);
-}
+} 
 
 /// Checks direct (i.e. non-inherited) access to an arbitrary class
 /// member.
@@ -1583,7 +1698,7 @@
   CXXRecordDecl *NamingClass = Ovl->getNamingClass();
 
   AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
-                      Context.getTypeDeclType(NamingClass));
+                      /*no instance context*/ QualType());
   Entity.setDiag(diag::err_access)
     << Ovl->getSourceRange();
 

Modified: cfe/branches/tooling/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaChecking.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaChecking.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaChecking.cpp Tue Apr 17 06:08:26 2012
@@ -250,30 +250,11 @@
   case Builtin::BI__sync_swap_8:
   case Builtin::BI__sync_swap_16:
     return SemaBuiltinAtomicOverloaded(move(TheCallResult));
-  case Builtin::BI__atomic_load:
-    return SemaAtomicOpsOverloaded(move(TheCallResult), AtomicExpr::Load);
-  case Builtin::BI__atomic_store:
-    return SemaAtomicOpsOverloaded(move(TheCallResult), AtomicExpr::Store);
-  case Builtin::BI__atomic_init:
-    return SemaAtomicOpsOverloaded(move(TheCallResult), AtomicExpr::Init);
-  case Builtin::BI__atomic_exchange:
-    return SemaAtomicOpsOverloaded(move(TheCallResult), AtomicExpr::Xchg);
-  case Builtin::BI__atomic_compare_exchange_strong:
-    return SemaAtomicOpsOverloaded(move(TheCallResult),
-                                   AtomicExpr::CmpXchgStrong);
-  case Builtin::BI__atomic_compare_exchange_weak:
-    return SemaAtomicOpsOverloaded(move(TheCallResult),
-                                   AtomicExpr::CmpXchgWeak);
-  case Builtin::BI__atomic_fetch_add:
-    return SemaAtomicOpsOverloaded(move(TheCallResult), AtomicExpr::Add);
-  case Builtin::BI__atomic_fetch_sub:
-    return SemaAtomicOpsOverloaded(move(TheCallResult), AtomicExpr::Sub);
-  case Builtin::BI__atomic_fetch_and:
-    return SemaAtomicOpsOverloaded(move(TheCallResult), AtomicExpr::And);
-  case Builtin::BI__atomic_fetch_or:
-    return SemaAtomicOpsOverloaded(move(TheCallResult), AtomicExpr::Or);
-  case Builtin::BI__atomic_fetch_xor:
-    return SemaAtomicOpsOverloaded(move(TheCallResult), AtomicExpr::Xor);
+#define BUILTIN(ID, TYPE, ATTRS)
+#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
+  case Builtin::BI##ID: \
+    return SemaAtomicOpsOverloaded(move(TheCallResult), AtomicExpr::AO##ID);
+#include "clang/Basic/Builtins.def"
   case Builtin::BI__builtin_annotation:
     if (CheckBuiltinAnnotationString(*this, TheCall->getArg(1)))
       return ExprError();
@@ -504,75 +485,177 @@
   return false;
 }
 
-ExprResult
-Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult, AtomicExpr::AtomicOp Op) {
+ExprResult Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult,
+                                         AtomicExpr::AtomicOp Op) {
   CallExpr *TheCall = cast<CallExpr>(TheCallResult.get());
   DeclRefExpr *DRE =cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
 
-  // All these operations take one of the following four forms:
-  // T   __atomic_load(_Atomic(T)*, int)                              (loads)
-  // T*  __atomic_add(_Atomic(T*)*, ptrdiff_t, int)         (pointer add/sub)
-  // int __atomic_compare_exchange_strong(_Atomic(T)*, T*, T, int, int)
-  //                                                                (cmpxchg)
-  // T   __atomic_exchange(_Atomic(T)*, T, int)             (everything else)
-  // where T is an appropriate type, and the int paremeterss are for orderings.
-  unsigned NumVals = 1;
-  unsigned NumOrders = 1;
-  if (Op == AtomicExpr::Load) {
-    NumVals = 0;
-  } else if (Op == AtomicExpr::CmpXchgWeak || Op == AtomicExpr::CmpXchgStrong) {
-    NumVals = 2;
-    NumOrders = 2;
+  // All these operations take one of the following forms:
+  enum {
+    // C    __c11_atomic_init(A *, C)
+    Init,
+    // C    __c11_atomic_load(A *, int)
+    Load,
+    // void __atomic_load(A *, CP, int)
+    Copy,
+    // C    __c11_atomic_add(A *, M, int)
+    Arithmetic,
+    // C    __atomic_exchange_n(A *, CP, int)
+    Xchg,
+    // void __atomic_exchange(A *, C *, CP, int)
+    GNUXchg,
+    // bool __c11_atomic_compare_exchange_strong(A *, C *, CP, int, int)
+    C11CmpXchg,
+    // bool __atomic_compare_exchange(A *, C *, CP, bool, int, int)
+    GNUCmpXchg
+  } Form = Init;
+  const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 4, 5, 6 };
+  const unsigned NumVals[] = { 1, 0, 1, 1, 1, 2, 2, 3 };
+  // where:
+  //   C is an appropriate type,
+  //   A is volatile _Atomic(C) for __c11 builtins and is C for GNU builtins,
+  //   CP is C for __c11 builtins and GNU _n builtins and is C * otherwise,
+  //   M is C if C is an integer, and ptrdiff_t if C is a pointer, and
+  //   the int parameters are for orderings.
+
+  assert(AtomicExpr::AO__c11_atomic_init == 0 &&
+         AtomicExpr::AO__c11_atomic_fetch_xor + 1 == AtomicExpr::AO__atomic_load
+         && "need to update code for modified C11 atomics");
+  bool IsC11 = Op >= AtomicExpr::AO__c11_atomic_init &&
+               Op <= AtomicExpr::AO__c11_atomic_fetch_xor;
+  bool IsN = Op == AtomicExpr::AO__atomic_load_n ||
+             Op == AtomicExpr::AO__atomic_store_n ||
+             Op == AtomicExpr::AO__atomic_exchange_n ||
+             Op == AtomicExpr::AO__atomic_compare_exchange_n;
+  bool IsAddSub = false;
+
+  switch (Op) {
+  case AtomicExpr::AO__c11_atomic_init:
+    Form = Init;
+    break;
+
+  case AtomicExpr::AO__c11_atomic_load:
+  case AtomicExpr::AO__atomic_load_n:
+    Form = Load;
+    break;
+
+  case AtomicExpr::AO__c11_atomic_store:
+  case AtomicExpr::AO__atomic_load:
+  case AtomicExpr::AO__atomic_store:
+  case AtomicExpr::AO__atomic_store_n:
+    Form = Copy;
+    break;
+
+  case AtomicExpr::AO__c11_atomic_fetch_add:
+  case AtomicExpr::AO__c11_atomic_fetch_sub:
+  case AtomicExpr::AO__atomic_fetch_add:
+  case AtomicExpr::AO__atomic_fetch_sub:
+  case AtomicExpr::AO__atomic_add_fetch:
+  case AtomicExpr::AO__atomic_sub_fetch:
+    IsAddSub = true;
+    // Fall through.
+  case AtomicExpr::AO__c11_atomic_fetch_and:
+  case AtomicExpr::AO__c11_atomic_fetch_or:
+  case AtomicExpr::AO__c11_atomic_fetch_xor:
+  case AtomicExpr::AO__atomic_fetch_and:
+  case AtomicExpr::AO__atomic_fetch_or:
+  case AtomicExpr::AO__atomic_fetch_xor:
+  case AtomicExpr::AO__atomic_fetch_nand:
+  case AtomicExpr::AO__atomic_and_fetch:
+  case AtomicExpr::AO__atomic_or_fetch:
+  case AtomicExpr::AO__atomic_xor_fetch:
+  case AtomicExpr::AO__atomic_nand_fetch:
+    Form = Arithmetic;
+    break;
+
+  case AtomicExpr::AO__c11_atomic_exchange:
+  case AtomicExpr::AO__atomic_exchange_n:
+    Form = Xchg;
+    break;
+
+  case AtomicExpr::AO__atomic_exchange:
+    Form = GNUXchg;
+    break;
+
+  case AtomicExpr::AO__c11_atomic_compare_exchange_strong:
+  case AtomicExpr::AO__c11_atomic_compare_exchange_weak:
+    Form = C11CmpXchg;
+    break;
+
+  case AtomicExpr::AO__atomic_compare_exchange:
+  case AtomicExpr::AO__atomic_compare_exchange_n:
+    Form = GNUCmpXchg;
+    break;
   }
-  if (Op == AtomicExpr::Init)
-    NumOrders = 0;
 
-  if (TheCall->getNumArgs() < NumVals+NumOrders+1) {
+  // Check we have the right number of arguments.
+  if (TheCall->getNumArgs() < NumArgs[Form]) {
     Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
-      << 0 << NumVals+NumOrders+1 << TheCall->getNumArgs()
+      << 0 << NumArgs[Form] << TheCall->getNumArgs()
       << TheCall->getCallee()->getSourceRange();
     return ExprError();
-  } else if (TheCall->getNumArgs() > NumVals+NumOrders+1) {
-    Diag(TheCall->getArg(NumVals+NumOrders+1)->getLocStart(),
+  } else if (TheCall->getNumArgs() > NumArgs[Form]) {
+    Diag(TheCall->getArg(NumArgs[Form])->getLocStart(),
          diag::err_typecheck_call_too_many_args)
-      << 0 << NumVals+NumOrders+1 << TheCall->getNumArgs()
+      << 0 << NumArgs[Form] << TheCall->getNumArgs()
       << TheCall->getCallee()->getSourceRange();
     return ExprError();
   }
 
-  // Inspect the first argument of the atomic operation.  This should always be
-  // a pointer to an _Atomic type.
+  // Inspect the first argument of the atomic operation.
   Expr *Ptr = TheCall->getArg(0);
   Ptr = DefaultFunctionArrayLvalueConversion(Ptr).get();
   const PointerType *pointerType = Ptr->getType()->getAs<PointerType>();
   if (!pointerType) {
-    Diag(DRE->getLocStart(), diag::err_atomic_op_needs_atomic)
+    Diag(DRE->getLocStart(), diag::err_atomic_builtin_must_be_pointer)
       << Ptr->getType() << Ptr->getSourceRange();
     return ExprError();
   }
 
-  QualType AtomTy = pointerType->getPointeeType();
-  if (!AtomTy->isAtomicType()) {
-    Diag(DRE->getLocStart(), diag::err_atomic_op_needs_atomic)
-      << Ptr->getType() << Ptr->getSourceRange();
-    return ExprError();
+  // For a __c11 builtin, this should be a pointer to an _Atomic type.
+  QualType AtomTy = pointerType->getPointeeType(); // 'A'
+  QualType ValType = AtomTy; // 'C'
+  if (IsC11) {
+    if (!AtomTy->isAtomicType()) {
+      Diag(DRE->getLocStart(), diag::err_atomic_op_needs_atomic)
+        << Ptr->getType() << Ptr->getSourceRange();
+      return ExprError();
+    }
+    ValType = AtomTy->getAs<AtomicType>()->getValueType();
   }
-  QualType ValType = AtomTy->getAs<AtomicType>()->getValueType();
 
-  if ((Op == AtomicExpr::Add || Op == AtomicExpr::Sub) &&
-      !ValType->isIntegerType() && !ValType->isPointerType()) {
+  // For an arithmetic operation, the implied arithmetic must be well-formed.
+  if (Form == Arithmetic) {
+    // gcc does not enforce these rules for GNU atomics, but we do so for sanity.
+    if (IsAddSub && !ValType->isIntegerType() && !ValType->isPointerType()) {
+      Diag(DRE->getLocStart(), diag::err_atomic_op_needs_atomic_int_or_ptr)
+        << IsC11 << Ptr->getType() << Ptr->getSourceRange();
+      return ExprError();
+    }
+    if (!IsAddSub && !ValType->isIntegerType()) {
+      Diag(DRE->getLocStart(), diag::err_atomic_op_bitwise_needs_atomic_int)
+        << IsC11 << Ptr->getType() << Ptr->getSourceRange();
+      return ExprError();
+    }
+  } else if (IsN && !ValType->isIntegerType() && !ValType->isPointerType()) {
+    // For __atomic_*_n operations, the value type must be a scalar integral or
+    // pointer type which is 1, 2, 4, 8 or 16 bytes in length.
     Diag(DRE->getLocStart(), diag::err_atomic_op_needs_atomic_int_or_ptr)
-      << Ptr->getType() << Ptr->getSourceRange();
+      << IsC11 << Ptr->getType() << Ptr->getSourceRange();
     return ExprError();
   }
 
-  if (!ValType->isIntegerType() &&
-      (Op == AtomicExpr::And || Op == AtomicExpr::Or || Op == AtomicExpr::Xor)){
-    Diag(DRE->getLocStart(), diag::err_atomic_op_logical_needs_atomic_int)
+  if (!IsC11 && !AtomTy.isTriviallyCopyableType(Context)) {
+    // For GNU atomics, require a trivially-copyable type. This is not part of
+    // the GNU atomics specification, but we enforce it for sanity.
+    Diag(DRE->getLocStart(), diag::err_atomic_op_needs_trivial_copy)
       << Ptr->getType() << Ptr->getSourceRange();
     return ExprError();
   }
 
+  // FIXME: For any builtin other than a load, the ValType must not be
+  // const-qualified.
+
   switch (ValType.getObjCLifetime()) {
   case Qualifiers::OCL_None:
   case Qualifiers::OCL_ExplicitNone:
@@ -582,63 +665,107 @@
   case Qualifiers::OCL_Weak:
   case Qualifiers::OCL_Strong:
   case Qualifiers::OCL_Autoreleasing:
+    // FIXME: Can this happen? By this point, ValType should be known
+    // to be trivially copyable.
     Diag(DRE->getLocStart(), diag::err_arc_atomic_ownership)
       << ValType << Ptr->getSourceRange();
     return ExprError();
   }
 
   QualType ResultType = ValType;
-  if (Op == AtomicExpr::Store || Op == AtomicExpr::Init)
+  if (Form == Copy || Form == GNUXchg || Form == Init)
     ResultType = Context.VoidTy;
-  else if (Op == AtomicExpr::CmpXchgWeak || Op == AtomicExpr::CmpXchgStrong)
+  else if (Form == C11CmpXchg || Form == GNUCmpXchg)
     ResultType = Context.BoolTy;
 
+  // The type of a parameter passed 'by value'. In the GNU atomics, such
+  // arguments are actually passed as pointers.
+  QualType ByValType = ValType; // 'CP'
+  if (!IsC11 && !IsN)
+    ByValType = Ptr->getType();
+
   // The first argument --- the pointer --- has a fixed type; we
   // deduce the types of the rest of the arguments accordingly.  Walk
   // the remaining arguments, converting them to the deduced value type.
-  for (unsigned i = 1; i != NumVals+NumOrders+1; ++i) {
-    ExprResult Arg = TheCall->getArg(i);
+  for (unsigned i = 1; i != NumArgs[Form]; ++i) {
     QualType Ty;
-    if (i < NumVals+1) {
-      // The second argument to a cmpxchg is a pointer to the data which will
-      // be exchanged. The second argument to a pointer add/subtract is the
-      // amount to add/subtract, which must be a ptrdiff_t.  The third
-      // argument to a cmpxchg and the second argument in all other cases
-      // is the type of the value.
-      if (i == 1 && (Op == AtomicExpr::CmpXchgWeak ||
-                     Op == AtomicExpr::CmpXchgStrong))
-         Ty = Context.getPointerType(ValType.getUnqualifiedType());
-      else if (!ValType->isIntegerType() &&
-               (Op == AtomicExpr::Add || Op == AtomicExpr::Sub))
-        Ty = Context.getPointerDiffType();
-      else
-        Ty = ValType;
+    if (i < NumVals[Form] + 1) {
+      switch (i) {
+      case 1:
+        // The second argument is the non-atomic operand. For arithmetic, this
+        // is always passed by value, and for a compare_exchange it is always
+        // passed by address. For the rest, GNU uses by-address and C11 uses
+        // by-value.
+        assert(Form != Load);
+        if (Form == Init || (Form == Arithmetic && ValType->isIntegerType()))
+          Ty = ValType;
+        else if (Form == Copy || Form == Xchg)
+          Ty = ByValType;
+        else if (Form == Arithmetic)
+          Ty = Context.getPointerDiffType();
+        else
+          Ty = Context.getPointerType(ValType.getUnqualifiedType());
+        break;
+      case 2:
+        // The third argument to compare_exchange / GNU exchange is a
+        // (pointer to a) desired value.
+        Ty = ByValType;
+        break;
+      case 3:
+        // The fourth argument to GNU compare_exchange is a 'weak' flag.
+        Ty = Context.BoolTy;
+        break;
+      }
     } else {
       // The order(s) are always converted to int.
       Ty = Context.IntTy;
     }
+
     InitializedEntity Entity =
         InitializedEntity::InitializeParameter(Context, Ty, false);
+    ExprResult Arg = TheCall->getArg(i);
     Arg = PerformCopyInitialization(Entity, SourceLocation(), Arg);
     if (Arg.isInvalid())
       return true;
     TheCall->setArg(i, Arg.get());
   }
 
+  // Permute the arguments into a 'consistent' order.
   SmallVector<Expr*, 5> SubExprs;
   SubExprs.push_back(Ptr);
-  if (Op == AtomicExpr::Load) {
-    SubExprs.push_back(TheCall->getArg(1)); // Order
-  } else if (Op == AtomicExpr::Init) {
+  switch (Form) {
+  case Init:
+    // Note, AtomicExpr::getVal1() has a special case for this atomic.
     SubExprs.push_back(TheCall->getArg(1)); // Val1
-  } else if (Op != AtomicExpr::CmpXchgWeak && Op != AtomicExpr::CmpXchgStrong) {
+    break;
+  case Load:
+    SubExprs.push_back(TheCall->getArg(1)); // Order
+    break;
+  case Copy:
+  case Arithmetic:
+  case Xchg:
     SubExprs.push_back(TheCall->getArg(2)); // Order
     SubExprs.push_back(TheCall->getArg(1)); // Val1
-  } else {
+    break;
+  case GNUXchg:
+    // Note, AtomicExpr::getVal2() has a special case for this atomic.
+    SubExprs.push_back(TheCall->getArg(3)); // Order
+    SubExprs.push_back(TheCall->getArg(1)); // Val1
+    SubExprs.push_back(TheCall->getArg(2)); // Val2
+    break;
+  case C11CmpXchg:
     SubExprs.push_back(TheCall->getArg(3)); // Order
     SubExprs.push_back(TheCall->getArg(1)); // Val1
     SubExprs.push_back(TheCall->getArg(4)); // OrderFail
     SubExprs.push_back(TheCall->getArg(2)); // Val2
+    break;
+  case GNUCmpXchg:
+    SubExprs.push_back(TheCall->getArg(4)); // Order
+    SubExprs.push_back(TheCall->getArg(1)); // Val1
+    SubExprs.push_back(TheCall->getArg(5)); // OrderFail
+    SubExprs.push_back(TheCall->getArg(2)); // Val2
+    SubExprs.push_back(TheCall->getArg(3)); // Weak
+    break;
   }
 
   return Owned(new (Context) AtomicExpr(TheCall->getCallee()->getLocStart(),
@@ -1176,7 +1303,6 @@
              "promotion from float to double is the only expected cast here");
       Cast->setSubExpr(0);
       TheCall->setArg(NumArgs-1, CastArg);
-      OrigArg = CastArg;
     }
   }
   
@@ -4109,7 +4235,7 @@
     if (S.SourceMgr.isInSystemMacro(CC))
       return;
     
-    if (SourceRange.Width == 64 && TargetRange.Width == 32)
+    if (TargetRange.Width == 32 && S.Context.getIntWidth(E->getType()) == 64)
       return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_64_32,
                              /* pruneControlFlow */ true);
     return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_precision);

Modified: cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp Tue Apr 17 06:08:26 2012
@@ -123,6 +123,8 @@
 
     /// \brief The allocator used to allocate new code-completion strings.
     CodeCompletionAllocator &Allocator;
+
+    CodeCompletionTUInfo &CCTUInfo;
     
     /// \brief If non-NULL, a filter function used to remove any code-completion
     /// results that are not desirable.
@@ -166,9 +168,11 @@
     
   public:
     explicit ResultBuilder(Sema &SemaRef, CodeCompletionAllocator &Allocator,
+                           CodeCompletionTUInfo &CCTUInfo,
                            const CodeCompletionContext &CompletionContext,
                            LookupFilter Filter = 0)
-      : SemaRef(SemaRef), Allocator(Allocator), Filter(Filter), 
+      : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
+        Filter(Filter), 
         AllowNestedNameSpecifiers(false), HasObjectTypeQualifiers(false), 
         CompletionContext(CompletionContext),
         ObjCImplementation(0) 
@@ -251,6 +255,8 @@
     
     /// \brief Retrieve the allocator used to allocate code completion strings.
     CodeCompletionAllocator &getAllocator() const { return Allocator; }
+
+    CodeCompletionTUInfo &getCodeCompletionTUInfo() const { return CCTUInfo; }
     
     /// \brief Determine whether the given declaration is at all interesting
     /// as a code-completion result.
@@ -514,14 +520,6 @@
         return false;
     }
   }
-   
-  // Skip out-of-line declarations and definitions.
-  // NOTE: Unless it's an Objective-C property, method, or ivar, where
-  // the contexts can be messy.
-  if (!ND->getDeclContext()->Equals(ND->getLexicalDeclContext()) &&
-      !(isa<ObjCPropertyDecl>(ND) || isa<ObjCIvarDecl>(ND) ||
-        isa<ObjCMethodDecl>(ND)))
-    return false;
 
   if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
       ((isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND)) &&
@@ -904,7 +902,7 @@
 
   if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
     return;
-      
+
   // Make sure that any given declaration only shows up in the result set once.
   if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()))
     return;
@@ -1239,7 +1237,8 @@
     Results.AddResult(Result("restrict", CCP_Type));
   }
   
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
   if (LangOpts.CPlusPlus) {
     // C++-specific
     Results.AddResult(Result("bool", CCP_Type + 
@@ -1349,7 +1348,8 @@
 static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt);
 
 static void AddTypedefResult(ResultBuilder &Results) {
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
   Builder.AddTypedTextChunk("typedef");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("type");
@@ -1442,7 +1442,7 @@
     return;
   
   CodeCompletionAllocator &Allocator = Results.getAllocator();
-  CodeCompletionBuilder Builder(Allocator);
+  CodeCompletionBuilder Builder(Allocator, Results.getCodeCompletionTUInfo());
   PrintingPolicy Policy = getCompletionPrintingPolicy(S);
   Builder.AddResultTypeChunk(GetCompletionTypeString(ThisTy, 
                                                      S.Context, 
@@ -1458,7 +1458,7 @@
                                    Sema &SemaRef,
                                    ResultBuilder &Results) {
   CodeCompletionAllocator &Allocator = Results.getAllocator();
-  CodeCompletionBuilder Builder(Allocator);
+  CodeCompletionBuilder Builder(Allocator, Results.getCodeCompletionTUInfo());
   PrintingPolicy Policy = getCompletionPrintingPolicy(SemaRef);
   
   typedef CodeCompletionResult Result;
@@ -1542,17 +1542,20 @@
 
         // public:
         Builder.AddTypedTextChunk("public");
-        Builder.AddChunk(CodeCompletionString::CK_Colon);
+        if (Results.includeCodePatterns())
+          Builder.AddChunk(CodeCompletionString::CK_Colon);
         Results.AddResult(Result(Builder.TakeString()));
 
         // protected:
         Builder.AddTypedTextChunk("protected");
-        Builder.AddChunk(CodeCompletionString::CK_Colon);
+        if (Results.includeCodePatterns())
+          Builder.AddChunk(CodeCompletionString::CK_Colon);
         Results.AddResult(Result(Builder.TakeString()));
 
         // private:
         Builder.AddTypedTextChunk("private");
-        Builder.AddChunk(CodeCompletionString::CK_Colon);
+        if (Results.includeCodePatterns())
+          Builder.AddChunk(CodeCompletionString::CK_Colon);
         Results.AddResult(Result(Builder.TakeString()));
       }
     }
@@ -2188,7 +2191,8 @@
     if (Param->hasDefaultArg() && !InOptional) {
       // When we see an optional default argument, put that argument and
       // the remaining default arguments into a new, optional string.
-      CodeCompletionBuilder Opt(Result.getAllocator());
+      CodeCompletionBuilder Opt(Result.getAllocator(),
+                                Result.getCodeCompletionTUInfo());
       if (!FirstParameter)
         Opt.AddChunk(CodeCompletionString::CK_Comma);
       AddFunctionParameterChunks(Context, Policy, Function, Opt, P, true);
@@ -2279,7 +2283,8 @@
     if (HasDefaultArg && !InDefaultArg) {
       // When we see an optional default argument, put that argument and
       // the remaining default arguments into a new, optional string.
-      CodeCompletionBuilder Opt(Result.getAllocator());
+      CodeCompletionBuilder Opt(Result.getAllocator(),
+                                Result.getCodeCompletionTUInfo());
       if (!FirstParameter)
         Opt.AddChunk(CodeCompletionString::CK_Comma);
       AddTemplateParameterChunks(Context, Policy, Template, Opt, MaxParameters,
@@ -2434,8 +2439,9 @@
 }
 
 CodeCompletionString *CodeCompletionResult::CreateCodeCompletionString(Sema &S,
-                                         CodeCompletionAllocator &Allocator) {
-  return CreateCodeCompletionString(S.Context, S.PP, Allocator);
+                                         CodeCompletionAllocator &Allocator,
+                                         CodeCompletionTUInfo &CCTUInfo) {
+  return CreateCodeCompletionString(S.Context, S.PP, Allocator, CCTUInfo);
 }
 
 /// \brief If possible, create a new code completion string for the given
@@ -2447,8 +2453,9 @@
 CodeCompletionString *
 CodeCompletionResult::CreateCodeCompletionString(ASTContext &Ctx,
                                                  Preprocessor &PP,
-                                           CodeCompletionAllocator &Allocator) {
-  CodeCompletionBuilder Result(Allocator, Priority, Availability);
+                                           CodeCompletionAllocator &Allocator,
+                                           CodeCompletionTUInfo &CCTUInfo) {
+  CodeCompletionBuilder Result(Allocator, CCTUInfo, Priority, Availability);
   
   PrintingPolicy Policy = getCompletionPrintingPolicy(Ctx, PP);
   if (Kind == RK_Pattern) {
@@ -2703,11 +2710,12 @@
 CodeCompleteConsumer::OverloadCandidate::CreateSignatureString(
                                                           unsigned CurrentArg,
                                                                Sema &S,
-                                     CodeCompletionAllocator &Allocator) const {
+                                     CodeCompletionAllocator &Allocator,
+                                     CodeCompletionTUInfo &CCTUInfo) const {
   PrintingPolicy Policy = getCompletionPrintingPolicy(S);
 
   // FIXME: Set priority, availability appropriately.
-  CodeCompletionBuilder Result(Allocator, 1, CXAvailability_Available);
+  CodeCompletionBuilder Result(Allocator,CCTUInfo, 1, CXAvailability_Available);
   FunctionDecl *FDecl = getFunction();
   AddResultTypeChunk(S.Context, Policy, FDecl, Result);
   const FunctionProtoType *Proto 
@@ -2994,7 +3002,8 @@
   for (CXXMethodDecl::method_iterator M = Method->begin_overridden_methods(),
                                    MEnd = Method->end_overridden_methods();
        M != MEnd; ++M) {
-    CodeCompletionBuilder Builder(Results.getAllocator());
+    CodeCompletionBuilder Builder(Results.getAllocator(),
+                                  Results.getCodeCompletionTUInfo());
     CXXMethodDecl *Overridden = const_cast<CXXMethodDecl *>(*M);
     if (Overridden->getCanonicalDecl() == Method->getCanonicalDecl())
       continue;
@@ -3042,11 +3051,12 @@
                                     ModuleIdPath Path) {
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
   
   CodeCompletionAllocator &Allocator = Results.getAllocator();
-  CodeCompletionBuilder Builder(Allocator);
+  CodeCompletionBuilder Builder(Allocator, Results.getCodeCompletionTUInfo());
   typedef CodeCompletionResult Result;
   if (Path.empty()) {
     // Enumerate all top-level modules.
@@ -3093,6 +3103,7 @@
                                     ParserCompletionContext CompletionContext) {
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         mapCodeCompletionContext(*this, CompletionContext));
   Results.EnterNewScope();
   
@@ -3188,6 +3199,7 @@
                                 bool AllowNestedNameSpecifiers) {
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         AllowNestedNameSpecifiers
                           ? CodeCompletionContext::CCC_PotentiallyQualifiedName
                           : CodeCompletionContext::CCC_Name);
@@ -3265,6 +3277,7 @@
                                   const CodeCompleteExpressionData &Data) {
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Expression);
   if (Data.ObjCCollection)
     Results.setFilter(&ResultBuilder::IsObjCCollection);
@@ -3347,7 +3360,8 @@
       if (M->getSelector().isUnarySelector())
         if (IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0))
           if (AddedProperties.insert(Name)) {
-            CodeCompletionBuilder Builder(Results.getAllocator());
+            CodeCompletionBuilder Builder(Results.getAllocator(),
+                                          Results.getCodeCompletionTUInfo());
             AddResultTypeChunk(Context, Policy, *M, Builder);
             Builder.AddTypedTextChunk(
                             Results.getAllocator().CopyString(Name->getName()));
@@ -3439,6 +3453,7 @@
   }
   
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                   CodeCompletionContext(contextKind,
                                         BaseType),
                         &ResultBuilder::IsMember);
@@ -3548,7 +3563,8 @@
     llvm_unreachable("Unknown type specifier kind in CodeCompleteTag");
   }
   
-  ResultBuilder Results(*this, CodeCompleter->getAllocator(), ContextKind);
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(), ContextKind);
   CodeCompletionDeclConsumer Consumer(Results, CurContext);
 
   // First pass: look for tags.
@@ -3568,6 +3584,7 @@
 
 void Sema::CodeCompleteTypeQualifiers(DeclSpec &DS) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_TypeQualifiers);
   Results.EnterNewScope();
   if (!(DS.getTypeQualifiers() & DeclSpec::TQ_const))
@@ -3648,6 +3665,7 @@
   
   // Add any enumerators that have not yet been mentioned.
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Expression);
   Results.EnterNewScope();
   for (EnumDecl::enumerator_iterator E = Enum->enumerator_begin(),
@@ -3838,6 +3856,7 @@
 void Sema::CodeCompleteAfterIf(Scope *S) {
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         mapCodeCompletionContext(*this, PCC_Statement));
   Results.setFilter(&ResultBuilder::IsOrdinaryName);
   Results.EnterNewScope();
@@ -3849,7 +3868,8 @@
   AddOrdinaryNameResults(PCC_Statement, S, *this, Results);
   
   // "else" block
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
   Builder.AddTypedTextChunk("else");
   if (Results.includeCodePatterns()) {
     Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
@@ -3916,6 +3936,7 @@
     return;
 
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Name);
   Results.EnterNewScope();
   
@@ -3947,6 +3968,7 @@
     return;
   
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_PotentiallyQualifiedName,
                         &ResultBuilder::IsNestedNameSpecifier);
   Results.EnterNewScope();
@@ -3974,6 +3996,7 @@
   // After "using namespace", we expect to see a namespace name or namespace
   // alias.
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Namespace,
                         &ResultBuilder::IsNamespaceOrAlias);
   Results.EnterNewScope();
@@ -3998,6 +4021,7 @@
     = Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
   
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         SuppressedGlobalResults
                           ? CodeCompletionContext::CCC_Namespace
                           : CodeCompletionContext::CCC_Other,
@@ -4037,6 +4061,7 @@
   
   // After "namespace", we expect to see a namespace or alias.
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Namespace,
                         &ResultBuilder::IsNamespaceOrAlias);
   CodeCompletionDeclConsumer Consumer(Results, CurContext);
@@ -4053,6 +4078,7 @@
 
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Type,
                         &ResultBuilder::IsType);
   Results.EnterNewScope();
@@ -4088,6 +4114,7 @@
     return;
   
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_PotentiallyQualifiedName);
   Results.EnterNewScope();
   
@@ -4104,7 +4131,8 @@
   }
   
   // Add completions for base classes.
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
   bool SawLastInitializer = (NumInitializers == 0);
   CXXRecordDecl *ClassDecl = Constructor->getParent();
   for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(),
@@ -4202,6 +4230,7 @@
 void Sema::CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro,
                                         bool AfterAmpersand) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
 
@@ -4254,7 +4283,8 @@
   // Since we have an implementation, we can end it.
   Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,end)));
   
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
   if (LangOpts.ObjC2) {
     // @dynamic
     Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,dynamic));
@@ -4292,7 +4322,8 @@
 
 static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt) {
   typedef CodeCompletionResult Result;
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
   
   // @class name ;
   Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,class));
@@ -4334,6 +4365,7 @@
 void Sema::CodeCompleteObjCAtDirective(Scope *S) {
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
   if (isa<ObjCImplDecl>(CurContext))
@@ -4350,7 +4382,8 @@
 
 static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt) {
   typedef CodeCompletionResult Result;
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
 
   // @encode ( type-name )
   const char *EncodeType = "char[]";
@@ -4403,7 +4436,8 @@
 
 static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt) {
   typedef CodeCompletionResult Result;
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
   
   if (Results.includeCodePatterns()) {
     // @try { statements } @catch ( declaration ) { statements } @finally
@@ -4459,6 +4493,7 @@
 
 void Sema::CodeCompleteObjCAtVisibility(Scope *S) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
   AddObjCVisibilityResults(getLangOpts(), Results, false);
@@ -4470,6 +4505,7 @@
 
 void Sema::CodeCompleteObjCAtStatement(Scope *S) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
   AddObjCStatementResults(Results, false);
@@ -4482,6 +4518,7 @@
 
 void Sema::CodeCompleteObjCAtExpression(Scope *S) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
   AddObjCExpressionResults(Results, false);
@@ -4535,6 +4572,7 @@
   
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
   if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_readonly))
@@ -4557,14 +4595,16 @@
   if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_atomic))
     Results.AddResult(CodeCompletionResult("atomic"));
   if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_setter)) {
-    CodeCompletionBuilder Setter(Results.getAllocator());
+    CodeCompletionBuilder Setter(Results.getAllocator(),
+                                 Results.getCodeCompletionTUInfo());
     Setter.AddTypedTextChunk("setter");
     Setter.AddTextChunk(" = ");
     Setter.AddPlaceholderChunk("method");
     Results.AddResult(CodeCompletionResult(Setter.TakeString()));
   }
   if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_getter)) {
-    CodeCompletionBuilder Getter(Results.getAllocator());
+    CodeCompletionBuilder Getter(Results.getAllocator(),
+                                 Results.getCodeCompletionTUInfo());
     Getter.AddTypedTextChunk("getter");
     Getter.AddTextChunk(" = ");
     Getter.AddPlaceholderChunk("method");
@@ -4755,6 +4795,7 @@
 
   // Find all of the potential getters.
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
 
@@ -4784,6 +4825,7 @@
 
   // Find all of the potential getters.
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
 
@@ -4801,6 +4843,7 @@
                                        bool IsParameter) {
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Type);
   Results.EnterNewScope();
   
@@ -4832,8 +4875,9 @@
   //   IBAction)<#selector#>:(id)sender
   if (DS.getObjCDeclQualifier() == 0 && !IsParameter &&
       Context.Idents.get("IBAction").hasMacroDefinition()) {
-    CodeCompletionBuilder Builder(Results.getAllocator(), CCP_CodePattern, 
-                                  CXAvailability_Available);
+    CodeCompletionBuilder Builder(Results.getAllocator(),
+                                  Results.getCodeCompletionTUInfo(),
+                                  CCP_CodePattern, CXAvailability_Available);
     Builder.AddTypedTextChunk("IBAction");
     Builder.AddChunk(CodeCompletionString::CK_RightParen);
     Builder.AddPlaceholderChunk("selector");
@@ -5004,7 +5048,8 @@
   }
   
   // We have a superclass method. Now, form the send-to-super completion.
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
   
   // Give this completion a return type.
   AddResultTypeChunk(S.Context, getCompletionPrintingPolicy(S), SuperMethod, 
@@ -5058,6 +5103,7 @@
 void Sema::CodeCompleteObjCMessageReceiver(Scope *S) {
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_ObjCMessageReceiver,
                         getLangOpts().CPlusPlus0x
                           ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
@@ -5278,6 +5324,7 @@
   QualType T = this->GetTypeFromParser(Receiver);
   
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
               CodeCompletionContext(CodeCompletionContext::CCC_ObjCClassMessage,
                                     T, SelIdents, NumSelIdents));
     
@@ -5343,6 +5390,7 @@
 
   // Build the set of methods we can see.
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
            CodeCompletionContext(CodeCompletionContext::CCC_ObjCInstanceMessage,
                                  ReceiverType, SelIdents, NumSelIdents));
   
@@ -5494,6 +5542,7 @@
   }
   
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_SelectorName);
   Results.EnterNewScope();
   for (GlobalMethodPool::iterator M = MethodPool.begin(),
@@ -5504,7 +5553,8 @@
     if (!isAcceptableObjCSelector(Sel, MK_Any, SelIdents, NumSelIdents))
       continue;
 
-    CodeCompletionBuilder Builder(Results.getAllocator());
+    CodeCompletionBuilder Builder(Results.getAllocator(),
+                                  Results.getCodeCompletionTUInfo());
     if (Sel.isUnarySelector()) {
       Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
                                                        Sel.getNameForSlot(0)));
@@ -5555,6 +5605,7 @@
 void Sema::CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
                                               unsigned NumProtocols) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_ObjCProtocolName);
   
   if (CodeCompleter && CodeCompleter->includeGlobals()) {
@@ -5582,6 +5633,7 @@
 
 void Sema::CodeCompleteObjCProtocolDecl(Scope *) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_ObjCProtocolName);
   
   if (CodeCompleter && CodeCompleter->includeGlobals()) {
@@ -5620,6 +5672,7 @@
 
 void Sema::CodeCompleteObjCInterfaceDecl(Scope *S) { 
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
   
@@ -5639,6 +5692,7 @@
 void Sema::CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName,
                                       SourceLocation ClassNameLoc) { 
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_ObjCInterfaceName);
   Results.EnterNewScope();
   
@@ -5663,6 +5717,7 @@
 
 void Sema::CodeCompleteObjCImplementationDecl(Scope *S) { 
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
 
@@ -5685,6 +5740,7 @@
   typedef CodeCompletionResult Result;
   
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_ObjCCategoryName);
   
   // Ignore any categories we find that have already been implemented by this
@@ -5728,6 +5784,7 @@
     return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
     
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_ObjCCategoryName);
   
   // Add all of the categories that have have corresponding interface 
@@ -5756,6 +5813,7 @@
 void Sema::CodeCompleteObjCPropertyDefinition(Scope *S) {
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
 
   // Figure out where this @synthesize lives.
@@ -5796,6 +5854,7 @@
                                                   IdentifierInfo *PropertyName) {
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
 
   // Figure out where this @synthesize lives.
@@ -5865,7 +5924,8 @@
     unsigned Priority = CCP_MemberDeclaration + 1;
     typedef CodeCompletionResult Result;
     CodeCompletionAllocator &Allocator = Results.getAllocator();
-    CodeCompletionBuilder Builder(Allocator, Priority,CXAvailability_Available);
+    CodeCompletionBuilder Builder(Allocator, Results.getCodeCompletionTUInfo(),
+                                  Priority,CXAvailability_Available);
 
     PrintingPolicy Policy = getCompletionPrintingPolicy(*this);
     Builder.AddResultTypeChunk(GetCompletionTypeString(PropertyType, Context,
@@ -5973,10 +6033,14 @@
 /// \brief Add the parenthesized return or parameter type chunk to a code 
 /// completion string.
 static void AddObjCPassingTypeChunk(QualType Type,
+                                    unsigned ObjCDeclQuals,
                                     ASTContext &Context,
                                     const PrintingPolicy &Policy,
                                     CodeCompletionBuilder &Builder) {
   Builder.AddChunk(CodeCompletionString::CK_LeftParen);
+  std::string Quals = formatObjCParamQualifiers(ObjCDeclQuals);
+  if (!Quals.empty())
+    Builder.AddTextChunk(Builder.getAllocator().CopyString(Quals));
   Builder.AddTextChunk(GetCompletionTypeString(Type, Context, Policy,
                                                Builder.getAllocator()));
   Builder.AddChunk(CodeCompletionString::CK_RightParen);
@@ -6012,7 +6076,7 @@
   // Builder that will create each code completion.
   typedef CodeCompletionResult Result;
   CodeCompletionAllocator &Allocator = Results.getAllocator();
-  CodeCompletionBuilder Builder(Allocator);
+  CodeCompletionBuilder Builder(Allocator, Results.getCodeCompletionTUInfo());
   
   // The selector table.
   SelectorTable &Selectors = Context.Selectors;
@@ -6051,7 +6115,8 @@
       KnownSelectors.insert(Selectors.getNullarySelector(PropName)) &&
       ReturnTypeMatchesProperty && !Property->getGetterMethodDecl()) {
     if (ReturnType.isNull())
-      AddObjCPassingTypeChunk(Property->getType(), Context, Policy, Builder);
+      AddObjCPassingTypeChunk(Property->getType(), /*Quals=*/0,
+                              Context, Policy, Builder);
     
     Builder.AddTypedTextChunk(Key);
     Results.AddResult(Result(Builder.TakeString(), CCP_CodePattern, 
@@ -6097,7 +6162,8 @@
       Builder.AddTypedTextChunk(
                                 Allocator.CopyString(SelectorId->getName()));
       Builder.AddTypedTextChunk(":");
-      AddObjCPassingTypeChunk(Property->getType(), Context, Policy, Builder);
+      AddObjCPassingTypeChunk(Property->getType(), /*Quals=*/0,
+                              Context, Policy, Builder);
       Builder.AddTextChunk(Key);
       Results.AddResult(Result(Builder.TakeString(), CCP_CodePattern, 
                                CXCursor_ObjCInstanceMethodDecl));
@@ -6666,6 +6732,7 @@
   // Add declarations or definitions for each of the known methods.
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   Results.EnterNewScope();
   PrintingPolicy Policy = getCompletionPrintingPolicy(*this);
@@ -6673,13 +6740,16 @@
                               MEnd = KnownMethods.end();
        M != MEnd; ++M) {
     ObjCMethodDecl *Method = M->second.first;
-    CodeCompletionBuilder Builder(Results.getAllocator());
+    CodeCompletionBuilder Builder(Results.getAllocator(),
+                                  Results.getCodeCompletionTUInfo());
     
     // If the result type was not already provided, add it to the
     // pattern as (type).
     if (ReturnType.isNull())
-      AddObjCPassingTypeChunk(Method->getResultType(), Context, Policy, 
-                              Builder);
+      AddObjCPassingTypeChunk(Method->getResultType(),
+                              Method->getObjCDeclQualifier(),
+                              Context, Policy,
+                              Builder); 
 
     Selector Sel = Method->getSelector();
 
@@ -6703,7 +6773,9 @@
         break;
 
       // Add the parameter type.
-      AddObjCPassingTypeChunk((*P)->getOriginalType(), Context, Policy, 
+      AddObjCPassingTypeChunk((*P)->getOriginalType(),
+                              (*P)->getObjCDeclQualifier(),
+                              Context, Policy,
                               Builder);
       
       if (IdentifierInfo *Id = (*P)->getIdentifier())
@@ -6804,6 +6876,7 @@
   // Build the set of methods we can see.
   typedef CodeCompletionResult Result;
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_Other);
   
   if (ReturnTy)
@@ -6826,7 +6899,8 @@
         if (NumSelIdents && NumSelIdents <= MethList->Method->param_size()) {
           ParmVarDecl *Param = MethList->Method->param_begin()[NumSelIdents-1];
           if (Param->getIdentifier()) {
-            CodeCompletionBuilder Builder(Results.getAllocator());
+            CodeCompletionBuilder Builder(Results.getAllocator(),
+                                          Results.getCodeCompletionTUInfo());
             Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
                                            Param->getIdentifier()->getName()));
             Results.AddResult(Builder.TakeString());
@@ -6852,11 +6926,13 @@
 
 void Sema::CodeCompletePreprocessorDirective(bool InConditional) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_PreprocessorDirective);
   Results.EnterNewScope();
   
   // #if <condition>
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
   Builder.AddTypedTextChunk("if");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("condition");
@@ -7015,11 +7091,13 @@
 
 void Sema::CodeCompletePreprocessorMacroName(bool IsDefinition) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         IsDefinition? CodeCompletionContext::CCC_MacroName
                                     : CodeCompletionContext::CCC_MacroNameUse);
   if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
     // Add just the names of macros, not their arguments.    
-    CodeCompletionBuilder Builder(Results.getAllocator());
+    CodeCompletionBuilder Builder(Results.getAllocator(),
+                                  Results.getCodeCompletionTUInfo());
     Results.EnterNewScope();
     for (Preprocessor::macro_iterator M = PP.macro_begin(), 
                                    MEnd = PP.macro_end();
@@ -7039,6 +7117,7 @@
 
 void Sema::CodeCompletePreprocessorExpression() {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+                        CodeCompleter->getCodeCompletionTUInfo(),
                         CodeCompletionContext::CCC_PreprocessorExpression);
   
   if (!CodeCompleter || CodeCompleter->includeMacros())
@@ -7046,7 +7125,8 @@
   
     // defined (<macro>)
   Results.EnterNewScope();
-  CodeCompletionBuilder Builder(Results.getAllocator());
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+                                Results.getCodeCompletionTUInfo());
   Builder.AddTypedTextChunk("defined");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddChunk(CodeCompletionString::CK_LeftParen);
@@ -7078,8 +7158,10 @@
 }
 
 void Sema::GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator,
+                                       CodeCompletionTUInfo &CCTUInfo,
                  SmallVectorImpl<CodeCompletionResult> &Results) {
-  ResultBuilder Builder(*this, Allocator, CodeCompletionContext::CCC_Recovery);
+  ResultBuilder Builder(*this, Allocator, CCTUInfo,
+                        CodeCompletionContext::CCC_Recovery);
   if (!CodeCompleter || CodeCompleter->includeGlobals()) {
     CodeCompletionDeclConsumer Consumer(Builder, 
                                         Context.getTranslationUnitDecl());

Modified: cfe/branches/tooling/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDecl.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDecl.cpp Tue Apr 17 06:08:26 2012
@@ -872,7 +872,13 @@
   if (!FD)
     return;
 
-  PushDeclContext(S, FD);
+  // Same implementation as PushDeclContext, but enters the context
+  // from the lexical parent, rather than the top-level class.
+  assert(CurContext == FD->getLexicalParent() &&
+    "The next DeclContext should be lexically contained in the current one.");
+  CurContext = FD;
+  S->setEntity(CurContext);
+
   for (unsigned P = 0, NumParams = FD->getNumParams(); P < NumParams; ++P) {
     ParmVarDecl *Param = FD->getParamDecl(P);
     // If the parameter has an identifier, then add it to the scope
@@ -884,6 +890,15 @@
 }
 
 
+void Sema::ActOnExitFunctionContext() {
+  // Same implementation as PopDeclContext, but returns to the lexical parent,
+  // rather than the top-level class.
+  assert(CurContext && "DeclContext imbalance!");
+  CurContext = CurContext->getLexicalParent();
+  assert(CurContext && "Popped translation unit!");
+}
+
+
 /// \brief Determine whether we allow overloading of the function
 /// PrevDecl with another declaration.
 ///
@@ -3292,7 +3307,7 @@
         << Name << SS.getRange();
     else
       Diag(Loc, diag::err_invalid_declarator_scope)
-      << Name << cast<NamedDecl>(DC) << SS.getRange();
+      << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.getRange();
     
     return true;
   }
@@ -4500,14 +4515,7 @@
 class DifferentNameValidatorCCC : public CorrectionCandidateCallback {
  public:
   DifferentNameValidatorCCC(CXXRecordDecl *Parent)
-      : ExpectedParent(Parent ? Parent->getCanonicalDecl() : 0) {
-    // Don't allow any additional qualification.
-    // FIXME: It would be nice to perform this additional qualification. 
-    // However, DiagnoseInvalidRedeclaration is unable to handle the 
-    // qualification, because it doesn't know how to pass the corrected
-    // nested-name-specifier through to ActOnFunctionDeclarator.
-    AllowAddedQualifier = false;
-  }
+      : ExpectedParent(Parent ? Parent->getCanonicalDecl() : 0) {}
 
   virtual bool ValidateCandidate(const TypoCorrection &candidate) {
     if (candidate.getEditDistance() == 0)
@@ -4596,12 +4604,11 @@
     // TODO: Refactor ActOnFunctionDeclarator so that we can call only the
     // pieces need to verify the typo-corrected C++ declaraction and hopefully
     // eliminate the need for the parameter pack ExtraArgs.
-    Result = SemaRef.ActOnFunctionDeclarator(ExtraArgs.S, ExtraArgs.D,
-                                             NewFD->getDeclContext(),
-                                             NewFD->getTypeSourceInfo(),
-                                             Previous,
-                                             ExtraArgs.TemplateParamLists,
-                                             ExtraArgs.AddToScope);
+    Result = SemaRef.ActOnFunctionDeclarator(
+        ExtraArgs.S, ExtraArgs.D,
+        Correction.getCorrectionDecl()->getDeclContext(),
+        NewFD->getTypeSourceInfo(), Previous, ExtraArgs.TemplateParamLists,
+        ExtraArgs.AddToScope);
     if (Trap.hasErrorOccurred()) {
       // Pretend the typo correction never occurred
       ExtraArgs.D.SetIdentifier(Name.getAsIdentifierInfo(),

Modified: cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp Tue Apr 17 06:08:26 2012
@@ -272,24 +272,25 @@
 
 /// \brief Thread Safety Analysis: Checks that the passed in RecordType
 /// resolves to a lockable object. May flag an error.
-static bool checkForLockableRecord(Sema &S, Decl *D, const AttributeList &Attr,
-                                   const RecordType *RT) {
-  // Flag error if could not get record type for this argument.
+static void checkForLockableRecord(Sema &S, Decl *D, const AttributeList &Attr,
+                                   QualType Ty) {
+  const RecordType *RT = getRecordType(Ty);
+                                   
+  // Warn if could not get record type for this argument.
   if (!RT) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_class)
-      << Attr.getName();
-    return false;
+    S.Diag(Attr.getLoc(), diag::warn_attribute_argument_not_class)
+      << Attr.getName() << Ty.getAsString();
+    return;
   }
   // Don't check for lockable if the class hasn't been defined yet. 
   if (RT->isIncompleteType())
-    return true;
-  // Flag error if the type is not lockable.
+    return;
+  // Warn if the type is not lockable.
   if (!RT->getDecl()->getAttr<LockableAttr>()) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_lockable)
-      << Attr.getName();
-    return false;
+    S.Diag(Attr.getLoc(), diag::warn_attribute_argument_not_lockable)
+      << Attr.getName() << Ty.getAsString();
+    return;
   }
-  return true;
 }
 
 /// \brief Thread Safety Analysis: Checks that all attribute arguments, starting
@@ -331,12 +332,10 @@
           return false;
         }
         ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
-        RT = getRecordType(ArgTy);
       }
     }
 
-    if (!checkForLockableRecord(S, D, Attr, RT))
-      return false;
+    checkForLockableRecord(S, D, Attr, ArgTy);
 
     Args.push_back(ArgExp);
   }
@@ -394,9 +393,7 @@
     return;
 
   if (!Arg->isTypeDependent()) {
-    if (!checkForLockableRecord(S, D, Attr, getRecordType(Arg->getType())))
-      return;
-    // FIXME -- semantic checks for dependent attributes
+    checkForLockableRecord(S, D, Attr, Arg->getType());
   }
 
   if (pointer)
@@ -481,7 +478,7 @@
   if (!QT->isDependentType()) {
     const RecordType *RT = getRecordType(QT);
     if (!RT || !RT->getDecl()->getAttr<LockableAttr>()) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_decl_not_lockable)
+      S.Diag(Attr.getLoc(), diag::warn_attribute_decl_not_lockable)
               << Attr.getName();
       return;
     }
@@ -651,8 +648,7 @@
     return;
 
   // check that the argument is lockable object
-  if (!checkForLockableRecord(S, D, Attr, getRecordType(Arg->getType())))
-    return;
+  checkForLockableRecord(S, D, Attr, Arg->getType());
 
   D->addAttr(::new (S.Context) LockReturnedAttr(Attr.getRange(), S.Context, Arg));
 }
@@ -1593,6 +1589,22 @@
                                           Attr.getRange(), S.Context));
 }
 
+static void handleObjCRootClassAttr(Sema &S, Decl *D, 
+                                    const AttributeList &Attr) {
+  if (!isa<ObjCInterfaceDecl>(D)) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_requires_objc_interface);
+    return;
+  }
+  
+  unsigned NumArgs = Attr.getNumArgs();
+  if (NumArgs > 0) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 0;
+    return;
+  }
+  
+  D->addAttr(::new (S.Context) ObjCRootClassAttr(Attr.getRange(), S.Context));
+}
+
 static void handleObjCRequiresPropertyDefsAttr(Sema &S, Decl *D, 
                                             const AttributeList &Attr) {
   if (!isa<ObjCInterfaceDecl>(D)) {
@@ -3658,6 +3670,9 @@
   case AttributeList::AT_objc_arc_weak_reference_unavailable: 
     handleArcWeakrefUnavailableAttr (S, D, Attr); 
     break;
+  case AttributeList::AT_objc_root_class:
+    handleObjCRootClassAttr(S, D, Attr);
+    break;
   case AttributeList::AT_objc_requires_property_definitions: 
     handleObjCRequiresPropertyDefsAttr (S, D, Attr); 
     break;

Modified: cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp Tue Apr 17 06:08:26 2012
@@ -3344,7 +3344,8 @@
     CheckDestructorAccess(Base->getLocStart(), Dtor,
                           PDiag(diag::err_access_dtor_base)
                             << Base->getType()
-                            << Base->getSourceRange());
+                            << Base->getSourceRange(),
+                          Context.getTypeDeclType(ClassDecl));
     
     MarkFunctionReferenced(Location, const_cast<CXXDestructorDecl*>(Dtor));
     DiagnoseUseOfDecl(Dtor, Location);
@@ -3355,7 +3356,7 @@
        E = ClassDecl->vbases_end(); VBase != E; ++VBase) {
 
     // Bases are always records in a well-formed non-dependent class.
-    const RecordType *RT = VBase->getType()->getAs<RecordType>();
+    const RecordType *RT = VBase->getType()->castAs<RecordType>();
 
     // Ignore direct virtual bases.
     if (DirectVirtualBases.count(RT))
@@ -3372,7 +3373,8 @@
     assert(Dtor && "No dtor found for BaseClassDecl!");
     CheckDestructorAccess(ClassDecl->getLocation(), Dtor,
                           PDiag(diag::err_access_dtor_vbase)
-                            << VBase->getType());
+                            << VBase->getType(),
+                          Context.getTypeDeclType(ClassDecl));
 
     MarkFunctionReferenced(Location, const_cast<CXXDestructorDecl*>(Dtor));
     DiagnoseUseOfDecl(Dtor, Location);
@@ -4396,9 +4398,31 @@
   bool shouldDeleteForSubobjectCall(Subobject Subobj,
                                     Sema::SpecialMemberOverloadResult *SMOR,
                                     bool IsDtorCallInCtor);
+
+  bool isAccessible(Subobject Subobj, CXXMethodDecl *D);
 };
 }
 
+/// Is the given special member inaccessible when used on the given
+/// sub-object.
+bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
+                                             CXXMethodDecl *target) {
+  /// If we're operating on a base class, the object type is the
+  /// type of this special member.
+  QualType objectTy;
+  AccessSpecifier access = target->getAccess();;
+  if (CXXBaseSpecifier *base = Subobj.dyn_cast<CXXBaseSpecifier*>()) {
+    objectTy = S.Context.getTypeDeclType(MD->getParent());
+    access = CXXRecordDecl::MergeAccess(base->getAccessSpecifier(), access);
+
+  // If we're operating on a field, the object type is the type of the field.
+  } else {
+    objectTy = S.Context.getTypeDeclType(target->getParent());
+  }
+
+  return S.isSpecialMemberAccessibleForDeletion(target, access, objectTy);
+}
+
 /// Check whether we should delete a special member due to the implicit
 /// definition containing a call to a special member of a subobject.
 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
@@ -4413,8 +4437,7 @@
     DiagKind = !Decl ? 0 : 1;
   else if (SMOR->getKind() == Sema::SpecialMemberOverloadResult::Ambiguous)
     DiagKind = 2;
-  else if (S.CheckDirectMemberAccess(Loc, Decl, S.PDiag())
-             != Sema::AR_accessible)
+  else if (!isAccessible(Subobj, Decl))
     DiagKind = 3;
   else if (!IsDtorCallInCtor && Field && Field->getParent()->isUnion() &&
            !Decl->isTrivial()) {
@@ -5776,7 +5799,6 @@
     S.Diag(Corrected.getCorrectionDecl()->getLocation(),
          diag::note_namespace_defined_here) << CorrectedQuotedStr;
 
-    Ident = Corrected.getCorrectionAsIdentifierInfo();
     R.addDecl(Corrected.getCorrectionDecl());
     return true;
   }
@@ -6278,6 +6300,13 @@
   if (!IsInstantiation)
     R.setHideTags(false);
 
+  // For the purposes of this lookup, we have a base object type
+  // equal to that of the current context.
+  if (CurContext->isRecord()) {
+    R.setBaseObjectType(
+                   Context.getTypeDeclType(cast<CXXRecordDecl>(CurContext)));
+  }
+
   LookupQualifiedName(R, LookupContext);
 
   if (R.empty()) {
@@ -6743,7 +6772,7 @@
 
   if (R.empty()) {
     if (!TryNamespaceTypoCorrection(*this, R, S, SS, IdentLoc, Ident)) {
-      Diag(NamespaceLoc, diag::err_expected_namespace_name) << SS.getRange();
+      Diag(IdentLoc, diag::err_expected_namespace_name) << SS.getRange();
       return 0;
     }
   }

Modified: cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp Tue Apr 17 06:08:26 2012
@@ -24,6 +24,7 @@
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Sema/DeclSpec.h"
+#include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/DenseSet.h"
 
 using namespace clang;
@@ -1537,7 +1538,7 @@
             // uses the protocol.
             if (ObjCMethodDecl *MethodInClass =
                   IDecl->lookupInstanceMethod(method->getSelector(), 
-                                              true /*noCategoryLookup*/))
+                                              true /*shallowCategoryLookup*/))
               if (C || MethodInClass->isSynthesized())
                 continue;
             unsigned DIAG = diag::warn_unimplemented_protocol_method;
@@ -1561,7 +1562,7 @@
         (!Super || !Super->lookupClassMethod(method->getSelector()))) {
       // See above comment for instance method lookups.
       if (C && IDecl->lookupClassMethod(method->getSelector(), 
-                                        true /*noCategoryLookup*/))
+                                        true /*shallowCategoryLookup*/))
         continue;
       unsigned DIAG = diag::warn_unimplemented_protocol_method;
       if (Diags.getDiagnosticLevel(DIAG, ImpLoc) !=
@@ -2371,11 +2372,39 @@
       AtomicPropertySetterGetterRules(IC, IDecl);
       DiagnoseOwningPropertyGetterSynthesis(IC);
   
-      if (LangOpts.ObjCNonFragileABI2)
+      bool HasRootClassAttr = IDecl->hasAttr<ObjCRootClassAttr>();
+      if (IDecl->getSuperClass() == NULL) {
+        // This class has no superclass, so check that it has been marked with
+        // __attribute((objc_root_class)).
+        if (!HasRootClassAttr) {
+          SourceLocation DeclLoc(IDecl->getLocation());
+          SourceLocation SuperClassLoc(PP.getLocForEndOfToken(DeclLoc));
+          Diag(DeclLoc, diag::warn_objc_root_class_missing)
+            << IDecl->getIdentifier();
+          // See if NSObject is in the current scope, and if it is, suggest
+          // adding " : NSObject " to the class declaration.
+          NamedDecl *IF = LookupSingleName(TUScope,
+                                           NSAPIObj->getNSClassId(NSAPI::ClassId_NSObject),
+                                           DeclLoc, LookupOrdinaryName);
+          ObjCInterfaceDecl *NSObjectDecl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
+          if (NSObjectDecl && NSObjectDecl->getDefinition()) {
+            Diag(SuperClassLoc, diag::note_objc_needs_superclass)
+              << FixItHint::CreateInsertion(SuperClassLoc, " : NSObject ");
+          } else {
+            Diag(SuperClassLoc, diag::note_objc_needs_superclass);
+          }
+        }
+      } else if (HasRootClassAttr) {
+        // Complain that only root classes may have this attribute.
+        Diag(IDecl->getLocation(), diag::err_objc_root_class_subclass);
+      }
+
+      if (LangOpts.ObjCNonFragileABI2) {
         while (IDecl->getSuperClass()) {
           DiagnoseDuplicateIvars(IDecl, IDecl->getSuperClass());
           IDecl = IDecl->getSuperClass();
         }
+      }
     }
     SetIvarInitializers(IC);
   } else if (ObjCCategoryImplDecl* CatImplClass =

Modified: cfe/branches/tooling/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExpr.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExpr.cpp Tue Apr 17 06:08:26 2012
@@ -374,10 +374,6 @@
   QualType T = E->getType();
   assert(!T.isNull() && "r-value conversion on typeless expression?");
 
-  // We can't do lvalue-to-rvalue on atomics yet.
-  if (T->isAtomicType())
-    return Owned(E);
-
   // We don't want to throw lvalue-to-rvalue casts on top of
   // expressions of certain types in C++.
   if (getLangOpts().CPlusPlus &&
@@ -413,6 +409,15 @@
   ExprResult Res = Owned(ImplicitCastExpr::Create(Context, T, CK_LValueToRValue,
                                                   E, 0, VK_RValue));
 
+  // C11 6.3.2.1p2:
+  //   ... if the lvalue has atomic type, the value has the non-atomic version 
+  //   of the type of the lvalue ...
+  if (const AtomicType *Atomic = T->getAs<AtomicType>()) {
+    T = Atomic->getValueType().getUnqualifiedType();
+    Res = Owned(ImplicitCastExpr::Create(Context, T, CK_AtomicToNonAtomic,
+                                         Res.get(), 0, VK_RValue));
+  }
+  
   return Res;
 }
 
@@ -3610,8 +3615,6 @@
           << FixItHint::CreateRemoval(
                                     SourceRange(Args[0]->getLocStart(),
                                                 Args[NumArgs-1]->getLocEnd()));
-
-        NumArgs = 0;
       }
 
       return Owned(new (Context) CallExpr(Context, Fn, 0, 0, Context.VoidTy,
@@ -4570,8 +4573,28 @@
     rhptee = RHSTy->castAs<PointerType>()->getPointeeType();
   }
 
-  if (!S.Context.typesAreCompatible(lhptee.getUnqualifiedType(),
-                                    rhptee.getUnqualifiedType())) {
+  // C99 6.5.15p6: If both operands are pointers to compatible types or to
+  // differently qualified versions of compatible types, the result type is
+  // a pointer to an appropriately qualified version of the composite
+  // type.
+
+  // Only CVR-qualifiers exist in the standard, and the differently-qualified
+  // clause doesn't make sense for our extensions. E.g. address space 2 should
+  // be incompatible with address space 3: they may live on different devices or
+  // anything.
+  Qualifiers lhQual = lhptee.getQualifiers();
+  Qualifiers rhQual = rhptee.getQualifiers();
+
+  unsigned MergedCVRQual = lhQual.getCVRQualifiers() | rhQual.getCVRQualifiers();
+  lhQual.removeCVRQualifiers();
+  rhQual.removeCVRQualifiers();
+
+  lhptee = S.Context.getQualifiedType(lhptee.getUnqualifiedType(), lhQual);
+  rhptee = S.Context.getQualifiedType(rhptee.getUnqualifiedType(), rhQual);
+
+  QualType CompositeTy = S.Context.mergeTypes(lhptee, rhptee);
+
+  if (CompositeTy.isNull()) {
     S.Diag(Loc, diag::warn_typecheck_cond_incompatible_pointers)
       << LHSTy << RHSTy << LHS.get()->getSourceRange()
       << RHS.get()->getSourceRange();
@@ -4585,16 +4608,12 @@
   }
 
   // The pointer types are compatible.
-  // C99 6.5.15p6: If both operands are pointers to compatible types *or* to
-  // differently qualified versions of compatible types, the result type is
-  // a pointer to an appropriately qualified version of the *composite*
-  // type.
-  // FIXME: Need to calculate the composite type.
-  // FIXME: Need to add qualifiers
+  QualType ResultTy = CompositeTy.withCVRQualifiers(MergedCVRQual);
+  ResultTy = S.Context.getPointerType(ResultTy);
 
-  LHS = S.ImpCastExprToType(LHS.take(), LHSTy, CK_BitCast);
-  RHS = S.ImpCastExprToType(RHS.take(), LHSTy, CK_BitCast);
-  return LHSTy;
+  LHS = S.ImpCastExprToType(LHS.take(), ResultTy, CK_BitCast);
+  RHS = S.ImpCastExprToType(RHS.take(), ResultTy, CK_BitCast);
+  return ResultTy;
 }
 
 /// \brief Return the resulting type when the operands are both block pointers.
@@ -7129,16 +7148,6 @@
   return false;
 }
 
-static bool IsConstProperty(Expr *E, Sema &S) {
-  const ObjCPropertyRefExpr *PropExpr = dyn_cast<ObjCPropertyRefExpr>(E);
-  if (!PropExpr) return false;
-  if (PropExpr->isImplicitProperty()) return false;
-    
-  ObjCPropertyDecl *PDecl = PropExpr->getExplicitProperty();
-  QualType T = PDecl->getType().getNonReferenceType();
-  return T.isConstQualified();
-}
-
 static bool IsReadonlyMessage(Expr *E, Sema &S) {
   const MemberExpr *ME = dyn_cast<MemberExpr>(E);
   if (!ME) return false;
@@ -7178,13 +7187,12 @@
 /// CheckForModifiableLvalue - Verify that E is a modifiable lvalue.  If not,
 /// emit an error and return true.  If so, return false.
 static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
+  assert(!E->hasPlaceholderType(BuiltinType::PseudoObject));
   SourceLocation OrigLoc = Loc;
   Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(S.Context,
                                                               &Loc);
   if (IsLV == Expr::MLV_Valid && IsReadonlyProperty(E, S))
     IsLV = Expr::MLV_ReadonlyProperty;
-  else if (Expr::MLV_ConstQualified && IsConstProperty(E, S))
-    IsLV = Expr::MLV_Valid;
   else if (IsLV == Expr::MLV_ClassTemporary && IsReadonlyMessage(E, S))
     IsLV = Expr::MLV_InvalidMessageExpression;
   if (IsLV == Expr::MLV_Valid)
@@ -8548,12 +8556,29 @@
   return cleanups;
 }
 
+void Sema::ActOnStartStmtExpr() {
+  PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+}
+
+void Sema::ActOnStmtExprError() {
+  // Note that function is also called by TreeTransform when leaving a
+  // StmtExpr scope without rebuilding anything.
+
+  DiscardCleanupsInEvaluationContext();
+  PopExpressionEvaluationContext();
+}
+
 ExprResult
 Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
                     SourceLocation RPLoc) { // "({..})"
   assert(SubStmt && isa<CompoundStmt>(SubStmt) && "Invalid action invocation!");
   CompoundStmt *Compound = cast<CompoundStmt>(SubStmt);
 
+  if (hasAnyUnrecoverableErrorsInThisFunction())
+    DiscardCleanupsInEvaluationContext();
+  assert(!ExprNeedsCleanups && "cleanups within StmtExpr not correctly bound!");
+  PopExpressionEvaluationContext();
+
   bool isFileScope
     = (getCurFunctionOrMethodDecl() == 0) && (getCurBlock() == 0);
   if (isFileScope)
@@ -9086,15 +9111,6 @@
 
   BSI->TheDecl->setBody(cast<CompoundStmt>(Body));
 
-  for (BlockDecl::capture_const_iterator ci = BSI->TheDecl->capture_begin(),
-       ce = BSI->TheDecl->capture_end(); ci != ce; ++ci) {
-    const VarDecl *variable = ci->getVariable();
-    QualType T = variable->getType();
-    QualType::DestructionKind destructKind = T.isDestructedType();
-    if (destructKind != QualType::DK_none)
-      getCurFunction()->setHasBranchProtectedScope();
-  }
-
   computeNRVO(Body, getCurBlock());
   
   BlockExpr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy);
@@ -9102,10 +9118,23 @@
   PopFunctionScopeInfo(&WP, Result->getBlockDecl(), Result);
 
   // If the block isn't obviously global, i.e. it captures anything at
-  // all, mark this full-expression as needing a cleanup.
+  // all, then we need to do a few things in the surrounding context:
   if (Result->getBlockDecl()->hasCaptures()) {
+    // First, this expression has a new cleanup object.
     ExprCleanupObjects.push_back(Result->getBlockDecl());
     ExprNeedsCleanups = true;
+
+    // It also gets a branch-protected scope if any of the captured
+    // variables needs destruction.
+    for (BlockDecl::capture_const_iterator
+           ci = Result->getBlockDecl()->capture_begin(),
+           ce = Result->getBlockDecl()->capture_end(); ci != ce; ++ci) {
+      const VarDecl *var = ci->getVariable();
+      if (var->getType().isDestructedType() != QualType::DK_none) {
+        getCurFunction()->setHasBranchProtectedScope();
+        break;
+      }
+    }
   }
 
   return Owned(Result);
@@ -10449,7 +10478,8 @@
 bool MarkReferencedDecls::TraverseTemplateArgument(
   const TemplateArgument &Arg) {
   if (Arg.getKind() == TemplateArgument::Declaration) {
-    S.MarkAnyDeclReferenced(Loc, Arg.getAsDecl());
+    if (Decl *D = Arg.getAsDecl())
+      S.MarkAnyDeclReferenced(Loc, D);
   }
 
   return Inherited::TraverseTemplateArgument(Arg);
@@ -11238,6 +11268,22 @@
 Sema::ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind) {
   assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
          "Unknown Objective-C Boolean value!");
+  QualType ObjCBoolLiteralQT = Context.ObjCBuiltinBoolTy;
+  // signed char is the default type for boolean literals. Use 'BOOL'
+  // instead, if BOOL typedef is visible in its scope instead.
+  Decl *TD = 
+    LookupSingleName(TUScope, &Context.Idents.get("BOOL"), 
+                     SourceLocation(), LookupOrdinaryName);
+  if (TypedefDecl *BoolTD = dyn_cast_or_null<TypedefDecl>(TD)) {
+    QualType QT = BoolTD->getUnderlyingType();
+    if (!QT->isIntegralOrUnscopedEnumerationType()) {
+      Diag(OpLoc, diag::warn_bool_for_boolean_literal) << QT;
+      Diag(BoolTD->getLocation(), diag::note_previous_declaration);
+    }
+    else
+      ObjCBoolLiteralQT = QT;
+  }
+  
   return Owned(new (Context) ObjCBoolLiteralExpr(Kind == tok::kw___objc_yes,
-                                        Context.ObjCBuiltinBoolTy, OpLoc));
+                                        ObjCBoolLiteralQT, OpLoc));
 }

Modified: cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp Tue Apr 17 06:08:26 2012
@@ -2276,8 +2276,9 @@
                                   CastLoc, ConstructorArgs))
       return ExprError();
 
-    S.CheckConstructorAccess(CastLoc, Constructor, Constructor->getAccess(),
-                             S.PDiag(diag::err_access_ctor));
+    S.CheckConstructorAccess(CastLoc, Constructor,
+                             InitializedEntity::InitializeTemporary(Ty),
+                             Constructor->getAccess());
     
     ExprResult Result
       = S.BuildCXXConstructExpr(CastLoc, Ty, cast<CXXConstructorDecl>(Method),
@@ -2764,6 +2765,13 @@
     llvm_unreachable("Improper third standard conversion");
   }
 
+  // If this conversion sequence involved a scalar -> atomic conversion, perform
+  // that conversion now.
+  if (const AtomicType *ToAtomic = ToType->getAs<AtomicType>())
+    if (Context.hasSameType(ToAtomic->getValueType(), From->getType()))
+      From = ImpCastExprToType(From, ToType, CK_NonAtomicToAtomic, VK_RValue, 0,
+                               CCK).take();
+      
   return Owned(From);
 }
 

Modified: cfe/branches/tooling/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprMember.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprMember.cpp Tue Apr 17 06:08:26 2012
@@ -194,30 +194,38 @@
 }
 
 /// Diagnose a reference to a field with no object available.
-static void DiagnoseInstanceReference(Sema &SemaRef,
+static void diagnoseInstanceReference(Sema &SemaRef,
                                       const CXXScopeSpec &SS,
-                                      NamedDecl *rep,
+                                      NamedDecl *Rep,
                                       const DeclarationNameInfo &nameInfo) {
   SourceLocation Loc = nameInfo.getLoc();
   SourceRange Range(Loc);
   if (SS.isSet()) Range.setBegin(SS.getRange().getBegin());
-  
-  if (isa<FieldDecl>(rep) || isa<IndirectFieldDecl>(rep)) {
-    if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(SemaRef.CurContext)) {
-      if (MD->isStatic()) {
-        // "invalid use of member 'x' in static member function"
-        SemaRef.Diag(Loc, diag::err_invalid_member_use_in_static_method)
-            << Range << nameInfo.getName();
-        return;
-      }
-    }
 
+  DeclContext *FunctionLevelDC = SemaRef.getFunctionLevelDeclContext();
+  CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FunctionLevelDC);
+  CXXRecordDecl *ContextClass = Method ? Method->getParent() : 0;
+  CXXRecordDecl *RepClass = dyn_cast<CXXRecordDecl>(Rep->getDeclContext());
+
+  bool InStaticMethod = Method && Method->isStatic();
+  bool IsField = isa<FieldDecl>(Rep) || isa<IndirectFieldDecl>(Rep);
+
+  if (IsField && InStaticMethod)
+    // "invalid use of member 'x' in static member function"
+    SemaRef.Diag(Loc, diag::err_invalid_member_use_in_static_method)
+        << Range << nameInfo.getName();
+  else if (ContextClass && RepClass && SS.isEmpty() && !InStaticMethod &&
+           !RepClass->Equals(ContextClass) && RepClass->Encloses(ContextClass))
+    // Unqualified lookup in a non-static member function found a member of an
+    // enclosing class.
+    SemaRef.Diag(Loc, diag::err_nested_non_static_member_use)
+      << IsField << RepClass << nameInfo.getName() << ContextClass << Range;
+  else if (IsField)
     SemaRef.Diag(Loc, diag::err_invalid_non_static_member_use)
-        << nameInfo.getName() << Range;
-    return;
-  }
-
-  SemaRef.Diag(Loc, diag::err_member_call_without_object) << Range;
+      << nameInfo.getName() << Range;
+  else
+    SemaRef.Diag(Loc, diag::err_member_call_without_object)
+      << Range;
 }
 
 /// Builds an expression which might be an implicit member expression.
@@ -248,7 +256,7 @@
 
   case IMA_Error_StaticContext:
   case IMA_Error_Unrelated:
-    DiagnoseInstanceReference(*this, SS, R.getRepresentativeDecl(),
+    diagnoseInstanceReference(*this, SS, R.getRepresentativeDecl(),
                               R.getLookupNameInfo());
     return ExprError();
   }
@@ -468,7 +476,7 @@
   // If this is an implicit member access, use a different set of
   // diagnostics.
   if (!BaseExpr)
-    return DiagnoseInstanceReference(SemaRef, SS, rep, nameInfo);
+    return diagnoseInstanceReference(SemaRef, SS, rep, nameInfo);
 
   SemaRef.Diag(nameInfo.getLoc(), diag::err_qualified_member_of_unrelated)
     << SS.getRange() << rep << BaseType;

Modified: cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp Tue Apr 17 06:08:26 2012
@@ -2232,6 +2232,11 @@
   }
 
   if (getLangOpts().ObjCAutoRefCount) {
+    if (Receiver &&
+        (Receiver->IgnoreParenImpCasts()->getType().getObjCLifetime() 
+          == Qualifiers::OCL_Weak))
+      Diag(Receiver->getLocStart(), diag::warn_receiver_is_weak);
+    
     // In ARC, annotate delegate init calls.
     if (Result->getMethodFamily() == OMF_init &&
         (SuperLoc.isValid() || isSelfExpr(Receiver))) {

Modified: cfe/branches/tooling/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaInit.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaInit.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaInit.cpp Tue Apr 17 06:08:26 2012
@@ -2877,7 +2877,7 @@
 
   // The type we're constructing needs to be complete.
   if (S.RequireCompleteType(Kind.getLocation(), DestType, 0)) {
-    Sequence.SetFailed(InitializationSequence::FK_Incomplete);
+    Sequence.setIncompleteTypeFailure(DestType);
     return;
   }
 
@@ -3109,7 +3109,7 @@
   }
   if (DestType->isRecordType()) {
     if (S.RequireCompleteType(InitList->getLocStart(), DestType, S.PDiag())) {
-      Sequence.SetFailed(InitializationSequence::FK_Incomplete);
+      Sequence.setIncompleteTypeFailure(DestType);
       return;
     }
 
@@ -4584,7 +4584,7 @@
   switch (OR) {
   case OR_Success:
     S.CheckConstructorAccess(Loc, cast<CXXConstructorDecl>(Best->Function),
-                             Best->FoundDecl.getAccess(), Diag);
+                             Entity, Best->FoundDecl.getAccess(), Diag);
     // FIXME: Check default arguments as far as that's possible.
     break;
 
@@ -4807,7 +4807,8 @@
                                   move(Args));
     }
     assert(Kind.getKind() == InitializationKind::IK_Copy ||
-           Kind.isExplicitCast());
+           Kind.isExplicitCast() || 
+           Kind.getKind() == InitializationKind::IK_DirectList);
     return ExprResult(Args.release()[0]);
   }
 
@@ -5686,7 +5687,7 @@
     break;
 
   case FK_Incomplete:
-    S.RequireCompleteType(Kind.getLocation(), DestType,
+    S.RequireCompleteType(Kind.getLocation(), FailedIncompleteType,
                           diag::err_init_incomplete_type);
     break;
 

Modified: cfe/branches/tooling/lib/Sema/SemaLambda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaLambda.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaLambda.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaLambda.cpp Tue Apr 17 06:08:26 2012
@@ -36,11 +36,27 @@
   return Class;
 }
 
+/// \brief Determine whether the given context is or is enclosed in an inline
+/// function.
+static bool isInInlineFunction(const DeclContext *DC) {
+  while (!DC->isFileContext()) {
+    if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(DC))
+      if (FD->isInlined())
+        return true;
+    
+    DC = DC->getLexicalParent();
+  }
+  
+  return false;
+}
+
 CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class,
-                                           SourceRange IntroducerRange,
-                                           TypeSourceInfo *MethodType,
-                                           SourceLocation EndLoc,
-                 llvm::ArrayRef<ParmVarDecl *> Params) {
+                 SourceRange IntroducerRange,
+                 TypeSourceInfo *MethodType,
+                 SourceLocation EndLoc,
+                 llvm::ArrayRef<ParmVarDecl *> Params,
+                 llvm::Optional<unsigned> ManglingNumber,
+                 Decl *ContextDecl) {
   // C++11 [expr.prim.lambda]p5:
   //   The closure type for a lambda-expression has a public inline function 
   //   call operator (13.5.4) whose parameters and return type are described by
@@ -83,6 +99,63 @@
       (*P)->setOwningFunction(Method);
   }
   
+  // If we don't already have a mangling number for this lambda expression,
+  // allocate one now.
+  if (!ManglingNumber) {
+    ContextDecl = ExprEvalContexts.back().LambdaContextDecl;
+    
+    enum ContextKind {
+      Normal,
+      DefaultArgument,
+      DataMember,
+      StaticDataMember
+    } Kind = Normal;
+    
+    // Default arguments of member function parameters that appear in a class
+    // definition, as well as the initializers of data members, receive special
+    // treatment. Identify them.
+    if (ContextDecl) {
+      if (ParmVarDecl *Param = dyn_cast<ParmVarDecl>(ContextDecl)) {
+        if (const DeclContext *LexicalDC
+            = Param->getDeclContext()->getLexicalParent())
+          if (LexicalDC->isRecord())
+            Kind = DefaultArgument;
+      } else if (VarDecl *Var = dyn_cast<VarDecl>(ContextDecl)) {
+        if (Var->getDeclContext()->isRecord())
+          Kind = StaticDataMember;
+      } else if (isa<FieldDecl>(ContextDecl)) {
+        Kind = DataMember;
+      }
+    }        
+    
+    switch (Kind) {
+      case Normal:
+        if (CurContext->isDependentContext() || isInInlineFunction(CurContext))
+          ManglingNumber = Context.getLambdaManglingNumber(Method);
+        else
+          ManglingNumber = 0;
+        
+        // There is no special context for this lambda.
+        ContextDecl = 0;        
+        break;
+        
+      case StaticDataMember:
+        if (!CurContext->isDependentContext()) {
+          ManglingNumber = 0;
+          ContextDecl = 0;
+          break;
+        }
+        // Fall through to assign a mangling number.
+        
+      case DataMember:
+      case DefaultArgument:
+        ManglingNumber = ExprEvalContexts.back().getLambdaMangleContext()
+                           .getManglingNumber(Method);
+        break;
+    }
+  }
+
+  Class->setLambdaMangling(*ManglingNumber, ContextDecl);
   return Method;
 }
 
@@ -491,25 +564,9 @@
   Conversion->setImplicit(true);
   Class->addDecl(Conversion);
 }
-
-/// \brief Determine whether the given context is or is enclosed in an inline
-/// function.
-static bool isInInlineFunction(const DeclContext *DC) {
-  while (!DC->isFileContext()) {
-    if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(DC))
-      if (FD->isInlined())
-        return true;
-    
-    DC = DC->getLexicalParent();
-  }
-  
-  return false;
-}
          
 ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, 
                                  Scope *CurScope, 
-                                 llvm::Optional<unsigned> ManglingNumber,
-                                 Decl *ContextDecl,
                                  bool IsInstantiation) {
   // Collect information from the lambda scope.
   llvm::SmallVector<LambdaExpr::Capture, 4> Captures;
@@ -655,69 +712,12 @@
 
   if (LambdaExprNeedsCleanups)
     ExprNeedsCleanups = true;
-
-  // If we don't already have a mangling number for this lambda expression,
-  // allocate one now.
-  if (!ManglingNumber) {
-    ContextDecl = ExprEvalContexts.back().LambdaContextDecl;
-    
-    enum ContextKind {
-      Normal,
-      DefaultArgument,
-      DataMember,
-      StaticDataMember
-    } Kind = Normal;
-
-    // Default arguments of member function parameters that appear in a class
-    // definition, as well as the initializers of data members, receive special
-    // treatment. Identify them.
-    if (ContextDecl) {
-      if (ParmVarDecl *Param = dyn_cast<ParmVarDecl>(ContextDecl)) {
-        if (const DeclContext *LexicalDC
-              = Param->getDeclContext()->getLexicalParent())
-          if (LexicalDC->isRecord())
-            Kind = DefaultArgument;
-      } else if (VarDecl *Var = dyn_cast<VarDecl>(ContextDecl)) {
-        if (Var->getDeclContext()->isRecord())
-          Kind = StaticDataMember;
-      } else if (isa<FieldDecl>(ContextDecl)) {
-        Kind = DataMember;
-      }
-    }        
-    
-    switch (Kind) {
-    case Normal:
-      if (CurContext->isDependentContext() || isInInlineFunction(CurContext))
-        ManglingNumber = Context.getLambdaManglingNumber(CallOperator);
-      else
-        ManglingNumber = 0;
-        
-      // There is no special context for this lambda.
-      ContextDecl = 0;        
-      break;
-      
-    case StaticDataMember:
-      if (!CurContext->isDependentContext()) {
-        ManglingNumber = 0;
-        ContextDecl = 0;
-        break;
-      }
-      // Fall through to assign a mangling number.
-        
-    case DataMember:
-    case DefaultArgument:
-      ManglingNumber = ExprEvalContexts.back().getLambdaMangleContext()
-                         .getManglingNumber(CallOperator);
-      break;
-    }
-  }
   
   LambdaExpr *Lambda = LambdaExpr::Create(Context, Class, IntroducerRange, 
                                           CaptureDefault, Captures, 
                                           ExplicitParams, ExplicitResultType,
                                           CaptureInits, ArrayIndexVars, 
-                                          ArrayIndexStarts, Body->getLocEnd(),
-                                          *ManglingNumber, ContextDecl);
+                                          ArrayIndexStarts, Body->getLocEnd());
 
   // C++11 [expr.prim.lambda]p2:
   //   A lambda-expression shall not appear in an unevaluated operand

Modified: cfe/branches/tooling/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaLookup.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaLookup.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaLookup.cpp Tue Apr 17 06:08:26 2012
@@ -25,6 +25,7 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclLookups.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
@@ -38,14 +39,14 @@
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/ADT/edit_distance.h"
 #include "llvm/Support/ErrorHandling.h"
+#include <algorithm>
+#include <iterator>
 #include <limits>
 #include <list>
+#include <map>
 #include <set>
-#include <vector>
-#include <iterator>
 #include <utility>
-#include <algorithm>
-#include <map>
+#include <vector>
 
 using namespace clang;
 using namespace sema;
@@ -2875,26 +2876,16 @@
     Result.getSema().ForceDeclarationOfImplicitMembers(Class);
 
   // Enumerate all of the results in this context.
-  llvm::SmallVector<DeclContext *, 2> Contexts;
-  Ctx->collectAllContexts(Contexts);
-  for (unsigned I = 0, N = Contexts.size(); I != N; ++I) {
-    DeclContext *CurCtx = Contexts[I];
-    for (DeclContext::decl_iterator D = CurCtx->decls_begin(),
-                                 DEnd = CurCtx->decls_end();
-         D != DEnd; ++D) {
-      if (NamedDecl *ND = dyn_cast<NamedDecl>(*D)) {
+  for (DeclContext::all_lookups_iterator L = Ctx->lookups_begin(),
+                                      LEnd = Ctx->lookups_end();
+       L != LEnd; ++L) {
+    for (DeclContext::lookup_result R = *L; R.first != R.second; ++R.first) {
+      if (NamedDecl *ND = dyn_cast<NamedDecl>(*R.first)) {
         if ((ND = Result.getAcceptableDecl(ND))) {
           Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
           Visited.add(ND);
         }
       }
-      
-      // Visit transparent contexts and inline namespaces inside this context.
-      if (DeclContext *InnerCtx = dyn_cast<DeclContext>(*D)) {
-        if (InnerCtx->isTransparentContext() || InnerCtx->isInlineNamespace())
-          LookupVisibleDecls(InnerCtx, Result, QualifiedNameLookup, InBaseClass,
-                             Consumer, Visited);
-      }
     }
   }
 
@@ -2984,7 +2975,7 @@
     if (IFace->getImplementation()) {
       ShadowContextRAII Shadow(Visited);
       LookupVisibleDecls(IFace->getImplementation(), Result,
-                         QualifiedNameLookup, true, Consumer, Visited);
+                         QualifiedNameLookup, InBaseClass, Consumer, Visited);
     }
   } else if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Ctx)) {
     for (ObjCProtocolDecl::protocol_iterator I = Protocol->protocol_begin(),
@@ -3815,7 +3806,7 @@
   // Determine whether we are going to search in the various namespaces for
   // corrections.
   bool SearchNamespaces
-    = getLangOpts().CPlusPlus && CCC.AllowAddedQualifier && 
+    = getLangOpts().CPlusPlus &&
       (IsUnqualifiedLookup || (QualifiedDC && QualifiedDC->isNamespace()));
   
   if (IsUnqualifiedLookup || SearchNamespaces) {

Modified: cfe/branches/tooling/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaOverload.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaOverload.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaOverload.cpp Tue Apr 17 06:08:26 2012
@@ -1294,6 +1294,11 @@
   return false;
 }
 
+static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType,
+                                bool InOverloadResolution,
+                                StandardConversionSequence &SCS,
+                                bool CStyle);
+  
 /// IsStandardConversion - Determines whether there is a standard
 /// conversion sequence (C++ [conv], C++ [over.ics.scs]) from the
 /// expression From to the type ToType. Standard conversion sequences
@@ -1389,6 +1394,12 @@
       S.Context.getCanonicalType(FromType) != S.Context.OverloadTy) {
     SCS.First = ICK_Lvalue_To_Rvalue;
 
+    // C11 6.3.2.1p2:
+    //   ... if the lvalue has atomic type, the value has the non-atomic version 
+    //   of the type of the lvalue ...
+    if (const AtomicType *Atomic = FromType->getAs<AtomicType>())
+      FromType = Atomic->getValueType();
+
     // If T is a non-class type, the type of the rvalue is the
     // cv-unqualified version of T. Otherwise, the type of the rvalue
     // is T (C++ 4.1p1). C++ can't get here with class types; in C, we
@@ -1520,6 +1531,11 @@
                                              SCS, CStyle)) {
     SCS.Second = ICK_TransparentUnionConversion;
     FromType = ToType;
+  } else if (tryAtomicConversion(S, From, ToType, InOverloadResolution, SCS,
+                                 CStyle)) {
+    // tryAtomicConversion has updated the standard conversion sequence
+    // appropriately.
+    return true;
   } else {
     // No second conversion required.
     SCS.Second = ICK_Identity;
@@ -2758,6 +2774,34 @@
   return UnwrappedAnyPointer && Context.hasSameUnqualifiedType(FromType,ToType);
 }
 
+/// \brief - Determine whether this is a conversion from a scalar type to an
+/// atomic type.
+///
+/// If successful, updates \c SCS's second and third steps in the conversion
+/// sequence to finish the conversion.
+static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType,
+                                bool InOverloadResolution,
+                                StandardConversionSequence &SCS,
+                                bool CStyle) {
+  const AtomicType *ToAtomic = ToType->getAs<AtomicType>();
+  if (!ToAtomic)
+    return false;
+  
+  StandardConversionSequence InnerSCS;
+  if (!IsStandardConversion(S, From, ToAtomic->getValueType(), 
+                            InOverloadResolution, InnerSCS,
+                            CStyle, /*AllowObjCWritebackConversion=*/false))
+    return false;
+  
+  SCS.Second = InnerSCS.Second;
+  SCS.setToType(1, InnerSCS.getToType(1));
+  SCS.Third = InnerSCS.Third;
+  SCS.QualificationIncludesObjCLifetime
+    = InnerSCS.QualificationIncludesObjCLifetime;
+  SCS.setToType(2, InnerSCS.getToType(2));
+  return true;
+}
+
 static bool isFirstArgumentCompatibleWithType(ASTContext &Context,
                                               CXXConstructorDecl *Constructor,
                                               QualType Type) {
@@ -4301,6 +4345,16 @@
               ImplicitConversionSequence::Worse)
         Result = ICS;
     }
+
+    // For an empty list, we won't have computed any conversion sequence.
+    // Introduce the identity conversion sequence.
+    if (From->getNumInits() == 0) {
+      Result.setStandard();
+      Result.Standard.setAsIdentityConversion();
+      Result.Standard.setFromType(ToType);
+      Result.Standard.setAllToTypes(ToType);
+    }
+
     Result.setListInitializationSequence();
     Result.setStdInitializerListElement(toStdInitializerList);
     return Result;
@@ -4433,6 +4487,8 @@
     else if (NumInits == 0) {
       Result.setStandard();
       Result.Standard.setAsIdentityConversion();
+      Result.Standard.setFromType(ToType);
+      Result.Standard.setAllToTypes(ToType);
     }
     Result.setListInitializationSequence();
     return Result;

Modified: cfe/branches/tooling/lib/Sema/SemaPseudoObject.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaPseudoObject.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaPseudoObject.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaPseudoObject.cpp Tue Apr 17 06:08:26 2012
@@ -1300,6 +1300,11 @@
   Expr *opaqueRef = E->IgnoreParens();
   if (ObjCPropertyRefExpr *refExpr
         = dyn_cast<ObjCPropertyRefExpr>(opaqueRef)) {
+    // Class and super property references don't have opaque values in them.
+    if (refExpr->isClassReceiver() || refExpr->isSuperReceiver())
+      return E;
+    
+    assert(refExpr->isObjectReceiver() && "Unknown receiver kind?");
     OpaqueValueExpr *baseOVE = cast<OpaqueValueExpr>(refExpr->getBase());
     return ObjCPropertyRefRebuilder(S, baseOVE->getSourceExpr()).rebuild(E);
   } else if (ObjCSubscriptRefExpr *refExpr

Modified: cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplate.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplate.cpp Tue Apr 17 06:08:26 2012
@@ -3461,6 +3461,99 @@
   return false;
 }
 
+enum NullPointerValueKind {
+  NPV_NotNullPointer,
+  NPV_NullPointer,
+  NPV_Error
+};
+
+/// \brief Determine whether the given template argument is a null pointer
+/// value of the appropriate type.
+static NullPointerValueKind
+isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param,
+                                   QualType ParamType, Expr *Arg) {
+  if (Arg->isValueDependent() || Arg->isTypeDependent())
+    return NPV_NotNullPointer;
+  
+  if (!S.getLangOpts().CPlusPlus0x)
+    return NPV_NotNullPointer;
+  
+  // Determine whether we have a constant expression.
+  ExprResult ArgRV = S.DefaultFunctionArrayConversion(Arg);
+  if (ArgRV.isInvalid())
+    return NPV_Error;
+  Arg = ArgRV.take();
+  
+  Expr::EvalResult EvalResult;
+  llvm::SmallVector<PartialDiagnosticAt, 8> Notes;
+  EvalResult.Diag = &Notes;
+  if (!Arg->EvaluateAsRValue(EvalResult, S.Context) ||
+      EvalResult.HasSideEffects) {
+    SourceLocation DiagLoc = Arg->getExprLoc();
+    
+    // If our only note is the usual "invalid subexpression" note, just point
+    // the caret at its location rather than producing an essentially
+    // redundant note.
+    if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
+        diag::note_invalid_subexpr_in_const_expr) {
+      DiagLoc = Notes[0].first;
+      Notes.clear();
+    }
+    
+    S.Diag(DiagLoc, diag::err_template_arg_not_address_constant)
+      << Arg->getType() << Arg->getSourceRange();
+    for (unsigned I = 0, N = Notes.size(); I != N; ++I)
+      S.Diag(Notes[I].first, Notes[I].second);
+    
+    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    return NPV_Error;
+  }
+  
+  // C++11 [temp.arg.nontype]p1:
+  //   - an address constant expression of type std::nullptr_t
+  if (Arg->getType()->isNullPtrType())
+    return NPV_NullPointer;
+  
+  //   - a constant expression that evaluates to a null pointer value (4.10); or
+  //   - a constant expression that evaluates to a null member pointer value
+  //     (4.11); or
+  if ((EvalResult.Val.isLValue() && !EvalResult.Val.getLValueBase()) ||
+      (EvalResult.Val.isMemberPointer() &&
+       !EvalResult.Val.getMemberPointerDecl())) {
+    // If our expression has an appropriate type, we've succeeded.
+    bool ObjCLifetimeConversion;
+    if (S.Context.hasSameUnqualifiedType(Arg->getType(), ParamType) ||
+        S.IsQualificationConversion(Arg->getType(), ParamType, false,
+                                     ObjCLifetimeConversion))
+      return NPV_NullPointer;
+    
+    // The types didn't match, but we know we got a null pointer; complain,
+    // then recover as if the types were correct.
+    S.Diag(Arg->getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
+      << Arg->getType() << ParamType << Arg->getSourceRange();
+    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    return NPV_NullPointer;
+  }
+
+  // If we don't have a null pointer value, but we do have a NULL pointer
+  // constant, suggest a cast to the appropriate type.
+  if (Arg->isNullPointerConstant(S.Context, Expr::NPC_NeverValueDependent)) {
+    std::string Code = "static_cast<" + ParamType.getAsString() + ">(";
+    S.Diag(Arg->getExprLoc(), diag::err_template_arg_untyped_null_constant)
+      << ParamType
+      << FixItHint::CreateInsertion(Arg->getLocStart(), Code)
+      << FixItHint::CreateInsertion(S.PP.getLocForEndOfToken(Arg->getLocEnd()),
+                                    ")");
+    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    return NPV_NullPointer;
+  }
+  
+  // FIXME: If we ever want to support general, address-constant expressions
+  // as non-type template arguments, we should return the ExprResult here to
+  // be interpreted by the caller.
+  return NPV_NotNullPointer;
+}
+
 /// \brief Checks whether the given template argument is the address
 /// of an object or function according to C++ [temp.arg.nontype]p1.
 static bool
@@ -3473,6 +3566,21 @@
   Expr *Arg = ArgIn;
   QualType ArgType = Arg->getType();
 
+  // If our parameter has pointer type, check for a null template value.
+  if (ParamType->isPointerType() || ParamType->isNullPtrType()) {
+    switch (isNullPointerValueTemplateArgument(S, Param, ParamType, Arg)) {
+    case NPV_NullPointer:
+      Converted = TemplateArgument((Decl *)0);
+      return false;
+
+    case NPV_Error:
+      return true;
+        
+    case NPV_NotNullPointer:
+      break;
+    }
+  }
+  
   // See through any implicit casts we added to fix the type.
   Arg = Arg->IgnoreImpCasts();
 
@@ -3527,20 +3635,20 @@
            dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
     Arg = subst->getReplacement()->IgnoreImpCasts();
 
-  DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Arg);
-  if (!DRE) {
-    S.Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
-      << Arg->getSourceRange();
-    S.Diag(Param->getLocation(), diag::note_template_param_here);
-    return true;
-  }
-
   // Stop checking the precise nature of the argument if it is value dependent,
   // it should be checked when instantiated.
   if (Arg->isValueDependent()) {
     Converted = TemplateArgument(ArgIn);
     return false;
   }
+  
+  DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Arg);
+  if (!DRE) {
+    S.Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
+    << Arg->getSourceRange();
+    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    return true;
+  }
 
   if (!isa<ValueDecl>(DRE->getDecl())) {
     S.Diag(Arg->getLocStart(),
@@ -3550,10 +3658,10 @@
     return true;
   }
 
-  NamedDecl *Entity = 0;
+  NamedDecl *Entity = DRE->getDecl();
 
   // Cannot refer to non-static data members
-  if (FieldDecl *Field = dyn_cast<FieldDecl>(DRE->getDecl())) {
+  if (FieldDecl *Field = dyn_cast<FieldDecl>(Entity)) {
     S.Diag(Arg->getLocStart(), diag::err_template_arg_field)
       << Field << Arg->getSourceRange();
     S.Diag(Param->getLocation(), diag::note_template_param_here);
@@ -3561,28 +3669,44 @@
   }
 
   // Cannot refer to non-static member functions
-  if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(DRE->getDecl()))
+  if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
     if (!Method->isStatic()) {
       S.Diag(Arg->getLocStart(), diag::err_template_arg_method)
         << Method << Arg->getSourceRange();
       S.Diag(Param->getLocation(), diag::note_template_param_here);
       return true;
     }
+  }
 
-  // Functions must have external linkage.
-  if (FunctionDecl *Func = dyn_cast<FunctionDecl>(DRE->getDecl())) {
-    if (!isExternalLinkage(Func->getLinkage())) {
-      S.Diag(Arg->getLocStart(),
-             diag::err_template_arg_function_not_extern)
-        << Func << Arg->getSourceRange();
-      S.Diag(Func->getLocation(), diag::note_template_arg_internal_object)
-        << true;
-      return true;
-    }
+  FunctionDecl *Func = dyn_cast<FunctionDecl>(Entity);
+  VarDecl *Var = dyn_cast<VarDecl>(Entity);
 
-    // Okay: we've named a function with external linkage.
-    Entity = Func;
+  // A non-type template argument must refer to an object or function.
+  if (!Func && !Var) {
+    // We found something, but we don't know specifically what it is.
+    S.Diag(Arg->getLocStart(), diag::err_template_arg_not_object_or_func)
+      << Arg->getSourceRange();
+    S.Diag(DRE->getDecl()->getLocation(), diag::note_template_arg_refers_here);
+    return true;
+  }
+
+  // Address / reference template args must have external linkage in C++98.
+  if (Entity->getLinkage() == InternalLinkage) {
+    S.Diag(Arg->getLocStart(), S.getLangOpts().CPlusPlus0x ?
+             diag::warn_cxx98_compat_template_arg_object_internal :
+             diag::ext_template_arg_object_internal)
+      << !Func << Entity << Arg->getSourceRange();
+    S.Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
+      << !Func;
+  } else if (Entity->getLinkage() == NoLinkage) {
+    S.Diag(Arg->getLocStart(), diag::err_template_arg_object_no_linkage)
+      << !Func << Entity << Arg->getSourceRange();
+    S.Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
+      << !Func;
+    return true;
+  }
 
+  if (Func) {
     // If the template parameter has pointer type, the function decays.
     if (ParamType->isPointerType() && !AddressTaken)
       ArgType = S.Context.getPointerType(Func->getType());
@@ -3605,16 +3729,7 @@
 
       ArgType = Func->getType();
     }
-  } else if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
-    if (!isExternalLinkage(Var->getLinkage())) {
-      S.Diag(Arg->getLocStart(),
-             diag::err_template_arg_object_not_extern)
-        << Var << Arg->getSourceRange();
-      S.Diag(Var->getLocation(), diag::note_template_arg_internal_object)
-        << true;
-      return true;
-    }
-
+  } else {
     // A value of reference type is not an object.
     if (Var->getType()->isReferenceType()) {
       S.Diag(Arg->getLocStart(),
@@ -3624,8 +3739,14 @@
       return true;
     }
 
-    // Okay: we've named an object with external linkage
-    Entity = Var;
+    // A template argument must have static storage duration.
+    // FIXME: Ensure this works for thread_local as well as __thread.
+    if (Var->isThreadSpecified()) {
+      S.Diag(Arg->getLocStart(), diag::err_template_arg_thread_local)
+        << Arg->getSourceRange();
+      S.Diag(Var->getLocation(), diag::note_template_arg_refers_here);
+      return true;
+    }
 
     // If the template parameter has pointer type, we must have taken
     // the address of this object.
@@ -3672,13 +3793,6 @@
         S.Diag(Param->getLocation(), diag::note_template_param_here);
       }
     }
-  } else {
-    // We found something else, but we don't know specifically what it is.
-    S.Diag(Arg->getLocStart(),
-           diag::err_template_arg_not_object_or_func)
-      << Arg->getSourceRange();
-    S.Diag(DRE->getDecl()->getLocation(), diag::note_template_arg_refers_here);
-    return true;
   }
 
   bool ObjCLifetimeConversion;
@@ -3739,10 +3853,41 @@
 
 /// \brief Checks whether the given template argument is a pointer to
 /// member constant according to C++ [temp.arg.nontype]p1.
-bool Sema::CheckTemplateArgumentPointerToMember(Expr *Arg,
-                                                TemplateArgument &Converted) {
+static bool CheckTemplateArgumentPointerToMember(Sema &S,
+                                                 NonTypeTemplateParmDecl *Param,
+                                                 QualType ParamType,
+                                                 Expr *&ResultArg,
+                                                 TemplateArgument &Converted) {
   bool Invalid = false;
 
+  // Check for a null pointer value.
+  Expr *Arg = ResultArg;
+  switch (isNullPointerValueTemplateArgument(S, Param, ParamType, Arg)) {
+  case NPV_Error:
+    return true;
+  case NPV_NullPointer:
+    Converted = TemplateArgument((Decl *)0);
+    return false;
+  case NPV_NotNullPointer:
+    break;
+  }
+
+  bool ObjCLifetimeConversion;
+  if (S.IsQualificationConversion(Arg->getType(),
+                                  ParamType.getNonReferenceType(),
+                                  false, ObjCLifetimeConversion)) {
+    Arg = S.ImpCastExprToType(Arg, ParamType, CK_NoOp,
+                              Arg->getValueKind()).take();
+    ResultArg = Arg;
+  } else if (!S.Context.hasSameUnqualifiedType(Arg->getType(),
+                ParamType.getNonReferenceType())) {
+    // We can't perform this conversion.
+    S.Diag(Arg->getLocStart(), diag::err_template_arg_not_convertible)
+      << Arg->getType() << ParamType << Arg->getSourceRange();
+    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    return true;
+  }
+
   // See through any implicit casts we added to fix the type.
   while (ImplicitCastExpr *Cast = dyn_cast<ImplicitCastExpr>(Arg))
     Arg = Cast->getSubExpr();
@@ -3760,10 +3905,10 @@
   bool ExtraParens = false;
   while (ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
     if (!Invalid && !ExtraParens) {
-      Diag(Arg->getLocStart(),
-           getLangOpts().CPlusPlus0x ?
-             diag::warn_cxx98_compat_template_arg_extra_parens :
-             diag::ext_template_arg_extra_parens)
+      S.Diag(Arg->getLocStart(),
+             S.getLangOpts().CPlusPlus0x ?
+               diag::warn_cxx98_compat_template_arg_extra_parens :
+               diag::ext_template_arg_extra_parens)
         << Arg->getSourceRange();
       ExtraParens = true;
     }
@@ -3789,7 +3934,7 @@
       if (VD->getType()->isMemberPointerType()) {
         if (isa<NonTypeTemplateParmDecl>(VD) ||
             (isa<VarDecl>(VD) &&
-             Context.getCanonicalType(VD->getType()).isConstQualified())) {
+             S.Context.getCanonicalType(VD->getType()).isConstQualified())) {
           if (Arg->isTypeDependent() || Arg->isValueDependent())
             Converted = TemplateArgument(Arg);
           else
@@ -3803,8 +3948,8 @@
   }
 
   if (!DRE)
-    return Diag(Arg->getLocStart(),
-                diag::err_template_arg_not_pointer_to_member_form)
+    return S.Diag(Arg->getLocStart(),
+                  diag::err_template_arg_not_pointer_to_member_form)
       << Arg->getSourceRange();
 
   if (isa<FieldDecl>(DRE->getDecl()) || isa<CXXMethodDecl>(DRE->getDecl())) {
@@ -3822,11 +3967,10 @@
   }
 
   // We found something else, but we don't know specifically what it is.
-  Diag(Arg->getLocStart(),
-       diag::err_template_arg_not_pointer_to_member_form)
-      << Arg->getSourceRange();
-  Diag(DRE->getDecl()->getLocation(),
-       diag::note_template_arg_refers_here);
+  S.Diag(Arg->getLocStart(),
+         diag::err_template_arg_not_pointer_to_member_form)
+    << Arg->getSourceRange();
+  S.Diag(DRE->getDecl()->getLocation(), diag::note_template_arg_refers_here);
   return true;
 }
 
@@ -4042,23 +4186,6 @@
   QualType ArgType = Arg->getType();
   DeclAccessPair FoundResult; // temporary for ResolveOverloadedFunction
 
-  // C++0x [temp.arg.nontype]p5 bullets 2, 4 and 6 permit conversion
-  // from a template argument of type std::nullptr_t to a non-type
-  // template parameter of type pointer to object, pointer to
-  // function, or pointer-to-member, respectively.
-  if (ArgType->isNullPtrType()) {
-    if (ParamType->isPointerType() || ParamType->isMemberPointerType()) {
-      Converted = TemplateArgument((NamedDecl *)0);
-      return Owned(Arg);
-    }
-    
-    if (ParamType->isNullPtrType()) {
-      llvm::APSInt Zero(Context.getTypeSize(Context.NullPtrTy), true);
-      Converted = TemplateArgument(Zero, Context.NullPtrTy);
-      return Owned(Arg);
-    }
-  }
-
   // Handle pointer-to-function, reference-to-function, and
   // pointer-to-member-function all in (roughly) the same way.
   if (// -- For a non-type template-parameter of type pointer to
@@ -4104,22 +4231,8 @@
       return Owned(Arg);
     }
 
-    bool ObjCLifetimeConversion;
-    if (IsQualificationConversion(ArgType, ParamType.getNonReferenceType(),
-                                  false, ObjCLifetimeConversion)) {
-      Arg = ImpCastExprToType(Arg, ParamType, CK_NoOp,
-                              Arg->getValueKind()).take();
-    } else if (!Context.hasSameUnqualifiedType(ArgType,
-                                           ParamType.getNonReferenceType())) {
-      // We can't perform this conversion.
-      Diag(Arg->getLocStart(),
-           diag::err_template_arg_not_convertible)
-        << Arg->getType() << InstantiatedParamType << Arg->getSourceRange();
-      Diag(Param->getLocation(), diag::note_template_param_here);
-      return ExprError();
-    }
-
-    if (CheckTemplateArgumentPointerToMember(Arg, Converted))
+    if (CheckTemplateArgumentPointerToMember(*this, Param, ParamType, Arg,
+                                             Converted))
       return ExprError();
     return Owned(Arg);
   }
@@ -4170,27 +4283,35 @@
     return Owned(Arg);
   }
 
+  // Deal with parameters of type std::nullptr_t.
+  if (ParamType->isNullPtrType()) {
+    if (Arg->isTypeDependent() || Arg->isValueDependent()) {
+      Converted = TemplateArgument(Arg);
+      return Owned(Arg);
+    }
+    
+    switch (isNullPointerValueTemplateArgument(*this, Param, ParamType, Arg)) {
+    case NPV_NotNullPointer:
+      Diag(Arg->getExprLoc(), diag::err_template_arg_not_convertible)
+        << Arg->getType() << ParamType;
+      Diag(Param->getLocation(), diag::note_template_param_here);
+      return ExprError();
+      
+    case NPV_Error:
+      return ExprError();
+      
+    case NPV_NullPointer:
+      Converted = TemplateArgument((Decl *)0);
+      return Owned(Arg);;
+    }
+  }
+
   //     -- For a non-type template-parameter of type pointer to data
   //        member, qualification conversions (4.4) are applied.
   assert(ParamType->isMemberPointerType() && "Only pointers to members remain");
 
-  bool ObjCLifetimeConversion;
-  if (Context.hasSameUnqualifiedType(ParamType, ArgType)) {
-    // Types match exactly: nothing more to do here.
-  } else if (IsQualificationConversion(ArgType, ParamType, false, 
-                                       ObjCLifetimeConversion)) {
-    Arg = ImpCastExprToType(Arg, ParamType, CK_NoOp,
-                            Arg->getValueKind()).take();
-  } else {
-    // We can't perform this conversion.
-    Diag(Arg->getLocStart(),
-         diag::err_template_arg_not_convertible)
-      << Arg->getType() << InstantiatedParamType << Arg->getSourceRange();
-    Diag(Param->getLocation(), diag::note_template_param_here);
-    return ExprError();
-  }
-
-  if (CheckTemplateArgumentPointerToMember(Arg, Converted))
+  if (CheckTemplateArgumentPointerToMember(*this, Param, ParamType, Arg,
+                                           Converted))
     return ExprError();
   return Owned(Arg);
 }
@@ -4249,6 +4370,18 @@
                                               SourceLocation Loc) {
   assert(Arg.getKind() == TemplateArgument::Declaration &&
          "Only declaration template arguments permitted here");
+  
+  // For a NULL non-type template argument, return nullptr casted to the
+  // parameter's type.
+  if (!Arg.getAsDecl()) {
+    return ImpCastExprToType(
+             new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc),
+                             ParamType,
+                             ParamType->getAs<MemberPointerType>()
+                               ? CK_NullToMemberPointer
+                               : CK_NullToPointer);
+  }
+  
   ValueDecl *VD = cast<ValueDecl>(Arg.getAsDecl());
 
   if (VD->getDeclContext()->isRecord() &&

Modified: cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp Tue Apr 17 06:08:26 2012
@@ -1586,8 +1586,7 @@
 
   case TemplateArgument::Declaration:
     if (Arg.getKind() == TemplateArgument::Declaration &&
-        Param.getAsDecl()->getCanonicalDecl() ==
-          Arg.getAsDecl()->getCanonicalDecl())
+        isSameDeclaration(Param.getAsDecl(), Arg.getAsDecl()))
       return Sema::TDK_Success;
 
     Info.FirstArg = Param;
@@ -1858,8 +1857,7 @@
              Context.getCanonicalType(Y.getAsType());
 
     case TemplateArgument::Declaration:
-      return X.getAsDecl()->getCanonicalDecl() ==
-             Y.getAsDecl()->getCanonicalDecl();
+      return isSameDeclaration(X.getAsDecl(), Y.getAsDecl());
 
     case TemplateArgument::Template:
     case TemplateArgument::TemplateExpansion:
@@ -1925,7 +1923,7 @@
   case TemplateArgument::Declaration: {
     Expr *E
       = S.BuildExpressionFromDeclTemplateArgument(Arg, NTTPType, Loc)
-    .takeAs<Expr>();
+          .takeAs<Expr>();
     return TemplateArgumentLoc(TemplateArgument(E), E);
   }
 
@@ -2935,8 +2933,12 @@
   }
 
   // For all other cases, just match by type.
+  QualType ArgType = Arg->getType();
+  if (AdjustFunctionParmAndArgTypesForDeduction(S, TemplateParams, ParamType, 
+                                                ArgType, Arg, TDF))
+    return Sema::TDK_FailedOverloadResolution;
   return DeduceTemplateArgumentsByTypeMatch(S, TemplateParams, ParamType,
-                                            Arg->getType(), Info, Deduced, TDF);
+                                            ArgType, Info, Deduced, TDF);
 }
 
 /// \brief Perform template argument deduction from a function call
@@ -3494,22 +3496,24 @@
   Deduced.resize(1);
   QualType InitType = Init->getType();
   unsigned TDF = 0;
-  if (AdjustFunctionParmAndArgTypesForDeduction(*this, &TemplateParams,
-                                                FuncParam, InitType, Init,
-                                                TDF))
-    return DAR_Failed;
 
   TemplateDeductionInfo Info(Context, Loc);
 
   InitListExpr * InitList = dyn_cast<InitListExpr>(Init);
   if (InitList) {
     for (unsigned i = 0, e = InitList->getNumInits(); i < e; ++i) {
-      if (DeduceTemplateArgumentsByTypeMatch(*this, &TemplateParams, FuncParam,
-                                             InitList->getInit(i)->getType(),
-                                             Info, Deduced, TDF))
+      if (DeduceTemplateArgumentByListElement(*this, &TemplateParams, 
+                                              TemplArg,
+                                              InitList->getInit(i),
+                                              Info, Deduced, TDF))
         return DAR_Failed;
     }
   } else {
+    if (AdjustFunctionParmAndArgTypesForDeduction(*this, &TemplateParams,
+                                                  FuncParam, InitType, Init,
+                                                  TDF))
+      return DAR_Failed;
+    
     if (DeduceTemplateArgumentsByTypeMatch(*this, &TemplateParams, FuncParam,
                                            InitType, Info, Deduced, TDF))
       return DAR_Failed;
@@ -4404,7 +4408,7 @@
   switch (TemplateArg.getKind()) {
   case TemplateArgument::Null:
   case TemplateArgument::Integral:
-    case TemplateArgument::Declaration:
+  case TemplateArgument::Declaration:
     break;
 
   case TemplateArgument::Type:

Modified: cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp Tue Apr 17 06:08:26 2012
@@ -1113,15 +1113,21 @@
     type = argExpr->getType();
 
   } else if (arg.getKind() == TemplateArgument::Declaration) {
-    ValueDecl *VD = cast<ValueDecl>(arg.getAsDecl());
-
-    // Find the instantiation of the template argument.  This is
-    // required for nested templates.
-    VD = cast_or_null<ValueDecl>(
-                       getSema().FindInstantiatedDecl(loc, VD, TemplateArgs));
-    if (!VD)
-      return ExprError();
-
+    ValueDecl *VD;
+    if (Decl *D = arg.getAsDecl()) {
+      VD = cast<ValueDecl>(D);
+
+      // Find the instantiation of the template argument.  This is
+      // required for nested templates.
+      VD = cast_or_null<ValueDecl>(
+             getSema().FindInstantiatedDecl(loc, VD, TemplateArgs));
+      if (!VD)
+        return ExprError();
+    } else {
+      // Propagate NULL template argument.
+      VD = 0;
+    }
+    
     // Derive the type we want the substituted decl to have.  This had
     // better be non-dependent, or these checks will have serious problems.
     if (parm->isExpandedParameterPack()) {

Modified: cfe/branches/tooling/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Apr 17 06:08:26 2012
@@ -2661,8 +2661,13 @@
   Consumer.HandleCXXStaticMemberVarInstantiation(Var);
 
   // If we already have a definition, we're done.
-  if (Var->getDefinition())
+  if (VarDecl *Def = Var->getDefinition()) {
+    // We may be explicitly instantiating something we've already implicitly
+    // instantiated.
+    Def->setTemplateSpecializationKind(Var->getTemplateSpecializationKind(),
+                                       PointOfInstantiation);
     return;
+  }
 
   InstantiatingTemplate Inst(*this, PointOfInstantiation, Var);
   if (Inst)

Modified: cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp Tue Apr 17 06:08:26 2012
@@ -667,6 +667,7 @@
   case TST_char16:
   case TST_char32:
   case TST_int:
+  case TST_int128:
   case TST_half:
   case TST_float:
   case TST_double:

Modified: cfe/branches/tooling/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaType.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaType.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaType.cpp Tue Apr 17 06:08:26 2012
@@ -26,6 +26,7 @@
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/DelayedDiagnostic.h"
 #include "clang/Sema/Lookup.h"
@@ -720,6 +721,12 @@
     }
     break;
   }
+  case DeclSpec::TST_int128:
+    if (DS.getTypeSpecSign() == DeclSpec::TSS_unsigned)
+      Result = Context.UnsignedInt128Ty;
+    else
+      Result = Context.Int128Ty;
+    break;
   case DeclSpec::TST_half: Result = Context.HalfTy; break;
   case DeclSpec::TST_float: Result = Context.FloatTy; break;
   case DeclSpec::TST_double:
@@ -973,6 +980,25 @@
       TypeQuals &= ~DeclSpec::TQ_volatile;
     }
 
+    // C90 6.5.3 constraints: "The same type qualifier shall not appear more
+    // than once in the same specifier-list or qualifier-list, either directly
+    // or via one or more typedefs."
+    if (!S.getLangOpts().C99 && !S.getLangOpts().CPlusPlus 
+        && TypeQuals & Result.getCVRQualifiers()) {
+      if (TypeQuals & DeclSpec::TQ_const && Result.isConstQualified()) {
+        S.Diag(DS.getConstSpecLoc(), diag::ext_duplicate_declspec) 
+          << "const";
+      }
+
+      if (TypeQuals & DeclSpec::TQ_volatile && Result.isVolatileQualified()) {
+        S.Diag(DS.getVolatileSpecLoc(), diag::ext_duplicate_declspec) 
+          << "volatile";
+      }
+
+      // C90 doesn't have restrict, so it doesn't force us to produce a warning
+      // in this case.
+    }
+
     Qualifiers Quals = Qualifiers::fromCVRMask(TypeQuals);
     Result = Context.getQualifiedType(Result, Quals);
   }

Modified: cfe/branches/tooling/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/TreeTransform.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/TreeTransform.h (original)
+++ cfe/branches/tooling/lib/Sema/TreeTransform.h Tue Apr 17 06:08:26 2012
@@ -6736,14 +6736,20 @@
 template<typename Derived>
 ExprResult 
 TreeTransform<Derived>::TransformStmtExpr(StmtExpr *E) {
+  SemaRef.ActOnStartStmtExpr();
   StmtResult SubStmt
     = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
-  if (SubStmt.isInvalid())
+  if (SubStmt.isInvalid()) {
+    SemaRef.ActOnStmtExprError();
     return ExprError();
+  }
 
   if (!getDerived().AlwaysRebuild() &&
-      SubStmt.get() == E->getSubStmt())
+      SubStmt.get() == E->getSubStmt()) {
+    // Calling this an 'error' is unintuitive, but it does the right thing.
+    SemaRef.ActOnStmtExprError();
     return SemaRef.MaybeBindToTemporary(E);
+  }
 
   return getDerived().RebuildStmtExpr(E->getLParenLoc(),
                                       SubStmt.get(),
@@ -7815,7 +7821,8 @@
 TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
   // Create the local class that will describe the lambda.
   CXXRecordDecl *Class
-    = getSema().createLambdaClosureType(E->getIntroducerRange());
+    = getSema().createLambdaClosureType(E->getIntroducerRange(),
+                                        /*KnownDependent=*/false);
   getDerived().transformedLocalDecl(E->getLambdaClass(), Class);
   
   // Transform the type of the lambda parameters and start the definition of
@@ -7836,11 +7843,15 @@
     Invalid = true;  
 
   // Build the call operator.
+  // Note: Once a lambda mangling number and context declaration have been
+  // assigned, they never change.
+  unsigned ManglingNumber = E->getLambdaClass()->getLambdaManglingNumber();
+  Decl *ContextDecl = E->getLambdaClass()->getLambdaContextDecl();  
   CXXMethodDecl *CallOperator
     = getSema().startLambdaDefinition(Class, E->getIntroducerRange(),
                                       MethodTy, 
                                       E->getCallOperator()->getLocEnd(),
-                                      Params);
+                                      Params, ManglingNumber, ContextDecl);
   getDerived().transformAttrs(E->getCallOperator(), CallOperator);
   
   // FIXME: Instantiation-specific.
@@ -7953,14 +7964,8 @@
     return ExprError();    
   }
 
-  // Note: Once a lambda mangling number and context declaration have been
-  // assigned, they never change.
-  unsigned ManglingNumber = E->getLambdaClass()->getLambdaManglingNumber();
-  Decl *ContextDecl = E->getLambdaClass()->getLambdaContextDecl();
   return getSema().ActOnLambdaExpr(E->getLocStart(), Body.take(), 
-                                   /*CurScope=*/0, ManglingNumber,
-                                   ContextDecl,
-                                   /*IsInstantiation=*/true);
+                                   /*CurScope=*/0, /*IsInstantiation=*/true);
 }
 
 template<typename Derived>

Modified: cfe/branches/tooling/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReader.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReader.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReader.cpp Tue Apr 17 06:08:26 2012
@@ -3350,7 +3350,6 @@
     unsigned Length = Record[Idx++];
     LangOpts.CurrentModule.assign(Record.begin() + Idx, 
                                   Record.begin() + Idx + Length);
-    Idx += Length;
     return Listener->ReadLanguageOptions(LangOpts);
   }
 
@@ -3898,9 +3897,9 @@
     ExceptionSpecificationType EST =
         static_cast<ExceptionSpecificationType>(Record[Idx++]);
     EPI.ExceptionSpecType = EST;
+    SmallVector<QualType, 2> Exceptions;
     if (EST == EST_Dynamic) {
       EPI.NumExceptions = Record[Idx++];
-      SmallVector<QualType, 2> Exceptions;
       for (unsigned I = 0; I != EPI.NumExceptions; ++I)
         Exceptions.push_back(readType(*Loc.F, Record, Idx));
       EPI.Exceptions = Exceptions.data();

Modified: cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp Tue Apr 17 06:08:26 2012
@@ -790,21 +790,12 @@
 
 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
   VisitExpr(E);
-  E->setOp(AtomicExpr::AtomicOp(Record[Idx++]));
-  E->setPtr(Reader.ReadSubExpr());
-  E->setOrder(Reader.ReadSubExpr());
-  E->setNumSubExprs(2);
-  if (E->getOp() != AtomicExpr::Load) {
-    E->setVal1(Reader.ReadSubExpr());
-    E->setNumSubExprs(3);
-  }
-  if (E->isCmpXChg()) {
-    E->setOrderFail(Reader.ReadSubExpr());
-    E->setVal2(Reader.ReadSubExpr());
-    E->setNumSubExprs(5);
-  }
-  E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
-  E->setRParenLoc(ReadSourceLocation(Record, Idx));
+  E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
+  E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
+  for (unsigned I = 0; I != E->NumSubExprs; ++I)
+    E->SubExprs[I] = Reader.ReadSubExpr();
+  E->BuiltinLoc = ReadSourceLocation(Record, Idx);
+  E->RParenLoc = ReadSourceLocation(Record, Idx);
 }
 
 //===----------------------------------------------------------------------===//

Modified: cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp Tue Apr 17 06:08:26 2012
@@ -751,14 +751,8 @@
 void ASTStmtWriter::VisitAtomicExpr(AtomicExpr *E) {
   VisitExpr(E);
   Record.push_back(E->getOp());
-  Writer.AddStmt(E->getPtr());
-  Writer.AddStmt(E->getOrder());
-  if (E->getOp() != AtomicExpr::Load)
-    Writer.AddStmt(E->getVal1());
-  if (E->isCmpXChg()) {
-    Writer.AddStmt(E->getOrderFail());
-    Writer.AddStmt(E->getVal2());
-  }
+  for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
+    Writer.AddStmt(E->getSubExprs()[I]);
   Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
   Writer.AddSourceLocation(E->getRParenLoc(), Record);
   Code = serialization::EXPR_ATOMIC;

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp Tue Apr 17 06:08:26 2012
@@ -112,8 +112,8 @@
       << " | Empty WorkList: "
       << (Eng.hasEmptyWorkList() ? "yes" : "no");
 
-  B.EmitBasicReport("Analyzer Statistics", "Internal Statistics", output.str(),
-      PathDiagnosticLocation(D, SM));
+  B.EmitBasicReport(D, "Analyzer Statistics", "Internal Statistics",
+                    output.str(), PathDiagnosticLocation(D, SM));
 
   // Emit warning for each block we bailed out on.
   typedef CoreEngine::BlocksExhausted::const_iterator ExhaustedIterator;
@@ -128,8 +128,9 @@
       llvm::raw_svector_ostream outputI(bufI);
       outputI << "(" << NameOfRootFunction << ")" <<
                  ": The analyzer generated a sink at this point";
-      B.EmitBasicReport("Sink Point", "Internal Statistics", outputI.str(),
-          PathDiagnosticLocation::createBegin(CS->getStmt(), SM, LC));
+      B.EmitBasicReport(D, "Sink Point", "Internal Statistics", outputI.str(),
+                        PathDiagnosticLocation::createBegin(CS->getStmt(),
+                                                            SM, LC));
     }
   }
 }

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp Tue Apr 17 06:08:26 2012
@@ -485,6 +485,7 @@
   mutable Selector arrayWithObjectsS;
   mutable Selector dictionaryWithObjectsAndKeysS;
   mutable Selector setWithObjectsS;
+  mutable Selector orderedSetWithObjectsS;
   mutable Selector initWithObjectsS;
   mutable Selector initWithObjectsAndKeysS;
   mutable OwningPtr<BugType> BT;
@@ -530,6 +531,11 @@
     if (isReceiverClassOrSuperclass(Class, "NSSet") &&
         S == initWithObjectsS)
       return true;
+
+    // -[NSOrderedSet initWithObjects:]
+    if (isReceiverClassOrSuperclass(Class, "NSOrderedSet") &&
+        S == initWithObjectsS)
+      return true;
   } else {
     const ObjCInterfaceDecl *Class = msg.getReceiverInterface();
 
@@ -547,6 +553,11 @@
     if (isReceiverClassOrSuperclass(Class, "NSSet") &&
         S == setWithObjectsS)
       return true;
+
+    // -[NSOrderedSet orderedSetWithObjects:]
+    if (isReceiverClassOrSuperclass(Class, "NSOrderedSet") &&
+        S == orderedSetWithObjectsS)
+      return true;
   }
 
   return false;
@@ -563,6 +574,7 @@
     dictionaryWithObjectsAndKeysS = 
       GetUnarySelector("dictionaryWithObjectsAndKeys", Ctx);
     setWithObjectsS = GetUnarySelector("setWithObjects", Ctx);
+    orderedSetWithObjectsS = GetUnarySelector("orderedSetWithObjects", Ctx);
 
     initWithObjectsS = GetUnarySelector("initWithObjects", Ctx);
     initWithObjectsAndKeysS = GetUnarySelector("initWithObjectsAndKeys", Ctx);

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt Tue Apr 17 06:08:26 2012
@@ -26,6 +26,7 @@
   CheckerDocumentation.cpp
   ChrootChecker.cpp
   ClangCheckers.cpp
+  CommonBugCategories.cpp
   DeadStoresChecker.cpp
   DebugCheckers.cpp
   DereferenceChecker.cpp

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Tue Apr 17 06:08:26 2012
@@ -982,6 +982,9 @@
 
 
 void CStringChecker::evalMemcpy(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 3)
+    return;
+
   // void *memcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is the address of the destination buffer.
   const Expr *Dest = CE->getArg(0);
@@ -991,6 +994,9 @@
 }
 
 void CStringChecker::evalMempcpy(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 3)
+    return;
+
   // void *mempcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is a pointer to the byte following the last written byte.
   const Expr *Dest = CE->getArg(0);
@@ -1000,6 +1006,9 @@
 }
 
 void CStringChecker::evalMemmove(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 3)
+    return;
+
   // void *memmove(void *dst, const void *src, size_t n);
   // The return value is the address of the destination buffer.
   const Expr *Dest = CE->getArg(0);
@@ -1009,12 +1018,18 @@
 }
 
 void CStringChecker::evalBcopy(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 3)
+    return;
+
   // void bcopy(const void *src, void *dst, size_t n);
   evalCopyCommon(C, CE, C.getState(), 
                  CE->getArg(2), CE->getArg(1), CE->getArg(0));
 }
 
 void CStringChecker::evalMemcmp(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 3)
+    return;
+
   // int memcmp(const void *s1, const void *s2, size_t n);
   CurrentFunctionDescription = "memory comparison function";
 
@@ -1089,12 +1104,18 @@
 
 void CStringChecker::evalstrLength(CheckerContext &C,
                                    const CallExpr *CE) const {
+  if (CE->getNumArgs() < 1)
+    return;
+
   // size_t strlen(const char *s);
   evalstrLengthCommon(C, CE, /* IsStrnlen = */ false);
 }
 
 void CStringChecker::evalstrnLength(CheckerContext &C,
                                     const CallExpr *CE) const {
+  if (CE->getNumArgs() < 2)
+    return;
+
   // size_t strnlen(const char *s, size_t maxlen);
   evalstrLengthCommon(C, CE, /* IsStrnlen = */ true);
 }
@@ -1225,6 +1246,9 @@
 }
 
 void CStringChecker::evalStrcpy(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 2)
+    return;
+
   // char *strcpy(char *restrict dst, const char *restrict src);
   evalStrcpyCommon(C, CE, 
                    /* returnEnd = */ false, 
@@ -1233,6 +1257,9 @@
 }
 
 void CStringChecker::evalStrncpy(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 3)
+    return;
+
   // char *strncpy(char *restrict dst, const char *restrict src, size_t n);
   evalStrcpyCommon(C, CE, 
                    /* returnEnd = */ false, 
@@ -1241,6 +1268,9 @@
 }
 
 void CStringChecker::evalStpcpy(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 2)
+    return;
+
   // char *stpcpy(char *restrict dst, const char *restrict src);
   evalStrcpyCommon(C, CE, 
                    /* returnEnd = */ true, 
@@ -1249,6 +1279,9 @@
 }
 
 void CStringChecker::evalStrcat(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 2)
+    return;
+
   //char *strcat(char *restrict s1, const char *restrict s2);
   evalStrcpyCommon(C, CE, 
                    /* returnEnd = */ false, 
@@ -1257,6 +1290,9 @@
 }
 
 void CStringChecker::evalStrncat(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 3)
+    return;
+
   //char *strncat(char *restrict s1, const char *restrict s2, size_t n);
   evalStrcpyCommon(C, CE, 
                    /* returnEnd = */ false, 
@@ -1568,23 +1604,35 @@
 }
 
 void CStringChecker::evalStrcmp(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 2)
+    return;
+
   //int strcmp(const char *s1, const char *s2);
   evalStrcmpCommon(C, CE, /* isBounded = */ false, /* ignoreCase = */ false);
 }
 
 void CStringChecker::evalStrncmp(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() < 3)
+    return;
+
   //int strncmp(const char *s1, const char *s2, size_t n);
   evalStrcmpCommon(C, CE, /* isBounded = */ true, /* ignoreCase = */ false);
 }
 
 void CStringChecker::evalStrcasecmp(CheckerContext &C, 
                                     const CallExpr *CE) const {
+  if (CE->getNumArgs() < 2)
+    return;
+
   //int strcasecmp(const char *s1, const char *s2);
   evalStrcmpCommon(C, CE, /* isBounded = */ false, /* ignoreCase = */ true);
 }
 
 void CStringChecker::evalStrncasecmp(CheckerContext &C, 
                                      const CallExpr *CE) const {
+  if (CE->getNumArgs() < 3)
+    return;
+
   //int strncasecmp(const char *s1, const char *s2, size_t n);
   evalStrcmpCommon(C, CE, /* isBounded = */ true, /* ignoreCase = */ true);
 }

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp Tue Apr 17 06:08:26 2012
@@ -157,7 +157,7 @@
         os << "U";
       os << "se a safer 'strlcat' API";
 
-      BR.EmitBasicReport("Anti-pattern in the argument", "C String API",
+      BR.EmitBasicReport(FD, "Anti-pattern in the argument", "C String API",
                          os.str(), Loc, &R, 1);
     }
   }

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Tue Apr 17 06:08:26 2012
@@ -179,7 +179,8 @@
     llvm::raw_string_ostream os(buf);
     os << "Objective-C class '" << *D << "' lacks a 'dealloc' instance method";
 
-    BR.EmitBasicReport(name, os.str(), DLoc);
+    BR.EmitBasicReport(D, name, categories::CoreFoundationObjectiveC,
+                       os.str(), DLoc);
     return;
   }
 
@@ -196,7 +197,8 @@
        << "' does not send a 'dealloc' message to its super class"
            " (missing [super dealloc])";
 
-    BR.EmitBasicReport(name, os.str(), DLoc);
+    BR.EmitBasicReport(MD, name, categories::CoreFoundationObjectiveC,
+                       os.str(), DLoc);
     return;
   }
 
@@ -236,9 +238,7 @@
     bool requiresRelease = PD->getSetterKind() != ObjCPropertyDecl::Assign;
     if (scan_ivar_release(MD->getBody(), ID, PD, RS, SelfII, Ctx)
        != requiresRelease) {
-      const char *name;
-      const char* category = "Memory (Core Foundation/Objective-C)";
-
+      const char *name = 0;
       std::string buf;
       llvm::raw_string_ostream os(buf);
 
@@ -263,7 +263,8 @@
       PathDiagnosticLocation SDLoc =
         PathDiagnosticLocation::createBegin((*I), BR.getSourceManager());
 
-      BR.EmitBasicReport(name, category, os.str(), SDLoc);
+      BR.EmitBasicReport(MD, name, categories::CoreFoundationObjectiveC,
+                         os.str(), SDLoc);
     }
   }
 }

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp Tue Apr 17 06:08:26 2012
@@ -70,7 +70,9 @@
       PathDiagnosticLocation::createBegin(MethDerived,
                                           BR.getSourceManager());
 
-    BR.EmitBasicReport("Incompatible instance method return type",
+    BR.EmitBasicReport(MethDerived,
+                       "Incompatible instance method return type",
+                       categories::CoreFoundationObjectiveC,
                        os.str(), MethDLoc);
   }
 }

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp Tue Apr 17 06:08:26 2012
@@ -286,7 +286,8 @@
 
   PathDiagnosticLocation FSLoc =
     PathDiagnosticLocation::createBegin(FS, BR.getSourceManager(), AC);
-  BR.EmitBasicReport(bugType, "Security", os.str(),
+  BR.EmitBasicReport(AC->getDecl(),
+                     bugType, "Security", os.str(),
                      FSLoc, ranges.data(), ranges.size());
 }
 
@@ -322,7 +323,8 @@
   SourceRange R = CE->getCallee()->getSourceRange();
   PathDiagnosticLocation CELoc =
     PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
-  BR.EmitBasicReport("Potential buffer overflow in call to 'gets'",
+  BR.EmitBasicReport(AC->getDecl(),
+                     "Potential buffer overflow in call to 'gets'",
                      "Security",
                      "Call to function 'gets' is extremely insecure as it can "
                      "always result in a buffer overflow",
@@ -363,7 +365,8 @@
   SourceRange R = CE->getCallee()->getSourceRange();
   PathDiagnosticLocation CELoc =
     PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
-  BR.EmitBasicReport("Potential buffer overflow in call to 'getpw'",
+  BR.EmitBasicReport(AC->getDecl(),
+                     "Potential buffer overflow in call to 'getpw'",
                      "Security",
                      "The getpw() function is dangerous as it may overflow the "
                      "provided buffer. It is obsoleted by getpwuid().",
@@ -405,10 +408,12 @@
   SourceRange R = CE->getCallee()->getSourceRange();
   PathDiagnosticLocation CELoc =
     PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
-  BR.EmitBasicReport("Potential insecure temporary file in call 'mktemp'",
+  BR.EmitBasicReport(AC->getDecl(),
+                     "Potential insecure temporary file in call 'mktemp'",
                      "Security",
                      "Call to function 'mktemp' is insecure as it always "
-                     "creates or uses insecure temporary file.  Use 'mkstemp' instead",
+                     "creates or uses insecure temporary file.  Use 'mkstemp' "
+                     "instead",
                      CELoc, &R, 1);
 }
 
@@ -490,7 +495,8 @@
     out << " used as a suffix";
   }
   out << ')';
-  BR.EmitBasicReport("Insecure temporary file creation", "Security",
+  BR.EmitBasicReport(AC->getDecl(),
+                     "Insecure temporary file creation", "Security",
                      out.str(), CELoc, &R, 1);
 }
 
@@ -511,13 +517,14 @@
   SourceRange R = CE->getCallee()->getSourceRange();
   PathDiagnosticLocation CELoc =
     PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
-  BR.EmitBasicReport("Potential insecure memory buffer bounds restriction in "
+  BR.EmitBasicReport(AC->getDecl(),
+                     "Potential insecure memory buffer bounds restriction in "
                      "call 'strcpy'",
                      "Security",
                      "Call to function 'strcpy' is insecure as it does not "
-		     "provide bounding of the memory buffer. Replace "
-		     "unbounded copy functions with analogous functions that "
-		     "support length arguments such as 'strlcpy'. CWE-119.",
+                     "provide bounding of the memory buffer. Replace "
+                     "unbounded copy functions with analogous functions that "
+                     "support length arguments such as 'strlcpy'. CWE-119.",
                      CELoc, &R, 1);
 }
 
@@ -538,13 +545,14 @@
   SourceRange R = CE->getCallee()->getSourceRange();
   PathDiagnosticLocation CELoc =
     PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
-  BR.EmitBasicReport("Potential insecure memory buffer bounds restriction in "
-		     "call 'strcat'",
-		     "Security",
-		     "Call to function 'strcat' is insecure as it does not "
-		     "provide bounding of the memory buffer. Replace "
-		     "unbounded copy functions with analogous functions that "
-		     "support length arguments such as 'strlcat'. CWE-119.",
+  BR.EmitBasicReport(AC->getDecl(),
+                     "Potential insecure memory buffer bounds restriction in "
+                     "call 'strcat'",
+                     "Security",
+                     "Call to function 'strcat' is insecure as it does not "
+                     "provide bounding of the memory buffer. Replace "
+                     "unbounded copy functions with analogous functions that "
+                     "support length arguments such as 'strlcat'. CWE-119.",
                      CELoc, &R, 1);
 }
 
@@ -619,7 +627,8 @@
   SourceRange R = CE->getCallee()->getSourceRange();
   PathDiagnosticLocation CELoc =
     PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
-  BR.EmitBasicReport(os1.str(), "Security", os2.str(), CELoc, &R, 1);
+  BR.EmitBasicReport(AC->getDecl(), os1.str(), "Security", os2.str(),
+                     CELoc, &R, 1);
 }
 
 //===----------------------------------------------------------------------===//
@@ -644,7 +653,8 @@
   SourceRange R = CE->getCallee()->getSourceRange();
   PathDiagnosticLocation CELoc =
     PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
-  BR.EmitBasicReport("'random' is not a secure random number generator",
+  BR.EmitBasicReport(AC->getDecl(),
+                     "'random' is not a secure random number generator",
                      "Security",
                      "The 'random' function produces a sequence of values that "
                      "an adversary may be able to predict.  Use 'arc4random' "
@@ -664,7 +674,8 @@
   SourceRange R = CE->getCallee()->getSourceRange();
   PathDiagnosticLocation CELoc =
     PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
-  BR.EmitBasicReport("Potential insecure implementation-specific behavior in "
+  BR.EmitBasicReport(AC->getDecl(),
+                     "Potential insecure implementation-specific behavior in "
                      "call 'vfork'",
                      "Security",
                      "Call to function 'vfork' is insecure as it can lead to "
@@ -736,7 +747,8 @@
   SourceRange R = CE->getCallee()->getSourceRange();
   PathDiagnosticLocation CELoc =
     PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
-  BR.EmitBasicReport(os1.str(), "Security", os2.str(), CELoc, &R, 1);
+  BR.EmitBasicReport(AC->getDecl(), os1.str(), "Security", os2.str(),
+                     CELoc, &R, 1);
 }
 
 //===----------------------------------------------------------------------===//

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp Tue Apr 17 06:08:26 2012
@@ -63,7 +63,8 @@
     SourceRange R = ArgEx->getSourceRange();
     PathDiagnosticLocation ELoc =
       PathDiagnosticLocation::createBegin(E, BR.getSourceManager(), AC);
-    BR.EmitBasicReport("Potential unintended use of sizeof() on pointer type",
+    BR.EmitBasicReport(AC->getDecl(),
+                       "Potential unintended use of sizeof() on pointer type",
                        "Logic",
                        "The code calls sizeof() on a pointer type. "
                        "This can produce an unexpected result.",

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ClangSACheckers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ClangSACheckers.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ClangSACheckers.h (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ClangSACheckers.h Tue Apr 17 06:08:26 2012
@@ -12,6 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "clang/StaticAnalyzer/Checkers/CommonBugCategories.h"
+
 #ifndef LLVM_CLANG_SA_LIB_CHECKERS_CLANGSACHECKERS_H
 #define LLVM_CLANG_SA_LIB_CHECKERS_CLANGSACHECKERS_H
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp Tue Apr 17 06:08:26 2012
@@ -68,6 +68,21 @@
   }
 }
 
+static const Expr *LookThroughTransitiveAssignments(const Expr *Ex) {
+  while (Ex) {
+    const BinaryOperator *BO =
+      dyn_cast<BinaryOperator>(Ex->IgnoreParenCasts());
+    if (!BO)
+      break;
+    if (BO->getOpcode() == BO_Assign) {
+      Ex = BO->getRHS();
+      continue;
+    }
+    break;
+  }
+  return Ex;
+}
+
 namespace {
 class DeadStoreObs : public LiveVariables::Observer {
   const CFG &cfg;
@@ -130,7 +145,7 @@
         return;
     }
 
-    BR.EmitBasicReport(BugType, "Dead store", os.str(), L, R);
+    BR.EmitBasicReport(AC->getDecl(), BugType, "Dead store", os.str(), L, R);
   }
 
   void CheckVarDecl(const VarDecl *VD, const Expr *Ex, const Expr *Val,
@@ -200,17 +215,18 @@
         if (VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
           // Special case: check for assigning null to a pointer.
           //  This is a common form of defensive programming.
+          const Expr *RHS = LookThroughTransitiveAssignments(B->getRHS());
+          
           QualType T = VD->getType();
           if (T->isPointerType() || T->isObjCObjectPointerType()) {
-            if (B->getRHS()->isNullPointerConstant(Ctx,
-                                              Expr::NPC_ValueDependentIsNull))
+            if (RHS->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNull))
               return;
           }
 
-          Expr *RHS = B->getRHS()->IgnoreParenCasts();
+          RHS = RHS->IgnoreParenCasts();
           // Special case: self-assignments.  These are often used to shut up
           //  "unused variable" compiler warnings.
-          if (DeclRefExpr *RhsDR = dyn_cast<DeclRefExpr>(RHS))
+          if (const DeclRefExpr *RhsDR = dyn_cast<DeclRefExpr>(RHS))
             if (VD == dyn_cast<VarDecl>(RhsDR->getDecl()))
               return;
 
@@ -252,10 +268,15 @@
           if (V->getType()->getAs<ReferenceType>())
             return;
             
-          if (Expr *E = V->getInit()) {
-            while (ExprWithCleanups *exprClean = dyn_cast<ExprWithCleanups>(E))
+          if (const Expr *E = V->getInit()) {
+            while (const ExprWithCleanups *exprClean =
+                    dyn_cast<ExprWithCleanups>(E))
               E = exprClean->getSubExpr();
             
+            // Look through transitive assignments, e.g.:
+            // int x = y = 0;
+            E = LookThroughTransitiveAssignments(E);
+            
             // Don't warn on C++ objects (yet) until we can show that their
             // constructors/destructors don't have side effects.
             if (isa<CXXConstructExpr>(E))
@@ -275,8 +296,9 @@
               if (E->isEvaluatable(Ctx))
                 return;
 
-              if (DeclRefExpr *DRE=dyn_cast<DeclRefExpr>(E->IgnoreParenCasts()))
-                if (VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
+              if (const DeclRefExpr *DRE =
+                  dyn_cast<DeclRefExpr>(E->IgnoreParenCasts()))
+                if (const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
                   // Special case: check for initialization from constant
                   //  variables.
                   //

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp Tue Apr 17 06:08:26 2012
@@ -350,6 +350,8 @@
 
     // The arguments are pointer arguments. The data they are pointing at is
     // tainted after the call.
+    if (CE->getNumArgs() < (ArgNum + 1))
+      return false;
     const Expr* Arg = CE->getArg(ArgNum);
     SymbolRef Sym = getPointedToSymbol(C, Arg);
     if (Sym)
@@ -458,7 +460,8 @@
       break;
     }
 
-    assert(ArgNum < CE->getNumArgs());
+    if (CE->getNumArgs() < (ArgNum + 1))
+      return State;
     if ((IsTainted = isTaintedOrPointsToTainted(CE->getArg(ArgNum), State, C)))
       break;
   }
@@ -525,9 +528,10 @@
 
 // If argument 0(protocol domain) is network, the return value should get taint.
 ProgramStateRef GenericTaintChecker::postSocket(const CallExpr *CE,
-                                                    CheckerContext &C) const {
-  assert(CE->getNumArgs() >= 3);
+                                                CheckerContext &C) const {
   ProgramStateRef State = C.getState();
+  if (CE->getNumArgs() < 3)
+    return State;
 
   SourceLocation DomLoc = CE->getArg(0)->getExprLoc();
   StringRef DomName = C.getMacroNameOrSpelling(DomLoc);
@@ -542,7 +546,9 @@
 ProgramStateRef GenericTaintChecker::postScanf(const CallExpr *CE,
                                                    CheckerContext &C) const {
   ProgramStateRef State = C.getState();
-  assert(CE->getNumArgs() >= 2);
+  if (CE->getNumArgs() < 2)
+    return State;
+
   SVal x = State->getSVal(CE->getArg(1), C.getLocationContext());
   // All arguments except for the very first one should get taint.
   for (unsigned int i = 1; i < CE->getNumArgs(); ++i) {
@@ -557,7 +563,7 @@
 }
 
 ProgramStateRef GenericTaintChecker::postRetTaint(const CallExpr *CE,
-                                                      CheckerContext &C) const {
+                                                  CheckerContext &C) const {
   return C.getState()->addTaint(CE, C.getLocationContext());
 }
 
@@ -677,7 +683,7 @@
     .Case("dlopen", 0)
     .Default(UINT_MAX);
 
-  if (ArgNum == UINT_MAX)
+  if (ArgNum == UINT_MAX || CE->getNumArgs() < (ArgNum + 1))
     return false;
 
   if (generateReportIfTainted(CE->getArg(ArgNum),
@@ -722,7 +728,7 @@
       ArgNum = 2;
   }
 
-  if (ArgNum != InvalidArgIndex &&
+  if (ArgNum != InvalidArgIndex && CE->getNumArgs() > ArgNum &&
       generateReportIfTainted(CE->getArg(ArgNum), MsgTaintedBufferSize, C))
     return true;
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp Tue Apr 17 06:08:26 2012
@@ -115,8 +115,10 @@
 namespace {
 class StringRefCheckerVisitor : public StmtVisitor<StringRefCheckerVisitor> {
   BugReporter &BR;
+  const Decl *DeclWithIssue;
 public:
-  StringRefCheckerVisitor(BugReporter &br) : BR(br) {}
+  StringRefCheckerVisitor(const Decl *declWithIssue, BugReporter &br)
+    : BR(br), DeclWithIssue(declWithIssue) {}
   void VisitChildren(Stmt *S) {
     for (Stmt::child_iterator I = S->child_begin(), E = S->child_end() ;
       I != E; ++I)
@@ -131,7 +133,7 @@
 } // end anonymous namespace
 
 static void CheckStringRefAssignedTemporary(const Decl *D, BugReporter &BR) {
-  StringRefCheckerVisitor walker(BR);
+  StringRefCheckerVisitor walker(D, BR);
   walker.Visit(D->getBody());
 }
 
@@ -176,7 +178,7 @@
                      "std::string that it outlives";
   PathDiagnosticLocation VDLoc =
     PathDiagnosticLocation::createBegin(VD, BR.getSourceManager());
-  BR.EmitBasicReport(desc, "LLVM Conventions", desc,
+  BR.EmitBasicReport(DeclWithIssue, desc, "LLVM Conventions", desc,
                      VDLoc, Init->getSourceRange());
 }
 
@@ -281,7 +283,7 @@
   // the class may be in the header file, for example).
   PathDiagnosticLocation L = PathDiagnosticLocation::createBegin(
                                FieldChain.front(), BR.getSourceManager());
-  BR.EmitBasicReport("AST node allocates heap memory", "LLVM Conventions",
+  BR.EmitBasicReport(Root, "AST node allocates heap memory", "LLVM Conventions",
                      os.str(), L);
 }
 

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Tue Apr 17 06:08:26 2012
@@ -368,6 +368,8 @@
 
   ProgramStateRef State = C.getState();
   if (FunI == II_malloc || FunI == II_valloc) {
+    if (CE->getNumArgs() < 1)
+      return;
     State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State);
   } else if (FunI == II_realloc) {
     State = ReallocMem(C, CE, false);
@@ -490,6 +492,9 @@
                                           ProgramStateRef state,
                                           unsigned Num,
                                           bool Hold) const {
+  if (CE->getNumArgs() < (Num + 1))
+    return 0;
+
   const Expr *ArgExpr = CE->getArg(Num);
   SVal ArgVal = state->getSVal(ArgExpr, C.getLocationContext());
   if (!isa<DefinedOrUnknownSVal>(ArgVal))
@@ -710,6 +715,9 @@
 ProgramStateRef MallocChecker::ReallocMem(CheckerContext &C,
                                           const CallExpr *CE,
                                           bool FreesOnFail) const {
+  if (CE->getNumArgs() < 2)
+    return 0;
+
   ProgramStateRef state = C.getState();
   const Expr *arg0Expr = CE->getArg(0);
   const LocationContext *LCtx = C.getLocationContext();
@@ -795,6 +803,9 @@
 }
 
 ProgramStateRef MallocChecker::CallocMem(CheckerContext &C, const CallExpr *CE){
+  if (CE->getNumArgs() < 2)
+    return 0;
+
   ProgramStateRef state = C.getState();
   SValBuilder &svalBuilder = C.getSValBuilder();
   const LocationContext *LCtx = C.getLocationContext();

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp Tue Apr 17 06:08:26 2012
@@ -214,11 +214,10 @@
        i != e;
        ++i) {
     SourceRange R = i->mulop->getSourceRange();
-    BR.EmitBasicReport("MallocOverflowSecurityChecker",
+    BR.EmitBasicReport(D, "malloc() size overflow", categories::UnixAPI,
       "the computation of the size of the memory allocation may overflow",
       PathDiagnosticLocation::createOperatorLoc(i->mulop,
-                                                BR.getSourceManager()),
-      &R, 1);
+                                                BR.getSourceManager()), &R, 1);
   }
 }
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp Tue Apr 17 06:08:26 2012
@@ -194,8 +194,10 @@
             PathDiagnosticLocation::createBegin(i->AllocCall->getCallee(),
                                                 BR.getSourceManager(), ADC);
 
-          BR.EmitBasicReport("allocator sizeof operand mismatch", OS.str(), L,
-                             Ranges.data(), Ranges.size());
+          BR.EmitBasicReport(D, "allocator sizeof operand mismatch",
+                             categories::UnixAPI,
+                             OS.str(),
+                             L, Ranges.data(), Ranges.size());
         }
       }
     }

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp Tue Apr 17 06:08:26 2012
@@ -74,7 +74,7 @@
         "error occurred";
     PathDiagnosticLocation L =
       PathDiagnosticLocation::create(D, BR.getSourceManager());
-    BR.EmitBasicReport("Bad return type when passing NSError**",
+    BR.EmitBasicReport(D, "Bad return type when passing NSError**",
                        "Coding conventions (Apple)", err, L);
   }
 }
@@ -122,7 +122,7 @@
         "error occurred";
     PathDiagnosticLocation L =
       PathDiagnosticLocation::create(D, BR.getSourceManager());
-    BR.EmitBasicReport("Bad return type when passing CFErrorRef*",
+    BR.EmitBasicReport(D, "Bad return type when passing CFErrorRef*",
                        "Coding conventions (Apple)", err, L);
   }
 }

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp Tue Apr 17 06:08:26 2012
@@ -120,8 +120,8 @@
       dyn_cast_or_null<TypedValueRegion>(location.getAsRegion())) {
     LoadTy = TR->getValueType();
   }
-  Eng.evalLoad(Tmp, theValueExpr, Pred,
-                  state, location, &OSAtomicLoadTag, LoadTy);
+  Eng.evalLoad(Tmp, CE, theValueExpr, Pred,
+               state, location, &OSAtomicLoadTag, LoadTy);
 
   if (Tmp.empty()) {
     // If no nodes were generated, other checkers must have generated sinks. 
@@ -172,8 +172,8 @@
         val = svalBuilder.evalCast(val,R->getValueType(), newValueExpr->getType());
       }
 
-      Eng.evalStore(TmpStore, NULL, theValueExpr, N,
-                       stateEqual, location, val, &OSAtomicStoreTag);
+      Eng.evalStore(TmpStore, CE, theValueExpr, N,
+                    stateEqual, location, val, &OSAtomicStoreTag);
 
       if (TmpStore.empty()) {
         // If no nodes were generated, other checkers must have generated sinks. 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp Tue Apr 17 06:08:26 2012
@@ -142,7 +142,8 @@
     SourceRange R = Arg->getSourceRange();
     PathDiagnosticLocation CELoc =
         PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
-    BR.EmitBasicReport(OsName.str(), "Core Foundation/Objective-C",
+    BR.EmitBasicReport(AC->getDecl(),
+                       OsName.str(), categories::CoreFoundationObjectiveC,
                        Os.str(), CELoc, &R, 1);
   }
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp Tue Apr 17 06:08:26 2012
@@ -34,13 +34,13 @@
   mutable OwningPtr<BugType> BT;
   inline void initBugType() const {
     if (!BT)
-      BT.reset(new BugType("CFArray API", "Core Foundation/Objective-C"));
+      BT.reset(new BugType("CFArray API",
+                           categories::CoreFoundationObjectiveC));
   }
 
   inline SymbolRef getArraySym(const Expr *E, CheckerContext &C) const {
     SVal ArrayRef = C.getState()->getSVal(E, C.getLocationContext());
     SymbolRef ArraySym = ArrayRef.getAsSymbol();
-    assert(ArraySym);
     return ArraySym;
   }
 
@@ -120,8 +120,12 @@
     // Retrieve the size.
     // Find out if we saw this array symbol before and have information about it.
     const Expr *ArrayExpr = CE->getArg(0);
-    const DefinedSVal *Size =
-                            State->get<ArraySizeMap>(getArraySym(ArrayExpr, C));
+    SymbolRef ArraySym = getArraySym(ArrayExpr, C);
+    if (!ArraySym)
+      return;
+
+    const DefinedSVal *Size = State->get<ArraySizeMap>(ArraySym);
+
     if (!Size)
       return;
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp Tue Apr 17 06:08:26 2012
@@ -83,7 +83,7 @@
   const std::string desc;
 public:
   InitSelfBug() : BugType("Missing \"self = [(super or self) init...]\"",
-                          "Core Foundation/Objective-C") {}
+                          categories::CoreFoundationObjectiveC) {}
 };
 
 } // end anonymous namespace

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp Tue Apr 17 06:08:26 2012
@@ -161,7 +161,7 @@
 
       PathDiagnosticLocation L =
         PathDiagnosticLocation::create(I->first, BR.getSourceManager());
-      BR.EmitBasicReport("Unused instance variable", "Optimization",
+      BR.EmitBasicReport(D, "Unused instance variable", "Optimization",
                          os.str(), L);
     }
 }

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Tue Apr 17 06:08:26 2012
@@ -1620,7 +1620,7 @@
   class CFRefBug : public BugType {
   protected:
     CFRefBug(StringRef name)
-    : BugType(name, "Memory (Core Foundation/Objective-C)") {}
+    : BugType(name, categories::MemoryCoreFoundationObjectiveC) {}
   public:
 
     // FIXME: Eventually remove.

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp Tue Apr 17 06:08:26 2012
@@ -67,7 +67,7 @@
                                   const char *name) {
   if (BT)
     return;
-  BT.reset(new BugType(name, "Unix API"));
+  BT.reset(new BugType(name, categories::UnixAPI));
 }
 
 //===----------------------------------------------------------------------===//

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp Tue Apr 17 06:08:26 2012
@@ -162,8 +162,8 @@
     if (SM.isInSystemHeader(SL) || SM.isInExternCSystemHeader(SL))
       continue;
 
-    B.EmitBasicReport("Unreachable code", "Dead code", "This statement is never"
-        " executed", DL, SR);
+    B.EmitBasicReport(D, "Unreachable code", "Dead code",
+                      "This statement is never executed", DL, SR);
   }
 }
 

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp Tue Apr 17 06:08:26 2012
@@ -186,7 +186,8 @@
   if (isPure) {
     os << "\n" <<  "Call pure virtual functions during construction or "
        << "destruction may leads undefined behaviour";
-    BR.EmitBasicReport("Call pure virtual function during construction or "
+    BR.EmitBasicReport(AC->getDecl(),
+                       "Call pure virtual function during construction or "
                        "Destruction",
                        "Cplusplus",
                        os.str(), CELoc, &R, 1);
@@ -195,7 +196,8 @@
   else {
     os << "\n" << "Call virtual functions during construction or "
        << "destruction will never go to a more derived class";
-    BR.EmitBasicReport("Call virtual function during construction or "
+    BR.EmitBasicReport(AC->getDecl(),
+                       "Call virtual function during construction or "
                        "Destruction",
                        "Cplusplus",
                        os.str(), CELoc, &R, 1);

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/AnalysisManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/AnalysisManager.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/AnalysisManager.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/AnalysisManager.cpp Tue Apr 17 06:08:26 2012
@@ -8,8 +8,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
-#include "clang/Index/Entity.h"
-#include "clang/Index/Indexer.h"
 
 using namespace clang;
 using namespace ento;
@@ -22,7 +20,6 @@
                                  StoreManagerCreator storemgr,
                                  ConstraintManagerCreator constraintmgr, 
                                  CheckerManager *checkerMgr,
-                                 idx::Indexer *idxer,
                                  unsigned maxnodes, unsigned maxvisit,
                                  bool vizdot, bool vizubi,
                                  AnalysisPurgeMode purge,
@@ -38,7 +35,7 @@
   : AnaCtxMgr(useUnoptimizedCFG, addImplicitDtors, addInitializers),
     Ctx(ctx), Diags(diags), LangOpts(lang), PD(pd),
     CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),
-    CheckerMgr(checkerMgr), Idxer(idxer),
+    CheckerMgr(checkerMgr), 
     AScope(ScopeDecl), MaxNodes(maxnodes), MaxVisit(maxvisit),
     VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
     EagerlyAssume(eager), TrimGraph(trim),
@@ -62,7 +59,6 @@
     CreateStoreMgr(ParentAM.CreateStoreMgr),
     CreateConstraintMgr(ParentAM.CreateConstraintMgr),
     CheckerMgr(ParentAM.CheckerMgr),
-    Idxer(ParentAM.Idxer),
     AScope(ScopeDecl),
     MaxNodes(ParentAM.MaxNodes),
     MaxVisit(ParentAM.MaxVisit),
@@ -80,21 +76,3 @@
 {
   AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd();
 }
-
-
-AnalysisDeclContext *
-AnalysisManager::getAnalysisDeclContextInAnotherTU(const Decl *D) {
-  idx::Entity Ent = idx::Entity::get(const_cast<Decl *>(D), 
-                                     Idxer->getProgram());
-  FunctionDecl *FuncDef;
-  idx::TranslationUnit *TU;
-  llvm::tie(FuncDef, TU) = Idxer->getDefinitionFor(Ent);
-
-  if (FuncDef == 0)
-    return 0;
-
-  // This AnalysisDeclContext wraps function definition in another translation unit.
-  // But it is still owned by the AnalysisManager associated with the current
-  // translation unit.
-  return AnaCtxMgr.getContext(FuncDef, TU);
-}

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp Tue Apr 17 06:08:26 2012
@@ -1241,6 +1241,18 @@
   }
 }
 
+const Decl *BugReport::getDeclWithIssue() const {
+  if (DeclWithIssue)
+    return DeclWithIssue;
+  
+  const ExplodedNode *N = getErrorNode();
+  if (!N)
+    return 0;
+  
+  const LocationContext *LC = N->getLocationContext();
+  return LC->getCurrentStackFrame()->getDecl();
+}
+
 void BugReport::Profile(llvm::FoldingSetNodeID& hash) const {
   hash.AddPointer(&BT);
   hash.AddString(Description);
@@ -1952,7 +1964,8 @@
   BugType& BT = exampleReport->getBugType();
 
   OwningPtr<PathDiagnostic>
-    D(new PathDiagnostic(exampleReport->getBugType().getName(),
+    D(new PathDiagnostic(exampleReport->getDeclWithIssue(),
+                         exampleReport->getBugType().getName(),
                          !PD || PD->useVerboseDescription()
                          ? exampleReport->getDescription() 
                          : exampleReport->getShortDescription(),
@@ -1960,9 +1973,6 @@
 
   if (!bugReports.empty())
     GeneratePathDiagnostic(*D.get(), bugReports);
-
-  if (IsCachedDiagnostic(exampleReport, D.get()))
-    return;
   
   // Get the meta data.
   const BugReport::ExtraTextList &Meta =
@@ -1977,24 +1987,23 @@
   llvm::tie(Beg, End) = exampleReport->getRanges();
   DiagnosticsEngine &Diag = getDiagnostic();
   
-  // Search the description for '%', as that will be interpretted as a
-  // format character by FormatDiagnostics.
-  StringRef desc = exampleReport->getShortDescription();
-  unsigned ErrorDiag;
-  {
+  if (!IsCachedDiagnostic(exampleReport, D.get())) {
+    // Search the description for '%', as that will be interpretted as a
+    // format character by FormatDiagnostics.
+    StringRef desc = exampleReport->getShortDescription();
+
     SmallString<512> TmpStr;
     llvm::raw_svector_ostream Out(TmpStr);
-    for (StringRef::iterator I=desc.begin(), E=desc.end(); I!=E; ++I)
+    for (StringRef::iterator I=desc.begin(), E=desc.end(); I!=E; ++I) {
       if (*I == '%')
         Out << "%%";
       else
         Out << *I;
+    }
     
     Out.flush();
-    ErrorDiag = Diag.getCustomDiagID(DiagnosticsEngine::Warning, TmpStr);
-  }        
+    unsigned ErrorDiag = Diag.getCustomDiagID(DiagnosticsEngine::Warning, TmpStr);
 
-  {
     DiagnosticBuilder diagBuilder = Diag.Report(
       exampleReport->getLocation(getSourceManager()).asLocation(), ErrorDiag);
     for (BugReport::ranges_iterator I = Beg; I != End; ++I)
@@ -2009,21 +2018,17 @@
     PathDiagnosticPiece *piece = new PathDiagnosticEventPiece(
                                  exampleReport->getLocation(getSourceManager()),
                                  exampleReport->getDescription());
+    for ( ; Beg != End; ++Beg)
+      piece->addRange(*Beg);
 
-    for ( ; Beg != End; ++Beg) piece->addRange(*Beg);
     D->getActivePath().push_back(piece);
   }
 
   PD->HandlePathDiagnostic(D.take());
 }
 
-void BugReporter::EmitBasicReport(StringRef name, StringRef str,
-                                  PathDiagnosticLocation Loc,
-                                  SourceRange* RBeg, unsigned NumRanges) {
-  EmitBasicReport(name, "", str, Loc, RBeg, NumRanges);
-}
-
-void BugReporter::EmitBasicReport(StringRef name,
+void BugReporter::EmitBasicReport(const Decl *DeclWithIssue,
+                                  StringRef name,
                                   StringRef category,
                                   StringRef str, PathDiagnosticLocation Loc,
                                   SourceRange* RBeg, unsigned NumRanges) {
@@ -2031,6 +2036,7 @@
   // 'BT' is owned by BugReporter.
   BugType *BT = getBugTypeForName(name, category);
   BugReport *R = new BugReport(*BT, str, Loc);
+  R->setDeclWithIssue(DeclWithIssue);
   for ( ; NumRanges > 0 ; --NumRanges, ++RBeg) R->addRange(*RBeg);
   EmitReport(R);
 }

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Tue Apr 17 06:08:26 2012
@@ -393,7 +393,7 @@
   // Issue a message saying that the method was skipped.
   PathDiagnosticLocation L(Receiver, BRC.getSourceManager(),
                                      N->getLocationContext());
-  return new PathDiagnosticEventPiece(L, "No method actually called "
+  return new PathDiagnosticEventPiece(L, "No method is called "
       "because the receiver is nil");
 }
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/CheckerManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/CheckerManager.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/CheckerManager.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/CheckerManager.cpp Tue Apr 17 06:08:26 2012
@@ -222,25 +222,30 @@
     const CheckersTy &Checkers;
     SVal Loc;
     bool IsLoad;
-    const Stmt *S;
+    const Stmt *NodeEx; /* Will become a CFGStmt */
+    const Stmt *BoundEx;
     ExprEngine &Eng;
 
     CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
     CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
 
     CheckLocationContext(const CheckersTy &checkers,
-                         SVal loc, bool isLoad, const Stmt *s, ExprEngine &eng)
-      : Checkers(checkers), Loc(loc), IsLoad(isLoad), S(s), Eng(eng) { }
+                         SVal loc, bool isLoad, const Stmt *NodeEx,
+                         const Stmt *BoundEx,
+                         ExprEngine &eng)
+      : Checkers(checkers), Loc(loc), IsLoad(isLoad), NodeEx(NodeEx),
+        BoundEx(BoundEx), Eng(eng) {}
 
     void runChecker(CheckerManager::CheckLocationFunc checkFn,
                     NodeBuilder &Bldr, ExplodedNode *Pred) {
       ProgramPoint::Kind K =  IsLoad ? ProgramPoint::PreLoadKind :
                                        ProgramPoint::PreStoreKind;
-      const ProgramPoint &L = ProgramPoint::getProgramPoint(S, K,
-                                Pred->getLocationContext(), checkFn.Checker);
+      const ProgramPoint &L =
+        ProgramPoint::getProgramPoint(NodeEx, K,
+                                      Pred->getLocationContext(),
+                                      checkFn.Checker);
       CheckerContext C(Bldr, Eng, Pred, L);
-
-      checkFn(Loc, IsLoad, S, C);
+      checkFn(Loc, IsLoad, BoundEx, C);
     }
   };
 }
@@ -250,8 +255,11 @@
 void CheckerManager::runCheckersForLocation(ExplodedNodeSet &Dst,
                                             const ExplodedNodeSet &Src,
                                             SVal location, bool isLoad,
-                                            const Stmt *S, ExprEngine &Eng) {
-  CheckLocationContext C(LocationCheckers, location, isLoad, S, Eng);
+                                            const Stmt *NodeEx,
+                                            const Stmt *BoundEx,
+                                            ExprEngine &Eng) {
+  CheckLocationContext C(LocationCheckers, location, isLoad, NodeEx,
+                         BoundEx, Eng);
   expandGraphWithCheckers(C, Dst, Src);
 }
 

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/CoreEngine.cpp Tue Apr 17 06:08:26 2012
@@ -17,7 +17,6 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
-#include "clang/Index/TranslationUnit.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/StmtCXX.h"
 #include "llvm/Support/Casting.h"

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp Tue Apr 17 06:08:26 2012
@@ -67,7 +67,7 @@
 //===----------------------------------------------------------------------===//
 
 ExprEngine::ExprEngine(AnalysisManager &mgr, bool gcEnabled,
-                       SetOfDecls *VisitedCallees,
+                       SetOfConstDecls *VisitedCallees,
                        FunctionSummariesTy *FS)
   : AMgr(mgr),
     AnalysisDeclContexts(mgr.getAnalysisDeclContextManager()),
@@ -1542,7 +1542,7 @@
                       ProgramPoint::PostLValueKind);
   else {
     Bldr.takeNodes(Pred);
-    evalLoad(Dst, M, Pred, state, L);
+    evalLoad(Dst, M, M, Pred, state, L);
     Bldr.addNodes(Dst);
   }
 }
@@ -1611,7 +1611,7 @@
 
   // Evaluate the location (checks for bad dereferences).
   ExplodedNodeSet Tmp;
-  evalLocation(Tmp, LocationE, Pred, state, location, tag, false);
+  evalLocation(Tmp, AssignE, LocationE, Pred, state, location, tag, false);
 
   if (Tmp.empty())
     return;
@@ -1623,15 +1623,17 @@
     evalBind(Dst, StoreE, *NI, location, Val, false);
 }
 
-void ExprEngine::evalLoad(ExplodedNodeSet &Dst, const Expr *Ex,
-                            ExplodedNode *Pred,
-                            ProgramStateRef state, SVal location,
-                            const ProgramPointTag *tag, QualType LoadTy) {
+void ExprEngine::evalLoad(ExplodedNodeSet &Dst,
+                          const Expr *NodeEx,
+                          const Expr *BoundEx,
+                          ExplodedNode *Pred,
+                          ProgramStateRef state,
+                          SVal location,
+                          const ProgramPointTag *tag,
+                          QualType LoadTy)
+{
   assert(!isa<NonLoc>(location) && "location cannot be a NonLoc.");
-
-  if (isa<loc::ObjCPropRef>(location)) {
-    assert(false);
-  }
+  assert(!isa<loc::ObjCPropRef>(location));
 
   // Are we loading from a region?  This actually results in two loads; one
   // to fetch the address of the referenced value and one to fetch the
@@ -1644,30 +1646,36 @@
       static SimpleProgramPointTag
              loadReferenceTag("ExprEngine : Load Reference");
       ExplodedNodeSet Tmp;
-      evalLoadCommon(Tmp, Ex, Pred, state, location, &loadReferenceTag,
+      evalLoadCommon(Tmp, NodeEx, BoundEx, Pred, state,
+                     location, &loadReferenceTag,
                      getContext().getPointerType(RT->getPointeeType()));
 
       // Perform the load from the referenced value.
       for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end() ; I!=E; ++I) {
         state = (*I)->getState();
-        location = state->getSVal(Ex, (*I)->getLocationContext());
-        evalLoadCommon(Dst, Ex, *I, state, location, tag, LoadTy);
+        location = state->getSVal(BoundEx, (*I)->getLocationContext());
+        evalLoadCommon(Dst, NodeEx, BoundEx, *I, state, location, tag, LoadTy);
       }
       return;
     }
   }
 
-  evalLoadCommon(Dst, Ex, Pred, state, location, tag, LoadTy);
+  evalLoadCommon(Dst, NodeEx, BoundEx, Pred, state, location, tag, LoadTy);
 }
 
-void ExprEngine::evalLoadCommon(ExplodedNodeSet &Dst, const Expr *Ex,
-                                  ExplodedNode *Pred,
-                                  ProgramStateRef state, SVal location,
-                                  const ProgramPointTag *tag, QualType LoadTy) {
-
+void ExprEngine::evalLoadCommon(ExplodedNodeSet &Dst,
+                                const Expr *NodeEx,
+                                const Expr *BoundEx,
+                                ExplodedNode *Pred,
+                                ProgramStateRef state,
+                                SVal location,
+                                const ProgramPointTag *tag,
+                                QualType LoadTy) {
+  assert(NodeEx);
+  assert(BoundEx);
   // Evaluate the location (checks for bad dereferences).
   ExplodedNodeSet Tmp;
-  evalLocation(Tmp, Ex, Pred, state, location, tag, true);
+  evalLocation(Tmp, NodeEx, BoundEx, Pred, state, location, tag, true);
   if (Tmp.empty())
     return;
 
@@ -1682,24 +1690,30 @@
 
     if (location.isUnknown()) {
       // This is important.  We must nuke the old binding.
-      Bldr.generateNode(Ex, *NI, state->BindExpr(Ex, LCtx, UnknownVal()),
-                        false, tag, ProgramPoint::PostLoadKind);
+      Bldr.generateNode(NodeEx, *NI,
+                        state->BindExpr(BoundEx, LCtx, UnknownVal()),
+                        false, tag,
+                        ProgramPoint::PostLoadKind);
     }
     else {
       if (LoadTy.isNull())
-        LoadTy = Ex->getType();
+        LoadTy = BoundEx->getType();
       SVal V = state->getSVal(cast<Loc>(location), LoadTy);
-      Bldr.generateNode(Ex, *NI, state->bindExprAndLocation(Ex, LCtx,
-                                                            location, V),
+      Bldr.generateNode(NodeEx, *NI,
+                        state->bindExprAndLocation(BoundEx, LCtx, location, V),
                         false, tag, ProgramPoint::PostLoadKind);
     }
   }
 }
 
-void ExprEngine::evalLocation(ExplodedNodeSet &Dst, const Stmt *S,
-                                ExplodedNode *Pred,
-                                ProgramStateRef state, SVal location,
-                                const ProgramPointTag *tag, bool isLoad) {
+void ExprEngine::evalLocation(ExplodedNodeSet &Dst,
+                              const Stmt *NodeEx,
+                              const Stmt *BoundEx,
+                              ExplodedNode *Pred,
+                              ProgramStateRef state,
+                              SVal location,
+                              const ProgramPointTag *tag,
+                              bool isLoad) {
   StmtNodeBuilder BldrTop(Pred, Dst, *currentBuilderContext);
   // Early checks for performance reason.
   if (location.isUnknown()) {
@@ -1721,12 +1735,11 @@
     
     // FIXME: why is 'tag' not used instead of etag?
     static SimpleProgramPointTag etag("ExprEngine: Location");
-
-    Bldr.generateNode(S, Pred, state, false, &etag);
+    Bldr.generateNode(NodeEx, Pred, state, false, &etag);
   }
   ExplodedNodeSet Tmp;
-  getCheckerManager().runCheckersForLocation(Tmp, Src, location, isLoad, S,
-                                             *this);
+  getCheckerManager().runCheckersForLocation(Tmp, Src, location, isLoad,
+                                             NodeEx, BoundEx, *this);
   BldrTop.addNodes(Tmp);
 }
 

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp Tue Apr 17 06:08:26 2012
@@ -92,7 +92,7 @@
     // null dereferences, and so on.
     ExplodedNodeSet Tmp;
     SVal location = LeftV;
-    evalLoad(Tmp, LHS, *it, state, location);
+    evalLoad(Tmp, B, LHS, *it, state, location);
     
     for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E;
          ++I) {
@@ -189,7 +189,7 @@
       ExplodedNode *subExprNode = *I;
       ProgramStateRef state = subExprNode->getState();
       const LocationContext *LCtx = subExprNode->getLocationContext();
-      evalLoad(Dst, CastE, subExprNode, state, state->getSVal(Ex, LCtx));
+      evalLoad(Dst, CastE, CastE, subExprNode, state, state->getSVal(Ex, LCtx));
     }
     return;
   }
@@ -283,8 +283,51 @@
         Bldr.generateNode(CastE, Pred, state);
         continue;
       }
-        // Various C++ casts that are not handled yet.
-      case CK_Dynamic:
+      // Handle C++ dyn_cast.
+      case CK_Dynamic: {
+        ProgramStateRef state = Pred->getState();
+        const LocationContext *LCtx = Pred->getLocationContext();
+        SVal val = state->getSVal(Ex, LCtx);
+
+        // Compute the type of the result.
+        QualType resultType = CastE->getType();
+        if (CastE->isLValue())
+          resultType = getContext().getPointerType(resultType);
+
+        bool Failed = false;
+
+        // Check if the value being cast evaluates to 0.
+        if (val.isZeroConstant())
+          Failed = true;
+        // Else, evaluate the cast.
+        else
+          val = getStoreManager().evalDynamicCast(val, T, Failed);
+
+        if (Failed) {
+          if (T->isReferenceType()) {
+            // A bad_cast exception is thrown if input value is a reference.
+            // Currently, we model this, by generating a sink.
+            Bldr.generateNode(CastE, Pred, state, true);
+            continue;
+          } else {
+            // If the cast fails on a pointer, bind to 0.
+            state = state->BindExpr(CastE, LCtx, svalBuilder.makeNull());
+          }
+        } else {
+          // If we don't know if the cast succeeded, conjure a new symbol.
+          if (val.isUnknown()) {
+            DefinedOrUnknownSVal NewSym = svalBuilder.getConjuredSymbolVal(NULL,
+                                 CastE, LCtx, resultType,
+                                 currentBuilderContext->getCurrentBlockCount());
+            state = state->BindExpr(CastE, LCtx, NewSym);
+          } else 
+            // Else, bind to the derived region value.
+            state = state->BindExpr(CastE, LCtx, val);
+        }
+        Bldr.generateNode(CastE, Pred, state);
+        continue;
+      }
+      // Various C++ casts that are not handled yet.
       case CK_ToUnion:
       case CK_BaseToDerived:
       case CK_NullToMemberPointer:
@@ -300,9 +343,8 @@
         if (CastE->isLValue())
           resultType = getContext().getPointerType(resultType);
         const LocationContext *LCtx = Pred->getLocationContext();
-        SVal result =
-	  svalBuilder.getConjuredSymbolVal(NULL, CastE, LCtx, resultType,
-                               currentBuilderContext->getCurrentBlockCount());
+        SVal result = svalBuilder.getConjuredSymbolVal(NULL, CastE, LCtx,
+                    resultType, currentBuilderContext->getCurrentBlockCount());
         ProgramStateRef state = Pred->getState()->BindExpr(CastE, LCtx,
                                                                result);
         Bldr.generateNode(CastE, Pred, state);
@@ -375,7 +417,12 @@
       // Recover some path-sensitivity if a scalar value evaluated to
       // UnknownVal.
       if (InitVal.isUnknown()) {
-        InitVal = svalBuilder.getConjuredSymbolVal(NULL, InitEx, LC,
+	QualType Ty = InitEx->getType();
+	if (InitEx->isLValue()) {
+	  Ty = getContext().getPointerType(Ty);
+	}
+
+        InitVal = svalBuilder.getConjuredSymbolVal(NULL, InitEx, LC, Ty,
                                  currentBuilderContext->getCurrentBlockCount());
       }
       B.takeNodes(N);
@@ -688,7 +735,7 @@
   
   // Perform a load.
   ExplodedNodeSet Tmp;
-  evalLoad(Tmp, Ex, Pred, state, loc);
+  evalLoad(Tmp, U, Ex, Pred, state, loc);
   
   ExplodedNodeSet Dst2;
   StmtNodeBuilder Bldr(Tmp, Dst2, *currentBuilderContext);
@@ -757,7 +804,7 @@
     // Perform the store.
     Bldr.takeNodes(*I);
     ExplodedNodeSet Dst3;
-    evalStore(Dst3, NULL, U, *I, state, loc, Result);
+    evalStore(Dst3, U, U, *I, state, loc, Result);
     Bldr.addNodes(Dst3);
   }
   Dst.insert(Dst2);

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp Tue Apr 17 06:08:26 2012
@@ -87,7 +87,7 @@
   
   ExplodedNodeSet dstLocation;
   Bldr.takeNodes(Pred);
-  evalLocation(dstLocation, elem, Pred, state, elementV, NULL, false);
+  evalLocation(dstLocation, S, elem, Pred, state, elementV, NULL, false);
   Bldr.addNodes(dstLocation);
   
   for (ExplodedNodeSet::iterator NI = dstLocation.begin(),

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp Tue Apr 17 06:08:26 2012
@@ -55,13 +55,16 @@
 PathDiagnosticCallPiece::~PathDiagnosticCallPiece() {}
 PathDiagnosticControlFlowPiece::~PathDiagnosticControlFlowPiece() {}
 PathDiagnosticMacroPiece::~PathDiagnosticMacroPiece() {}
-PathDiagnostic::PathDiagnostic() : path(pathImpl) {}
+
+
 PathPieces::~PathPieces() {}
 PathDiagnostic::~PathDiagnostic() {}
 
-PathDiagnostic::PathDiagnostic(StringRef bugtype, StringRef desc,
+PathDiagnostic::PathDiagnostic(const Decl *declWithIssue,
+                               StringRef bugtype, StringRef desc,
                                StringRef category)
-  : BugType(StripTrailingDots(bugtype)),
+  : DeclWithIssue(declWithIssue),
+    BugType(StripTrailingDots(bugtype)),
     Desc(StripTrailingDots(desc)),
     Category(StripTrailingDots(category)),
     path(pathImpl) {}

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Tue Apr 17 06:08:26 2012
@@ -145,10 +145,9 @@
   Indent(o, indent) << "</array>\n";
 }
 
-static raw_ostream &EmitString(raw_ostream &o,
-                                     const std::string& s) {
+static raw_ostream &EmitString(raw_ostream &o, StringRef s) {
   o << "<string>";
-  for (std::string::const_iterator I=s.begin(), E=s.end(); I!=E; ++I) {
+  for (StringRef::const_iterator I = s.begin(), E = s.end(); I != E; ++I) {
     char c = *I;
     switch (c) {
     default:   o << c; break;
@@ -252,7 +251,7 @@
   // FIXME: Really use a short string.
   Indent(o, indent) << "<key>message</key>\n";
   EmitString(o, P.getString()) << '\n';
-
+  
   // Finish up.
   --indent;
   Indent(o, indent); o << "</dict>\n";
@@ -447,6 +446,38 @@
     EmitString(o, D->getCategory()) << '\n';
     o << "   <key>type</key>";
     EmitString(o, D->getBugType()) << '\n';
+    
+    // Output information about the semantic context where
+    // the issue occurred.
+    if (const Decl *DeclWithIssue = D->getDeclWithIssue()) {
+      // FIXME: handle blocks, which have no name.
+      if (const NamedDecl *ND = dyn_cast<NamedDecl>(DeclWithIssue)) {
+        StringRef declKind;
+        switch (ND->getKind()) {
+          case Decl::CXXRecord:
+            declKind = "C++ class";
+            break;
+          case Decl::CXXMethod:
+            declKind = "C++ method";
+            break;
+          case Decl::ObjCMethod:
+            declKind = "Objective-C method";
+            break;
+          case Decl::Function:
+            declKind = "function";
+            break;
+          default:
+            break;
+        }
+        if (!declKind.empty()) {
+          const std::string &declName = ND->getDeclName().getAsString();
+          o << "  <key>issue_context_kind</key>";
+          EmitString(o, declKind) << '\n';
+          o << "  <key>issue_context</key>";
+          EmitString(o, declName) << '\n';
+        }
+      }
+    }
 
     // Output the location of the bug.
     o << "  <key>location</key>\n";

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/RegionStore.cpp Tue Apr 17 06:08:26 2012
@@ -229,6 +229,16 @@
   /// For DerivedToBase casts, create a CXXBaseObjectRegion and return it.
   virtual SVal evalDerivedToBase(SVal derived, QualType basePtrType);
 
+  /// \brief Evaluates C++ dynamic_cast cast.
+  /// The callback may result in the following 3 scenarios:
+  ///  - Successful cast (ex: derived is subclass of base).
+  ///  - Failed cast (ex: derived is definitely not a subclass of base).
+  ///  - We don't know (base is a symbolic region and we don't have 
+  ///    enough info to determine if the cast will succeed at run time).
+  /// The function returns an SVal representing the derived class; it's
+  /// valid only if Failed flag is set to false.
+  virtual SVal evalDynamicCast(SVal base, QualType derivedPtrType,bool &Failed);
+
   StoreRef getInitialStore(const LocationContext *InitLoc) {
     return StoreRef(RBFactory.getEmptyMap().getRootWithoutRetain(), *this);
   }
@@ -877,6 +887,75 @@
   return loc::MemRegionVal(baseReg);
 }
 
+SVal RegionStoreManager::evalDynamicCast(SVal base, QualType derivedType,
+                                         bool &Failed) {
+  Failed = false;
+
+  loc::MemRegionVal *baseRegVal = dyn_cast<loc::MemRegionVal>(&base);
+  if (!baseRegVal)
+    return UnknownVal();
+  const MemRegion *BaseRegion = baseRegVal->stripCasts();
+
+  // Assume the derived class is a pointer or a reference to a CXX record.
+  derivedType = derivedType->getPointeeType();
+  assert(!derivedType.isNull());
+  const CXXRecordDecl *DerivedDecl = derivedType->getAsCXXRecordDecl();
+  if (!DerivedDecl && !derivedType->isVoidType())
+    return UnknownVal();
+
+  // Drill down the CXXBaseObject chains, which represent upcasts (casts from
+  // derived to base).
+  const MemRegion *SR = BaseRegion;
+  while (const TypedRegion *TSR = dyn_cast_or_null<TypedRegion>(SR)) {
+    QualType BaseType = TSR->getLocationType()->getPointeeType();
+    assert(!BaseType.isNull());
+    const CXXRecordDecl *SRDecl = BaseType->getAsCXXRecordDecl();
+    if (!SRDecl)
+      return UnknownVal();
+
+    // If found the derived class, the cast succeeds.
+    if (SRDecl == DerivedDecl)
+      return loc::MemRegionVal(TSR);
+
+    // If the region type is a subclass of the derived type.
+    if (!derivedType->isVoidType() && SRDecl->isDerivedFrom(DerivedDecl)) {
+      // This occurs in two cases.
+      // 1) We are processing an upcast.
+      // 2) We are processing a downcast but we jumped directly from the
+      // ancestor to a child of the cast value, so conjure the
+      // appropriate region to represent value (the intermediate node).
+      return loc::MemRegionVal(MRMgr.getCXXBaseObjectRegion(DerivedDecl,
+                                                            BaseRegion));
+    }
+
+    // If super region is not a parent of derived class, the cast definitely
+    // fails.
+    if (!derivedType->isVoidType() &&
+        DerivedDecl->isProvablyNotDerivedFrom(SRDecl)) {
+      Failed = true;
+      return UnknownVal();
+    }
+
+    if (const CXXBaseObjectRegion *R = dyn_cast<CXXBaseObjectRegion>(TSR))
+      // Drill down the chain to get the derived classes.
+      SR = R->getSuperRegion();
+    else {
+      // We reached the bottom of the hierarchy.
+
+      // If this is a cast to void*, return the region.
+      if (derivedType->isVoidType())
+        return loc::MemRegionVal(TSR);
+
+      // We did not find the derived class. We we must be casting the base to
+      // derived, so the cast should fail.
+      Failed = true;
+      return UnknownVal();
+    }
+  }
+
+  return UnknownVal();
+}
+
 //===----------------------------------------------------------------------===//
 // Loading values from regions.
 //===----------------------------------------------------------------------===//

Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/SVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/SVals.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/SVals.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/SVals.cpp Tue Apr 17 06:08:26 2012
@@ -103,10 +103,6 @@
   if (const nonloc::SymbolVal *X = dyn_cast<nonloc::SymbolVal>(this))
     return X->getSymbol();
 
-  if (const nonloc::SymbolVal *X = dyn_cast<nonloc::SymbolVal>(this))
-    if (SymbolRef Y = X->getSymbol())
-      return Y;
-
   return getAsLocSymbol();
 }
 

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Tue Apr 17 06:08:26 2012
@@ -41,6 +41,7 @@
 #include "llvm/Support/Timer.h"
 #include "llvm/ADT/DepthFirstIterator.h"
 #include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/Statistic.h"
 
 #include <queue>
@@ -95,6 +96,13 @@
   AnalyzerOptions Opts;
   ArrayRef<std::string> Plugins;
 
+  /// \brief Stores the declarations from the local translation unit.
+  /// Note, we pre-compute the local declarations at parse time as an
+  /// optimization to make sure we do not deserialize everything from disk.
+  /// The local declaration to all declarations ratio might be very small when
+  /// working with a PCH file.
+  SetOfDecls LocalTUDecls;
+
   // PD is owned by AnalysisManager.
   PathDiagnosticConsumer *PD;
 
@@ -125,13 +133,6 @@
   }
 
   ~AnalysisConsumer() {
-    // Count how many basic blocks we have not covered.
-    NumBlocksInAnalyzedFunctions = FunctionSummaries.getTotalNumBasicBlocks();
-    if (NumBlocksInAnalyzedFunctions > 0)
-      PercentReachableBlocks =
-        (FunctionSummaries.getTotalNumVisitedBasicBlocks() * 100) /
-          NumBlocksInAnalyzedFunctions;
-
     if (Opts.PrintStats)
       delete TUTotalTimer;
   }
@@ -206,7 +207,6 @@
                                   PP.getLangOpts(), PD,
                                   CreateStoreMgr, CreateConstraintMgr,
                                   checkerMgr.get(),
-                                  /* Indexer */ 0, 
                                   Opts.MaxNodes, Opts.MaxLoop,
                                   Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
                                   Opts.AnalysisPurgeOpt, Opts.EagerlyAssume,
@@ -221,11 +221,16 @@
                                   Opts.NoRetryExhausted));
   }
 
+  /// \brief Store the top level decls in the set to be processed later on.
+  /// (Doing this pre-processing avoids deserialization of data from PCH.)
+  virtual bool HandleTopLevelDecl(DeclGroupRef D);
+  virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
+
   virtual void HandleTranslationUnit(ASTContext &C);
 
-  /// \brief Build the call graph for the TU and use it to define the order
-  /// in which the functions should be visited.
-  void HandleDeclsGallGraph(TranslationUnitDecl *TU);
+  /// \brief Build the call graph for all the top level decls of this TU and
+  /// use it to define the order in which the functions should be visited.
+  void HandleDeclsGallGraph();
 
   /// \brief Run analyzes(syntax or path sensitive) on the given function.
   /// \param Mode - determines if we are requesting syntax only or path
@@ -233,13 +238,12 @@
   /// \param VisitedCallees - The output parameter, which is populated with the
   /// set of functions which should be considered analyzed after analyzing the
   /// given root function.
-  void HandleCode(Decl *D, AnalysisMode Mode, SetOfDecls *VisitedCallees = 0);
-
-  /// \brief Check if we should skip (not analyze) the given function.
-  bool skipFunction(Decl *D);
+  void HandleCode(Decl *D, AnalysisMode Mode,
+                  SetOfConstDecls *VisitedCallees = 0);
 
-  void RunPathSensitiveChecks(Decl *D, SetOfDecls *VisitedCallees);
-  void ActionExprEngine(Decl *D, bool ObjCGCEnabled, SetOfDecls *VisitedCallees);
+  void RunPathSensitiveChecks(Decl *D, SetOfConstDecls *VisitedCallees);
+  void ActionExprEngine(Decl *D, bool ObjCGCEnabled,
+                        SetOfConstDecls *VisitedCallees);
 
   /// Visitors for the RecursiveASTVisitor.
 
@@ -269,6 +273,13 @@
       HandleCode(MD, RecVisitorMode);
     return true;
   }
+
+private:
+  void storeTopLevelDecls(DeclGroupRef DG);
+
+  /// \brief Check if we should skip (not analyze) the given function.
+  bool skipFunction(Decl *D);
+
 };
 } // end anonymous namespace
 
@@ -278,11 +289,35 @@
 //===----------------------------------------------------------------------===//
 llvm::Timer* AnalysisConsumer::TUTotalTimer = 0;
 
-void AnalysisConsumer::HandleDeclsGallGraph(TranslationUnitDecl *TU) {
+bool AnalysisConsumer::HandleTopLevelDecl(DeclGroupRef DG) {
+  storeTopLevelDecls(DG);
+  return true;
+}
+
+void AnalysisConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef DG) {
+  storeTopLevelDecls(DG);
+}
+
+void AnalysisConsumer::storeTopLevelDecls(DeclGroupRef DG) {
+  for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I) {
+
+    // Skip ObjCMethodDecl, wait for the objc container to avoid
+    // analyzing twice.
+    if (isa<ObjCMethodDecl>(*I))
+      continue;
+
+    LocalTUDecls.insert(*I);
+  }
+}
+
+void AnalysisConsumer::HandleDeclsGallGraph() {
   // Otherwise, use the Callgraph to derive the order.
   // Build the Call Graph.
   CallGraph CG;
-  CG.addToCallGraph(TU);
+  // Add all the top level declarations to the graph.
+  for (SetOfDecls::iterator I = LocalTUDecls.begin(),
+                            E = LocalTUDecls.end(); I != E; ++I)
+    CG.addToCallGraph(*I);
 
   // Find the top level nodes - children of root + the unreachable (parentless)
   // nodes.
@@ -323,15 +358,15 @@
       continue;
 
     // Analyze the function.
-    SetOfDecls VisitedCallees;
+    SetOfConstDecls VisitedCallees;
     Decl *D = N->getDecl();
     assert(D);
     HandleCode(D, ANALYSIS_PATH,
                (Mgr->InliningMode == All ? 0 : &VisitedCallees));
 
     // Add the visited callees to the global visited set.
-    for (SetOfDecls::const_iterator I = VisitedCallees.begin(),
-                                    E = VisitedCallees.end(); I != E; ++I) {
+    for (SetOfConstDecls::const_iterator I = VisitedCallees.begin(),
+                                         E = VisitedCallees.end(); I != E; ++I){
       CallGraphNode *VN = CG.getNode(*I);
       if (VN)
         Visited.insert(VN);
@@ -365,10 +400,14 @@
     // sensitive analyzes as well.
     RecVisitorMode = (Mgr->shouldInlineCall() ? ANALYSIS_SYNTAX : ANALYSIS_ALL);
     RecVisitorBR = &BR;
-    TraverseDecl(TU);
+
+    // Process all the top level declarations.
+    for (SetOfDecls::iterator I = LocalTUDecls.begin(),
+                              E = LocalTUDecls.end(); I != E; ++I)
+      TraverseDecl(*I);
 
     if (Mgr->shouldInlineCall())
-      HandleDeclsGallGraph(TU);
+      HandleDeclsGallGraph();
 
     // After all decls handled, run checkers on the entire TranslationUnit.
     checkerMgr->runCheckersOnEndOfTranslationUnit(TU, *Mgr, BR);
@@ -383,6 +422,14 @@
   Mgr.reset(NULL);
 
   if (TUTotalTimer) TUTotalTimer->stopTimer();
+
+  // Count how many basic blocks we have not covered.
+  NumBlocksInAnalyzedFunctions = FunctionSummaries.getTotalNumBasicBlocks();
+  if (NumBlocksInAnalyzedFunctions > 0)
+    PercentReachableBlocks =
+      (FunctionSummaries.getTotalNumVisitedBasicBlocks() * 100) /
+        NumBlocksInAnalyzedFunctions;
+
 }
 
 static void FindBlocks(DeclContext *D, SmallVectorImpl<Decl*> &WL) {
@@ -423,7 +470,7 @@
 }
 
 void AnalysisConsumer::HandleCode(Decl *D, AnalysisMode Mode,
-                                  SetOfDecls *VisitedCallees) {
+                                  SetOfConstDecls *VisitedCallees) {
   if (skipFunction(D))
     return;
 
@@ -457,7 +504,7 @@
 //===----------------------------------------------------------------------===//
 
 void AnalysisConsumer::ActionExprEngine(Decl *D, bool ObjCGCEnabled,
-                                        SetOfDecls *VisitedCallees) {
+                                        SetOfConstDecls *VisitedCallees) {
   // Construct the analysis engine.  First check if the CFG is valid.
   // FIXME: Inter-procedural analysis will need to handle invalid CFGs.
   if (!Mgr->getCFG(D))
@@ -488,7 +535,8 @@
   Eng.getBugReporter().FlushReports();
 }
 
-void AnalysisConsumer::RunPathSensitiveChecks(Decl *D, SetOfDecls *Visited) {
+void AnalysisConsumer::RunPathSensitiveChecks(Decl *D,
+                                              SetOfConstDecls *Visited) {
 
   switch (Mgr->getLangOpts().getGC()) {
   case LangOptions::NonGC:

Modified: cfe/branches/tooling/lib/Tooling/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Tooling/CMakeLists.txt?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Tooling/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/Tooling/CMakeLists.txt Tue Apr 17 06:08:26 2012
@@ -3,6 +3,7 @@
                    clangRewrite)
 
 add_clang_library(clangTooling
+  CompilationDatabase.cpp
   Refactoring.cpp
   Tooling.cpp
   )

Propchange: cfe/branches/tooling/lib/Tooling/CompilationDatabase.cpp
------------------------------------------------------------------------------
    svn:eol-style = LF

Propchange: cfe/branches/tooling/lib/Tooling/CompilationDatabase.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 17 06:08:26 2012
@@ -0,0 +1,2 @@
+/cfe/branches/type-system-rewrite/lib/Tooling/CompilationDatabase.cpp:134693-134817
+/cfe/trunk/test/SemaTemplate/lib/Tooling/CompilationDatabase.cpp:126920

Modified: cfe/branches/tooling/lib/Tooling/Refactoring.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Tooling/Refactoring.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Tooling/Refactoring.cpp (original)
+++ cfe/branches/tooling/lib/Tooling/Refactoring.cpp Tue Apr 17 06:08:26 2012
@@ -145,12 +145,14 @@
   return End.second - Start.second;
 }
 
-RefactoringTool::RefactoringTool(int argc, char **argv) : Tool(argc, argv) {}
+RefactoringTool::RefactoringTool(const CompilationDatabase &Compilations,
+                                 ArrayRef<std::string> SourcePaths)
+  : Tool(Compilations, SourcePaths) {}
 
 Replacements &RefactoringTool::GetReplacements() { return Replace; }
 
 int RefactoringTool::Run(FrontendActionFactory *ActionFactory) {
-  int Result = Tool.Run(ActionFactory);
+  int Result = Tool.run(ActionFactory);
   LangOptions DefaultLangOptions;
   DiagnosticOptions DefaultDiagnosticOptions;
   TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(),
@@ -158,7 +160,7 @@
   DiagnosticsEngine Diagnostics(
       llvm::IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()),
       &DiagnosticPrinter, false);
-  SourceManager Sources(Diagnostics, Tool.GetFiles());
+  SourceManager Sources(Diagnostics, Tool.getFiles());
   Rewriter Rewrite(Sources, DefaultLangOptions);
   if (!ApplyAllReplacements(Replace, Rewrite)) {
     llvm::errs() << "Skipped some replacements.\n";

Propchange: cfe/branches/tooling/lib/Tooling/Tooling.cpp
------------------------------------------------------------------------------
    svn:eol-style = LF

Propchange: cfe/branches/tooling/lib/Tooling/Tooling.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 17 06:08:26 2012
@@ -0,0 +1,2 @@
+/cfe/branches/type-system-rewrite/lib/Tooling/Tooling.cpp:134693-134817
+/cfe/trunk/test/SemaTemplate/lib/Tooling/Tooling.cpp:126920

Modified: cfe/branches/tooling/test/Analysis/CFContainers.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/CFContainers.mm?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/CFContainers.mm (original)
+++ cfe/branches/tooling/test/Analysis/CFContainers.mm Tue Apr 17 06:08:26 2012
@@ -198,3 +198,7 @@
   const void *s1 = CFArrayGetValueAtIndex(B, 2);
 
 }
+
+void TestNullArray() {
+  CFArrayGetValueAtIndex(0, 0);
+}

Modified: cfe/branches/tooling/test/Analysis/CheckNSError.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/CheckNSError.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/CheckNSError.m (original)
+++ cfe/branches/tooling/test/Analysis/CheckNSError.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
 
 
 typedef signed char BOOL;

Modified: cfe/branches/tooling/test/Analysis/NSPanel.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/NSPanel.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/NSPanel.m (original)
+++ cfe/branches/tooling/test/Analysis/NSPanel.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
 
 // BEGIN delta-debugging reduced header stuff
 

Modified: cfe/branches/tooling/test/Analysis/NSString.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/NSString.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/NSString.m (original)
+++ cfe/branches/tooling/test/Analysis/NSString.m Tue Apr 17 06:08:26 2012
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
-// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
 
 
 //===----------------------------------------------------------------------===//

Modified: cfe/branches/tooling/test/Analysis/ObjCProperties.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/ObjCProperties.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/ObjCProperties.m (original)
+++ cfe/branches/tooling/test/Analysis/ObjCProperties.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic %s -verify
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic -Wno-objc-root-class %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -Wno-objc-root-class %s -verify
 
 // The point of this test cases is to exercise properties in the static
 // analyzer

Modified: cfe/branches/tooling/test/Analysis/ObjCRetSigs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/ObjCRetSigs.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/ObjCRetSigs.m (original)
+++ cfe/branches/tooling/test/Analysis/ObjCRetSigs.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify -Wno-objc-root-class %s
 
 int printf(const char *, ...);
 

Modified: cfe/branches/tooling/test/Analysis/array-struct-region.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/array-struct-region.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/array-struct-region.c (original)
+++ cfe/branches/tooling/test/Analysis/array-struct-region.c Tue Apr 17 06:08:26 2012
@@ -25,8 +25,8 @@
 }
 
 void nested_compound_literals(int rad) {
-  int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
-                   {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+  int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},  // expected-warning 6 {{implicit conversion turns literal floating-point number into integer}}
+                   {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; // expected-warning 6 {{implicit conversion turns literal floating-point number into integer}}
   int a;
 
   for (a = 0; a < 6; ++a) {

Modified: cfe/branches/tooling/test/Analysis/dead-stores.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/dead-stores.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/dead-stores.c (original)
+++ cfe/branches/tooling/test/Analysis/dead-stores.c Tue Apr 17 06:08:26 2012
@@ -526,3 +526,25 @@
     rdar8405222_aux(i);
 }
 
+// Look through chains of assignements, e.g.: int x = y = 0, when employing
+// silencing heuristics.
+int radar11185138_foo() {
+  int x, y;
+  x = y = 0; // expected-warning {{never read}}
+  return y;
+}
+
+int rdar11185138_bar() {
+  int y;
+  int x = y = 0; // no-warning
+  x = 2;
+  y = 2;
+  return x + y;
+}
+
+int *radar11185138_baz() {
+  int *x, *y;
+  x = y = 0; // no-warning
+  return y;
+}
+

Modified: cfe/branches/tooling/test/Analysis/dead-stores.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/dead-stores.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/dead-stores.m (original)
+++ cfe/branches/tooling/test/Analysis/dead-stores.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -fblocks -verify -Wno-objc-root-class %s
 
 typedef signed char BOOL;
 typedef unsigned int NSUInteger;

Modified: cfe/branches/tooling/test/Analysis/inline-plist.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/inline-plist.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/inline-plist.c (original)
+++ cfe/branches/tooling/test/Analysis/inline-plist.c Tue Apr 17 06:08:26 2012
@@ -23,6 +23,7 @@
   has_bug(0);
 }
 
+
 // CHECK: <?xml version="1.0" encoding="UTF-8"?>
 // CHECK: <plist version="1.0">
 // CHECK: <dict>
@@ -232,6 +233,8 @@
 // CHECK:    <key>description</key><string>Division by zero</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Division by zero</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>foo</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>14</integer>
@@ -312,7 +315,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>19</integer>
-// CHECK:            <key>col</key><integer>4</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -352,6 +355,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>has_bug</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>19</integer>

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/inline-unique-reports.c (original)
+++ cfe/branches/tooling/test/Analysis/inline-unique-reports.c Tue Apr 17 06:08:26 2012
@@ -34,12 +34,12 @@
 // CHECK:         <key>start</key>
 // CHECK:          <array>
 // CHECK:           <dict>
-// CHECK:            <key>line</key><integer>14</integer>
+// CHECK:            <key>line</key><integer>9</integer>
 // CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:           <dict>
-// CHECK:            <key>line</key><integer>14</integer>
+// CHECK:            <key>line</key><integer>9</integer>
 // CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
@@ -47,12 +47,12 @@
 // CHECK:         <key>end</key>
 // CHECK:          <array>
 // CHECK:           <dict>
-// CHECK:            <key>line</key><integer>15</integer>
+// 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>15</integer>
+// CHECK:            <key>line</key><integer>10</integer>
 // CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
@@ -64,7 +64,7 @@
 // CHECK:      <key>kind</key><string>event</string>
 // CHECK:      <key>location</key>
 // CHECK:      <dict>
-// CHECK:       <key>line</key><integer>15</integer>
+// CHECK:       <key>line</key><integer>10</integer>
 // CHECK:       <key>col</key><integer>3</integer>
 // CHECK:       <key>file</key><integer>0</integer>
 // CHECK:      </dict>
@@ -72,12 +72,12 @@
 // CHECK:      <array>
 // CHECK:        <array>
 // CHECK:         <dict>
-// CHECK:          <key>line</key><integer>15</integer>
+// 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>15</integer>
+// CHECK:          <key>line</key><integer>10</integer>
 // CHECK:          <key>col</key><integer>8</integer>
 // CHECK:          <key>file</key><integer>0</integer>
 // CHECK:         </dict>
@@ -99,9 +99,9 @@
 // CHECK:      </dict>
 // CHECK:      <key>depth</key><integer>1</integer>
 // CHECK:      <key>extended_message</key>
-// CHECK:      <string>Entered call from 'test_bug_2'</string>
+// CHECK:      <string>Entered call from 'test_bug_1'</string>
 // CHECK:      <key>message</key>
-// CHECK: <string>Entered call from 'test_bug_2'</string>
+// CHECK: <string>Entered call from 'test_bug_1'</string>
 // CHECK:     </dict>
 // CHECK:     <dict>
 // CHECK:      <key>kind</key><string>control</string>
@@ -130,7 +130,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>5</integer>
-// CHECK:            <key>col</key><integer>4</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -170,6 +170,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>bug</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>5</integer>

Modified: cfe/branches/tooling/test/Analysis/malloc-plist.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc-plist.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc-plist.c (original)
+++ cfe/branches/tooling/test/Analysis/malloc-plist.c Tue Apr 17 06:08:26 2012
@@ -306,6 +306,8 @@
 // CHECK:    <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'p'</string>
 // CHECK:    <key>category</key><string>Memory Error</string>
 // CHECK:    <key>type</key><string>Memory leak</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>diagnosticTest</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>14</integer>
@@ -465,6 +467,8 @@
 // CHECK:    <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'A'</string>
 // CHECK:    <key>category</key><string>Memory Error</string>
 // CHECK:    <key>type</key><string>Memory leak</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>myArrayAllocation</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>21</integer>
@@ -862,6 +866,8 @@
 // CHECK:    <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'buf'</string>
 // CHECK:    <key>category</key><string>Memory Error</string>
 // CHECK:    <key>type</key><string>Memory leak</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>reallocDiagnostics</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>28</integer>
@@ -1258,6 +1264,8 @@
 // CHECK:    <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'buf'</string>
 // CHECK:    <key>category</key><string>Memory Error</string>
 // CHECK:    <key>type</key><string>Memory leak</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_wrapper</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>45</integer>
@@ -1775,6 +1783,8 @@
 // CHECK:    <key>description</key><string>Use of memory after it is freed</string>
 // CHECK:    <key>category</key><string>Memory Error</string>
 // CHECK:    <key>type</key><string>Use-after-free</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_double_action_call</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>61</integer>
@@ -2346,6 +2356,8 @@
 // CHECK:    <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'buf'</string>
 // CHECK:    <key>category</key><string>Memory Error</string>
 // CHECK:    <key>type</key><string>Memory leak</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>reallocIntra</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>76</integer>
@@ -2611,6 +2623,8 @@
 // CHECK:    <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'v'</string>
 // CHECK:    <key>category</key><string>Memory Error</string>
 // CHECK:    <key>type</key><string>Memory leak</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>use_ret</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>86</integer>
@@ -2785,6 +2799,8 @@
 // CHECK:    <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'm'</string>
 // CHECK:    <key>category</key><string>Memory Error</string>
 // CHECK:    <key>type</key><string>Memory leak</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>LeakedSymbol</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>97</integer>
@@ -2795,3 +2811,4 @@
 // CHECK:  </array>
 // CHECK: </dict>
 // CHECK: </plist>
+

Modified: cfe/branches/tooling/test/Analysis/malloc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc.m (original)
+++ cfe/branches/tooling/test/Analysis/malloc.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class %s
 #include "system-header-simulator-objc.h"
 
 @class NSString;

Modified: cfe/branches/tooling/test/Analysis/malloc.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc.mm?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc.mm (original)
+++ cfe/branches/tooling/test/Analysis/malloc.mm Tue Apr 17 06:08:26 2012
@@ -136,3 +136,21 @@
     OSAtomicEnqueue(pool, newItem, 4);
 }
 
+// Pointer might escape through CGDataProviderCreateWithData (radar://11187558).
+typedef struct CGDataProvider *CGDataProviderRef;
+typedef void (*CGDataProviderReleaseDataCallback)(void *info, const void *data,
+    size_t size);
+extern CGDataProviderRef CGDataProviderCreateWithData(void *info,
+    const void *data, size_t size,
+    CGDataProviderReleaseDataCallback releaseData)
+    __attribute__((visibility("default")));
+void *calloc(size_t, size_t);
+
+static void releaseDataCallback (void *info, const void *data, size_t size) {
+#pragma unused (info, size)
+  free((void*)data);
+}
+void testCGDataProviderCreateWithData() { 
+  void* b = calloc(8, 8);
+  CGDataProviderRef p = CGDataProviderCreateWithData(0, b, 8*8, releaseDataCallback);
+}
\ No newline at end of file

Modified: cfe/branches/tooling/test/Analysis/misc-ps-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/misc-ps-cxx0x.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/misc-ps-cxx0x.cpp (original)
+++ cfe/branches/tooling/test/Analysis/misc-ps-cxx0x.cpp Tue Apr 17 06:08:26 2012
@@ -68,3 +68,8 @@
   *p = 0xDEADBEEF;  // no-warning
 }
 
+// Do not crash on the following when constructing the
+// callgraph.
+struct RDar11178609 {
+  ~RDar11178609() = delete;
+};

Modified: cfe/branches/tooling/test/Analysis/misc-ps-region-store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/misc-ps-region-store.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/misc-ps-region-store.cpp (original)
+++ cfe/branches/tooling/test/Analysis/misc-ps-region-store.cpp Tue Apr 17 06:08:26 2012
@@ -568,3 +568,13 @@
 void PR11146::baz() {
   (void) &Entry::x;
 }
+
+// Test symbolicating a reference.  In this example, the
+// analyzer (originally) didn't know how to handle x[index - index2],
+// returning an UnknownVal.  The conjured symbol wasn't a location,
+// and would result in a crash.
+void rdar10924675(unsigned short x[], int index, int index2) {
+  unsigned short &y = x[index - index2];
+  if (y == 0)
+    return;
+}

Modified: cfe/branches/tooling/test/Analysis/misc-ps-region-store.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/misc-ps-region-store.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/misc-ps-region-store.m (original)
+++ cfe/branches/tooling/test/Analysis/misc-ps-region-store.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks   -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks   -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
 
 typedef long unsigned int size_t;
 void *memcpy(void *, const void *, size_t);

Modified: cfe/branches/tooling/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/misc-ps.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/misc-ps.m (original)
+++ cfe/branches/tooling/test/Analysis/misc-ps.m Tue Apr 17 06:08:26 2012
@@ -1,8 +1,8 @@
 // NOTE: Use '-fobjc-gc' to test the analysis being run twice, and multiple reports are not issued.
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
 
 #ifndef __clang_analyzer__
 #error __clang_analyzer__ not defined

Modified: cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m (original)
+++ cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=range -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=range -analyzer-store=region -verify -Wno-objc-root-class %s
 
 // <rdar://problem/6888289> - This test case shows that a nil instance
 // variable can possibly be initialized by a method.

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=154919&r1=154918&r2=154919&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 Apr 17 06:08:26 2012
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin8 %s
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s
-// RUN: %clang_cc1 -triple thumbv6-apple-ios4.0 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s
+// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin8 %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin9 %s
+// RUN: %clang_cc1 -triple thumbv6-apple-ios4.0 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin9 %s
 
 @interface MyClass {}
 - (void *)voidPtrM;

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/plist-output-alternate.m (original)
+++ cfe/branches/tooling/test/Analysis/plist-output-alternate.m Tue Apr 17 06:08:26 2012
@@ -95,7 +95,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>6</integer>
-// CHECK:            <key>col</key><integer>4</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -125,6 +125,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -134,6 +135,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_init</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>6</integer>
@@ -171,7 +174,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>12</integer>
-// CHECK:            <key>col</key><integer>4</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -201,6 +204,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -210,6 +214,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_assign</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>12</integer>
@@ -247,7 +253,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>19</integer>
-// CHECK:            <key>col</key><integer>4</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -277,6 +283,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'q')</string>
 // CHECK:      <key>message</key>
@@ -286,6 +293,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'q')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_assign_transitive</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>19</integer>
@@ -353,6 +362,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Assuming 'p' is null</string>
 // CHECK:      <key>message</key>
@@ -385,7 +395,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>24</integer>
-// CHECK:            <key>col</key><integer>6</integer>
+// CHECK:            <key>col</key><integer>5</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -415,6 +425,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -424,6 +435,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_cond</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>24</integer>
@@ -529,7 +542,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>31</integer>
-// CHECK:            <key>col</key><integer>6</integer>
+// CHECK:            <key>col</key><integer>5</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -559,6 +572,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -568,6 +582,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_cond_transitive</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>31</integer>
@@ -639,7 +655,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>38</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>
@@ -669,6 +685,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from field 'p')</string>
 // CHECK:      <key>message</key>
@@ -678,6 +695,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from field 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_field</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>38</integer>
@@ -779,6 +798,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count</string>
 // CHECK:      <key>message</key>
@@ -928,6 +948,7 @@
 // CHECK:       <key>col</key><integer>1</integer>
 // CHECK:       <key>file</key><integer>0</integer>
 // CHECK:      </dict>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // 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:      <key>message</key>
@@ -937,6 +958,8 @@
 // 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>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>rdar8331641</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>58</integer>

Modified: cfe/branches/tooling/test/Analysis/plist-output.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/plist-output.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/plist-output.m (original)
+++ cfe/branches/tooling/test/Analysis/plist-output.m Tue Apr 17 06:08:26 2012
@@ -118,7 +118,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>6</integer>
-// CHECK:            <key>col</key><integer>4</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -148,6 +148,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -157,6 +158,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_init</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>6</integer>
@@ -194,7 +197,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>12</integer>
-// CHECK:            <key>col</key><integer>4</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -224,6 +227,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -233,6 +237,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_assign</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>12</integer>
@@ -270,7 +276,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>19</integer>
-// CHECK:            <key>col</key><integer>4</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -300,6 +306,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'q')</string>
 // CHECK:      <key>message</key>
@@ -309,6 +316,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'q')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_assign_transitive</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>19</integer>
@@ -376,6 +385,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Assuming 'p' is null</string>
 // CHECK:      <key>message</key>
@@ -408,7 +418,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>24</integer>
-// CHECK:            <key>col</key><integer>6</integer>
+// CHECK:            <key>col</key><integer>5</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -438,6 +448,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -447,6 +458,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_cond</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>24</integer>
@@ -552,7 +565,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>32</integer>
-// CHECK:            <key>col</key><integer>6</integer>
+// CHECK:            <key>col</key><integer>5</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -582,6 +595,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -591,6 +605,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_cond_transitive</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>32</integer>
@@ -662,7 +678,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>39</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>
@@ -692,6 +708,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from field 'p')</string>
 // CHECK:      <key>message</key>
@@ -701,6 +718,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from field 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_null_field</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>39</integer>
@@ -874,7 +893,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>51</integer>
-// CHECK:            <key>col</key><integer>4</integer>
+// CHECK:            <key>col</key><integer>3</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -904,6 +923,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -913,6 +933,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_assumptions</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>51</integer>
@@ -1014,6 +1036,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Assuming 'p' is null</string>
 // CHECK:      <key>message</key>
@@ -1110,6 +1133,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -1119,6 +1143,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>function</string>
+// CHECK:   <key>issue_context</key><string>test_cond_assign</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>59</integer>
@@ -1258,7 +1284,7 @@
 // CHECK:           </dict>
 // CHECK:           <dict>
 // CHECK:            <key>line</key><integer>78</integer>
-// CHECK:            <key>col</key><integer>6</integer>
+// CHECK:            <key>col</key><integer>5</integer>
 // CHECK:            <key>file</key><integer>0</integer>
 // CHECK:           </dict>
 // CHECK:          </array>
@@ -1288,6 +1314,7 @@
 // CHECK:         </dict>
 // CHECK:        </array>
 // CHECK:      </array>
+// CHECK:      <key>depth</key><integer>0</integer>
 // CHECK:      <key>extended_message</key>
 // CHECK:      <string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:      <key>message</key>
@@ -1297,6 +1324,8 @@
 // CHECK:    <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
 // CHECK:    <key>category</key><string>Logic error</string>
 // CHECK:    <key>type</key><string>Dereference of null pointer</string>
+// CHECK:   <key>issue_context_kind</key><string>Objective-C method</string>
+// CHECK:   <key>issue_context</key><string>test</string>
 // CHECK:   <key>location</key>
 // CHECK:   <dict>
 // CHECK:    <key>line</key><integer>78</integer>
@@ -1308,4 +1337,3 @@
 // CHECK: </dict>
 // CHECK: </plist>
 
-

Modified: cfe/branches/tooling/test/Analysis/pr_2542_rdar_6793404.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/pr_2542_rdar_6793404.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/pr_2542_rdar_6793404.m (original)
+++ cfe/branches/tooling/test/Analysis/pr_2542_rdar_6793404.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -pedantic -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -pedantic -analyzer-store=region -verify -Wno-objc-root-class %s
 
 // BEGIN delta-debugging reduced header stuff
 

Modified: cfe/branches/tooling/test/Analysis/properties.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/properties.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/properties.m (original)
+++ cfe/branches/tooling/test/Analysis/properties.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -Wno-objc-root-class %s
 
 typedef signed char BOOL;
 typedef unsigned int NSUInteger;

Modified: cfe/branches/tooling/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m (original)
+++ cfe/branches/tooling/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -verify -Wno-objc-root-class %s
 
 typedef struct Foo { int x; } Bar;
 

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/retain-release-gc-only.m (original)
+++ cfe/branches/tooling/test/Analysis/retain-release-gc-only.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.NSAutoreleasePool -analyzer-store=region -fobjc-gc-only -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.NSAutoreleasePool -analyzer-store=region -fobjc-gc-only -fblocks -verify -Wno-objc-root-class %s
 
 //===----------------------------------------------------------------------===//
 // Header stuff.

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/retain-release.m (original)
+++ cfe/branches/tooling/test/Analysis/retain-release.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -x objective-c++ %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -x objective-c++ -Wno-objc-root-class %s
 
 #if __has_feature(attribute_ns_returns_retained)
 #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))

Modified: cfe/branches/tooling/test/Analysis/unused-ivars.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/unused-ivars.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/unused-ivars.m (original)
+++ cfe/branches/tooling/test/Analysis/unused-ivars.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=osx.cocoa.UnusedIvars %s -verify
+// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=osx.cocoa.UnusedIvars -verify -Wno-objc-root-class %s
 
 //===--- BEGIN: Delta-debugging reduced headers. --------------------------===//
 

Modified: cfe/branches/tooling/test/Analysis/variadic-method-types.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/variadic-method-types.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/variadic-method-types.m (original)
+++ cfe/branches/tooling/test/Analysis/variadic-method-types.m Tue Apr 17 06:08:26 2012
@@ -57,6 +57,12 @@
 + (id)setWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
 - (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
 @end
+ at interface NSOrderedSet : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+ at end
+ at interface NSOrderedSet (NSOrderedSetCreation)
++ (id)orderedSetWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+ at end
 @protocol P;
 @class C;
 
@@ -71,6 +77,7 @@
   [NSArray arrayWithObjects:@"Foo", "Bar", "Baz", nil]; // expected-warning 2 {{Argument to 'NSArray' method 'arrayWithObjects:' should be an Objective-C pointer type, not 'char *'}}
   [NSDictionary dictionaryWithObjectsAndKeys:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSDictionary' method 'dictionaryWithObjectsAndKeys:' should be an Objective-C pointer type, not 'char *'}}
   [NSSet setWithObjects:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSSet' method 'setWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+  [NSOrderedSet orderedSetWithObjects:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSOrderedSet' method 'orderedSetWithObjects:' should be an Objective-C pointer type, not 'char *'}}
 
   [[[NSArray alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSArray' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
   [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSDictionary' method 'initWithObjectsAndKeys:' should be an Objective-C pointer type, not 'char *'}}
@@ -79,6 +86,7 @@
   [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", fooType, nil] autorelease]; // no-warning
   [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", barType, nil] autorelease]; // expected-warning {{Argument to 'NSDictionary' method 'initWithObjectsAndKeys:' should be an Objective-C pointer type, not 'BarType'}}
   [[[NSSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSSet' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+  [[[NSOrderedSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSOrderedSet' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
 }
 
 // This previously crashed the variadic argument checker.

Modified: cfe/branches/tooling/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CMakeLists.txt?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CMakeLists.txt (original)
+++ cfe/branches/tooling/test/CMakeLists.txt Tue Apr 17 06:08:26 2012
@@ -112,6 +112,7 @@
   add_dependencies(clang-test.deps
                  clang clang-headers c-index-test diagtool
                  arcmt-test c-arcmt-test remove-cstr-calls
+                 clang-check
                  )
 
 endif()

Modified: cfe/branches/tooling/test/CXX/class.access/class.protected/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/class.access/class.protected/p1.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/class.access/class.protected/p1.cpp (original)
+++ cfe/branches/tooling/test/CXX/class.access/class.protected/p1.cpp Tue Apr 17 06:08:26 2012
@@ -68,7 +68,7 @@
 
 namespace test2 {
   class A {
-    protected: int x; // expected-note 3 {{object type must derive}}
+    protected: int x; // expected-note 3 {{can only access this member on an object of type}}
     static int sx;
     static void test(A&);
   };
@@ -103,7 +103,7 @@
 namespace test3 {
   class B;
   class A {
-    protected: int x; // expected-note {{object type must derive}}
+    protected: int x; //expected-note {{declared protected}} // expected-note {{can only access this member on an object of type}}
     static int sx;
     static void test(B&);
   };
@@ -130,7 +130,7 @@
     (void) b.sx;
   }
   void D::test(B &b) {
-    (void) b.x;
+    (void) b.x; // expected-error {{'x' is a protected member}}
     (void) b.sx;
   }
 }
@@ -138,7 +138,7 @@
 namespace test4 {
   class C;
   class A {
-    protected: int x; // expected-note {{declared}} expected-note 2 {{object type must derive}}
+    protected: int x; // expected-note 2{{declared protected here}} expected-note{{member is declared here}}
     static int sx;    // expected-note 3{{member is declared here}}
     static void test(C&);
   };
@@ -215,7 +215,7 @@
   class Static {};
   class A {
   protected:
-    void foo(int); // expected-note 3 {{object type must derive}}
+    void foo(int); // expected-note 3 {{can only access this member on an object of type}}
     void foo(long);
     static void foo(Static);
 
@@ -253,7 +253,7 @@
   class Static {};
   class A {
     protected:
-    void foo(int); // expected-note 3 {{object type must derive}}
+    void foo(int); // expected-note 3 {{must name member using the type of the current context}}
     void foo(long);
     static void foo(Static);
 
@@ -291,7 +291,7 @@
   class Static {};
   class A {
     protected:
-    void foo(int); // expected-note 3 {{object type must derive}}
+    void foo(int); // expected-note 3 {{must name member using the type of the current context}}
     void foo(long);
     static void foo(Static);
 
@@ -329,7 +329,7 @@
 
 namespace test9 {
   class A { // expected-note {{member is declared here}}
-  protected: int foo(); // expected-note 4 {{declared}} expected-note 2 {{object type must derive}} expected-note {{object type 'test9::A' must derive}}
+  protected: int foo(); // expected-note 4 {{declared}} expected-note 2 {{can only access this member on an object of type}} expected-note {{member is declared here}}
   };
 
   class B : public A { // expected-note {{member is declared here}}
@@ -423,7 +423,7 @@
 // This friendship is not considered because a public member of A is
 // inaccessible in C.
 namespace test13 {
-  class A { protected: int foo(); }; // expected-note {{object type 'test13::D' must derive from context type 'test13::C'}}
+  class A { protected: int foo(); }; // expected-note {{can only access this member on an object of type}}
   class B : private virtual A {};
   class C : private B { friend void test(); };
   class D : public virtual A {};
@@ -433,3 +433,87 @@
     d.A::foo(); // expected-error {{protected member}}
   }
 }
+
+// PR8058
+namespace test14 {
+  class A {
+  protected:
+    template <class T> void temp(T t); // expected-note {{must name member using the type of the current context}}
+
+    void nontemp(int); // expected-note {{must name member using the type of the current context}}
+
+    template <class T> void ovl_temp(T t); // expected-note {{must name member using the type of the current context}}
+    void ovl_temp(float);
+
+    void ovl_nontemp(int); // expected-note {{must name member using the type of the current context}}
+    void ovl_nontemp(float);
+
+    template <class T> void ovl_withtemp(T);
+    void ovl_withtemp(int); // expected-note {{must name member using the type of the current context}}
+  };
+
+  class B : public A {
+    void use() {
+      void (A::*ptr)(int);
+      ptr = &A::temp; // expected-error {{protected member}}
+      ptr = &A::nontemp; // expected-error {{protected member}}
+      ptr = &A::ovl_temp; // expected-error {{protected member}}
+      ptr = &A::ovl_nontemp; // expected-error {{protected member}}
+      ptr = &A::ovl_withtemp; // expected-error {{protected member}}
+    }
+  };
+}
+
+namespace test15 {
+  class A {
+  protected:
+    A(); // expected-note 2 {{protected constructor can only be used to construct a base class subobject}}
+    A(const A &); // expected-note {{protected constructor can only be used to construct a base class subobject}}
+    ~A(); // expected-note 3 {{protected destructor can only be used to destroy a base class subobject}}
+  };
+
+  class B : public A {
+    // The uses here are fine.
+    B() {}
+    B(int i) : A() {}
+    ~B() {}
+
+    // All these uses are bad.
+
+    void test0() {
+      A a; // expected-error {{protected constructor}} expected-error {{protected destructor}}
+    }
+
+    A *test1() {
+      return new A(); // expected-error {{protected constructor}}
+    }
+
+    void test2(A *a) {
+      delete a; // expected-error {{protected destructor}}
+    }
+
+    A test3(A *a) {
+      return *a; // expected-error {{protected constructor}}
+    }
+
+    void test4(A *a) {
+      a->~A(); // expected-error {{protected member}}
+    }
+  };
+}
+
+namespace test16 {
+  class A {
+  protected:
+    ~A();
+  };
+
+  class B : public virtual A {
+  public:
+    ~B() {}
+  };
+
+  class C : public B {
+    ~C() {}
+  };
+}

Modified: cfe/branches/tooling/test/CXX/class.access/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/class.access/p4.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/class.access/p4.cpp (original)
+++ cfe/branches/tooling/test/CXX/class.access/p4.cpp Tue Apr 17 06:08:26 2012
@@ -372,7 +372,7 @@
     int private_foo; // expected-note {{declared private here}}
     static int private_sfoo; // expected-note {{declared private here}}
   protected:
-    int protected_foo; // expected-note 3 {{declared protected here}} // expected-note {{object type must derive from context type 'test15::B<int>'}}
+    int protected_foo; // expected-note 3 {{declared protected here}} // expected-note {{can only access this member on an object of type 'test15::B<int>'}}
     static int protected_sfoo; // expected-note 3 {{declared protected here}}
 
     int test1(A<int> &a) {

Modified: cfe/branches/tooling/test/CXX/class/class.nest/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/class/class.nest/p1.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/class/class.nest/p1.cpp (original)
+++ cfe/branches/tooling/test/CXX/class/class.nest/p1.cpp Tue Apr 17 06:08:26 2012
@@ -5,9 +5,9 @@
   static int sx;
   int f();
 
-  // C++0x does relax this rule (see 5.1.1.10) in the first case, but we need to enforce it in C++03 mode.
+  // C++11 does relax this rule (see 5.1.1.10) in the first case, but we need to enforce it in C++03 mode.
   class Inner {
-    static char a[sizeof(x)]; // expected-error {{invalid use of nonstatic data member 'x'}}
+    static char a[sizeof(x)]; // expected-error {{invalid use of non-static data member 'x'}}
     static char b[sizeof(sx)]; // okay
     static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}}
   };

Modified: cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp (original)
+++ cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp Tue Apr 17 06:08:26 2012
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fcxx-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -fcxx-exceptions -Wno-invalid-constexpr %s
 
 namespace StdExample {
 

Modified: cfe/branches/tooling/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp (original)
+++ cfe/branches/tooling/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp Tue Apr 17 06:08:26 2012
@@ -1,5 +1,17 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
 
 void f0() {
   int &ir = { 17 }; // expected-error{{reference to type 'int' cannot bind to an initializer list}}
 }
+
+namespace PR12453 {
+  template<typename T>
+  void f(int i) {
+    T x{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \
+    // expected-note{{override this message by inserting an explicit cast}}
+    T y{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \
+    // expected-note{{override this message by inserting an explicit cast}}
+  }
+
+  template void f<float>(int); // expected-note{{in instantiation of function template specialization 'PR12453::f<float>' requested here}}
+}

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=154919&r1=154918&r2=154919&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 Apr 17 06:08:26 2012
@@ -26,7 +26,7 @@
 }
 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& m = typeid(*(Poly*)S::m); // expected-error {{invalid use of non-static data member}}
 const std::type_info& n = typeid(*(Poly*)(0*sizeof S::m)); 
 
 namespace PR11956 {

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=154919&r1=154918&r2=154919&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 Apr 17 06:08:26 2012
@@ -2,9 +2,9 @@
 
 struct S {
   S *p = this; // ok
-  decltype(this) q; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+  decltype(this) q; // expected-error {{invalid use of 'this' outside of a non-static member function}}
 
-  int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+  int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a non-static member function}}
   int sz = sizeof(this); // ok
 };
 

Modified: cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp (original)
+++ cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp Tue Apr 17 06:08:26 2012
@@ -27,7 +27,7 @@
 
       static void static_bar() {
         (void)[this](){}; // expected-error{{'this' cannot be captured in this context}}
-        (void)[&](){i = 7; }; // expected-error{{invalid use of nonstatic data member 'i'}}
+        (void)[&](){i = 7; }; // expected-error{{invalid use of member 'i' in static member function}}
       }
     };
   }

Modified: cfe/branches/tooling/test/CXX/special/class.free/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.free/p1.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.free/p1.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.free/p1.cpp Tue Apr 17 06:08:26 2012
@@ -3,9 +3,9 @@
 
 struct A {
   void *operator new(size_t) {
-    return this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+    return this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
   }
   void *operator new[](size_t) {
-    return this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+    return this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
   }
 };

Modified: cfe/branches/tooling/test/CXX/special/class.free/p6.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.free/p6.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.free/p6.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.free/p6.cpp Tue Apr 17 06:08:26 2012
@@ -3,9 +3,9 @@
 
 struct A {
   void operator delete(void*) {
-    (void)this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+    (void)this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
   }
   void operator delete[](void*) {
-    (void)this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+    (void)this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
   }
 };

Modified: cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp (original)
+++ cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp Tue Apr 17 06:08:26 2012
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu %s
 
-// C++0x [temp.arg.nontype]p1:
+// C++11 [temp.arg.nontype]p1:
 //
 //   A template-argument for a non-type, non-template template-parameter shall
 //   be one of:
@@ -19,27 +19,65 @@
   template <typename T, int (T::* M)(int)> X5<T, M>::X5() { }
 }
 
-//   -- the address of an object or function with external linkage, including
-//      function templates and function template-ids but excluding non-static
-//      class members, expressed as & id-expression where the & is optional if
-//      the name refers to a function or array, or if the corresponding
-//      template-parameter is a reference; or
+//   -- a constant expression that designates the address of an object with
+//      static storage duration and external or internal linkage or a function
+//      with external or internal linkage, including function templates and
+//      function template-ids, but excluting non-static class members, expressed
+//      (ignoring parentheses) as & id-expression, except that the & may be
+//      omitted if the name refers to a function or array and shall be omitted
+//      if the corresopnding template-parameter is a reference; or
 namespace addr_of_obj_or_func {
-  template <int* p> struct X0 { };
+  template <int* p> struct X0 { }; // expected-note 4{{here}}
   template <int (*fp)(int)> struct X1 { };
-  // FIXME: Add reference template parameter tests.
+  template <int &p> struct X2 { }; // expected-note 4{{here}}
+  template <const int &p> struct X2k { }; // expected-note {{here}}
+  template <int (&fp)(int)> struct X3 { }; // expected-note 4{{here}}
 
   int i = 42;
   int iarr[10];
   int f(int i);
+  const int ki = 9; // expected-note 5{{here}}
+  __thread int ti = 100; // expected-note 2{{here}}
+  static int f_internal(int); // expected-note 4{{here}}
   template <typename T> T f_tmpl(T t);
+
   void test() {
-    X0<&i> x0a;
+    X0<i> x0a; // expected-error {{must have its address taken}}
+    X0<&i> x0a_addr;
     X0<iarr> x0b;
-    X1<&f> x1a;
-    X1<f> x1b;
-    X1<f_tmpl> x1c;
-    X1<f_tmpl<int> > x1d;
+    X0<&iarr> x0b_addr; // expected-error {{cannot be converted to a value of type 'int *'}}
+    X0<ki> x0c; // expected-error {{must have its address taken}} expected-warning {{internal linkage is a C++11 extension}}
+    X0<&ki> x0c_addr; // expected-error {{cannot be converted to a value of type 'int *'}} expected-warning {{internal linkage is a C++11 extension}}
+    X0<&ti> x0d_addr; // expected-error {{refers to thread-local object}}
+    X1<f> x1a;
+    X1<&f> x1a_addr;
+    X1<f_tmpl> x1b;
+    X1<&f_tmpl> x1b_addr;
+    X1<f_tmpl<int> > x1c;
+    X1<&f_tmpl<int> > x1c_addr;
+    X1<f_internal> x1d; // expected-warning {{internal linkage is a C++11 extension}}
+    X1<&f_internal> x1d_addr; // expected-warning {{internal linkage is a C++11 extension}}
+    X2<i> x2a;
+    X2<&i> x2a_addr; // expected-error {{address taken}}
+    X2<iarr> x2b; // expected-error {{cannot bind to template argument of type 'int [10]'}}
+    X2<&iarr> x2b_addr; // expected-error {{address taken}}
+    X2<ki> x2c; // expected-error {{ignores qualifiers}} expected-warning {{internal linkage is a C++11 extension}}
+    X2k<ki> x2kc; // expected-warning {{internal linkage is a C++11 extension}}
+    X2k<&ki> x2kc_addr; // expected-error {{address taken}} expected-warning {{internal linkage is a C++11 extension}}
+    X2<ti> x2d_addr; // expected-error {{refers to thread-local object}}
+    X3<f> x3a;
+    X3<&f> x3a_addr; // expected-error {{address taken}}
+    X3<f_tmpl> x3b;
+    X3<&f_tmpl> x3b_addr; // expected-error {{address taken}}
+    X3<f_tmpl<int> > x3c;
+    X3<&f_tmpl<int> > x3c_addr; // expected-error {{address taken}}
+    X3<f_internal> x3d; // expected-warning {{internal linkage is a C++11 extension}}
+    X3<&f_internal> x3d_addr; // expected-error {{address taken}} expected-warning {{internal linkage is a C++11 extension}}
+
+    int n; // expected-note {{here}}
+    X0<&n> x0_no_linkage; // expected-error {{non-type template argument refers to object 'n' that does not have linkage}}
+    struct Local { static int f() {} }; // expected-note {{here}}
+    X1<&Local::f> x1_no_linkage; // expected-error {{non-type template argument refers to function 'f' that does not have linkage}}
   }
 }
 

Modified: cfe/branches/tooling/test/CXX/temp/temp.spec/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/temp/temp.spec/p5.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/temp/temp.spec/p5.cpp (original)
+++ cfe/branches/tooling/test/CXX/temp/temp.spec/p5.cpp Tue Apr 17 06:08:26 2012
@@ -14,9 +14,10 @@
 };
 
 template<typename T>
-T X0<T>::value = 3.14;
+T X0<T>::value = 3.14; // expected-warning{{implicit conversion turns literal floating-point number into integer}}
 
-template struct X0<int>; // expected-note{{previous explicit instantiation}}
+template struct X0<int>; // expected-note{{previous explicit instantiation}} \
+                            expected-note{{requested here}}
 template struct X0<int>; // expected-error{{duplicate explicit instantiation}}
 
 template void X0<float>::f(float); // expected-note{{previous explicit instantiation}}

Modified: cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp Tue Apr 17 06:08:26 2012
@@ -33,7 +33,7 @@
 template<> void N0::f0(int) { } // okay
 
 namespace N1 {
-  template<> void N0::f0(long) { } // expected-error{{not in a namespace enclosing}}
+  template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}}
 }
 
 template<> void N0::f0(double) { }
@@ -129,7 +129,7 @@
 template<> float N0::X0<float>::member = 3.14f;
 
 namespace N1 {
-  template<> double N0::X0<double>::member = 3.14; // expected-error{{not in a namespace enclosing}}
+  template<> double N0::X0<double>::member = 3.14; // expected-error{{does not enclose namespace}}
 }
 
 //    -- member class of a class template
@@ -227,7 +227,7 @@
 
 namespace N1 {
   template<> template<>
-  void N0::X0<void*>::ft1(void *, long) { } // expected-error{{enclosing}}
+  void N0::X0<void*>::ft1(void *, long) { } // expected-error{{does not enclose namespace}}
 }
 
 

Modified: cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp (original)
+++ cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp Tue Apr 17 06:08:26 2012
@@ -33,7 +33,7 @@
 template<> void N0::f0(int) { } // okay
 
 namespace N1 {
-  template<> void N0::f0(long) { } // expected-error{{not in a namespace enclosing}}
+  template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}}
 }
 
 template<> void N0::f0(double); // expected-warning{{C++11 extension}}
@@ -130,7 +130,7 @@
 template<> float N0::X0<float>::member = 3.14f;
 
 namespace N1 {
-  template<> double N0::X0<double>::member = 3.14; // expected-error{{not in a namespace enclosing}}
+  template<> double N0::X0<double>::member = 3.14; // expected-error{{does not enclose namespace}}
 }
 
 //    -- member class of a class template
@@ -228,7 +228,7 @@
 
 namespace N1 {
   template<> template<>
-  void N0::X0<void*>::ft1(void *, long) { } // expected-error{{enclosing}}
+  void N0::X0<void*>::ft1(void *, long) { } // expected-error{{does not enclose namespace}}
 }
 
 

Modified: cfe/branches/tooling/test/CodeGen/atomic-ops.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/atomic-ops.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/atomic-ops.c (original)
+++ cfe/branches/tooling/test/CodeGen/atomic-ops.c Tue Apr 17 06:08:26 2012
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | FileCheck %s
 
-// Basic IRGen tests for __atomic_*
+// Also test serialization of atomic operations here, to avoid duplicating the
+// test.
+// RUN: %clang_cc1 %s -emit-pch -o %t -triple=i686-apple-darwin9
+// RUN: %clang_cc1 %s -include-pch %t -triple=i686-apple-darwin9 -emit-llvm -o - | FileCheck %s
+#ifndef ALREADY_INCLUDED
+#define ALREADY_INCLUDED
 
-// FIXME: Need to implement __atomic_is_lock_free
+// Basic IRGen tests for __c11_atomic_* and GNU __atomic_*
 
 typedef enum memory_order {
   memory_order_relaxed, memory_order_consume, memory_order_acquire,
@@ -12,74 +17,215 @@
 int fi1(_Atomic(int) *i) {
   // CHECK: @fi1
   // CHECK: load atomic i32* {{.*}} seq_cst
-  return __atomic_load(i, memory_order_seq_cst);
+  return __c11_atomic_load(i, memory_order_seq_cst);
+}
+
+int fi1a(int *i) {
+  // CHECK: @fi1a
+  // CHECK: load atomic i32* {{.*}} seq_cst
+  int v;
+  __atomic_load(i, &v, memory_order_seq_cst);
+  return v;
+}
+
+int fi1b(int *i) {
+  // CHECK: @fi1b
+  // CHECK: load atomic i32* {{.*}} seq_cst
+  return __atomic_load_n(i, memory_order_seq_cst);
 }
 
 void fi2(_Atomic(int) *i) {
   // CHECK: @fi2
   // CHECK: store atomic i32 {{.*}} seq_cst
-  __atomic_store(i, 1, memory_order_seq_cst);
+  __c11_atomic_store(i, 1, memory_order_seq_cst);
+}
+
+void fi2a(int *i) {
+  // CHECK: @fi2a
+  // CHECK: store atomic i32 {{.*}} seq_cst
+  int v = 1;
+  __atomic_store(i, &v, memory_order_seq_cst);
 }
 
-void fi3(_Atomic(int) *i) {
+void fi2b(int *i) {
+  // CHECK: @fi2b
+  // CHECK: store atomic i32 {{.*}} seq_cst
+  __atomic_store_n(i, 1, memory_order_seq_cst);
+}
+
+int fi3(_Atomic(int) *i) {
   // CHECK: @fi3
   // CHECK: atomicrmw and
-  __atomic_fetch_and(i, 1, memory_order_seq_cst);
+  // CHECK-NOT: and
+  return __c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
+}
+
+int fi3a(int *i) {
+  // CHECK: @fi3a
+  // CHECK: atomicrmw xor
+  // CHECK-NOT: xor
+  return __atomic_fetch_xor(i, 1, memory_order_seq_cst);
+}
+
+int fi3b(int *i) {
+  // CHECK: @fi3b
+  // CHECK: atomicrmw add
+  // CHECK: add
+  return __atomic_add_fetch(i, 1, memory_order_seq_cst);
+}
+
+int fi3c(int *i) {
+  // CHECK: @fi3c
+  // CHECK: atomicrmw nand
+  // CHECK-NOT: and
+  return __atomic_fetch_nand(i, 1, memory_order_seq_cst);
+}
+
+int fi3d(int *i) {
+  // CHECK: @fi3d
+  // CHECK: atomicrmw nand
+  // CHECK: and
+  // CHECK: xor
+  return __atomic_nand_fetch(i, 1, memory_order_seq_cst);
+}
+
+_Bool fi4(_Atomic(int) *i) {
+  // CHECK: @fi4
+  // CHECK: cmpxchg i32*
+  int cmp = 0;
+  return __c11_atomic_compare_exchange_strong(i, &cmp, 1, memory_order_acquire, memory_order_acquire);
+}
+
+_Bool fi4a(int *i) {
+  // CHECK: @fi4
+  // CHECK: cmpxchg i32*
+  int cmp = 0;
+  int desired = 1;
+  return __atomic_compare_exchange(i, &cmp, &desired, 0, memory_order_acquire, memory_order_acquire);
 }
 
-void fi4(_Atomic(int) *i) {
+_Bool fi4b(int *i) {
   // CHECK: @fi4
   // CHECK: cmpxchg i32*
   int cmp = 0;
-  __atomic_compare_exchange_strong(i, &cmp, 1, memory_order_acquire, memory_order_acquire);
+  return __atomic_compare_exchange_n(i, &cmp, 1, 1, memory_order_acquire, memory_order_acquire);
 }
 
 float ff1(_Atomic(float) *d) {
   // CHECK: @ff1
   // CHECK: load atomic i32* {{.*}} monotonic
-  return __atomic_load(d, memory_order_relaxed);
+  return __c11_atomic_load(d, memory_order_relaxed);
 }
 
 void ff2(_Atomic(float) *d) {
   // CHECK: @ff2
   // CHECK: store atomic i32 {{.*}} release
-  __atomic_store(d, 1, memory_order_release);
+  __c11_atomic_store(d, 1, memory_order_release);
 }
 
 float ff3(_Atomic(float) *d) {
-  return __atomic_exchange(d, 2, memory_order_seq_cst);
+  return __c11_atomic_exchange(d, 2, memory_order_seq_cst);
 }
 
 int* fp1(_Atomic(int*) *p) {
   // CHECK: @fp1
   // CHECK: load atomic i32* {{.*}} seq_cst
-  return __atomic_load(p, memory_order_seq_cst);
+  return __c11_atomic_load(p, memory_order_seq_cst);
 }
 
 int* fp2(_Atomic(int*) *p) {
   // CHECK: @fp2
   // CHECK: store i32 4
   // CHECK: atomicrmw add {{.*}} monotonic
-  return __atomic_fetch_add(p, 1, memory_order_relaxed);
+  return __c11_atomic_fetch_add(p, 1, memory_order_relaxed);
+}
+
+int *fp2a(int **p) {
+  // CHECK: @fp2a
+  // CHECK: store i32 4
+  // CHECK: atomicrmw sub {{.*}} monotonic
+  // Note, the GNU builtins do not multiply by sizeof(T)!
+  return __atomic_fetch_sub(p, 4, memory_order_relaxed);
 }
 
 _Complex float fc(_Atomic(_Complex float) *c) {
   // CHECK: @fc
   // CHECK: atomicrmw xchg i64*
-  return __atomic_exchange(c, 2, memory_order_seq_cst);
+  return __c11_atomic_exchange(c, 2, memory_order_seq_cst);
 }
 
 typedef struct X { int x; } X;
 X fs(_Atomic(X) *c) {
   // CHECK: @fs
   // CHECK: atomicrmw xchg i32*
-  return __atomic_exchange(c, (X){2}, memory_order_seq_cst);
+  return __c11_atomic_exchange(c, (X){2}, memory_order_seq_cst);
 }
 
-int lock_free() {
+X fsa(X *c, X *d) {
+  // CHECK: @fsa
+  // CHECK: atomicrmw xchg i32*
+  X ret;
+  __atomic_exchange(c, d, &ret, memory_order_seq_cst);
+  return ret;
+}
+
+_Bool fsb(_Bool *c) {
+  // CHECK: @fsb
+  // CHECK: atomicrmw xchg i8*
+  return __atomic_exchange_n(c, 1, memory_order_seq_cst);
+}
+
+char flag1;
+volatile char flag2;
+void test_and_set() {
+  // CHECK: atomicrmw xchg i8* @flag1, i8 1 seq_cst
+  __atomic_test_and_set(&flag1, memory_order_seq_cst);
+  // CHECK: atomicrmw volatile xchg i8* @flag2, i8 1 acquire
+  __atomic_test_and_set(&flag2, memory_order_acquire);
+  // CHECK: store atomic volatile i8 0, i8* @flag2 release
+  __atomic_clear(&flag2, memory_order_release);
+  // CHECK: store atomic i8 0, i8* @flag1 seq_cst
+  __atomic_clear(&flag1, memory_order_seq_cst);
+}
+
+struct Sixteen {
+  char c[16];
+} sixteen;
+struct Seventeen {
+  char c[17];
+} seventeen;
+
+int lock_free(struct Incomplete *incomplete) {
   // CHECK: @lock_free
+
+  // CHECK: call i32 @__atomic_is_lock_free(i32 3, i8* null)
+  __c11_atomic_is_lock_free(3);
+
+  // CHECK: call i32 @__atomic_is_lock_free(i32 16, i8* {{.*}}@sixteen{{.*}})
+  __atomic_is_lock_free(16, &sixteen);
+
+  // CHECK: call i32 @__atomic_is_lock_free(i32 17, i8* {{.*}}@seventeen{{.*}})
+  __atomic_is_lock_free(17, &seventeen);
+
+  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  __atomic_is_lock_free(4, incomplete);
+
+  char cs[20];
+  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  __atomic_is_lock_free(4, cs+1);
+
+  // CHECK-NOT: call
+  __atomic_always_lock_free(3, 0);
+  __atomic_always_lock_free(16, 0);
+  __atomic_always_lock_free(17, 0);
+  __atomic_always_lock_free(16, &sixteen);
+  __atomic_always_lock_free(17, &seventeen);
+
+  int n;
+  __atomic_is_lock_free(4, &n);
+
   // CHECK: ret i32 1
-  return __atomic_is_lock_free(sizeof(_Atomic(int)));
+  return __c11_atomic_is_lock_free(sizeof(_Atomic(int)));
 }
 
 // Tests for atomic operations on big values.  These should call the functions
@@ -89,31 +235,80 @@
 struct foo {
   int big[128];
 };
+struct bar {
+  char c[3];
+};
 
+struct bar smallThing, thing1, thing2;
+struct foo bigThing;
 _Atomic(struct foo) bigAtomic;
 
 void structAtomicStore() {
   // CHECK: @structAtomicStore
   struct foo f = {0};
-  __atomic_store(&bigAtomic, f, 5);
-  // CHECK: call void @__atomic_store(i32 512, i8* bitcast (%struct.foo* @bigAtomic to i8*), 
+  __c11_atomic_store(&bigAtomic, f, 5);
+  // CHECK: call void @__atomic_store(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
+
+  struct bar b = {0};
+  __atomic_store(&smallThing, &b, 5);
+  // CHECK: call void @__atomic_store(i32 3, i8* {{.*}} @smallThing
+
+  __atomic_store(&bigThing, &f, 5);
+  // CHECK: call void @__atomic_store(i32 512, i8* {{.*}} @bigThing
 }
 void structAtomicLoad() {
   // CHECK: @structAtomicLoad
-  struct foo f = __atomic_load(&bigAtomic, 5);
-  // CHECK: call void @__atomic_load(i32 512, i8* bitcast (%struct.foo* @bigAtomic to i8*), 
+  struct foo f = __c11_atomic_load(&bigAtomic, 5);
+  // CHECK: call void @__atomic_load(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
+
+  struct bar b;
+  __atomic_load(&smallThing, &b, 5);
+  // CHECK: call void @__atomic_load(i32 3, i8* {{.*}} @smallThing
+
+  __atomic_load(&bigThing, &f, 5);
+  // CHECK: call void @__atomic_load(i32 512, i8* {{.*}} @bigThing
 }
 struct foo structAtomicExchange() {
   // CHECK: @structAtomicExchange
   struct foo f = {0};
-  return __atomic_exchange(&bigAtomic, f, 5);
-  // CHECK: call void @__atomic_exchange(i32 512, i8* bitcast (%struct.foo* @bigAtomic to i8*), 
+  struct foo old;
+  __atomic_exchange(&f, &bigThing, &old, 5);
+  // CHECK: call void @__atomic_exchange(i32 512, {{.*}}, i8* bitcast ({{.*}} @bigThing to i8*),
+
+  return __c11_atomic_exchange(&bigAtomic, f, 5);
+  // CHECK: call void @__atomic_exchange(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
 }
 int structAtomicCmpExchange() {
   // CHECK: @structAtomicCmpExchange
+  _Bool x = __atomic_compare_exchange(&smallThing, &thing1, &thing2, 1, 5, 5);
+  // CHECK: call zeroext i1 @__atomic_compare_exchange(i32 3, {{.*}} @smallThing{{.*}} @thing1{{.*}} @thing2
+
   struct foo f = {0};
   struct foo g = {0};
   g.big[12] = 12;
-  return __atomic_compare_exchange_strong(&bigAtomic, &f, g, 5, 5);
-  // CHECK: call zeroext i1 @__atomic_compare_exchange(i32 512, i8* bitcast (%struct.foo* @bigAtomic to i8*), 
+  return x & __c11_atomic_compare_exchange_strong(&bigAtomic, &f, g, 5, 5);
+  // CHECK: call zeroext i1 @__atomic_compare_exchange(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
 }
+
+// Check that no atomic operations are used in any initialisation of _Atomic
+// types.
+_Atomic(int) atomic_init_i = 42;
+
+// CHECK: @atomic_init_foo
+void atomic_init_foo()
+{
+  // CHECK-NOT: }
+  // CHECK-NOT: atomic
+  // CHECK: store
+  _Atomic(int) j = 12;
+
+  // CHECK-NOT: }
+  // CHECK-NOT: atomic
+  // CHECK: store
+  __c11_atomic_init(&j, 42);
+
+  // CHECK-NOT: atomic
+  // CHECK: }
+}
+
+#endif

Removed: cfe/branches/tooling/test/CodeGen/atomic_init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/atomic_init.c?rev=154918&view=auto
==============================================================================
--- cfe/branches/tooling/test/CodeGen/atomic_init.c (original)
+++ cfe/branches/tooling/test/CodeGen/atomic_init.c (removed)
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
-
-// Check that no atomic operations are used in any initialisation of _Atomic
-// types.  
-
-_Atomic(int) i = 42;
-
-void foo()
-{
-  _Atomic(int) j = 12; // CHECK: store 
-                       // CHECK-NOT: atomic
-  __atomic_init(&j, 42); // CHECK: store 
-                         // CHECK-NOT: atomic
-}

Modified: cfe/branches/tooling/test/CodeGen/switch-dce.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/switch-dce.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/switch-dce.c (original)
+++ cfe/branches/tooling/test/CodeGen/switch-dce.c Tue Apr 17 06:08:26 2012
@@ -216,32 +216,19 @@
   }
 }
 
-
-// rdar://9289524 - Check that the empty cases don't produce an empty block.
+// Verify that case 42 only calls test14 once.
 // CHECK: @test13
-// CHECK: switch 
-// CHECK:     i32 42, label [[EPILOG:%[0-9.a-z]+]]
-// CHECK:     i32 11, label [[EPILOG]]
+// CHECK: call void @test13(i32 97)
+// CHECK-NEXT: br label %[[EPILOG2:[0-9.a-z]+]]
+// CHECK: [[EPILOG2]]
+// CHECK-NEXT: br label [[EPILOG:%[0-9.a-z]+]]
+// CHECK: call void @test13(i32 42)
+// CHECK-NEXT: br label [[EPILOG]]
 void test13(int x) {
   switch (x) {
-  case 42: break;  // No empty block please.
-  case 11: break;  // No empty block please.
-  default: test13(42); break;
-  }
-}
-
-
-// Verify that case 42 only calls test14 once.
-// CHECK: @test14
-// CHECK: call void @test14(i32 97)
-// CHECK-NEXT: br label [[EPILOG2:%[0-9.a-z]+]]
-// CHECK: call void @test14(i32 42)
-// CHECK-NEXT: br label [[EPILOG2]]
-void test14(int x) {
-  switch (x) {
-    case 42: test14(97);  // fallthrough
+    case 42: test13(97);  // fallthrough
     case 11: break;
-    default: test14(42); break;
+    default: test13(42); break;
   }
 }
 

Modified: cfe/branches/tooling/test/CodeGenCXX/arm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/arm.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/arm.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/arm.cpp Tue Apr 17 06:08:26 2012
@@ -20,9 +20,17 @@
 
 // The global dtor needs the right calling conv with -fno-use-cxa-atexit
 // rdar://7817590
-// Checked at end of file.
 bar baz;
 
+// PR9593
+// Make sure atexit(3) is used for global dtors.
+
+// CHECK:      call [[BAR:%.*]]* @_ZN3barC1Ev(
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor_baz)
+
+// CHECK: define internal void @__dtor_baz()
+// CHECK: call [[BAR]]* @_ZN3barD1Ev([[BAR]]* @baz)
+
 // Destructors and constructors must return this.
 namespace test1 {
   void foo();
@@ -357,5 +365,5 @@
   // CHECK:   call void @_ZN5test21CD0Ev(
   // CHECK:   ret void
 
-// CHECK: @_GLOBAL__D_a()
-// CHECK: call %class.bar* @_ZN3barD1Ev(%class.bar* @baz)
+// CH_ECK: @_GLOBAL__D_a()
+// CH_ECK: call %class.bar* @_ZN3barD1Ev(%class.bar* @baz)

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp Tue Apr 17 06:08:26 2012
@@ -414,3 +414,12 @@
     consume(a);
   }
 }
+
+namespace Null {
+  decltype(nullptr) null();
+  // CHECK: call {{.*}} @_ZN4Null4nullEv(
+  int *p = null();
+  struct S {};
+  // CHECK: call {{.*}} @_ZN4Null4nullEv(
+  int S::*q = null();
+}

Modified: cfe/branches/tooling/test/CodeGenCXX/global-dtor-no-atexit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/global-dtor-no-atexit.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/global-dtor-no-atexit.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/global-dtor-no-atexit.cpp Tue Apr 17 06:08:26 2012
@@ -3,10 +3,15 @@
 // PR7097
 // RUN: %clang_cc1 -triple x86_64 %s -fno-use-cxa-atexit -mconstructor-aliases -emit-llvm -o - | FileCheck %s
 
-// CHECK: define internal void @_GLOBAL__D_a()
-// CHECK:   call void @_ZN1AD1Ev(%class.A* @b)
-// CHECK:   call void @_ZN1AD1Ev(%class.A* @a)
-// CHECK: }
+// CHECK:      call void @_ZN1AC1Ev([[A:%.*]]* @a)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor_a)
+// CHECK:      define internal void @__dtor_a() nounwind
+// CHECK:      call void @_ZN1AD1Ev([[A]]* @a)
+
+// CHECK:      call void @_ZN1AC1Ev([[A]]* @b)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor_b)
+// CHECK:      define internal void @__dtor_b() nounwind
+// CHECK:      call void @_ZN1AD1Ev([[A]]* @b)
 
 class A {
 public:
@@ -15,3 +20,25 @@
 };
 
 A a, b;
+
+// PR9593
+// CHECK:      define void @_Z4funcv()
+// CHECK:      call i32 @__cxa_guard_acquire(i64* @_ZGVZ4funcvE2a1)
+// CHECK:      call void @_ZN1AC1Ev([[A]]* @_ZZ4funcvE2a1)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor__ZZ4funcvE2a1)
+// CHECK-NEXT: call void @__cxa_guard_release(i64* @_ZGVZ4funcvE2a1)
+
+// CHECK:      call i32 @__cxa_guard_acquire(i64* @_ZGVZ4funcvE2a2)
+// CHECK:      call void @_ZN1AC1Ev([[A]]* @_ZZ4funcvE2a2)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor__ZZ4funcvE2a2)
+// CHECK-NEXT: call void @__cxa_guard_release(i64* @_ZGVZ4funcvE2a2)
+
+// CHECK:      define internal void @__dtor__ZZ4funcvE2a1() nounwind
+// CHECK:      call void @_ZN1AD1Ev([[A]]* @_ZZ4funcvE2a1)
+
+// CHECK:      define internal void @__dtor__ZZ4funcvE2a2() nounwind
+// CHECK:      call void @_ZN1AD1Ev([[A]]* @_ZZ4funcvE2a2)
+
+void func() {
+  static A a1, a2;
+}

Modified: cfe/branches/tooling/test/CodeGenCXX/global-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/global-init.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/global-init.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/global-init.cpp Tue Apr 17 06:08:26 2012
@@ -12,7 +12,7 @@
 
 struct D { ~D(); };
 
-// CHECK: @__dso_handle = external unnamed_addr global i8*
+// CHECK: @__dso_handle = external unnamed_addr global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
 // It's okay if we ever implement the IR-generation optimization to remove this.
@@ -24,18 +24,18 @@
 // CHECK: @_ZN6PR59741bE = global %"struct.PR5974::B"* bitcast (i8* getelementptr (i8* bitcast (%"struct.PR5974::C"* @_ZN6PR59741cE to i8*), i64 4) to %"struct.PR5974::B"*), align 8
 
 // CHECK: call void @_ZN1AC1Ev(%struct.A* @a)
-// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @a, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
+// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @a, i32 0, i32 0), i8* @__dso_handle)
 A a;
 
 // CHECK: call void @_ZN1BC1Ev(%struct.B* @b)
-// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.B*)* @_ZN1BD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.B* @b, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
+// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.B*)* @_ZN1BD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.B* @b, i32 0, i32 0), i8* @__dso_handle)
 B b;
 
 // PR6205: this should not require a global initializer
 // CHECK-NOT: call void @_ZN1CC1Ev(%struct.C* @c)
 C c;
 
-// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.D*)* @_ZN1DD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.D* @d, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
+// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.D*)* @_ZN1DD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.D* @d, i32 0, i32 0), i8* @__dso_handle)
 D d;
 
 // <rdar://problem/7458115>

Modified: cfe/branches/tooling/test/CodeGenCXX/mangle-lambdas.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/mangle-lambdas.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/mangle-lambdas.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/mangle-lambdas.cpp Tue Apr 17 06:08:26 2012
@@ -150,6 +150,8 @@
   func_template<int>();
 }
 
+// CHECK: define linkonce_odr void @_Z1fIZZNK23TestNestedInstantiationclEvENKUlvE_clEvEUlvE_EvT_
+
 struct Members {
   int x = [] { return 1; }() + [] { return 2; }();
   int y = [] { return 3; }();
@@ -165,6 +167,20 @@
   // CHECK: ret void
 }
 
+template<typename P> void f(P) { }
+
+struct TestNestedInstantiation {
+   void operator()() const {
+     []() -> void {
+       return f([]{});
+     }();
+   }
+};
+
+void test_NestedInstantiation() {
+  TestNestedInstantiation()();
+}
+
 // Check the linkage of the lambdas used in test_Members.
 // CHECK: define linkonce_odr i32 @_ZNK7Members1xMUlvE_clEv
 // CHECK: ret i32 1

Modified: cfe/branches/tooling/test/CodeGenCXX/mangle-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/mangle-template.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/mangle-template.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/mangle-template.cpp Tue Apr 17 06:08:26 2012
@@ -153,3 +153,20 @@
   template void f<char>(A<char,cmp> &);
   // CHECK: @_ZN6test111fIcEEvRNS_1AIT_L_ZNS_3cmpEccEEE(
 }
+
+namespace test12 {
+  // Make sure we can mangle non-type template args with internal linkage.
+  static int f();
+  const int n = 10;
+  template<typename T, T v> void test() {}
+  void use() {
+    // CHECK: define internal void @_ZN6test124testIFivEXadL_ZNS_L1fEvEEEEvv(
+    test<int(), &f>();
+    // CHECK: define internal void @_ZN6test124testIRFivEXadL_ZNS_L1fEvEEEEvv(
+    test<int(&)(), f>();
+    // CHECK: define internal void @_ZN6test124testIPKiXadL_ZNS_L1nEEEEEvv(
+    test<const int*, &n>();
+    // CHECK: define internal void @_ZN6test124testIRKiXadL_ZNS_L1nEEEEEvv(
+    test<const int&, n>();
+  }
+}

Modified: cfe/branches/tooling/test/CodeGenCXX/predefined-expr-sizeof.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/predefined-expr-sizeof.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/predefined-expr-sizeof.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/predefined-expr-sizeof.cpp Tue Apr 17 06:08:26 2012
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
 
-// CHECK: store i32 49, i32* %size
-// CHECK: store i32 52, i32* %size
+// CHECK: store i32 59, i32* %size
+// CHECK: store i32 65, i32* %size
 template<typename T>
 class TemplateClass {
 public:
@@ -10,8 +10,8 @@
   }
 };
 
-// CHECK: store i32 27, i32* %size
-// CHECK: store i32 30, i32* %size
+// CHECK: store i32 35, i32* %size
+// CHECK: store i32 38, i32* %size
 template<typename T>
 void functionTemplate(T t) {
   int size = sizeof(__PRETTY_FUNCTION__);

Modified: cfe/branches/tooling/test/CodeGenCXX/predefined-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/predefined-expr.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/predefined-expr.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/predefined-expr.cpp Tue Apr 17 06:08:26 2012
@@ -1,15 +1,29 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - | FileCheck %s
 
 // CHECK: private unnamed_addr constant [15 x i8] c"externFunction\00"
 // CHECK: private unnamed_addr constant [26 x i8] c"void NS::externFunction()\00"
+// CHECK: private unnamed_addr constant [49 x i8] c"void functionTemplateExplicitSpecialization(int)\00"
+
+// CHECK: private unnamed_addr constant [95 x i8] c"void SpecializedClassTemplate<char>::memberFunctionTemplate(T, U) const [T = char, U = double]\00"
+// CHECK: private unnamed_addr constant [85 x i8] c"void SpecializedClassTemplate<int>::memberFunctionTemplate(int, U) const [U = float]\00"
+// CHECK: private unnamed_addr constant [57 x i8] c"void NonTypeTemplateParam<42>::size() const [Count = 42]\00"
+// CHECK: private unnamed_addr constant [122 x i8] c"static void ClassWithTemplateTemplateParam<char, NS::ClassTemplate>::staticMember() [T = char, Param = NS::ClassTemplate]\00"
+// CHECK: private unnamed_addr constant [106 x i8] c"void OuterClass<int *>::MiddleClass::InnerClass<float>::memberFunction(T, U) const [T = int *, U = float]\00"
+// CHECK: private unnamed_addr constant [65 x i8] c"void functionTemplateWithUnnamedTemplateParameter(T) [T = float]\00"
+
+// CHECK: private unnamed_addr constant [60 x i8] c"void functionTemplateExplicitSpecialization(T) [T = double]\00"
+// CHECK: private unnamed_addr constant [52 x i8] c"T *functionTemplateWithCompoundTypes(T *) [T = int]\00" 
+// CHECK: private unnamed_addr constant [54 x i8] c"T functionTemplateWithTemplateReturnType() [T = char]\00"
+// CHECK: private unnamed_addr constant [57 x i8] c"void functionTemplateWithoutParameterList() [T = double]\00"
+// CHECK: private unnamed_addr constant [62 x i8] c"void functionTemplateWithTwoParams(T, U) [T = int, U = float]\00"
 
 // CHECK: private unnamed_addr constant [22 x i8] c"classTemplateFunction\00"
-// CHECK: private unnamed_addr constant [60 x i8] c"void NS::ClassTemplate<NS::Base *>::classTemplateFunction()\00"
-// CHECK: private unnamed_addr constant [53 x i8] c"void NS::ClassTemplate<int>::classTemplateFunction()\00"
+// CHECK: private unnamed_addr constant [77 x i8] c"void NS::ClassTemplate<NS::Base *>::classTemplateFunction() [T = NS::Base *]\00"
+// CHECK: private unnamed_addr constant [63 x i8] c"void NS::ClassTemplate<int>::classTemplateFunction() [T = int]\00"
 
 // CHECK: private unnamed_addr constant [18 x i8] c"functionTemplate1\00"
-// CHECK: private unnamed_addr constant [45 x i8] c"void NS::Base::functionTemplate1(NS::Base *)\00"
-// CHECK: private unnamed_addr constant [38 x i8] c"void NS::Base::functionTemplate1(int)\00"
+// CHECK: private unnamed_addr constant [53 x i8] c"void NS::Base::functionTemplate1(T) [T = NS::Base *]\00"
+// CHECK: private unnamed_addr constant [46 x i8] c"void NS::Base::functionTemplate1(T) [T = int]\00"
 
 // CHECK: private unnamed_addr constant [23 x i8] c"anonymousUnionFunction\00"
 // CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous union>::anonymousUnionFunction()\00"
@@ -31,6 +45,10 @@
 // CHECK: private unnamed_addr constant [16 x i8] c"virtualFunction\00"
 // CHECK: private unnamed_addr constant [44 x i8] c"virtual void NS::Derived::virtualFunction()\00"
 
+// CHECK: private unnamed_addr constant [21 x i8] c"refQualifiedFunction\00"
+// CHECK: private unnamed_addr constant [41 x i8] c"void NS::Base::refQualifiedFunction() &&\00"
+// CHECK: private unnamed_addr constant [40 x i8] c"void NS::Base::refQualifiedFunction() &\00"
+
 // CHECK: private unnamed_addr constant [22 x i8] c"constVolatileFunction\00"
 // CHECK: private unnamed_addr constant [54 x i8] c"void NS::Base::constVolatileFunction() const volatile\00"
 
@@ -78,6 +96,8 @@
 // CHECK: private unnamed_addr constant [19 x i8] c"localClassFunction\00"
 // CHECK: private unnamed_addr constant [59 x i8] c"void NS::localClass(int)::LocalClass::localClassFunction()\00"
 
+
+
 int printf(const char * _Format, ...);
 
 class ClassInTopLevelNamespace {
@@ -203,11 +223,23 @@
     printf("__FUNCTION__ %s\n", __FUNCTION__);
     printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
   }
+
+  void refQualifiedFunction() & {
+    printf("__func__ %s\n", __func__);
+    printf("__FUNCTION__ %s\n", __FUNCTION__);
+    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+  }
+
+  void refQualifiedFunction() && {
+    printf("__func__ %s\n", __func__);
+    printf("__FUNCTION__ %s\n", __FUNCTION__);
+    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+  }
 };
 
 class Derived : public Base {
 public:
-  // Virtual function without being explicitally written.
+  // Virtual function without being explicitly written.
   void virtualFunction() {
     printf("__func__ %s\n", __func__);
     printf("__FUNCTION__ %s\n", __FUNCTION__);
@@ -294,6 +326,116 @@
 
 } // end NS namespace
 
+// additional tests for __PRETTY_FUNCTION__
+template <typename T, typename U>
+void functionTemplateWithTwoParams(T, U)
+{
+  printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename T>
+void functionTemplateWithoutParameterList()
+{
+  T t = T();
+
+  printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename T>
+T functionTemplateWithTemplateReturnType()
+{
+  printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+
+  return T();
+}
+
+template <typename T>
+T * functionTemplateWithCompoundTypes(T a[])
+{
+  printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+
+  return 0;
+}
+
+template <typename T>
+void functionTemplateExplicitSpecialization(T t)
+{
+  printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <>
+void functionTemplateExplicitSpecialization<int>(int i)
+{
+  printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename, typename T>
+void functionTemplateWithUnnamedTemplateParameter(T t)
+{
+  printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename T>
+class OuterClass
+{
+public:
+  class MiddleClass
+  {
+  public:
+    template <typename U>
+    class InnerClass
+    {
+    public:
+      void memberFunction(T x, U y) const
+      {
+        printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+      }
+    };
+  };
+};
+
+template <typename T, template <typename> class Param = NS::ClassTemplate>
+class ClassWithTemplateTemplateParam
+{
+public:
+  static void staticMember()
+  {
+    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+  }
+};
+
+template <int Count>
+class NonTypeTemplateParam
+{
+public:
+  void size() const
+  {
+    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+  }
+};
+
+template <typename T>
+class SpecializedClassTemplate
+{
+public:
+  template <typename U>
+  void memberFunctionTemplate(T t, U u) const
+  {
+    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+  }
+};
+
+template <>
+class SpecializedClassTemplate<int>
+{
+public:
+  template <typename U>
+  void memberFunctionTemplate(int i, U u) const
+  {
+    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+  }
+};
+
 int main() {
   ClassInAnonymousNamespace anonymousNamespace;
   anonymousNamespace.anonymousNamespaceFunction();
@@ -319,6 +461,8 @@
   b.constFunction();
   b.volatileFunction();
   b.constVolatileFunction();
+  b.refQualifiedFunction();
+  NS::Base().refQualifiedFunction();
 
   NS::Derived d;
   d.virtualFunction();
@@ -345,5 +489,29 @@
 
   NS::externFunction();
 
+  // additional tests for __PRETTY_FUNCTION__
+
+  functionTemplateWithTwoParams(0, 0.0f);
+  functionTemplateWithoutParameterList<double>();
+  functionTemplateWithTemplateReturnType<char>();
+  int array[] = { 1, 2, 3 };
+  functionTemplateWithCompoundTypes(array);
+  functionTemplateExplicitSpecialization(0);
+  functionTemplateExplicitSpecialization(0.0);
+  functionTemplateWithUnnamedTemplateParameter<int, float>(0.0f);
+
+  OuterClass<int *>::MiddleClass::InnerClass<float> omi;
+  omi.memberFunction(0, 0.0f);
+
+  ClassWithTemplateTemplateParam<char>::staticMember();
+
+  NonTypeTemplateParam<42> ntt;
+  ntt.size();
+
+  SpecializedClassTemplate<int> sct1;
+  sct1.memberFunctionTemplate(0, 0.0f);
+  SpecializedClassTemplate<char> sct2;
+  sct2.memberFunctionTemplate('0', 0.0);
+
   return 0;
 }

Modified: cfe/branches/tooling/test/CodeGenCXX/static-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/static-init.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/static-init.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/static-init.cpp Tue Apr 17 06:08:26 2012
@@ -17,7 +17,7 @@
   // CHECK: load atomic i8* bitcast (i64* @_ZGVZ1fvE1a to i8*) acquire, align 1
   // CHECK: call i32 @__cxa_guard_acquire
   // CHECK: call void @_ZN1AC1Ev
-  // CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @_ZZ1fvE1a, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
+  // CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @_ZZ1fvE1a, i32 0, i32 0), i8* @__dso_handle)
   // CHECK: call void @__cxa_guard_release
   static A a;
 }

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/arc-blocks.m Tue Apr 17 06:08:26 2012
@@ -514,3 +514,10 @@
 void test14() {
   void (^const x[1])(void) = { ^{} };
 }
+
+// rdar://11149025
+// Don't make invalid ASTs and crash.
+void test15_helper(void (^block)(void), int x);
+void test15(int a) {
+  test15_helper(^{ (void) a; }, ({ a; }));
+}

Modified: cfe/branches/tooling/test/CodeGenObjC/debug-info-block-helper.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/debug-info-block-helper.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/debug-info-block-helper.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/debug-info-block-helper.m Tue Apr 17 06:08:26 2012
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s -o - | FileCheck %s
 extern void foo(void(^)(void));
 
-// CHECK: !40 = metadata !{i32 {{.*}}, i32 0, metadata !25, metadata !"__destroy_helper_block_", metadata !"__destroy_helper_block_", metadata !"", metadata !25, i32 24, metadata !41, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i8*)* @__destroy_helper_block_, null, null, metadata !43, i32 24} ; [ DW_TAG_subprogram ]
+// CHECK: metadata !{i32 786478, i32 0, metadata !27, metadata !"__destroy_helper_block_", metadata !"__destroy_helper_block_", metadata !"", metadata !27, i32 24, metadata !43, i1 true, i1 true, i32 0, i32 0, null, i32 0, i1 false, void (i8*)* @__destroy_helper_block_, null, null, metadata !45, i32 24} ; [ DW_TAG_subprogram ]
 
 @interface NSObject {
   struct objc_object *isa;

Modified: cfe/branches/tooling/test/CodeGenObjC/debug-info-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/debug-info-property.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/debug-info-property.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/debug-info-property.m Tue Apr 17 06:08:26 2012
@@ -1,8 +1,6 @@
 // RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
 
 // CHECK: AT_APPLE_property_name
-// CHECK: AT_APPLE_property_getter
-// CHECK: AT_APPLE_property_setter
 // CHECK: AT_APPLE_property_attribute
 // CHECK: AT_APPLE_property
 @interface I1 {

Modified: cfe/branches/tooling/test/CodeGenObjC/debug-info-property3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/debug-info-property3.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/debug-info-property3.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/debug-info-property3.m Tue Apr 17 06:08:26 2012
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -S -emit-llvm -g %s -o - | FileCheck %s
 
-// CHECK: metadata !"p1", metadata !6, i32 5, metadata !"p1", metadata !"setP1:", i32 2316, metadata !9} ; [ DW_TAG_APPLE_property ]
+// CHECK: metadata !"p1", metadata !6, i32 5, metadata !"", metadata !"", i32 2316, metadata !9} ; [ DW_TAG_APPLE_property ]
 @interface I1
 @property int p1;
 @end

Modified: cfe/branches/tooling/test/CodeGenObjC/debug-info-property4.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/debug-info-property4.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/debug-info-property4.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/debug-info-property4.m Tue Apr 17 06:08:26 2012
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -fobjc-default-synthesize-properties -masm-verbose -S -g %s -o - | FileCheck %s
 
 // CHECK: AT_APPLE_property_name
-// CHECK: AT_APPLE_property_getter
-// CHECK: AT_APPLE_property_setter
+// CHECK-NOT: AT_APPLE_property_getter
+// CHECK-NOT: AT_APPLE_property_setter
 // CHECK: AT_APPLE_property_attribute
 // CHECK: AT_APPLE_property
 

Modified: cfe/branches/tooling/test/CodeGenObjC/debug-info-pubtypes.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/debug-info-pubtypes.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/debug-info-pubtypes.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/debug-info-pubtypes.m Tue Apr 17 06:08:26 2012
@@ -1,7 +1,7 @@
 // REQUIRES: x86-64-registered-target
 // RUN: %clang -cc1 -triple x86_64-apple-darwin10 -g -emit-llvm %s -o - | FileCheck %s
 
-// CHECK: !10 = metadata !{i32 {{.*}}, metadata !6, metadata !"H", metadata !6, i32 6, i64 0, i64 8, i32 0, i32 512, null, metadata !2, i32 16, i32 0} ; [ DW_TAG_structure_type ]
+// CHECK: !5 = metadata !{i32 {{.*}}, metadata !6, metadata !"H", metadata !6, i32 6, i64 0, i64 8, i32 0, i32 512, null, metadata !2, i32 16, i32 0} ; [ DW_TAG_structure_type ]
 
 @interface H
 -(void) foo;

Modified: cfe/branches/tooling/test/CodeGenObjC/debug-info-synthesis.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/debug-info-synthesis.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/debug-info-synthesis.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/debug-info-synthesis.m Tue Apr 17 06:08:26 2012
@@ -30,5 +30,5 @@
   }
 }
 
-// CHECK: !11 = metadata !{i32 {{.*}}, metadata !"./foo.h"
-// CHECK: !29 = metadata !{i32 {{.*}}, i32 0, metadata !11, metadata !"-[Foo dict]", metadata !"-[Foo dict]", metadata !"", metadata !11, i32 8, metadata !30, i1 true, i1 true, i32 0, i32 0, null, i32 320, i1 false, %1* (%0*, i8*)* @"\01-[Foo dict]", null, null, metadata !32, i32 8} ; [ DW_TAG_subprogram ]
+// CHECK: !7 = metadata !{i32 {{.*}}, metadata !"./foo.h"
+// CHECK: !31 = metadata !{i32 {{.*}}, i32 0, metadata !7, metadata !"-[Foo dict]", metadata !"-[Foo dict]", metadata !"", metadata !7, i32 8, metadata !32, i1 true, i1 true, i32 0, i32 0, null, i32 320, i1 false, %1* (%0*, i8*)* @"\01-[Foo dict]", null, null, metadata !34, i32 8} ; [ DW_TAG_subprogram ]

Modified: cfe/branches/tooling/test/CodeGenObjCXX/arc.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjCXX/arc.mm?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjCXX/arc.mm (original)
+++ cfe/branches/tooling/test/CodeGenObjCXX/arc.mm Tue Apr 17 06:08:26 2012
@@ -241,3 +241,14 @@
 // CHECK: call i8* @objc_autoreleaseReturnValue
 template Test37* instantiate_init<int>();
 
+// Just make sure that the AST invariants hold properly here,
+// i.e. that we don't crash.
+// The block should get bound in the full-expression outside
+// the statement-expression.
+template <class T> class Test38 {
+  void test(T x) {
+    ^{ (void) x; }, ({ x; });
+  }
+};
+// CHECK: define weak_odr void @_ZN6Test38IiE4testEi(
+template class Test38<int>;

Modified: cfe/branches/tooling/test/CodeGenOpenCL/fpaccuracy.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenOpenCL/fpaccuracy.cl?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenOpenCL/fpaccuracy.cl (original)
+++ cfe/branches/tooling/test/CodeGenOpenCL/fpaccuracy.cl Tue Apr 17 06:08:26 2012
@@ -22,4 +22,4 @@
   return a / b;
 }
 
-// CHECK: ![[MD]] = metadata !{i{{[0-9]+}} 5, i{{[0-9]+}} 2}
+// CHECK: ![[MD]] = metadata !{float 2.500000e+00}

Modified: cfe/branches/tooling/test/Driver/altivec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/altivec.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/altivec.cpp (original)
+++ cfe/branches/tooling/test/Driver/altivec.cpp Tue Apr 17 06:08:26 2012
@@ -1,14 +1,14 @@
 // Check that we error when -faltivec is specified on non-ppc platforms.
 
-// RUN: %clang -target powerpc-apple-darwin -faltivec -fsyntax-only %s
-// RUN: %clang -target powerpc64-linux-gnu -faltivec -fsyntax-only %s
+// RUN: %clang -ccc-clang-archs powerpc -target powerpc-apple-darwin -faltivec -fsyntax-only %s
+// RUN: %clang -ccc-clang-archs powerpc64 -target powerpc64-linux-gnu -faltivec -fsyntax-only %s
 
 // RUN: %clang -target i386-pc-win32 -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64-unknown-freebsd -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
 // RUN: %clang -target armv6-apple-darwin -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
 // RUN: %clang -target armv7-apple-darwin -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: %clang -target mips-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: %clang -target mips64-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: %clang -target sparc-unknown-solaris -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -ccc-clang-archs mips -target mips-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -ccc-clang-archs mips64 -target mips64-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -ccc-clang-archs sparc -target sparc-unknown-solaris -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
 
 // CHECK: invalid argument '-faltivec' only allowed with 'ppc/ppc64'

Modified: cfe/branches/tooling/test/Driver/apple-kext-i386.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/apple-kext-i386.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/apple-kext-i386.cpp (original)
+++ cfe/branches/tooling/test/Driver/apple-kext-i386.cpp Tue Apr 17 06:08:26 2012
@@ -40,3 +40,11 @@
 
 // CHECK-UNSUPPORTED2: cc1plus"
 // CHECK-UNSUPPORTED2-NOT: "-Wconstant-logical-operand"
+
+// Check that --serialize-diagnostics does not cause an "argument unused" error.
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN:   -Wall -fapple-kext -### --serialize-diagnostics %t.dia -c %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-UNUSED %s
+
+// CHECK-UNUSED-NOT: argument unused
+// CHECK-UNUSED: cc1plus

Modified: cfe/branches/tooling/test/Driver/freebsd.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/freebsd.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/freebsd.c (original)
+++ cfe/branches/tooling/test/Driver/freebsd.c Tue Apr 17 06:08:26 2012
@@ -1,12 +1,14 @@
 // REQUIRES: ppc32-registered-target,ppc64-registered-target
-// RUN: %clang -no-canonical-prefixes -target powerpc-pc-freebsd8 %s \
+// RUN: %clang -ccc-clang-archs powerpc -no-canonical-prefixes \
+// RUN:   -target powerpc-pc-freebsd8 %s    \
 // RUN:   --sysroot=%S/Inputs/basic_freebsd_tree -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PPC %s
 // CHECK-PPC: clang{{.*}}" "-cc1" "-triple" "powerpc-pc-freebsd8"
 // CHECK-PPC: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-PPC: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
 //
-// RUN: %clang -no-canonical-prefixes -target powerpc64-pc-freebsd8 %s \
+// RUN: %clang  -ccc-clang-archs powerpc64 -no-canonical-prefixes \
+// RUN:   -target powerpc64-pc-freebsd8 %s                              \
 // RUN:   --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PPC64 %s
 // CHECK-PPC64: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8"

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/linux-header-search.cpp (original)
+++ cfe/branches/tooling/test/Driver/linux-header-search.cpp Tue Apr 17 06:08:26 2012
@@ -45,7 +45,7 @@
 // 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: %clang -ccc-clang-archs powerpc -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
@@ -59,7 +59,7 @@
 // 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: %clang -ccc-clang-archs powerpc64 -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

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/linux-ld.c (original)
+++ cfe/branches/tooling/test/Driver/linux-ld.c Tue Apr 17 06:08:26 2012
@@ -92,6 +92,20 @@
 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target x86_64-unknown-linux -m32 \
+// RUN:     -gcc-toolchain %S/Inputs/multilib_64bit_linux_tree/usr \
+// RUN:     --sysroot=%S/Inputs/multilib_32bit_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-64-TO-32-SYSROOT %s
+// CHECK-64-TO-32-SYSROOT: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-64-TO-32-SYSROOT: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o"
+// CHECK-64-TO-32-SYSROOT: "-L{{[^"]*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-64-TO-32-SYSROOT: "-L{{[^"]*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/lib"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -target i386-unknown-linux -m32 \
 // RUN:     -ccc-install-dir %S/Inputs/fake_install_tree/bin \
 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
@@ -173,26 +187,35 @@
 // CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/../lib64"
 //
 // Check that we do not pass --hash-style=gnu and --hash-style=both to linker
-// when build for MIPS platforms.
+// and provide correct path to the dynamic linker and emulation mode when build
+// for MIPS platforms.
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     -target mips-linux-gnu -ccc-clang-archs mips \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS %s
 // CHECK-MIPS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS: "-m" "elf32btsmip"
+// CHECK-MIPS: "-dynamic-linker" "{{.*}}/lib/ld.so.1"
 // CHECK-MIPS-NOT: "--hash-style={{gnu|both}}"
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     -target mipsel-linux-gnu -ccc-clang-archs mipsel \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPSEL %s
 // CHECK-MIPSEL: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPSEL: "-m" "elf32ltsmip"
+// CHECK-MIPSEL: "-dynamic-linker" "{{.*}}/lib/ld.so.1"
 // CHECK-MIPSEL-NOT: "--hash-style={{gnu|both}}"
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     -target mips64-linux-gnu -ccc-clang-archs mips64 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64 %s
 // CHECK-MIPS64: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS64: "-m" "elf64btsmip"
+// CHECK-MIPS64: "-dynamic-linker" "{{.*}}/lib64/ld.so.1"
 // CHECK-MIPS64-NOT: "--hash-style={{gnu|both}}"
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     -target mips64el-linux-gnu -ccc-clang-archs mips64el \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL %s
 // CHECK-MIPS64EL: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS64EL: "-m" "elf64ltsmip"
+// CHECK-MIPS64EL: "-dynamic-linker" "{{.*}}/lib64/ld.so.1"
 // CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}"
 //
 // Thoroughly exercise the Debian multiarch environment.

Modified: cfe/branches/tooling/test/Driver/mips-float.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/mips-float.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/mips-float.c (original)
+++ cfe/branches/tooling/test/Driver/mips-float.c Tue Apr 17 06:08:26 2012
@@ -2,19 +2,19 @@
 // when build for MIPS platforms.
 //
 // Default
-// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
 // RUN:     -target mips-linux-gnu \
 // RUN:   | FileCheck --check-prefix=CHECK-DEF %s
 // CHECK-DEF: "-mfloat-abi" "hard"
 //
 // -mhard-float
-// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
 // RUN:     -target mips-linux-gnu -mhard-float \
 // RUN:   | FileCheck --check-prefix=CHECK-HARD %s
 // CHECK-HARD: "-mfloat-abi" "hard"
 //
 // -msoft-float
-// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
 // RUN:     -target mips-linux-gnu -msoft-float \
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT %s
 // CHECK-SOFT: "-msoft-float"
@@ -22,13 +22,13 @@
 // CHECK-SOFT: "-target-feature" "+soft-float"
 //
 // -mfloat-abi=hard
-// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
 // RUN:     -target mips-linux-gnu -mfloat-abi=hard \
 // RUN:   | FileCheck --check-prefix=CHECK-ABI-HARD %s
 // CHECK-ABI-HARD: "-mfloat-abi" "hard"
 //
 // -mfloat-abi=soft
-// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
 // RUN:     -target mips-linux-gnu -mfloat-abi=soft \
 // RUN:   | FileCheck --check-prefix=CHECK-ABI-SOFT %s
 // CHECK-ABI-SOFT: "-msoft-float"
@@ -36,24 +36,7 @@
 // CHECK-ABI-SOFT: "-target-feature" "+soft-float"
 //
 // -mfloat-abi=single
-// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
 // RUN:     -target mips-linux-gnu -mfloat-abi=single \
 // RUN:   | FileCheck --check-prefix=CHECK-ABI-SINGLE %s
 // CHECK-ABI-SINGLE: "-target-feature" "+single-float"
-//
-// Let's check float ABI related macros.
-//
-// -mfloat-abi=hard
-// RUN: %clang -c %s -dM -E 2>&1 \
-// RUN:     -target mips-linux-gnu -mfloat-abi=hard \
-// RUN:   | grep "#define __mips_hard_float 1"
-//
-// -mfloat-abi=soft
-// RUN: %clang -c %s -dM -E 2>&1 \
-// RUN:     -target mips-linux-gnu -mfloat-abi=soft \
-// RUN:   | grep "#define __mips_soft_float 1"
-//
-// -mfloat-abi=single
-// RUN: %clang -c %s -dM -E 2>&1 \
-// RUN:     -target mips-linux-gnu -mfloat-abi=single \
-// RUN:   | grep "#define __mips_single_float 1"

Modified: cfe/branches/tooling/test/Driver/rewrite-objc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/rewrite-objc.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/rewrite-objc.m (original)
+++ cfe/branches/tooling/test/Driver/rewrite-objc.m Tue Apr 17 06:08:26 2012
@@ -3,7 +3,7 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
 // TEST0: rewrite-objc.m"
 
 // RUN: not %clang -ccc-no-clang -target unknown -rewrite-objc %s -o - -### 2>&1 | \

Modified: cfe/branches/tooling/test/FixIt/fixit-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/FixIt/fixit-cxx0x.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/FixIt/fixit-cxx0x.cpp (original)
+++ cfe/branches/tooling/test/FixIt/fixit-cxx0x.cpp Tue Apr 17 06:08:26 2012
@@ -100,3 +100,11 @@
   int f = me.f(ifn, kfn);
   int g = me.g(ifn, kfn);
 }
+
+template<template<typename> ...Foo, // expected-error {{template template parameter requires 'class' after the parameter list}}
+         template<template<template<typename>>>> // expected-error 3 {{template template parameter requires 'class' after the parameter list}}
+void func();
+
+template<int *ip> struct IP { }; // expected-note{{declared here}}
+IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
+

Modified: cfe/branches/tooling/test/FixIt/fixit-missing-method-return-type.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/FixIt/fixit-missing-method-return-type.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/FixIt/fixit-missing-method-return-type.m (original)
+++ cfe/branches/tooling/test/FixIt/fixit-missing-method-return-type.m Tue Apr 17 06:08:26 2012
@@ -1,12 +1,12 @@
 // Objective-C recovery
 // RUN: cp %s %t
-// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c %t
-// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c %t
+// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c -Wno-objc-root-class %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c -Wno-objc-root-class %t
 
 // Objective-C++ recovery
 // RUN: cp %s %t
-// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c++ %t
-// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c++ %t
+// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c++ -Wno-objc-root-class %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c++ -Wno-objc-root-class %t
 // rdar://9615045
 
 @interface I

Modified: cfe/branches/tooling/test/FixIt/fixit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/FixIt/fixit.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/FixIt/fixit.cpp (original)
+++ cfe/branches/tooling/test/FixIt/fixit.cpp Tue Apr 17 06:08:26 2012
@@ -200,7 +200,7 @@
   return Mystery<T>::get();
 }
 
-template<template<typename> Foo, // expected-error {{expected 'class' before 'Foo'}}
-         template<typename> typename Bar, // expected-error {{expected 'class' instead of 'typename'}}
-         template<typename> struct Baz> // expected-error {{expected 'class' instead of 'struct'}}
+template<template<typename> Foo, // expected-error {{template template parameter requires 'class' after the parameter list}}
+         template<typename> typename Bar, // expected-error {{template template parameter requires 'class' after the parameter list}}
+         template<typename> struct Baz> // expected-error {{template template parameter requires 'class' after the parameter list}}
 void func();

Modified: cfe/branches/tooling/test/FixIt/typo-crash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/FixIt/typo-crash.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/FixIt/typo-crash.cpp (original)
+++ cfe/branches/tooling/test/FixIt/typo-crash.cpp Tue Apr 17 06:08:26 2012
@@ -19,11 +19,11 @@
     namespace B {
       typedef short   T;
         
-      T global();
+      T global(); // expected-note {{'A::B::global' declared here}}
     }
   }
 
   using namespace A::B;
 
-  T A::global(); // expected-error{{out-of-line definition of 'global' does not match any declaration in namespace 'PR12297::A'}}
+  T A::global(); // expected-error {{out-of-line definition of 'global' does not match any declaration in namespace 'PR12297::A'; did you mean 'A::B::global'?}}
 }

Modified: cfe/branches/tooling/test/FixIt/typo.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/FixIt/typo.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/FixIt/typo.m (original)
+++ cfe/branches/tooling/test/FixIt/typo.m Tue Apr 17 06:08:26 2012
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -DNON_FIXITS -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -DNON_FIXITS -verify -Wno-objc-root-class %s
 // RUN: cp %s %t
-// RUN: not %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fixit %t
-// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -pedantic -Werror %t
+// RUN: not %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fixit -Wno-objc-root-class %t
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -pedantic -Werror -Wno-objc-root-class %t
 // RUN: grep "@implementation Sub3" %t
 
 @interface NSString // expected-note 2{{'NSString' declared here}}

Modified: cfe/branches/tooling/test/Index/complete-method-decls.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/complete-method-decls.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/complete-method-decls.m (original)
+++ cfe/branches/tooling/test/Index/complete-method-decls.m Tue Apr 17 06:08:26 2012
@@ -4,7 +4,7 @@
 @protocol P1
 - (id)abc;
 - (id)initWithInt:(int)x;
-- (id)initWithTwoInts:(int)x second:(int)y;
+- (id)initWithTwoInts:(inout int)x second:(int)y;
 - (int)getInt;
 - (id)getSelf;
 @end
@@ -57,7 +57,7 @@
 @end
 
 @interface Passing
-- (oneway void)method:(in id x);
+- (oneway void)method:(in id)x;
 @end
 
 @interface Gaps
@@ -65,7 +65,11 @@
 @end
 
 @implementation Gaps
-- (void)method:(int)x :(int)y;
+- (void)method:(int)x :(int)y {}
+ at end
+
+ at implementation Passing
+- (oneway void)method:(in id x) {}
 @end
 
 // RUN: c-index-test -code-completion-at=%s:17:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
@@ -73,25 +77,25 @@
 // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} (40) (parent: ObjCProtocolDecl 'P1')
 // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} (40) (parent: ObjCProtocolDecl 'P1')
 // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x} (40) (parent: ObjCProtocolDecl 'P1')
-// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y} (40) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y} (40) (parent: ObjCProtocolDecl 'P1')
 // RUN: c-index-test -code-completion-at=%s:17:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: ObjCInstanceMethodDecl:{TypedText abc}
 // CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
 // CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
-// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
+// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
 // RUN: c-index-test -code-completion-at=%s:24:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText abc}
 // CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
 // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText init}
 // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
-// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
+// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
 // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:3 %s | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace  }{LeftBrace {}{VerticalSpace  }{Text return}{HorizontalSpace  }{Placeholder expression}{SemiColon ;}{VerticalSpace  }{RightBrace }} (42)
 // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace  }{LeftBrace {}{VerticalSpace
 // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace  }{LeftBrace {}{VerticalSpace
 // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace  }{LeftBrace {}{VerticalSpace  }{Text return}{HorizontalSpace  }{Placeholder expression}{SemiColon ;}{VerticalSpace  }{RightBrace }} (40)
 // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace  }{LeftBrace {}{VerticalSpace
-// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace  }{LeftBrace {}{VerticalSpace
+// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace  }{LeftBrace {}{VerticalSpace
 // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText setValue}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace  }{LeftBrace {}{VerticalSpace
 // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:8 %s | FileCheck -check-prefix=CHECK-CC5 %s
 // CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getInt}{HorizontalSpace  }{LeftBrace {}{VerticalSpace  }{Text return}{HorizontalSpace  }{Placeholder expression}{SemiColon ;}{VerticalSpace  }{RightBrace }} (42) (parent: ObjCProtocolDecl 'P1')
@@ -102,7 +106,7 @@
 // CHECK-CC6: ObjCInstanceMethodDecl:{TypedText abc}{HorizontalSpace  }{LeftBrace {}{VerticalSpace 
 // CHECK-CC6: ObjCInstanceMethodDecl:{TypedText getSelf}{HorizontalSpace  }{LeftBrace {}{VerticalSpace  }{Text return}{HorizontalSpace  }{Placeholder expression}{SemiColon ;}{VerticalSpace  }{RightBrace }} (40)
 // CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace  }{LeftBrace {}{VerticalSpace 
-// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace  }{LeftBrace {}{VerticalSpace 
+// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace  }{LeftBrace {}{VerticalSpace 
 // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:42:3 %s | FileCheck -check-prefix=CHECK-CC7 %s
 // CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace  }{LeftBrace {}{VerticalSpace  }{Text return}{HorizontalSpace  }{Placeholder expression}{SemiColon ;}{VerticalSpace  }{RightBrace }} (42)
 // CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace  }{LeftBrace {}{VerticalSpace 
@@ -174,3 +178,7 @@
 // <rdar://problem/8939352>
 // RUN: c-index-test -code-completion-at=%s:68:9 %s | FileCheck -check-prefix=CHECK-8939352 %s
 // CHECK-8939352: ObjCInstanceMethodDecl:{TypedText method}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text y} (40)
+
+
+// RUN: c-index-test -code-completion-at=%s:72:2 %s | FileCheck -check-prefix=CHECK-ONEWAY %s
+// CHECK-ONEWAY: ObjCInstanceMethodDecl:{LeftParen (}{Text oneway }{Text void}{RightParen )}{TypedText method}{TypedText :}{LeftParen (}{Text in }{Text id}{RightParen )}{Text x} (40) (parent: ObjCInterfaceDecl 'Passing')

Modified: cfe/branches/tooling/test/Index/complete-super.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/complete-super.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/complete-super.cpp (original)
+++ cfe/branches/tooling/test/Index/complete-super.cpp Tue Apr 17 06:08:26 2012
@@ -31,3 +31,12 @@
 // RUN: c-index-test -code-completion-at=%s:16:6 %s | FileCheck -check-prefix=CHECK-FOO-QUAL %s
 // CHECK-FOO-QUAL: CXXMethod:{TypedText foo}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (20)
 
+// RUN: c-index-test -code-completion-at=%s:5:1 %s | FileCheck -check-prefix=CHECK-ACCESS %s
+// CHECK-ACCESS: NotImplemented:{TypedText private} (40)
+// CHECK-ACCESS: NotImplemented:{TypedText protected} (40)
+// CHECK-ACCESS: NotImplemented:{TypedText public} (40)
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:5:1 %s | FileCheck -check-prefix=CHECK-ACCESS-PATTERN %s
+// CHECK-ACCESS-PATTERN: NotImplemented:{TypedText private}{Colon :} (40)
+// CHECK-ACCESS-PATTERN: NotImplemented:{TypedText protected}{Colon :} (40)
+// CHECK-ACCESS-PATTERN: NotImplemented:{TypedText public}{Colon :} (40)

Modified: cfe/branches/tooling/test/Index/complete-synthesized.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/complete-synthesized.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/complete-synthesized.m (original)
+++ cfe/branches/tooling/test/Index/complete-synthesized.m Tue Apr 17 06:08:26 2012
@@ -35,12 +35,12 @@
 }
 @end
 
-// RUN: c-index-test -code-completion-at=%s:24:1 -fobjc-nonfragile-abi -fobjc-default-synthesize-properties %s | FileCheck %s
-// RUN: c-index-test -code-completion-at=%s:30:2 -fobjc-nonfragile-abi -fobjc-default-synthesize-properties %s | FileCheck %s
-// RUN: c-index-test -code-completion-at=%s:34:2 -fobjc-nonfragile-abi -fobjc-default-synthesize-properties %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:24:1 -target x86_64-apple-macosx10.7 -fobjc-nonfragile-abi %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:30:2 -target x86_64-apple-macosx10.7 -fobjc-nonfragile-abi %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:34:2 -target x86_64-apple-macosx10.7 -fobjc-nonfragile-abi %s | FileCheck %s
 
 // CHECK: NotImplemented:{TypedText _Bool} (50)
 // CHECK: ObjCIvarDecl:{ResultType float}{TypedText _prop2} (35)
 // CHECK-NOT: prop2
 // CHECK-NOT: prop3
-// CHECK: ObjCIvarDecl:{ResultType double}{TypedText _prop4} (37)
+// CHECK: ObjCIvarDecl:{ResultType double}{TypedText _prop4} (35)

Modified: cfe/branches/tooling/test/Index/fix-its.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/fix-its.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/fix-its.c (original)
+++ cfe/branches/tooling/test/Index/fix-its.c Tue Apr 17 06:08:26 2012
@@ -8,7 +8,7 @@
 
 void f(struct X *x) {
   // CHECK: error: no member named 'wobble' in 'struct X'; did you mean 'wibble'?
-  // CHECK: FIX-IT: Replace [13:12 - 13:24] with "wibble"
+  // CHECK: FIX-IT: Replace [13:12 - 13:18] with "wibble"
   // CHECK: note: 'wibble' declared here
   MACRO(x->wobble = 17);
   // CHECK: error: no member named 'wabble' in 'struct X'; did you mean 'wibble'?
@@ -16,3 +16,12 @@
   // CHECK: note: 'wibble' declared here
   x->wabble = 17;
 }
+
+int printf(const char *restrict, ...);
+
+void f2() {
+  unsigned long index;
+  // CHECK: warning: format specifies type 'int' but the argument has type 'unsigned long'
+  // CHECK: FIX-IT: Replace [26:17 - 26:19] with "%ld"
+  MACRO(printf("%d", index));
+}

Modified: cfe/branches/tooling/test/Index/overrides.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/overrides.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/overrides.m (original)
+++ cfe/branches/tooling/test/Index/overrides.m Tue Apr 17 06:08:26 2012
@@ -36,6 +36,20 @@
 - (void)protoMethod;
 @end
 
+ at interface B2
+ at end
+
+ at interface B2(cat)
+-(void)meth;
+ at end
+
+ at interface I2 : B2
+ at end
+
+ at implementation I2
+-(void)meth { }
+ at end
+
 // RUN: c-index-test -test-load-source local %s | FileCheck %s
 // CHECK: overrides.m:12:9: ObjCInstanceMethodDecl=protoMethod:12:9 [Overrides @3:9]
 // CHECK: overrides.m:22:9: ObjCInstanceMethodDecl=method:22:9 [Overrides @16:9]
@@ -44,3 +58,4 @@
 // CHECK: overrides.m:28:9: ObjCClassMethodDecl=methodWithParam::28:9 (Definition) [Overrides @18:9]
 // CHECK: overrides.m:32:9: ObjCInstanceMethodDecl=protoMethod:32:9 [Overrides @8:9]
 // CHECK: overrides.m:36:9: ObjCInstanceMethodDecl=protoMethod:36:9 [Overrides @12:9, @8:9, @32:9, @17:9]
+// CHECK: overrides.m:50:8: ObjCInstanceMethodDecl=meth:50:8 (Definition) [Overrides @43:8]

Modified: cfe/branches/tooling/test/Index/print-typekind.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/print-typekind.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/print-typekind.c (original)
+++ cfe/branches/tooling/test/Index/print-typekind.c Tue Apr 17 06:08:26 2012
@@ -10,7 +10,7 @@
 // RUN: c-index-test -test-print-typekind %s | FileCheck %s
 // CHECK: TypedefDecl=FooType:1:13 (Definition) typekind=Typedef [canonical=Int] [isPOD=1]
 // CHECK: VarDecl=p:2:6 typekind=Pointer [isPOD=1]
-// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer] [isPOD=0]
+// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer] [args= Pointer Pointer Typedef] [isPOD=0]
 // CHECK: ParmDecl=p:3:13 (Definition) typekind=Pointer [isPOD=1]
 // CHECK: ParmDecl=x:3:22 (Definition) typekind=Pointer [isPOD=1]
 // CHECK: ParmDecl=z:3:33 (Definition) typekind=Typedef [canonical=Int] [isPOD=1]

Modified: cfe/branches/tooling/test/Index/print-typekind.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/print-typekind.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/print-typekind.m (original)
+++ cfe/branches/tooling/test/Index/print-typekind.m Tue Apr 17 06:08:26 2012
@@ -1,10 +1,10 @@
 @interface Foo
 @property (readonly) id x;
 -(int) mymethod;
+-(int) mymethod2:(int)x blah:(float)y;
 @end
 
 // RUN: c-index-test -test-print-typekind %s | FileCheck %s
 // CHECK: ObjCPropertyDecl=x:2:25 typekind=Typedef [canonical=ObjCObjectPointer]
 // CHECK: ObjCInstanceMethodDecl=mymethod:3:8 typekind=Invalid [result=Int]
-
-
+// CHECK: ObjCInstanceMethodDecl=mymethod2:blah::4:8 typekind=Invalid [result=Int] [args= Int Float]

Modified: cfe/branches/tooling/test/Lexer/has_extension_cxx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Lexer/has_extension_cxx.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Lexer/has_extension_cxx.cpp (original)
+++ cfe/branches/tooling/test/Lexer/has_extension_cxx.cpp Tue Apr 17 06:08:26 2012
@@ -39,3 +39,11 @@
 #if __has_extension(cxx_rvalue_references)
 int has_rvalue_references();
 #endif
+
+#if __has_extension(cxx_local_type_template_args)
+int has_local_type_template_args();
+#else
+int no_local_type_template_args();
+#endif
+
+// CHECK: has_local_type_template_args

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Lexer/has_feature_cxx0x.cpp (original)
+++ cfe/branches/tooling/test/Lexer/has_feature_cxx0x.cpp Tue Apr 17 06:08:26 2012
@@ -40,6 +40,16 @@
 // CHECK-NO-0X: no_decltype
 
 
+#if __has_feature(cxx_decltype_incomplete_return_types)
+int has_decltype_incomplete_return_types();
+#else
+int no_decltype_incomplete_return_types();
+#endif
+
+// CHECK-0X: has_decltype_incomplete_return_types
+// CHECK-NO-0X: no_decltype_incomplete_return_types
+
+
 #if __has_feature(cxx_auto_type)
 int has_auto_type();
 #else
@@ -253,3 +263,12 @@
 
 // CHECK-0X: has_user_literals
 // CHECK-NO-0X: no_user_literals
+
+#if __has_feature(cxx_local_type_template_args)
+int has_local_type_template_args();
+#else
+int no_local_type_template_args();
+#endif
+
+// CHECK-0X: has_local_type_template_args
+// CHECK-NO-0X: no_local_type_template_args

Modified: cfe/branches/tooling/test/Lexer/newline-eof.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Lexer/newline-eof.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Lexer/newline-eof.c (original)
+++ cfe/branches/tooling/test/Lexer/newline-eof.c Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang -fsyntax-only -Wnewline-eof -verify %s 
+// RUN: %clang -cc1 -fsyntax-only -Wnewline-eof -verify %s
 // rdar://9133072
 
 // The following line isn't terminated, don't fix it.
-void foo() {} // expected-warning{{No newline at end of file}}
\ No newline at end of file
+void foo() {} // expected-warning{{no newline at end of file}}
\ No newline at end of file

Removed: cfe/branches/tooling/test/Misc/pubnames.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/pubnames.c?rev=154918&view=auto
==============================================================================
--- cfe/branches/tooling/test/Misc/pubnames.c (original)
+++ cfe/branches/tooling/test/Misc/pubnames.c (removed)
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 -pubnames-dump %s | FileCheck %s
-#define FOO
-#define BAR
-#undef FOO
-#define WIBBLE
-
-int foo();
-int bar(float);
-int wibble;
-
-// CHECK: BAR
-// CHECK-NOT: FOO
-// CHECK: WIBBLE
-// CHECK-NOT: __clang_major__
-// CHECK: bar
-// CHECK: foo
-// CHECK: wibble
-
-

Modified: cfe/branches/tooling/test/Misc/serialized-diags-single-issue.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/serialized-diags-single-issue.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/serialized-diags-single-issue.c (original)
+++ cfe/branches/tooling/test/Misc/serialized-diags-single-issue.c Tue Apr 17 06:08:26 2012
@@ -10,7 +10,7 @@
 // NOTE: it is important that this test case only contain a single issue.  This test case checks
 // if we can handle serialized diagnostics that contain only one diagnostic.
 
-// CHECK: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
+// CHECK: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] [Semantic Issue]
 // CHECK: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18
 // CHECK: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
 // CHECK: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13

Modified: cfe/branches/tooling/test/Misc/serialized-diags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/serialized-diags.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/serialized-diags.c (original)
+++ cfe/branches/tooling/test/Misc/serialized-diags.c Tue Apr 17 06:08:26 2012
@@ -58,11 +58,10 @@
 // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6
 // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 {{.*[/\\]}}serialized-diags.c:20:16
 // CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here []
-// CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int';  [-Wint-conversion]
+// CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
 // CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 {{.*[/\\]}}serialized-diags.h:5:17
 // CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from {{.*[/\\]}}serialized-diags.c:26: []
 // CHECK: Number FIXITs = 0
 // CHECK: {{.*[/\\]}}serialized-diags.c:30:12: warning: unused variable 'x'
 // CHECK: Number FIXITs = 0
 // CHECK: Number of diagnostics: 6
-

Modified: cfe/branches/tooling/test/Modules/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Modules/Inputs/module.map?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Modules/Inputs/module.map (original)
+++ cfe/branches/tooling/test/Modules/Inputs/module.map Tue Apr 17 06:08:26 2012
@@ -36,6 +36,8 @@
 module category_other { header "category_other.h" }
 module redeclarations_left { header "redeclarations_left.h" }
 module redeclarations_right { header "redeclarations_right.h" }
+module redecl_namespaces_left { header "redecl_namespaces_left.h" }
+module redecl_namespaces_right { header "redecl_namespaces_right.h" }
 module load_failure { header "load_failure.h" }
 
 module decldef {

Modified: cfe/branches/tooling/test/Modules/redecl-merge.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Modules/redecl-merge.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Modules/redecl-merge.m (original)
+++ cfe/branches/tooling/test/Modules/redecl-merge.m Tue Apr 17 06:08:26 2012
@@ -1,6 +1,6 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify
-// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -Wno-objc-root-class
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -Wno-objc-root-class
 @class C2;
 @class C3;
 @class C3;

Modified: cfe/branches/tooling/test/PCH/chain-categories2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/chain-categories2.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/PCH/chain-categories2.m (original)
+++ cfe/branches/tooling/test/PCH/chain-categories2.m Tue Apr 17 06:08:26 2012
@@ -1,10 +1,10 @@
 // Test that infinite loop in rdar://10418538 was fixed.
 
 // Without PCH
-// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -include %s -include %s %s
 
 // With PCH
-// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s -chain-include %s -chain-include %s
 
 #ifndef HEADER1
 #define HEADER1

Modified: cfe/branches/tooling/test/PCH/chain-selectors.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/chain-selectors.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/PCH/chain-selectors.m (original)
+++ cfe/branches/tooling/test/PCH/chain-selectors.m Tue Apr 17 06:08:26 2012
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include %S/Inputs/chain-selectors1.h -include %S/Inputs/chain-selectors2.h
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s -Wselector -include %S/Inputs/chain-selectors1.h -include %S/Inputs/chain-selectors2.h
 
-// RUN: %clang_cc1 -x objective-c -emit-pch -o %t1 %S/Inputs/chain-selectors1.h
-// RUN: %clang_cc1 -x objective-c -emit-pch -o %t2 %S/Inputs/chain-selectors2.h -include-pch %t1
-// RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include-pch %t2
+// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -emit-pch -o %t1 %S/Inputs/chain-selectors1.h
+// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -emit-pch -o %t2 %S/Inputs/chain-selectors2.h -include-pch %t1
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s -Wselector -include-pch %t2
 
 @implementation X
 -(void)f {}

Modified: cfe/branches/tooling/test/PCH/exprs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/exprs.h?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/PCH/exprs.h (original)
+++ cfe/branches/tooling/test/PCH/exprs.h Tue Apr 17 06:08:26 2012
@@ -86,7 +86,9 @@
 struct {
   int x;
   float y;
-} designated_inits[3] = { [0].y = 17, [2].x = 12.3, 3.5 };
+} designated_inits[3] = { [0].y = 17,
+                          [2].x = 12.3, // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+                          3.5 };
 
 // TypesCompatibleExpr
 typedef typeof(__builtin_types_compatible_p(float, double)) types_compatible;

Modified: cfe/branches/tooling/test/PCH/method_pool.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/method_pool.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/PCH/method_pool.m (original)
+++ cfe/branches/tooling/test/PCH/method_pool.m Tue Apr 17 06:08:26 2012
@@ -1,9 +1,9 @@
 // Test this without pch.
-// RUN: %clang_cc1 -include %S/method_pool.h -fsyntax-only -verify %s
+// RUN: %clang_cc1 -include %S/method_pool.h -fsyntax-only -verify -Wno-objc-root-class %s
 
 // Test with pch.
-// RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/method_pool.h
-// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -emit-pch -o %t %S/method_pool.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify -Wno-objc-root-class %s 
 
 int message_id(id x) {
    return [x instMethod:17]; // expected-warning{{multiple methods}}

Modified: cfe/branches/tooling/test/Parser/cxx-template-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/cxx-template-decl.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/cxx-template-decl.cpp (original)
+++ cfe/branches/tooling/test/Parser/cxx-template-decl.cpp Tue Apr 17 06:08:26 2012
@@ -6,13 +6,20 @@
                         // expected-error {{does not refer}}
 export template x;      // expected-error {{expected '<' after 'template'}}
 export template<class T> class x0; // expected-warning {{exported templates are unsupported}}
-template < ;            // expected-error {{parse error}} \
+template < ;            // expected-error {{expected template parameter}} \
 // expected-error{{expected ',' or '>' in template-parameter-list}} \
 // expected-warning {{declaration does not declare anything}}
+template <int +> struct x1; // expected-error {{expected ',' or '>' in template-parameter-list}}
+
+// verifies that we only walk to the ',' & still produce errors on the rest of the template parameters
+template <int +, T> struct x2; // expected-error {{expected ',' or '>' in template-parameter-list}} \
+                                expected-error {{expected unqualified-id}}
+template<template<int+>> struct x3; // expected-error {{expected ',' or '>' in template-parameter-list}} \
+                                         expected-error {{template template parameter requires 'class' after the parameter list}}
 template <template X> struct Err1; // expected-error {{expected '<' after 'template'}} \
 // expected-error{{extraneous}}
-template <template <typename> > struct Err2;       // expected-error {{expected 'class' before '>'}}
-template <template <typename> Foo> struct Err3;    // expected-error {{expected 'class' before 'Foo'}}
+template <template <typename> > struct Err2;       // expected-error {{template template parameter requires 'class' after the parameter list}}
+template <template <typename> Foo> struct Err3;    // expected-error {{template template parameter requires 'class' after the parameter list}}
 
 // Template function declarations
 template <typename T> void foo();

Modified: cfe/branches/tooling/test/Parser/cxx-typeof.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/cxx-typeof.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/cxx-typeof.cpp (original)
+++ cfe/branches/tooling/test/Parser/cxx-typeof.cpp Tue Apr 17 06:08:26 2012
@@ -9,5 +9,5 @@
 // Part of rdar://problem/8347416;  from the gcc test suite.
 struct S {
   int i;
-  __typeof(S::i) foo(); // expected-error {{invalid use of nonstatic data member 'i'}}
+  __typeof(S::i) foo(); // expected-error {{invalid use of non-static data member 'i'}}
 };

Modified: cfe/branches/tooling/test/Parser/cxx0x-attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/cxx0x-attributes.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/cxx0x-attributes.cpp (original)
+++ cfe/branches/tooling/test/Parser/cxx0x-attributes.cpp Tue Apr 17 06:08:26 2012
@@ -5,22 +5,31 @@
 int [[]] between_attr;
 int after_attr [[]];
 int * [[]] ptr_attr;
+int & [[]] ref_attr = after_attr;
+int && [[]] rref_attr = 0;
 int array_attr [1] [[]];
 alignas(8) int aligned_attr;
 [[test::valid(for 42 [very] **** '+' symbols went on a trip; the end.)]]
   int garbage_attr;
+[[,,,static, class, namespace,, inline, constexpr, mutable,, bi\
+tand, bitor::compl(!.*_ Cx.!U^*R),,,]] int more_garbage_attr;
+[[u8"invalid!"]] int invalid_string_attr; // expected-error {{expected ']'}}
 void fn_attr () [[]];
+void noexcept_fn_attr () noexcept [[]];
+struct MemberFnOrder {
+  virtual void f() const volatile && noexcept [[]] final = 0;
+};
 class [[]] class_attr {};
 extern "C++" [[]] int extern_attr;
 template <typename T> [[]] void template_attr ();
 [[]] [[]] int [[]] [[]] multi_attr [[]] [[]];
 
-int comma_attr [[,]]; // expected-error {{expected identifier}}
+int comma_attr [[,]];
 int scope_attr [[foo::]]; // expected-error {{expected identifier}}
+int (paren_attr) [[]]; // expected-error {{an attribute list cannot appear here}}
 unsigned [[]] int attr_in_decl_spec; // expected-error {{expected unqualified-id}}
-int & [[]] ref_attr = after_attr; // expected-error {{an attribute list cannot appear here}}
 class foo {
-  void after_const_attr () const [[]]; // expected-error {{expected body of lambda expression}}
+  void const_after_attr () [[]] const; // expected-error {{expected ';'}}
 };
 extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
 [[]] template <typename T> void before_template_attr (); // expected-error {{an attribute list cannot appear here}}
@@ -58,6 +67,17 @@
   [[]] try {
   } [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
   }
-  
+  struct S { int arr[2]; } s;
+  (void)s.arr[ [] { return 0; }() ]; // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}}
+  int n = __builtin_offsetof(S, arr[ [] { return 0; }() ]); // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}}
+
+  void bar [[noreturn]] ([[]] int i, [[]] int j);
+  using FuncType = void ([[]] int);
+  void baz([[]]...); // expected-error {{expected parameter declarator}}
+
   [[]] return;
 }
+
+template<typename...Ts> void variadic() {
+  void bar [[noreturn...]] (); // expected-error {{attribute 'noreturn' cannot be used as an attribute pack}}
+}

Modified: cfe/branches/tooling/test/Parser/declarators.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/declarators.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/declarators.c (original)
+++ cfe/branches/tooling/test/Parser/declarators.c Tue Apr 17 06:08:26 2012
@@ -97,3 +97,6 @@
 
 // rdar://problem/8358508
 long struct X { int x; } test15(); // expected-error {{'long struct' is invalid}}
+
+void test16(i) int i j; { } // expected-error {{expected ';' at end of declaration}}
+void test17(i, j) int i, j k; { } // expected-error {{expected ';' at end of declaration}}

Modified: cfe/branches/tooling/test/Parser/missing-end-4.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/missing-end-4.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/missing-end-4.m (original)
+++ cfe/branches/tooling/test/Parser/missing-end-4.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface X1
 @end

Modified: cfe/branches/tooling/test/Parser/objc-forcollection-neg-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/objc-forcollection-neg-2.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/objc-forcollection-neg-2.m (original)
+++ cfe/branches/tooling/test/Parser/objc-forcollection-neg-2.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 typedef struct objc_class *Class;
 struct __objcFastEnumerationState; 

Modified: cfe/branches/tooling/test/Parser/objc-forcollection-neg.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/objc-forcollection-neg.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/objc-forcollection-neg.m (original)
+++ cfe/branches/tooling/test/Parser/objc-forcollection-neg.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 struct __objcFastEnumerationState; 
 typedef struct objc_class *Class;

Modified: cfe/branches/tooling/test/Parser/objc-foreach-syntax.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/objc-foreach-syntax.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/objc-foreach-syntax.m (original)
+++ cfe/branches/tooling/test/Parser/objc-foreach-syntax.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 struct __objcFastEnumerationState; 
 @implementation MyList // expected-warning {{cannot find interface declaration for 'MyList'}}

Modified: cfe/branches/tooling/test/Parser/objc-init.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/objc-init.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/objc-init.m (original)
+++ cfe/branches/tooling/test/Parser/objc-init.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify %s -pedantic
-// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -x objective-c++ %s 
+// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -pedantic -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -x objective-c++ -Wno-objc-root-class %s
 // rdar://5707001
 
 @interface NSNumber;

Modified: cfe/branches/tooling/test/Parser/objc-property-syntax.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/objc-property-syntax.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/objc-property-syntax.m (original)
+++ cfe/branches/tooling/test/Parser/objc-property-syntax.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface MyClass {
   int prop;

Modified: cfe/branches/tooling/test/Parser/objc-synthesized-recover.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/objc-synthesized-recover.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/objc-synthesized-recover.m (original)
+++ cfe/branches/tooling/test/Parser/objc-synthesized-recover.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface I1 
 {

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/feature_tests.c (original)
+++ cfe/branches/tooling/test/Preprocessor/feature_tests.c Tue Apr 17 06:08:26 2012
@@ -12,6 +12,7 @@
 #if  !__has_builtin(__builtin_huge_val) || \
      !__has_builtin(__builtin_shufflevector) || \
      !__has_builtin(__builtin_trap) || \
+     !__has_builtin(__c11_atomic_init) || \
      !__has_feature(attribute_analyzer_noreturn) || \
      !__has_feature(attribute_overloadable)
 #error Clang should have these

Modified: cfe/branches/tooling/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/init.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/init.c (original)
+++ cfe/branches/tooling/test/Preprocessor/init.c Tue Apr 17 06:08:26 2012
@@ -410,6 +410,462 @@
 // I386-LINUX:#define __i386__ 1
 // I386-LINUX:#define i386 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips-none-none < /dev/null | FileCheck -check-prefix MIPS32BE %s
+//
+// MIPS32BE:#define MIPSEB 1
+// MIPS32BE:#define _ABIO32 1
+// MIPS32BE:#define _MIPSEB 1
+// MIPS32BE:#define _MIPS_SIM _ABIO32
+// MIPS32BE:#define _MIPS_SZINT 32
+// MIPS32BE:#define _MIPS_SZLONG 32
+// MIPS32BE:#define _MIPS_SZPTR 32
+// MIPS32BE:#define __CHAR16_TYPE__ unsigned short
+// MIPS32BE:#define __CHAR32_TYPE__ unsigned int
+// MIPS32BE:#define __CHAR_BIT__ 8
+// MIPS32BE:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS32BE:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32BE:#define __DBL_DIG__ 15
+// MIPS32BE:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32BE:#define __DBL_HAS_DENORM__ 1
+// MIPS32BE:#define __DBL_HAS_INFINITY__ 1
+// MIPS32BE:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS32BE:#define __DBL_MANT_DIG__ 53
+// MIPS32BE:#define __DBL_MAX_10_EXP__ 308
+// MIPS32BE:#define __DBL_MAX_EXP__ 1024
+// MIPS32BE:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS32BE:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS32BE:#define __DBL_MIN_EXP__ (-1021)
+// MIPS32BE:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS32BE:#define __DECIMAL_DIG__ 17
+// MIPS32BE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS32BE:#define __FLT_DIG__ 6
+// MIPS32BE:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS32BE:#define __FLT_EVAL_METHOD__ 0
+// MIPS32BE:#define __FLT_HAS_DENORM__ 1
+// MIPS32BE:#define __FLT_HAS_INFINITY__ 1
+// MIPS32BE:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS32BE:#define __FLT_MANT_DIG__ 24
+// MIPS32BE:#define __FLT_MAX_10_EXP__ 38
+// MIPS32BE:#define __FLT_MAX_EXP__ 128
+// MIPS32BE:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS32BE:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS32BE:#define __FLT_MIN_EXP__ (-125)
+// MIPS32BE:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS32BE:#define __FLT_RADIX__ 2
+// MIPS32BE:#define __INT16_TYPE__ short
+// MIPS32BE:#define __INT32_TYPE__ int
+// MIPS32BE:#define __INT64_C_SUFFIX__ LL
+// MIPS32BE:#define __INT64_TYPE__ long long int
+// MIPS32BE:#define __INT8_TYPE__ char
+// MIPS32BE:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS32BE:#define __INTMAX_TYPE__ long long int
+// MIPS32BE:#define __INTMAX_WIDTH__ 64
+// MIPS32BE:#define __INTPTR_TYPE__ long int
+// MIPS32BE:#define __INTPTR_WIDTH__ 32
+// MIPS32BE:#define __INT_MAX__ 2147483647
+// MIPS32BE:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32BE:#define __LDBL_DIG__ 15
+// MIPS32BE:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32BE:#define __LDBL_HAS_DENORM__ 1
+// MIPS32BE:#define __LDBL_HAS_INFINITY__ 1
+// MIPS32BE:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS32BE:#define __LDBL_MANT_DIG__ 53
+// MIPS32BE:#define __LDBL_MAX_10_EXP__ 308
+// MIPS32BE:#define __LDBL_MAX_EXP__ 1024
+// MIPS32BE:#define __LDBL_MAX__ 1.7976931348623157e+308
+// MIPS32BE:#define __LDBL_MIN_10_EXP__ (-307)
+// MIPS32BE:#define __LDBL_MIN_EXP__ (-1021)
+// MIPS32BE:#define __LDBL_MIN__ 2.2250738585072014e-308
+// MIPS32BE:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS32BE:#define __LONG_MAX__ 2147483647L
+// MIPS32BE:#define __MIPSEB 1
+// MIPS32BE:#define __MIPSEB__ 1
+// MIPS32BE:#define __NO_INLINE__ 1
+// MIPS32BE:#define __POINTER_WIDTH__ 32
+// MIPS32BE:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS32BE:#define __PTRDIFF_TYPE__ int
+// MIPS32BE:#define __PTRDIFF_WIDTH__ 32
+// MIPS32BE:#define __REGISTER_PREFIX__ 
+// MIPS32BE:#define __SCHAR_MAX__ 127
+// MIPS32BE:#define __SHRT_MAX__ 32767
+// MIPS32BE:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS32BE:#define __SIZEOF_DOUBLE__ 8
+// MIPS32BE:#define __SIZEOF_FLOAT__ 4
+// MIPS32BE:#define __SIZEOF_INT__ 4
+// MIPS32BE:#define __SIZEOF_LONG_DOUBLE__ 8
+// MIPS32BE:#define __SIZEOF_LONG_LONG__ 8
+// MIPS32BE:#define __SIZEOF_LONG__ 4
+// MIPS32BE:#define __SIZEOF_POINTER__ 4
+// MIPS32BE:#define __SIZEOF_PTRDIFF_T__ 4
+// MIPS32BE:#define __SIZEOF_SHORT__ 2
+// MIPS32BE:#define __SIZEOF_SIZE_T__ 4
+// MIPS32BE:#define __SIZEOF_WCHAR_T__ 4
+// MIPS32BE:#define __SIZEOF_WINT_T__ 4
+// MIPS32BE:#define __SIZE_TYPE__ unsigned int
+// MIPS32BE:#define __SIZE_WIDTH__ 32
+// MIPS32BE:#define __STDC_HOSTED__ 0
+// MIPS32BE:#define __STDC_VERSION__ 199901L
+// MIPS32BE:#define __STDC__ 1
+// MIPS32BE:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS32BE:#define __USER_LABEL_PREFIX__ _
+// MIPS32BE:#define __WCHAR_MAX__ 2147483647
+// MIPS32BE:#define __WCHAR_TYPE__ int
+// MIPS32BE:#define __WCHAR_WIDTH__ 32
+// MIPS32BE:#define __WINT_TYPE__ int
+// MIPS32BE:#define __WINT_WIDTH__ 32
+// MIPS32BE:#define __clang__ 1
+// MIPS32BE:#define __llvm__ 1
+// MIPS32BE:#define __mips 1
+// MIPS32BE:#define __mips__ 1
+// MIPS32BE:#define __mips_hard_float 1
+// MIPS32BE:#define __mips_o32 1
+// MIPS32BE:#define _mips 1
+// MIPS32BE:#define mips 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mipsel-none-none < /dev/null | FileCheck -check-prefix MIPS32EL %s
+//
+// MIPS32EL:#define MIPSEL 1
+// MIPS32EL:#define _ABIO32 1
+// MIPS32EL:#define _MIPSEL 1
+// MIPS32EL:#define _MIPS_SIM _ABIO32
+// MIPS32EL:#define _MIPS_SZINT 32
+// MIPS32EL:#define _MIPS_SZLONG 32
+// MIPS32EL:#define _MIPS_SZPTR 32
+// MIPS32EL:#define __CHAR16_TYPE__ unsigned short
+// MIPS32EL:#define __CHAR32_TYPE__ unsigned int
+// MIPS32EL:#define __CHAR_BIT__ 8
+// MIPS32EL:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS32EL:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32EL:#define __DBL_DIG__ 15
+// MIPS32EL:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32EL:#define __DBL_HAS_DENORM__ 1
+// MIPS32EL:#define __DBL_HAS_INFINITY__ 1
+// MIPS32EL:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS32EL:#define __DBL_MANT_DIG__ 53
+// MIPS32EL:#define __DBL_MAX_10_EXP__ 308
+// MIPS32EL:#define __DBL_MAX_EXP__ 1024
+// MIPS32EL:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS32EL:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS32EL:#define __DBL_MIN_EXP__ (-1021)
+// MIPS32EL:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS32EL:#define __DECIMAL_DIG__ 17
+// MIPS32EL:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS32EL:#define __FLT_DIG__ 6
+// MIPS32EL:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS32EL:#define __FLT_EVAL_METHOD__ 0
+// MIPS32EL:#define __FLT_HAS_DENORM__ 1
+// MIPS32EL:#define __FLT_HAS_INFINITY__ 1
+// MIPS32EL:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS32EL:#define __FLT_MANT_DIG__ 24
+// MIPS32EL:#define __FLT_MAX_10_EXP__ 38
+// MIPS32EL:#define __FLT_MAX_EXP__ 128
+// MIPS32EL:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS32EL:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS32EL:#define __FLT_MIN_EXP__ (-125)
+// MIPS32EL:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS32EL:#define __FLT_RADIX__ 2
+// MIPS32EL:#define __INT16_TYPE__ short
+// MIPS32EL:#define __INT32_TYPE__ int
+// MIPS32EL:#define __INT64_C_SUFFIX__ LL
+// MIPS32EL:#define __INT64_TYPE__ long long int
+// MIPS32EL:#define __INT8_TYPE__ char
+// MIPS32EL:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS32EL:#define __INTMAX_TYPE__ long long int
+// MIPS32EL:#define __INTMAX_WIDTH__ 64
+// MIPS32EL:#define __INTPTR_TYPE__ long int
+// MIPS32EL:#define __INTPTR_WIDTH__ 32
+// MIPS32EL:#define __INT_MAX__ 2147483647
+// MIPS32EL:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32EL:#define __LDBL_DIG__ 15
+// MIPS32EL:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32EL:#define __LDBL_HAS_DENORM__ 1
+// MIPS32EL:#define __LDBL_HAS_INFINITY__ 1
+// MIPS32EL:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS32EL:#define __LDBL_MANT_DIG__ 53
+// MIPS32EL:#define __LDBL_MAX_10_EXP__ 308
+// MIPS32EL:#define __LDBL_MAX_EXP__ 1024
+// MIPS32EL:#define __LDBL_MAX__ 1.7976931348623157e+308
+// MIPS32EL:#define __LDBL_MIN_10_EXP__ (-307)
+// MIPS32EL:#define __LDBL_MIN_EXP__ (-1021)
+// MIPS32EL:#define __LDBL_MIN__ 2.2250738585072014e-308
+// MIPS32EL:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS32EL:#define __LONG_MAX__ 2147483647L
+// MIPS32EL:#define __MIPSEL 1
+// MIPS32EL:#define __MIPSEL__ 1
+// MIPS32EL:#define __NO_INLINE__ 1
+// MIPS32EL:#define __POINTER_WIDTH__ 32
+// MIPS32EL:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS32EL:#define __PTRDIFF_TYPE__ int
+// MIPS32EL:#define __PTRDIFF_WIDTH__ 32
+// MIPS32EL:#define __REGISTER_PREFIX__ 
+// MIPS32EL:#define __SCHAR_MAX__ 127
+// MIPS32EL:#define __SHRT_MAX__ 32767
+// MIPS32EL:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS32EL:#define __SIZEOF_DOUBLE__ 8
+// MIPS32EL:#define __SIZEOF_FLOAT__ 4
+// MIPS32EL:#define __SIZEOF_INT__ 4
+// MIPS32EL:#define __SIZEOF_LONG_DOUBLE__ 8
+// MIPS32EL:#define __SIZEOF_LONG_LONG__ 8
+// MIPS32EL:#define __SIZEOF_LONG__ 4
+// MIPS32EL:#define __SIZEOF_POINTER__ 4
+// MIPS32EL:#define __SIZEOF_PTRDIFF_T__ 4
+// MIPS32EL:#define __SIZEOF_SHORT__ 2
+// MIPS32EL:#define __SIZEOF_SIZE_T__ 4
+// MIPS32EL:#define __SIZEOF_WCHAR_T__ 4
+// MIPS32EL:#define __SIZEOF_WINT_T__ 4
+// MIPS32EL:#define __SIZE_TYPE__ unsigned int
+// MIPS32EL:#define __SIZE_WIDTH__ 32
+// MIPS32EL:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS32EL:#define __USER_LABEL_PREFIX__ _
+// MIPS32EL:#define __WCHAR_MAX__ 2147483647
+// MIPS32EL:#define __WCHAR_TYPE__ int
+// MIPS32EL:#define __WCHAR_WIDTH__ 32
+// MIPS32EL:#define __WINT_TYPE__ int
+// MIPS32EL:#define __WINT_WIDTH__ 32
+// MIPS32EL:#define __clang__ 1
+// MIPS32EL:#define __llvm__ 1
+// MIPS32EL:#define __mips 1
+// MIPS32EL:#define __mips__ 1
+// MIPS32EL:#define __mips_hard_float 1
+// MIPS32EL:#define __mips_o32 1
+// MIPS32EL:#define _mips 1
+// MIPS32EL:#define mips 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-none-none < /dev/null | FileCheck -check-prefix MIPS64BE %s
+//
+// MIPS64BE:#define MIPSEB 1
+// MIPS64BE:#define _ABI64 3
+// MIPS64BE:#define _MIPSEB 1
+// MIPS64BE:#define _MIPS_SIM _ABI64
+// MIPS64BE:#define _MIPS_SZINT 32
+// MIPS64BE:#define _MIPS_SZLONG 64
+// MIPS64BE:#define _MIPS_SZPTR 64
+// MIPS64BE:#define __CHAR16_TYPE__ unsigned short
+// MIPS64BE:#define __CHAR32_TYPE__ unsigned int
+// MIPS64BE:#define __CHAR_BIT__ 8
+// MIPS64BE:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS64BE:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS64BE:#define __DBL_DIG__ 15
+// MIPS64BE:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS64BE:#define __DBL_HAS_DENORM__ 1
+// MIPS64BE:#define __DBL_HAS_INFINITY__ 1
+// MIPS64BE:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS64BE:#define __DBL_MANT_DIG__ 53
+// MIPS64BE:#define __DBL_MAX_10_EXP__ 308
+// MIPS64BE:#define __DBL_MAX_EXP__ 1024
+// MIPS64BE:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS64BE:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS64BE:#define __DBL_MIN_EXP__ (-1021)
+// MIPS64BE:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS64BE:#define __DECIMAL_DIG__ 36
+// MIPS64BE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS64BE:#define __FLT_DIG__ 6
+// MIPS64BE:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS64BE:#define __FLT_EVAL_METHOD__ 0
+// MIPS64BE:#define __FLT_HAS_DENORM__ 1
+// MIPS64BE:#define __FLT_HAS_INFINITY__ 1
+// MIPS64BE:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS64BE:#define __FLT_MANT_DIG__ 24
+// MIPS64BE:#define __FLT_MAX_10_EXP__ 38
+// MIPS64BE:#define __FLT_MAX_EXP__ 128
+// MIPS64BE:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS64BE:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS64BE:#define __FLT_MIN_EXP__ (-125)
+// MIPS64BE:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS64BE:#define __FLT_RADIX__ 2
+// MIPS64BE:#define __INT16_TYPE__ short
+// MIPS64BE:#define __INT32_TYPE__ int
+// MIPS64BE:#define __INT64_C_SUFFIX__ LL
+// MIPS64BE:#define __INT64_TYPE__ long long int
+// MIPS64BE:#define __INT8_TYPE__ char
+// MIPS64BE:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS64BE:#define __INTMAX_TYPE__ long long int
+// MIPS64BE:#define __INTMAX_WIDTH__ 64
+// MIPS64BE:#define __INTPTR_TYPE__ long int
+// MIPS64BE:#define __INTPTR_WIDTH__ 64
+// MIPS64BE:#define __INT_MAX__ 2147483647
+// MIPS64BE:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
+// MIPS64BE:#define __LDBL_DIG__ 33
+// MIPS64BE:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
+// MIPS64BE:#define __LDBL_HAS_DENORM__ 1
+// MIPS64BE:#define __LDBL_HAS_INFINITY__ 1
+// MIPS64BE:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS64BE:#define __LDBL_MANT_DIG__ 113
+// MIPS64BE:#define __LDBL_MAX_10_EXP__ 4932
+// MIPS64BE:#define __LDBL_MAX_EXP__ 16384
+// MIPS64BE:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
+// MIPS64BE:#define __LDBL_MIN_10_EXP__ (-4931)
+// MIPS64BE:#define __LDBL_MIN_EXP__ (-16381)
+// MIPS64BE:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+// MIPS64BE:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS64BE:#define __LONG_MAX__ 9223372036854775807L
+// MIPS64BE:#define __MIPSEB 1
+// MIPS64BE:#define __MIPSEB__ 1
+// MIPS64BE:#define __NO_INLINE__ 1
+// MIPS64BE:#define __POINTER_WIDTH__ 64
+// MIPS64BE:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS64BE:#define __PTRDIFF_TYPE__ long int
+// MIPS64BE:#define __PTRDIFF_WIDTH__ 64
+// MIPS64BE:#define __REGISTER_PREFIX__ 
+// MIPS64BE:#define __SCHAR_MAX__ 127
+// MIPS64BE:#define __SHRT_MAX__ 32767
+// MIPS64BE:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS64BE:#define __SIZEOF_DOUBLE__ 8
+// MIPS64BE:#define __SIZEOF_FLOAT__ 4
+// MIPS64BE:#define __SIZEOF_INT__ 4
+// MIPS64BE:#define __SIZEOF_LONG_DOUBLE__ 16
+// MIPS64BE:#define __SIZEOF_LONG_LONG__ 8
+// MIPS64BE:#define __SIZEOF_LONG__ 8
+// MIPS64BE:#define __SIZEOF_POINTER__ 8
+// MIPS64BE:#define __SIZEOF_PTRDIFF_T__ 8
+// MIPS64BE:#define __SIZEOF_SHORT__ 2
+// MIPS64BE:#define __SIZEOF_SIZE_T__ 8
+// MIPS64BE:#define __SIZEOF_WCHAR_T__ 4
+// MIPS64BE:#define __SIZEOF_WINT_T__ 4
+// MIPS64BE:#define __SIZE_TYPE__ long unsigned int
+// MIPS64BE:#define __SIZE_WIDTH__ 64
+// MIPS64BE:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS64BE:#define __USER_LABEL_PREFIX__ _
+// MIPS64BE:#define __WCHAR_MAX__ 2147483647
+// MIPS64BE:#define __WCHAR_TYPE__ int
+// MIPS64BE:#define __WCHAR_WIDTH__ 32
+// MIPS64BE:#define __WINT_TYPE__ int
+// MIPS64BE:#define __WINT_WIDTH__ 32
+// MIPS64BE:#define __clang__ 1
+// MIPS64BE:#define __llvm__ 1
+// MIPS64BE:#define __mips 1
+// MIPS64BE:#define __mips__ 1
+// MIPS64BE:#define __mips_hard_float 1
+// MIPS64BE:#define __mips_n64 1
+// MIPS64BE:#define _mips 1
+// MIPS64BE:#define mips 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-none-none < /dev/null | FileCheck -check-prefix MIPS64EL %s
+//
+// MIPS64EL:#define MIPSEL 1
+// MIPS64EL:#define _ABI64 3
+// MIPS64EL:#define _MIPSEL 1
+// MIPS64EL:#define _MIPS_SIM _ABI64
+// MIPS64EL:#define _MIPS_SZINT 32
+// MIPS64EL:#define _MIPS_SZLONG 64
+// MIPS64EL:#define _MIPS_SZPTR 64
+// MIPS64EL:#define __CHAR16_TYPE__ unsigned short
+// MIPS64EL:#define __CHAR32_TYPE__ unsigned int
+// MIPS64EL:#define __CHAR_BIT__ 8
+// MIPS64EL:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS64EL:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS64EL:#define __DBL_DIG__ 15
+// MIPS64EL:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS64EL:#define __DBL_HAS_DENORM__ 1
+// MIPS64EL:#define __DBL_HAS_INFINITY__ 1
+// MIPS64EL:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS64EL:#define __DBL_MANT_DIG__ 53
+// MIPS64EL:#define __DBL_MAX_10_EXP__ 308
+// MIPS64EL:#define __DBL_MAX_EXP__ 1024
+// MIPS64EL:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS64EL:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS64EL:#define __DBL_MIN_EXP__ (-1021)
+// MIPS64EL:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS64EL:#define __DECIMAL_DIG__ 36
+// MIPS64EL:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS64EL:#define __FLT_DIG__ 6
+// MIPS64EL:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS64EL:#define __FLT_EVAL_METHOD__ 0
+// MIPS64EL:#define __FLT_HAS_DENORM__ 1
+// MIPS64EL:#define __FLT_HAS_INFINITY__ 1
+// MIPS64EL:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS64EL:#define __FLT_MANT_DIG__ 24
+// MIPS64EL:#define __FLT_MAX_10_EXP__ 38
+// MIPS64EL:#define __FLT_MAX_EXP__ 128
+// MIPS64EL:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS64EL:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS64EL:#define __FLT_MIN_EXP__ (-125)
+// MIPS64EL:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS64EL:#define __FLT_RADIX__ 2
+// MIPS64EL:#define __INT16_TYPE__ short
+// MIPS64EL:#define __INT32_TYPE__ int
+// MIPS64EL:#define __INT64_C_SUFFIX__ LL
+// MIPS64EL:#define __INT64_TYPE__ long long int
+// MIPS64EL:#define __INT8_TYPE__ char
+// MIPS64EL:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS64EL:#define __INTMAX_TYPE__ long long int
+// MIPS64EL:#define __INTMAX_WIDTH__ 64
+// MIPS64EL:#define __INTPTR_TYPE__ long int
+// MIPS64EL:#define __INTPTR_WIDTH__ 64
+// MIPS64EL:#define __INT_MAX__ 2147483647
+// MIPS64EL:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
+// MIPS64EL:#define __LDBL_DIG__ 33
+// MIPS64EL:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
+// MIPS64EL:#define __LDBL_HAS_DENORM__ 1
+// MIPS64EL:#define __LDBL_HAS_INFINITY__ 1
+// MIPS64EL:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS64EL:#define __LDBL_MANT_DIG__ 113
+// MIPS64EL:#define __LDBL_MAX_10_EXP__ 4932
+// MIPS64EL:#define __LDBL_MAX_EXP__ 16384
+// MIPS64EL:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
+// MIPS64EL:#define __LDBL_MIN_10_EXP__ (-4931)
+// MIPS64EL:#define __LDBL_MIN_EXP__ (-16381)
+// MIPS64EL:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+// MIPS64EL:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS64EL:#define __LONG_MAX__ 9223372036854775807L
+// MIPS64EL:#define __MIPSEL 1
+// MIPS64EL:#define __MIPSEL__ 1
+// MIPS64EL:#define __NO_INLINE__ 1
+// MIPS64EL:#define __POINTER_WIDTH__ 64
+// MIPS64EL:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS64EL:#define __PTRDIFF_TYPE__ long int
+// MIPS64EL:#define __PTRDIFF_WIDTH__ 64
+// MIPS64EL:#define __REGISTER_PREFIX__ 
+// MIPS64EL:#define __SCHAR_MAX__ 127
+// MIPS64EL:#define __SHRT_MAX__ 32767
+// MIPS64EL:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS64EL:#define __SIZEOF_DOUBLE__ 8
+// MIPS64EL:#define __SIZEOF_FLOAT__ 4
+// MIPS64EL:#define __SIZEOF_INT__ 4
+// MIPS64EL:#define __SIZEOF_LONG_DOUBLE__ 16
+// MIPS64EL:#define __SIZEOF_LONG_LONG__ 8
+// MIPS64EL:#define __SIZEOF_LONG__ 8
+// MIPS64EL:#define __SIZEOF_POINTER__ 8
+// MIPS64EL:#define __SIZEOF_PTRDIFF_T__ 8
+// MIPS64EL:#define __SIZEOF_SHORT__ 2
+// MIPS64EL:#define __SIZEOF_SIZE_T__ 8
+// MIPS64EL:#define __SIZEOF_WCHAR_T__ 4
+// MIPS64EL:#define __SIZEOF_WINT_T__ 4
+// MIPS64EL:#define __SIZE_TYPE__ long unsigned int
+// MIPS64EL:#define __SIZE_WIDTH__ 64
+// MIPS64EL:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS64EL:#define __USER_LABEL_PREFIX__ _
+// MIPS64EL:#define __WCHAR_MAX__ 2147483647
+// MIPS64EL:#define __WCHAR_TYPE__ int
+// MIPS64EL:#define __WCHAR_WIDTH__ 32
+// MIPS64EL:#define __WINT_TYPE__ int
+// MIPS64EL:#define __WINT_WIDTH__ 32
+// MIPS64EL:#define __clang__ 1
+// MIPS64EL:#define __llvm__ 1
+// MIPS64EL:#define __mips 1
+// MIPS64EL:#define __mips__ 1
+// MIPS64EL:#define __mips_hard_float 1
+// MIPS64EL:#define __mips_n64 1
+// MIPS64EL:#define _mips 1
+// MIPS64EL:#define mips 1
+//
+// Check MIPS float ABI macros
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding \
+// RUN:   -triple=mips-none-none < /dev/null \
+// RUN:   | FileCheck -check-prefix MIPS-FABI-HARD %s
+// MIPS-FABI-HARD:#define __mips_hard_float 1
+//
+// RUN: %clang_cc1 -target-feature +soft-float -E -dM -ffreestanding \
+// RUN:   -triple=mips-none-none < /dev/null \
+// RUN:   | FileCheck -check-prefix MIPS-FABI-SOFT %s
+// MIPS-FABI-SOFT:#define __mips_soft_float 1
+//
+// RUN: %clang_cc1 -target-feature +single-float -E -dM -ffreestanding \
+// RUN:   -triple=mips-none-none < /dev/null \
+// RUN:   | FileCheck -check-prefix MIPS-FABI-SINGLE %s
+// MIPS-FABI-SINGLE:#define __mips_single_float 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -check-prefix MSP430 %s
 //
 // MSP430:#define MSP430 1

Modified: cfe/branches/tooling/test/Preprocessor/pic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/pic.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/pic.c (original)
+++ cfe/branches/tooling/test/Preprocessor/pic.c Tue Apr 17 06:08:26 2012
@@ -1,9 +1,34 @@
-// RUN: %clang -target i386-unknown-unknown -static -dM -E -o %t %s
-// RUN: grep '#define __PIC__' %t | count 0
-// RUN: grep '#define __pic__' %t | count 0
-// RUN: %clang -target i386-unknown-unknown -fpic -dM -E -o %t %s
-// RUN: grep '#define __PIC__ 1' %t | count 1
-// RUN: grep '#define __pic__ 1' %t | count 1
-// RUN: %clang -target i386-unknown-unknown -fPIC -dM -E -o %t %s
-// RUN: grep '#define __PIC__ 2' %t | count 1
-// RUN: grep '#define __pic__ 2' %t | count 1
+// RUN: %clang_cc1 -dM -E -o - %s \
+// RUN:   | FileCheck %s
+// CHECK-NOT: #define __PIC__
+// CHECK-NOT: #define __PIE__
+// CHECK-NOT: #define __pic__
+// CHECK-NOT: #define __pie__
+//
+// RUN: %clang_cc1 -pic-level 1 -dM -E -o - %s \
+// RUN:   | FileCheck --check-prefix=CHECK-PIC1 %s
+// CHECK-PIC1: #define __PIC__ 1
+// CHECK-PIC1-NOT: #define __PIE__
+// CHECK-PIC1: #define __pic__ 1
+// CHECK-PIC1-NOT: #define __pie__
+//
+// RUN: %clang_cc1 -pic-level 2 -dM -E -o - %s \
+// RUN:   | FileCheck --check-prefix=CHECK-PIC2 %s
+// CHECK-PIC2: #define __PIC__ 2
+// CHECK-PIC2-NOT: #define __PIE__
+// CHECK-PIC2: #define __pic__ 2
+// CHECK-PIC2-NOT: #define __pie__
+//
+// RUN: %clang_cc1 -pie-level 1 -dM -E -o - %s \
+// RUN:   | FileCheck --check-prefix=CHECK-PIE1 %s
+// CHECK-PIE1-NOT: #define __PIC__
+// CHECK-PIE1: #define __PIE__ 1
+// CHECK-PIE1-NOT: #define __pic__
+// CHECK-PIE1: #define __pie__ 1
+//
+// RUN: %clang_cc1 -pie-level 2 -dM -E -o - %s \
+// RUN:   | FileCheck --check-prefix=CHECK-PIE2 %s
+// CHECK-PIE2-NOT: #define __PIC__
+// CHECK-PIE2: #define __PIE__ 2
+// CHECK-PIE2-NOT: #define __pic__
+// CHECK-PIE2: #define __pie__ 2

Modified: cfe/branches/tooling/test/Rewriter/rewrite-modern-ivars-2.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-modern-ivars-2.mm?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-modern-ivars-2.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-modern-ivars-2.mm Tue Apr 17 06:08:26 2012
@@ -71,3 +71,31 @@
 
 @implementation NSFileLocationComponent @end
 
+// rdar://11229770
+
+ at interface Foo {
+  int bar:26;
+}
+ at end
+
+ at implementation Foo
+ at end
+
+ at interface Foo1 {
+  int bar:26;
+  int bar2:4;
+}
+ at end
+
+ at implementation Foo1
+ at end
+
+ at interface Foo3 {
+  int foo;
+  int bar:26;
+}
+ at end
+
+ at implementation Foo3
+ at end
+

Modified: cfe/branches/tooling/test/Sema/128bitint.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/128bitint.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/128bitint.c (original)
+++ cfe/branches/tooling/test/Sema/128bitint.c Tue Apr 17 06:08:26 2012
@@ -7,3 +7,7 @@
 
 // PR5435
 __uint128_t b = (__uint128_t)-1;
+
+// PR11916: Support for libstdc++ 4.7
+__int128 i = (__int128)0;
+unsigned __int128 u = (unsigned __int128)-1;

Modified: cfe/branches/tooling/test/Sema/array-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/array-init.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/array-init.c (original)
+++ cfe/branches/tooling/test/Sema/array-init.c Tue Apr 17 06:08:26 2012
@@ -48,7 +48,9 @@
   
   extern int blockScopeExtern[3] = { 1, 3, 5 }; // expected-error{{'extern' variable cannot have an initializer}}
   
-  static long x2[3] = { 1.0, "abc" , 5.8 }; // expected-warning{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [4]'}}
+  static long x2[3] = { 1.0,
+                        "abc", // expected-warning{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [4]'}}
+                         5.8 }; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
 }
 
 void test() {

Modified: cfe/branches/tooling/test/Sema/atomic-ops.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/atomic-ops.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/atomic-ops.c (original)
+++ cfe/branches/tooling/test/Sema/atomic-ops.c Tue Apr 17 06:08:26 2012
@@ -1,37 +1,165 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=i686-linux-gnu
 
-// Basic parsing/Sema tests for __atomic_*
-
-// FIXME: Need to implement __atomic_is_lock_free
+// Basic parsing/Sema tests for __c11_atomic_*
 
 typedef enum memory_order {
   memory_order_relaxed, memory_order_consume, memory_order_acquire,
   memory_order_release, memory_order_acq_rel, memory_order_seq_cst
 } memory_order;
 
-void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d) {
-  __atomic_load(0); // expected-error {{too few arguments to function}}
-  __atomic_load(0,0,0); // expected-error {{too many arguments to function}}
-  __atomic_store(0,0,0); // expected-error {{first argument to atomic operation}}
-  __atomic_store((int*)0,0,0); // expected-error {{first argument to atomic operation}}
-
-  __atomic_load(i, memory_order_seq_cst);
-  __atomic_load(p, memory_order_seq_cst);
-  __atomic_load(d, memory_order_seq_cst);
-
-  __atomic_store(i, 1, memory_order_seq_cst);
-  __atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}}
-  (int)__atomic_store(d, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
-
-  __atomic_fetch_add(i, 1, memory_order_seq_cst);
-  __atomic_fetch_add(p, 1, memory_order_seq_cst);
-  __atomic_fetch_add(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or pointer}}
-
-  __atomic_fetch_and(i, 1, memory_order_seq_cst);
-  __atomic_fetch_and(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
-  __atomic_fetch_and(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
-
-  __atomic_compare_exchange_strong(i, 0, 1, memory_order_seq_cst, memory_order_seq_cst);
-  __atomic_compare_exchange_strong(p, 0, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
-  __atomic_compare_exchange_strong(d, (int*)0, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
+struct S { char c[3]; };
+
+_Static_assert(__GCC_ATOMIC_BOOL_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_CHAR_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_CHAR16_T_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_CHAR32_T_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
+_Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
+
+_Static_assert(__c11_atomic_is_lock_free(1), "");
+_Static_assert(__c11_atomic_is_lock_free(2), "");
+_Static_assert(__c11_atomic_is_lock_free(3), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__c11_atomic_is_lock_free(4), "");
+_Static_assert(__c11_atomic_is_lock_free(8), "");
+_Static_assert(__c11_atomic_is_lock_free(16), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__c11_atomic_is_lock_free(17), ""); // expected-error {{not an integral constant expression}}
+
+_Static_assert(__atomic_is_lock_free(1, 0), "");
+_Static_assert(__atomic_is_lock_free(2, 0), "");
+_Static_assert(__atomic_is_lock_free(3, 0), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(4, 0), "");
+_Static_assert(__atomic_is_lock_free(8, 0), "");
+_Static_assert(__atomic_is_lock_free(16, 0), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(17, 0), ""); // expected-error {{not an integral constant expression}}
+
+char i8;
+short i16;
+int i32;
+int __attribute__((vector_size(8))) i64;
+struct Incomplete *incomplete;
+
+_Static_assert(__atomic_is_lock_free(1, &i8), "");
+_Static_assert(__atomic_is_lock_free(1, &i64), "");
+_Static_assert(__atomic_is_lock_free(2, &i8), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(2, &i16), "");
+_Static_assert(__atomic_is_lock_free(2, &i64), "");
+_Static_assert(__atomic_is_lock_free(4, &i16), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(4, &i32), "");
+_Static_assert(__atomic_is_lock_free(4, &i64), "");
+_Static_assert(__atomic_is_lock_free(8, &i32), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(8, &i64), "");
+
+_Static_assert(__atomic_always_lock_free(1, 0), "");
+_Static_assert(__atomic_always_lock_free(2, 0), "");
+_Static_assert(!__atomic_always_lock_free(3, 0), "");
+_Static_assert(__atomic_always_lock_free(4, 0), "");
+_Static_assert(__atomic_always_lock_free(8, 0), "");
+_Static_assert(!__atomic_always_lock_free(16, 0), "");
+_Static_assert(!__atomic_always_lock_free(17, 0), "");
+
+_Static_assert(__atomic_always_lock_free(1, incomplete), "");
+_Static_assert(!__atomic_always_lock_free(2, incomplete), "");
+_Static_assert(!__atomic_always_lock_free(4, incomplete), "");
+
+_Static_assert(__atomic_always_lock_free(1, &i8), "");
+_Static_assert(__atomic_always_lock_free(1, &i64), "");
+_Static_assert(!__atomic_always_lock_free(2, &i8), "");
+_Static_assert(__atomic_always_lock_free(2, &i16), "");
+_Static_assert(__atomic_always_lock_free(2, &i64), "");
+_Static_assert(!__atomic_always_lock_free(4, &i16), "");
+_Static_assert(__atomic_always_lock_free(4, &i32), "");
+_Static_assert(__atomic_always_lock_free(4, &i64), "");
+_Static_assert(!__atomic_always_lock_free(8, &i32), "");
+_Static_assert(__atomic_always_lock_free(8, &i64), "");
+
+void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d,
+       int *I, int **P, float *D, struct S *s1, struct S *s2) {
+  __c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}
+  __c11_atomic_load(0); // expected-error {{too few arguments to function}}
+  __c11_atomic_load(0,0,0); // expected-error {{too many arguments to function}}
+  __c11_atomic_store(0,0,0); // expected-error {{first argument to atomic builtin must be a pointer}}
+  __c11_atomic_store((int*)0,0,0); // expected-error {{first argument to atomic operation must be a pointer to _Atomic}}
+
+  __c11_atomic_load(i, memory_order_seq_cst);
+  __c11_atomic_load(p, memory_order_seq_cst);
+  __c11_atomic_load(d, memory_order_seq_cst);
+
+  int load_n_1 = __atomic_load_n(I, memory_order_relaxed);
+  int *load_n_2 = __atomic_load_n(P, memory_order_relaxed);
+  float load_n_3 = __atomic_load_n(D, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
+  __atomic_load_n(s1, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
+
+  __atomic_load(i, I, memory_order_relaxed); // expected-error {{must be a pointer to a trivially-copyable type}}
+  __atomic_load(I, i, memory_order_relaxed); // expected-warning {{passing '_Atomic(int) *' to parameter of type 'int *'}}
+  __atomic_load(I, *P, memory_order_relaxed);
+  __atomic_load(I, *P, memory_order_relaxed, 42); // expected-error {{too many arguments}}
+  (int)__atomic_load(I, I, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+  __atomic_load(s1, s2, memory_order_acquire);
+
+  __c11_atomic_store(i, 1, memory_order_seq_cst);
+  __c11_atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}}
+  (int)__c11_atomic_store(d, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+
+  __atomic_store_n(I, 4, memory_order_release);
+  __atomic_store_n(I, 4.0, memory_order_release);
+  __atomic_store_n(I, P, memory_order_release); // expected-warning {{parameter of type 'int'}}
+  __atomic_store_n(i, 1, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
+  __atomic_store_n(s1, *s2, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
+
+  __atomic_store(I, *P, memory_order_release);
+  __atomic_store(s1, s2, memory_order_release);
+  __atomic_store(i, I, memory_order_release); // expected-error {{trivially-copyable}}
+
+  int exchange_1 = __c11_atomic_exchange(i, 1, memory_order_seq_cst);
+  int exchange_2 = __c11_atomic_exchange(I, 1, memory_order_seq_cst); // expected-error {{must be a pointer to _Atomic}}
+  int exchange_3 = __atomic_exchange_n(i, 1, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+  int exchange_4 = __atomic_exchange_n(I, 1, memory_order_seq_cst);
+
+  __atomic_exchange(s1, s2, s2, memory_order_seq_cst);
+  __atomic_exchange(s1, I, P, memory_order_seq_cst); // expected-warning 2{{parameter of type 'struct S *'}}
+  (int)__atomic_exchange(s1, s2, s2, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+
+  __c11_atomic_fetch_add(i, 1, memory_order_seq_cst);
+  __c11_atomic_fetch_add(p, 1, memory_order_seq_cst);
+  __c11_atomic_fetch_add(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or pointer}}
+
+  __atomic_fetch_add(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer or pointer}}
+  __atomic_fetch_sub(I, 3, memory_order_seq_cst);
+  __atomic_fetch_sub(P, 3, memory_order_seq_cst);
+  __atomic_fetch_sub(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+  __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+
+  __c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
+  __c11_atomic_fetch_and(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
+  __c11_atomic_fetch_and(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
+
+  __atomic_fetch_and(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer}}
+  __atomic_fetch_or(I, 3, memory_order_seq_cst);
+  __atomic_fetch_xor(P, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
+  __atomic_fetch_or(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
+  __atomic_fetch_and(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
+
+  _Bool cmpexch_1 = __c11_atomic_compare_exchange_strong(i, 0, 1, memory_order_seq_cst, memory_order_seq_cst);
+  _Bool cmpexch_2 = __c11_atomic_compare_exchange_strong(p, 0, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
+  _Bool cmpexch_3 = __c11_atomic_compare_exchange_strong(d, (int*)0, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
+
+  _Bool cmpexch_4 = __atomic_compare_exchange_n(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst);
+  _Bool cmpexch_5 = __atomic_compare_exchange_n(I, P, 5, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
+  _Bool cmpexch_6 = __atomic_compare_exchange_n(I, I, P, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int **' to parameter of type 'int'}}
+
+  _Bool cmpexch_7 = __atomic_compare_exchange(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int' to parameter of type 'int *'}}
+  _Bool cmpexch_8 = __atomic_compare_exchange(I, P, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
+  _Bool cmpexch_9 = __atomic_compare_exchange(I, I, I, 0, memory_order_seq_cst, memory_order_seq_cst);
+
+  const volatile int flag_k = 0;
+  volatile int flag = 0;
+  (void)(int)__atomic_test_and_set(&flag_k, memory_order_seq_cst); // expected-warning {{passing 'const volatile int *' to parameter of type 'volatile void *'}}
+  (void)(int)__atomic_test_and_set(&flag, memory_order_seq_cst);
+  __atomic_clear(&flag_k, memory_order_seq_cst); // expected-warning {{passing 'const volatile int *' to parameter of type 'volatile void *'}}
+  __atomic_clear(&flag, memory_order_seq_cst);
+  (int)__atomic_clear(&flag, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
 }

Modified: cfe/branches/tooling/test/Sema/c89.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/c89.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/c89.c (original)
+++ cfe/branches/tooling/test/Sema/c89.c Tue Apr 17 06:08:26 2012
@@ -92,4 +92,21 @@
 
 struct x { int x,y[]; }; /* expected-warning {{Flexible array members are a C99-specific feature}} */
 
+/* Duplicated type-qualifiers aren't allowed by C90 */
+const const int c_i; /* expected-warning {{duplicate 'const' declaration specifier}} */
+typedef volatile int vol_int;
+volatile vol_int volvol_i; /* expected-warning {{duplicate 'volatile' declaration specifier}} */
+typedef volatile vol_int volvol_int; /* expected-warning {{duplicate 'volatile' declaration specifier}} */
+const int * const c;
+
+typedef const int CI;
+
+const CI mine1[5][5]; /* expected-warning {{duplicate 'const' declaration specifier}} */
+
+typedef CI array_of_CI[5];
+const array_of_CI mine2; /* expected-warning {{duplicate 'const' declaration specifier}} */
+
+typedef CI *array_of_pointer_to_CI[5];
+const array_of_pointer_to_CI mine3;
+
 void main() {} /* expected-error {{'main' must return 'int'}} */

Modified: cfe/branches/tooling/test/Sema/conditional-expr.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/conditional-expr.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/conditional-expr.c (original)
+++ cfe/branches/tooling/test/Sema/conditional-expr.c Tue Apr 17 06:08:26 2012
@@ -60,6 +60,23 @@
   test0 = test0 ? EVal : test1; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
   test0 = test0 ? test1 : EVal; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
 
+  const int *const_int;
+  int *nonconst_int;
+  *(test0 ? const_int : nonconst_int) = 42; // expected-error {{read-only variable is not assignable}}
+  *(test0 ? nonconst_int : const_int) = 42; // expected-error {{read-only variable is not assignable}}
+
+  // The composite type here should be "int (*)[12]", fine for the sizeof
+  int (*incomplete)[];
+  int (*complete)[12];
+  sizeof(*(test0 ? incomplete : complete)); // expected-warning {{expression result unused}}
+  sizeof(*(test0 ? complete : incomplete)); // expected-warning {{expression result unused}}
+
+  int __attribute__((address_space(2))) *adr2;
+  int __attribute__((address_space(3))) *adr3;
+  test0 ? adr2 : adr3; // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
+
+  // Make sure address-space mask ends up in the result type
+  (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
 }
 
 int Postgresql() {

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/const-eval.c (original)
+++ cfe/branches/tooling/test/Sema/const-eval.c Tue Apr 17 06:08:26 2012
@@ -117,3 +117,7 @@
 float varfloat;
 const float constfloat = 0;
 EVAL_EXPR(43, varfloat && constfloat) // expected-error {{must have a constant size}}
+
+// <rdar://problem/11205586>
+// (Make sure we continue to reject this.)
+EVAL_EXPR(44, "x"[0]); // expected-error {{variable length array}}

Modified: cfe/branches/tooling/test/Sema/conversion-64-32.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/conversion-64-32.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/conversion-64-32.c (original)
+++ cfe/branches/tooling/test/Sema/conversion-64-32.c Tue Apr 17 06:08:26 2012
@@ -13,3 +13,7 @@
   int4  v127 = a;  // no warning.
   return v127; 
 }
+
+int test2(long v) {
+  return v / 2; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}
+}

Modified: cfe/branches/tooling/test/Sema/types.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/types.c?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/types.c (original)
+++ cfe/branches/tooling/test/Sema/types.c Tue Apr 17 06:08:26 2012
@@ -19,7 +19,21 @@
   int __int128_t;
   int __uint128_t;
 }
-
+// __int128 is a keyword
+int c() {
+  __int128 i;
+  unsigned __int128 j;
+  long unsigned __int128 k; // expected-error {{'long __int128' is invalid}}
+  int __int128; // expected-error {{cannot combine with previous}} expected-warning {{does not declare anything}}
+}
+// __int128_t is __int128; __uint128_t is unsigned __int128.
+typedef __int128 check_int_128; // expected-note {{here}}
+typedef __int128_t check_int_128; // expected-note {{here}} expected-warning {{redefinition}}
+typedef int check_int_128; // expected-error {{different types ('int' vs '__int128_t' (aka '__int128'))}}
+
+typedef unsigned __int128 check_uint_128; // expected-note {{here}}
+typedef __uint128_t check_uint_128; // expected-note {{here}} expected-warning {{redefinition}}
+typedef int check_uint_128; // expected-error {{different types ('int' vs '__uint128_t' (aka 'unsigned __int128'))}}
 
 // Array type merging should convert array size to whatever matches the target
 // pointer size.

Modified: cfe/branches/tooling/test/SemaCXX/atomic-type.cxx
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/atomic-type.cxx?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/atomic-type.cxx (original)
+++ cfe/branches/tooling/test/SemaCXX/atomic-type.cxx Tue Apr 17 06:08:26 2012
@@ -10,3 +10,26 @@
 };
 
 user<int> u;
+
+// Test overloading behavior of atomics.
+struct A { };
+
+int &ovl1(_Atomic(int));
+long &ovl1(_Atomic(long));
+float &ovl1(_Atomic(float));
+double &ovl1(_Atomic(A const *const *));
+short &ovl1(_Atomic(A **));
+
+void test_overloading(int i, float f, _Atomic(int) ai, _Atomic(float) af,
+                      long l, _Atomic(long) al, A const *const *acc,
+                      A const ** ac, A **a) {
+  int& ir1 = ovl1(i);
+  int& ir2 = ovl1(ai);
+  long& lr1 = ovl1(l);
+  long& lr2 = ovl1(al);
+  float &fr1 = ovl1(f);
+  float &fr2 = ovl1(af);
+  double &dr1 = ovl1(acc);
+  double &dr2 = ovl1(ac);
+  short &sr1 = ovl1(a);
+}

Modified: cfe/branches/tooling/test/SemaCXX/class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/class.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/class.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/class.cpp Tue Apr 17 06:08:26 2012
@@ -7,16 +7,18 @@
 
   static void sm() {
     sx = 0;
-    this->x = 0; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+    this->x = 0; // expected-error {{invalid use of 'this' outside of a non-static member function}}
     x = 0; // expected-error {{invalid use of member 'x' in static member function}}
   }
 
   class NestedC {
   public:
     NestedC(int);
-    void m() {
+    void f() {
       sx = 0;
-      x = 0; // expected-error {{invalid use of nonstatic data member 'x'}}
+      x = 0; // expected-error {{use of non-static data member 'x' of 'C' from nested type 'NestedC'}}
+      sm();
+      m(); // expected-error {{call to non-static member function 'm' of 'C' from nested type 'NestedC'}}
     }
   };
 
@@ -129,10 +131,10 @@
     bogus<foo<T1,T2> > // expected-error {{unknown template name 'bogus'}} \
                        // BOGUS expected-error {{expected '{' after base class list}} \
                        // BOGUS expected-error {{expected ';' after struct}} \
-                       // BOGUS expected-error {{expected unqualified-id}} \
+                       // BOGUS expected-error {{expected unqualified-id}}
   { };
 
-  template<> struct foo<unknown,unknown> { // why isn't there an error here?
+  template<> struct foo<unknown,unknown> { // expected-error {{undeclared identifier 'unknown'}}
     template <typename U1, typename U2> struct bar {
       typedef bar type;
       static const int value = 0;
@@ -186,7 +188,7 @@
 };
 
 void f() {
-    S::c; // expected-error {{invalid use of nonstatic data member}}
+    S::c; // expected-error {{invalid use of non-static data member}}
 }
 }
 

Modified: cfe/branches/tooling/test/SemaCXX/constexpr-printing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/constexpr-printing.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/constexpr-printing.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/constexpr-printing.cpp Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -triple x86_64-linux-gnu
 
 struct S;
 constexpr int extract(const S &s);
@@ -85,8 +85,8 @@
   expected-error {{}} expected-note {{u"test\000\\\"\t\a\b\234\u1234"}}
 constexpr char32_t c32 = get(U"test\0\\\"\t\a\b\234\u1234\U0010ffff"); // \
   expected-error {{}} expected-note {{U"test\000\\\"\t\a\b\234\u1234\U0010FFFF"}}
-constexpr wchar_t wc = get(L"test\0\\\"\t\a\b\234\u1234"); // \
-  expected-error {{}} expected-note {{L"test\000\\\"\t\a\b\234\u1234"}}
+constexpr wchar_t wc = get(L"test\0\\\"\t\a\b\234\u1234\xffffffff"); // \
+  expected-error {{}} expected-note {{L"test\000\\\"\t\a\b\234\x1234\xFFFFFFFF"}}
 
 constexpr char32_t c32_err = get(U"\U00110000"); // expected-error {{invalid universal character}}
 

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-constructor.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-constructor.cpp Tue Apr 17 06:08:26 2012
@@ -267,3 +267,17 @@
   struct B { explicit B(short); B(long); }; // expected-note 2 {{candidate}}
   B b = { 0 }; // expected-error {{ambiguous}}
 }
+
+namespace PR12498 {
+  class ArrayRef; // expected-note{{forward declaration}}
+
+  struct C {
+    void foo(const ArrayRef&); // expected-note{{passing argument to parameter here}}
+  };
+
+  static void bar(C* c)
+  {
+    c->foo({ nullptr, 1 }); // expected-error{{initialization of incomplete type 'const PR12498::ArrayRef'}}
+  }
+
+}

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Tue Apr 17 06:08:26 2012
@@ -150,3 +150,28 @@
     g({il, {2, 3}});
   }
 }
+
+namespace Decay {
+  template<typename T>
+  void f(std::initializer_list<T>) {
+    T x = 1; // expected-error{{cannot initialize a variable of type 'const char *' with an rvalue of type 'int'}}
+  }
+
+  void g() {
+    f({"A", "BB", "CCC"}); // expected-note{{in instantiation of function template specialization 'Decay::f<const char *>' requested here}}
+
+    auto x = { "A", "BB", "CCC" };
+    std::initializer_list<const char *> *il = &x;
+
+    for( auto s : {"A", "BB", "CCC", "DDD"}) { }
+  }
+}
+
+namespace PR12436 {
+  struct X {
+    template<typename T>
+    X(std::initializer_list<int>, T);
+  };
+  
+  X x({}, 17);
+}

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp Tue Apr 17 06:08:26 2012
@@ -291,3 +291,11 @@
   const char *s1 = "foo\u0031"; // expected-warning {{specifying character '1' with a universal character name is incompatible with C++98}}
   const wchar_t *s2 = L"bar\u0085"; // expected-warning {{universal character name referring to a control character is incompatible with C++98}}
 }
+
+namespace NonTypeTemplateArgs {
+  template<typename T, T v> struct S {};
+  const int k = 5; // expected-note {{here}}
+  static void f() {} // expected-note {{here}}
+  S<const int&, k> s1; // expected-warning {{non-type template argument referring to object 'k' with internal linkage is incompatible with C++98}}
+  S<void(&)(), f> s2; // expected-warning {{non-type template argument referring to function 'f' with internal linkage is incompatible with C++98}}
+}

Modified: cfe/branches/tooling/test/SemaCXX/default2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/default2.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/default2.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/default2.cpp Tue Apr 17 06:08:26 2012
@@ -28,7 +28,7 @@
 void g2(int x, int y, int z = x + y); // expected-error {{default argument references parameter 'x'}} expected-error {{default argument references parameter 'y'}}
 
 class X {
-  void f(X* x = this); // expected-error{{invalid use of 'this' outside of a nonstatic member function}}
+  void f(X* x = this); // expected-error{{invalid use of 'this' outside of a non-static member function}}
 
   void g() { 
     int f(X* x = this); // expected-error{{default argument references 'this'}}
@@ -55,7 +55,7 @@
 // C++ [dcl.fct.default]p9
 struct Y { 
   int a; 
-  int mem1(int i = a); // expected-error{{invalid use of nonstatic data member 'a'}}
+  int mem1(int i = a); // expected-error{{invalid use of non-static data member 'a'}}
   int mem2(int i = b); // OK; use Y::b 
   int mem3(int i);
   int mem4(int i);
@@ -64,8 +64,8 @@
     int mem5(int i = b, // OK; use Y::b
              int j = c, // OK; use Y::Nested::c
              int k = j, // expected-error{{default argument references parameter 'j'}}
-             int l = a,  // expected-error{{invalid use of nonstatic data member 'a'}}
-             Nested* self = this, // expected-error{{invalid use of 'this' outside of a nonstatic member function}}
+             int l = a,  // expected-error{{invalid use of non-static data member 'a'}}
+             Nested* self = this, // expected-error{{invalid use of 'this' outside of a non-static member function}}
              int m); // expected-error{{missing default argument on parameter 'm'}}
     static int c;
     Nested(int i = 42);
@@ -78,7 +78,7 @@
 
 int Y::mem3(int i = b) { return i; } // OK; use X::b
 
-int Y::mem4(int i = a) // expected-error{{invalid use of nonstatic data member 'a'}}
+int Y::mem4(int i = a) // expected-error{{invalid use of non-static data member 'a'}}
 { return i; }
 
 

Modified: cfe/branches/tooling/test/SemaCXX/function-redecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/function-redecl.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/function-redecl.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/function-redecl.cpp Tue Apr 17 06:08:26 2012
@@ -76,9 +76,12 @@
   void GetCart(int count) const;
 };
 // This out-of-line definition was fine...
-void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}}
+void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}} \
+                                     // expected-note {{'cart' declared here}} \
+                                     // expected-note {{previous definition is here}}
 // ...while this one crashed clang
-void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'}}
+void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'; did you mean 'cart'?}} \
+                                      // expected-error {{redefinition of 'cart'}}
 
 class TestConst {
  public:

Modified: cfe/branches/tooling/test/SemaCXX/goto.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/goto.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/goto.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/goto.cpp Tue Apr 17 06:08:26 2012
@@ -115,3 +115,13 @@
     ;
   }
 }
+
+namespace test12 {
+  struct A { A(); A(const A&); ~A(); };
+  void test(A a) { // expected-note {{jump enters lifetime of block}} FIXME: wierd location
+    goto lbl; // expected-error {{goto into protected scope}}
+    (void) ^{ (void) a; };
+  lbl:
+    return;
+  }
+}

Modified: cfe/branches/tooling/test/SemaCXX/namespace-alias.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/namespace-alias.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/namespace-alias.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/namespace-alias.cpp Tue Apr 17 06:08:26 2012
@@ -11,9 +11,13 @@
 namespace C = N; // expected-error {{redefinition of 'C'}}
 
 int i;
-namespace D = i; // expected-error {{expected namespace name}}
+namespace D =
+i; // expected-error {{expected namespace name}}
 
-namespace E = N::Foo; // expected-error {{expected namespace name}}
+namespace E1 = N::
+Foo; // expected-error {{expected namespace name}}
+namespace E2 = N::
+X; // expected-error {{expected namespace name}}
 
 namespace F {
   namespace A { namespace B { } } // expected-note {{candidate found by name lookup is 'F::A::B'}}

Modified: cfe/branches/tooling/test/SemaCXX/nested-name-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/nested-name-spec.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/nested-name-spec.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/nested-name-spec.cpp Tue Apr 17 06:08:26 2012
@@ -45,7 +45,7 @@
 }
 
 namespace B {
-  void ::A::Af() {} // expected-error {{definition or redeclaration of 'Af' not in a namespace enclosing 'A'}}
+  void ::A::Af() {} // expected-error {{cannot define or redeclare 'Af' here because namespace 'B' does not enclose namespace 'A'}}
 }
 
 void f1() {

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/new-delete.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/new-delete.cpp Tue Apr 17 06:08:26 2012
@@ -102,8 +102,7 @@
 void bad_deletes()
 {
   delete 0; // expected-error {{cannot delete expression of type 'int'}}
-  delete [0] (int*)0; // expected-error {{expected ']'}} \
-                      // expected-note {{to match this '['}}
+  delete [0] (int*)0; // expected-error {{expected expression}}
   delete (void*)0; // expected-warning {{cannot delete expression with pointer-to-'void' type 'void *'}}
   delete (T*)0; // expected-warning {{deleting pointer to incomplete type}}
   ::S::delete (int*)0; // expected-error {{expected unqualified-id}}

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/overload-call.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/overload-call.cpp Tue Apr 17 06:08:26 2012
@@ -233,7 +233,7 @@
 
 void intref_test() {
   float* ir1 = intref(5);
-  float* ir2 = intref(5.5);
+  float* ir2 = intref(5.5); // expected-warning{{implicit conversion turns literal floating-point number into integer}}
 }
 
 void derived5(C&); // expected-note{{candidate function not viable: cannot bind base class object of type 'A' to derived class reference 'C &' for 1st argument}}

Modified: cfe/branches/tooling/test/SemaCXX/qual-id-test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/qual-id-test.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/qual-id-test.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/qual-id-test.cpp Tue Apr 17 06:08:26 2012
@@ -137,13 +137,13 @@
 
 a a;
 
-int a::sa = a.a; // expected-error {{invalid use of nonstatic data member 'a'}}
+int a::sa = a.a; // expected-error {{invalid use of non-static data member 'a'}}
 
 
 namespace PR6645 {
   typedef int foo;
   namespace Inner {
     typedef int PR6645::foo; // expected-error{{typedef declarator cannot be qualified}} \
-    // expected-error{{definition or redeclaration of 'foo' not in a namespace enclosing 'PR6645'}}
+    // expected-error{{cannot define or redeclare 'foo' here because namespace 'Inner' does not enclose namespace 'PR6645'}}
   }
 }

Modified: cfe/branches/tooling/test/SemaCXX/qualified-id-lookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/qualified-id-lookup.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/qualified-id-lookup.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/qualified-id-lookup.cpp Tue Apr 17 06:08:26 2012
@@ -146,3 +146,8 @@
     Z(foo::X()).Work();
   }
 }
+
+namespace pr12339 {
+  extern "C" void i;
+  pr12339::FOO  // expected-error{{no type named 'FOO' in namespace 'pr12339'}}
+}  // expected-error{{expected unqualified-id}}

Modified: cfe/branches/tooling/test/SemaCXX/static-assert.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/static-assert.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/static-assert.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/static-assert.cpp Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=x86_64-linux-gnu
 
 int f(); // expected-note {{declared here}}
 
@@ -27,3 +27,10 @@
 
 S<char> s1; // expected-note {{in instantiation of template class 'S<char>' requested here}}
 S<int> s2;
+
+static_assert(false, L"\xFFFFFFFF"); // expected-error {{static_assert failed L"\xFFFFFFFF"}}
+static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u"\U000317FF"}}
+// FIXME: render this as u8"\u03A9"
+static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}}
+static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}}
+static_assert(false, L"\x1ff" "0\x123" "fx\xfffff" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFFFFFgoop"}}

Modified: cfe/branches/tooling/test/SemaCXX/this.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/this.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/this.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/this.cpp Tue Apr 17 06:08:26 2012
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s 
-int x = this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+int x = this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
 
 void f() {
-  int x = this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+  int x = this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
 }

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/typo-correction.cpp Tue Apr 17 06:08:26 2012
@@ -183,3 +183,10 @@
         getExprAs<ConstructExpr>(); // expected-error{{use of undeclared identifier 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}}
   }
 };
+
+namespace test1 {
+  struct S {
+    struct Foobar *f;  // expected-note{{'Foobar' declared here}}
+  };
+  test1::FooBar *b;  // expected-error{{no type named 'FooBar' in namespace 'test1'; did you mean 'Foobar'?}}
+}

Modified: cfe/branches/tooling/test/SemaCXX/uninitialized.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/uninitialized.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/uninitialized.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/uninitialized.cpp Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -std=c++11 -verify %s
 
 int foo(int x);
 int bar(int* x);
@@ -162,3 +162,8 @@
   return x;
 }
 
+// Test lambda expressions with -Wuninitialized
+int test_lambda() {
+  auto f1 = [] (int x, int y) { int z; return x + y + z; }; // expected-warning {{C++11 requires lambda with omitted result type to consist of a single return statement}} expected-warning{{variable 'z' is uninitialized when used here}} expected-note {{initialize the variable 'z' to silence this warning}}
+  return f1(1, 2);
+}

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp Tue Apr 17 06:08:26 2012
@@ -1153,7 +1153,7 @@
 int Foo::foo()
 {
   int res;
-  w = 5.2;
+  w = 5;
   res = a_ + 5;
   return res;
 }
@@ -1167,7 +1167,7 @@
   mu_.Unlock();
   if (x > 5) {
     mu1.Lock();
-    g = 2.3;
+    g = 2;
     mu1.Unlock();
   }
 }
@@ -1185,7 +1185,7 @@
   f2->bar(); // expected-warning {{cannot call function 'bar' while mutex 'mu_' is locked}}
   f2->mu_.Unlock();
   mu2.Lock();
-  w = 2.5;
+  w = 2;
   mu2.Unlock();
 }
 } // end namespace thread_annot_lock_13

Modified: cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp Tue Apr 17 06:08:26 2012
@@ -1,9 +1,26 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
 
+#define LOCKABLE            __attribute__ ((lockable))
+#define SCOPED_LOCKABLE     __attribute__ ((scoped_lockable))
+#define GUARDED_BY(x)       __attribute__ ((guarded_by(x)))
+#define GUARDED_VAR         __attribute__ ((guarded_var))
+#define PT_GUARDED_BY(x)    __attribute__ ((pt_guarded_by(x)))
+#define PT_GUARDED_VAR      __attribute__ ((pt_guarded_var))
+#define ACQUIRED_AFTER(...) __attribute__ ((acquired_after(__VA_ARGS__)))
+#define ACQUIRED_BEFORE(...) __attribute__ ((acquired_before(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...)   __attribute__ ((exclusive_lock_function(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...)      __attribute__ ((shared_lock_function(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__ ((exclusive_trylock_function(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...)    __attribute__ ((shared_trylock_function(__VA_ARGS__)))
+#define UNLOCK_FUNCTION(...)            __attribute__ ((unlock_function(__VA_ARGS__)))
+#define LOCK_RETURNED(x)    __attribute__ ((lock_returned(x)))
+#define LOCKS_EXCLUDED(...) __attribute__ ((locks_excluded(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...) \
+  __attribute__ ((exclusive_locks_required(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...) \
+  __attribute__ ((shared_locks_required(__VA_ARGS__)))
+#define NO_THREAD_SAFETY_ANALYSIS  __attribute__ ((no_thread_safety_analysis))
 
-//-----------------------------------------//
-//  Helper fields
-//-----------------------------------------//
 
 class __attribute__((lockable)) Mu {
   public:
@@ -324,13 +341,13 @@
 
 // illegal attribute arguments
 int gb_var_arg_bad_1 __attribute__((guarded_by(1))); // \
-  // expected-error {{'guarded_by' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'int'}}
 int gb_var_arg_bad_2 __attribute__((guarded_by("mu"))); // \
-  // expected-error {{'guarded_by' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'const char [3]'}}
 int gb_var_arg_bad_3 __attribute__((guarded_by(muDoublePointer))); // \
-  // expected-error {{'guarded_by' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'class Mu **'}}
 int gb_var_arg_bad_4 __attribute__((guarded_by(umu))); // \
-  // expected-error {{'guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute; type here is 'class UnlockableMu'}}
 
 //3.
 // Thread Safety analysis tests
@@ -395,13 +412,13 @@
 
 // illegal attribute arguments
 int * pgb_var_arg_bad_1 __attribute__((pt_guarded_by(1))); // \
-  // expected-error {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
 int * pgb_var_arg_bad_2 __attribute__((pt_guarded_by("mu"))); // \
-  // expected-error {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
 int * pgb_var_arg_bad_3 __attribute__((pt_guarded_by(muDoublePointer))); // \
-  // expected-error {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
 int * pgb_var_arg_bad_4 __attribute__((pt_guarded_by(umu))); // \
-  // expected-error {{'pt_guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'pt_guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 
 
 //-----------------------------------------//
@@ -456,15 +473,15 @@
 
 // illegal attribute arguments
 Mu aa_var_arg_bad_1 __attribute__((acquired_after(1))); // \
-  // expected-error {{'acquired_after' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}}
 Mu aa_var_arg_bad_2 __attribute__((acquired_after("mu"))); // \
-  // expected-error {{'acquired_after' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}}
 Mu aa_var_arg_bad_3 __attribute__((acquired_after(muDoublePointer))); // \
-  // expected-error {{'acquired_after' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}}
 Mu aa_var_arg_bad_4 __attribute__((acquired_after(umu))); // \
-  // expected-error {{'acquired_after' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'acquired_after' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 UnlockableMu aa_var_arg_bad_5 __attribute__((acquired_after(mu_aa))); // \
-  // expected-error {{'acquired_after' attribute can only be applied in a context annotated with 'lockable' attribute}}
+  // expected-warning {{'acquired_after' attribute can only be applied in a context annotated with 'lockable' attribute}}
 
 //-----------------------------------------//
 //  Acquired Before (ab)
@@ -519,15 +536,15 @@
 
 // illegal attribute arguments
 Mu ab_var_arg_bad_1 __attribute__((acquired_before(1))); // \
-  // expected-error {{'acquired_before' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}}
 Mu ab_var_arg_bad_2 __attribute__((acquired_before("mu"))); // \
-  // expected-error {{'acquired_before' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}}
 Mu ab_var_arg_bad_3 __attribute__((acquired_before(muDoublePointer))); // \
-  // expected-error {{'acquired_before' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}}
 Mu ab_var_arg_bad_4 __attribute__((acquired_before(umu))); // \
-  // expected-error {{'acquired_before' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'acquired_before' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 UnlockableMu ab_var_arg_bad_5 __attribute__((acquired_before(mu_ab))); // \
-  // expected-error {{'acquired_before' attribute can only be applied in a context annotated with 'lockable' attribute}}
+  // expected-warning {{'acquired_before' attribute can only be applied in a context annotated with 'lockable' attribute}}
 
 
 //-----------------------------------------//
@@ -586,11 +603,11 @@
 
 // illegal attribute arguments
 int elf_function_bad_2() __attribute__((exclusive_lock_function("mu"))); // \
-  // expected-error {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}}
 int elf_function_bad_3() __attribute__((exclusive_lock_function(muDoublePointer))); // \
-  // expected-error {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}}
 int elf_function_bad_4() __attribute__((exclusive_lock_function(umu))); // \
-  // expected-error {{'exclusive_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'exclusive_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 
 int elf_function_bad_1() __attribute__((exclusive_lock_function(1))); // \
   // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
@@ -658,11 +675,11 @@
 
 // illegal attribute arguments
 int slf_function_bad_2() __attribute__((shared_lock_function("mu"))); // \
-  // expected-error {{'shared_lock_function' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'shared_lock_function' attribute requires arguments that are class type or point to class type}}
 int slf_function_bad_3() __attribute__((shared_lock_function(muDoublePointer))); // \
-  // expected-error {{'shared_lock_function' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'shared_lock_function' attribute requires arguments that are class type or point to class type}}
 int slf_function_bad_4() __attribute__((shared_lock_function(umu))); // \
-  // expected-error {{'shared_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'shared_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 
 int slf_function_bad_1() __attribute__((shared_lock_function(1))); // \
   // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
@@ -740,11 +757,11 @@
   // expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}}
 
 int etf_function_bad_4() __attribute__((exclusive_trylock_function(1, "mu"))); // \
-  // expected-error {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}}
 int etf_function_bad_5() __attribute__((exclusive_trylock_function(1, muDoublePointer))); // \
-  // expected-error {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}}
 int etf_function_bad_6() __attribute__((exclusive_trylock_function(1, umu))); // \
-  // expected-error {{'exclusive_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'exclusive_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 
 
 //-----------------------------------------//
@@ -814,11 +831,11 @@
   // expected-error {{'shared_trylock_function' attribute first argument must be of int or bool type}}
 
 int stf_function_bad_4() __attribute__((shared_trylock_function(1, "mu"))); // \
-  // expected-error {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}}
 int stf_function_bad_5() __attribute__((shared_trylock_function(1, muDoublePointer))); // \
-  // expected-error {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}}
 int stf_function_bad_6() __attribute__((shared_trylock_function(1, umu))); // \
-  // expected-error {{'shared_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'shared_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 
 
 //-----------------------------------------//
@@ -877,11 +894,11 @@
 
 // illegal attribute arguments
 int uf_function_bad_2() __attribute__((unlock_function("mu"))); // \
-  // expected-error {{'unlock_function' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'unlock_function' attribute requires arguments that are class type or point to class type}}
 int uf_function_bad_3() __attribute__((unlock_function(muDoublePointer))); // \
-  // expected-error {{'unlock_function' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'unlock_function' attribute requires arguments that are class type or point to class type}}
 int uf_function_bad_4() __attribute__((unlock_function(umu))); // \
-  // expected-error {{'unlock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'unlock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 
 int uf_function_bad_1() __attribute__((unlock_function(1))); // \
   // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
@@ -951,13 +968,13 @@
 
 // illegal attribute arguments
 int lr_function_bad_1() __attribute__((lock_returned(1))); // \
-  // expected-error {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
 int lr_function_bad_2() __attribute__((lock_returned("mu"))); // \
-  // expected-error {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
 int lr_function_bad_3() __attribute__((lock_returned(muDoublePointer))); // \
-  // expected-error {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
 int lr_function_bad_4() __attribute__((lock_returned(umu))); // \
-  // expected-error {{'lock_returned' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'lock_returned' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 
 
 
@@ -1018,13 +1035,13 @@
 
 // illegal attribute arguments
 int le_function_bad_1() __attribute__((locks_excluded(1))); // \
-  // expected-error {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
 int le_function_bad_2() __attribute__((locks_excluded("mu"))); // \
-  // expected-error {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
 int le_function_bad_3() __attribute__((locks_excluded(muDoublePointer))); // \
-  // expected-error {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
 int le_function_bad_4() __attribute__((locks_excluded(umu))); // \
-  // expected-error {{'locks_excluded' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'locks_excluded' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 
 
 
@@ -1085,13 +1102,13 @@
 
 // illegal attribute arguments
 int elr_function_bad_1() __attribute__((exclusive_locks_required(1))); // \
-  // expected-error {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
 int elr_function_bad_2() __attribute__((exclusive_locks_required("mu"))); // \
-  // expected-error {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
 int elr_function_bad_3() __attribute__((exclusive_locks_required(muDoublePointer))); // \
-  // expected-error {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
 int elr_function_bad_4() __attribute__((exclusive_locks_required(umu))); // \
-  // expected-error {{'exclusive_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'exclusive_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 
 
 
@@ -1153,13 +1170,13 @@
 
 // illegal attribute arguments
 int slr_function_bad_1() __attribute__((shared_locks_required(1))); // \
-  // expected-error {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
 int slr_function_bad_2() __attribute__((shared_locks_required("mu"))); // \
-  // expected-error {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
 int slr_function_bad_3() __attribute__((shared_locks_required(muDoublePointer))); // \
-  // expected-error {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
+  // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
 int slr_function_bad_4() __attribute__((shared_locks_required(umu))); // \
-  // expected-error {{'shared_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+  // expected-warning {{'shared_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}}
 
 
 //-----------------------------------------//
@@ -1303,5 +1320,26 @@
 };
 
 
+namespace NestedClassLateDecl {
+
+class Foo {
+  class Bar {
+    int a GUARDED_BY(mu);
+    int b GUARDED_BY(fooMuStatic);
+
+    void bar()        EXCLUSIVE_LOCKS_REQUIRED(mu)       { a = 0;    }
+    void bar2(Bar* b) EXCLUSIVE_LOCKS_REQUIRED(b->mu)    { b->a = 0; }
+    void bar3(Foo* f) EXCLUSIVE_LOCKS_REQUIRED(f->fooMu) { f->a = 0; }
+
+    Mu mu;
+  };
+
+  int a GUARDED_BY(fooMu);
+  Mu fooMu;
+  static Mu fooMuStatic;
+};
+
+}
+
 } // end namespace TestMultiDecl
 

Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 17 06:08:26 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-153950
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-154675

Modified: cfe/branches/tooling/test/SemaObjC/ClassPropertyNotObject.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/ClassPropertyNotObject.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/ClassPropertyNotObject.m (original)
+++ cfe/branches/tooling/test/SemaObjC/ClassPropertyNotObject.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://10565506
 
 @protocol P @end

Modified: cfe/branches/tooling/test/SemaObjC/ContClassPropertyLookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/ContClassPropertyLookup.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/ContClassPropertyLookup.m (original)
+++ cfe/branches/tooling/test/SemaObjC/ContClassPropertyLookup.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface MyObject {
     int _foo;

Modified: cfe/branches/tooling/test/SemaObjC/DoubleMethod.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/DoubleMethod.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/DoubleMethod.m (original)
+++ cfe/branches/tooling/test/SemaObjC/DoubleMethod.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wduplicate-method-match -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wduplicate-method-match -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface Subclass
 {

Modified: cfe/branches/tooling/test/SemaObjC/alias-test-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/alias-test-2.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/alias-test-2.m (original)
+++ cfe/branches/tooling/test/SemaObjC/alias-test-2.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 // Note: GCC doesn't produce any of the following errors.
 @interface Super @end // expected-note {{previous definition is here}}

Modified: cfe/branches/tooling/test/SemaObjC/arc-decls.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-decls.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-decls.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-decls.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify -Wno-objc-root-class %s
 
 // rdar://8843524
 

Modified: cfe/branches/tooling/test/SemaObjC/arc-jump-block.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-jump-block.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-jump-block.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-jump-block.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
 // rdar://9535237
 
 typedef struct dispatch_queue_s *dispatch_queue_t;
@@ -82,3 +82,16 @@
 - (void)pageLeft {}
 - (void)pageRight {}
 @end
+
+// Test 2.  rdar://problem/11150919
+int test2(id obj, int state) { // expected-note {{jump enters lifetime of block}} FIXME: wierd location
+  switch (state) {
+  case 0:
+    (void) ^{ (void) obj; };
+    return 0;
+
+  default: // expected-error {{switch case is in protected scope}}
+    return 1;
+  }
+}
+

Modified: cfe/branches/tooling/test/SemaObjC/arc-no-runtime.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-no-runtime.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-no-runtime.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-no-runtime.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-arc -verify %s
+// RUN: %clang_cc1 -fobjc-arc -verify -Wno-objc-root-class %s
 
 // rdar://problem/9150784
 void test(void) {

Modified: cfe/branches/tooling/test/SemaObjC/arc-objc-lifetime.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-objc-lifetime.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-objc-lifetime.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-objc-lifetime.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
-// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
 // rdar://10244607
 
 typedef const struct __CFString * CFStringRef;

Modified: cfe/branches/tooling/test/SemaObjC/arc-property-lifetime.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-property-lifetime.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-property-lifetime.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-property-lifetime.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
 // rdar://9340606
 
 @interface Foo {

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-property.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-property.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
 // rdar://9309489
 
 @interface MyClass {

Modified: cfe/branches/tooling/test/SemaObjC/arc-readonly-property-ivar-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-readonly-property-ivar-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-readonly-property-ivar-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-readonly-property-ivar-1.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1  -fobjc-default-synthesize-properties  -triple x86_64-apple-darwin11  -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify %s
-// RUN: %clang_cc1  -x objective-c++ -fobjc-default-synthesize-properties  -triple x86_64-apple-darwin11  -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify %s
+// RUN: %clang_cc1  -fobjc-default-synthesize-properties  -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1  -x objective-c++ -fobjc-default-synthesize-properties  -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar:// 10558871
 
 @interface PP

Modified: cfe/branches/tooling/test/SemaObjC/arc-readonly-property-ivar.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-readonly-property-ivar.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-readonly-property-ivar.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-readonly-property-ivar.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -triple x86_64-apple-darwin11  -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify %s
+// RUN: %clang_cc1  -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar:// 10558871
 
 @interface PP

Modified: cfe/branches/tooling/test/SemaObjC/arc-retain-block-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-retain-block-property.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-retain-block-property.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-retain-block-property.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify -Wno-objc-root-class %s
 // rdar://9829425
 
 extern void doSomething();

Modified: cfe/branches/tooling/test/SemaObjC/arc-setter-property-match.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-setter-property-match.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-setter-property-match.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-setter-property-match.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
 // rdar://10156674
 
 @class NSArray;

Modified: cfe/branches/tooling/test/SemaObjC/arc-unavailable-for-weakref.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-unavailable-for-weakref.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-unavailable-for-weakref.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-unavailable-for-weakref.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
 // rdar://9693477
 
 __attribute__((objc_arc_weak_reference_unavailable))

Modified: cfe/branches/tooling/test/SemaObjC/arc-unsafe-assigns.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-unsafe-assigns.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-unsafe-assigns.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-unsafe-assigns.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
 // rdar://9495837
 
 @interface Foo {

Modified: cfe/branches/tooling/test/SemaObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
 
 typedef unsigned long NSUInteger;
 typedef const void * CFTypeRef;

Modified: cfe/branches/tooling/test/SemaObjC/assign-rvalue-message.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/assign-rvalue-message.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/assign-rvalue-message.m (original)
+++ cfe/branches/tooling/test/SemaObjC/assign-rvalue-message.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://9005189
 
 @interface Foo 

Modified: cfe/branches/tooling/test/SemaObjC/atomoic-property-synnthesis-rules.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/atomoic-property-synnthesis-rules.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/atomoic-property-synnthesis-rules.m (original)
+++ cfe/branches/tooling/test/SemaObjC/atomoic-property-synnthesis-rules.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 /*
   Conditions for warning:

Modified: cfe/branches/tooling/test/SemaObjC/attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/attr-deprecated.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/attr-deprecated.m (original)
+++ cfe/branches/tooling/test/SemaObjC/attr-deprecated.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface A {
   int X __attribute__((deprecated));

Modified: cfe/branches/tooling/test/SemaObjC/autoreleasepool.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/autoreleasepool.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/autoreleasepool.m (original)
+++ cfe/branches/tooling/test/SemaObjC/autoreleasepool.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 void *objc_autoreleasepool_push();
 void autoreleasepool_pop(void*);

Modified: cfe/branches/tooling/test/SemaObjC/bad-property-synthesis-crash.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/bad-property-synthesis-crash.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/bad-property-synthesis-crash.m (original)
+++ cfe/branches/tooling/test/SemaObjC/bad-property-synthesis-crash.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://10177744
 
 @interface Foo

Modified: cfe/branches/tooling/test/SemaObjC/block-on-method-param.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/block-on-method-param.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/block-on-method-param.m (original)
+++ cfe/branches/tooling/test/SemaObjC/block-on-method-param.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks %s
-// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
 
 // rdar://10681443
 @interface I

Modified: cfe/branches/tooling/test/SemaObjC/block-type-safety.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/block-type-safety.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/block-type-safety.m (original)
+++ cfe/branches/tooling/test/SemaObjC/block-type-safety.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
 // test for block type safety.
 
 @interface Super  @end

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/category-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/category-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface MyClass1 @end
 

Modified: cfe/branches/tooling/test/SemaObjC/category-method-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/category-method-lookup.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/category-method-lookup.m (original)
+++ cfe/branches/tooling/test/SemaObjC/category-method-lookup.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface Foo
 @end

Modified: cfe/branches/tooling/test/SemaObjC/check-dup-objc-decls-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/check-dup-objc-decls-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/check-dup-objc-decls-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/check-dup-objc-decls-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface Foo // expected-note {{previous definition is here}}
 @end

Modified: cfe/branches/tooling/test/SemaObjC/class-extension-after-implementation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/class-extension-after-implementation.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/class-extension-after-implementation.m (original)
+++ cfe/branches/tooling/test/SemaObjC/class-extension-after-implementation.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://7822210
 
 @interface A @end

Modified: cfe/branches/tooling/test/SemaObjC/class-getter-using-dotsyntax.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/class-getter-using-dotsyntax.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/class-getter-using-dotsyntax.m (original)
+++ cfe/branches/tooling/test/SemaObjC/class-getter-using-dotsyntax.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 typedef struct objc_class *Class;
 

Modified: cfe/branches/tooling/test/SemaObjC/class-impl-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/class-impl-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/class-impl-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/class-impl-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 typedef int INTF3; // expected-note {{previous definition is here}}
 

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/class-message-protocol-lookup.m (original)
+++ cfe/branches/tooling/test/SemaObjC/class-message-protocol-lookup.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://9224670
 
 @interface RandomObject {

Modified: cfe/branches/tooling/test/SemaObjC/class-method-self.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/class-method-self.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/class-method-self.m (original)
+++ cfe/branches/tooling/test/SemaObjC/class-method-self.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s 
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
 
 typedef struct objc_class *Class;
 @interface XX

Modified: cfe/branches/tooling/test/SemaObjC/class-protocol-method-match.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/class-protocol-method-match.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/class-protocol-method-match.m (original)
+++ cfe/branches/tooling/test/SemaObjC/class-protocol-method-match.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -Woverriding-method-mismatch -fsyntax-only -verify %s
+// RUN: %clang_cc1  -Woverriding-method-mismatch -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://9352731
 
 @protocol Bar 

Modified: cfe/branches/tooling/test/SemaObjC/compatible-protocol-qualified-types.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/compatible-protocol-qualified-types.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/compatible-protocol-qualified-types.m (original)
+++ cfe/branches/tooling/test/SemaObjC/compatible-protocol-qualified-types.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -pedantic -fsyntax-only -verify %s
+// RUN: %clang_cc1 -pedantic -fsyntax-only -verify -Wno-objc-root-class %s
 typedef signed char BOOL;
 
 @class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;

Modified: cfe/branches/tooling/test/SemaObjC/comptypes-10.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/comptypes-10.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/comptypes-10.m (original)
+++ cfe/branches/tooling/test/SemaObjC/comptypes-10.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 //rdar: //8591619
 // pr8453
 

Modified: cfe/branches/tooling/test/SemaObjC/comptypes-a.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/comptypes-a.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/comptypes-a.m (original)
+++ cfe/branches/tooling/test/SemaObjC/comptypes-a.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wmethod-signatures -verify -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -Wmethod-signatures -verify -pedantic -Wno-objc-root-class %s
 typedef signed char BOOL;
 typedef int NSInteger;
 

Modified: cfe/branches/tooling/test/SemaObjC/conditional-expr-5.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/conditional-expr-5.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/conditional-expr-5.m (original)
+++ cfe/branches/tooling/test/SemaObjC/conditional-expr-5.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface PBXBuildSettingsDictionary
 {

Modified: cfe/branches/tooling/test/SemaObjC/conditional-expr.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/conditional-expr.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/conditional-expr.m (original)
+++ cfe/branches/tooling/test/SemaObjC/conditional-expr.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wno-objc-root-class %s
 @protocol NSObject
 @end
 

Modified: cfe/branches/tooling/test/SemaObjC/conflict-nonfragile-abi2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/conflict-nonfragile-abi2.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/conflict-nonfragile-abi2.m (original)
+++ cfe/branches/tooling/test/SemaObjC/conflict-nonfragile-abi2.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
 // rdar://8225011
 
 int glob;

Modified: cfe/branches/tooling/test/SemaObjC/conflicting-ivar-test-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/conflicting-ivar-test-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/conflicting-ivar-test-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/conflicting-ivar-test-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-fragile-abi -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fobjc-fragile-abi -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface INTF 
 {

Modified: cfe/branches/tooling/test/SemaObjC/continuation-class-err.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/continuation-class-err.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/continuation-class-err.m (original)
+++ cfe/branches/tooling/test/SemaObjC/continuation-class-err.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface ReadOnly 
 {

Modified: cfe/branches/tooling/test/SemaObjC/custom-atomic-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/custom-atomic-property.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/custom-atomic-property.m (original)
+++ cfe/branches/tooling/test/SemaObjC/custom-atomic-property.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -Wcustom-atomic-properties -verify %s
+// RUN: %clang_cc1  -fsyntax-only -Wcustom-atomic-properties -verify -Wno-objc-root-class %s
 
 @interface Foo
 @property (assign) Foo *myProp; // expected-note {{property declared here}} expected-note {{property declared here}}

Modified: cfe/branches/tooling/test/SemaObjC/default-synthesize-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/default-synthesize-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/default-synthesize-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/default-synthesize-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
 
 @interface NSObject 
 - (void) release;

Modified: cfe/branches/tooling/test/SemaObjC/default-synthesize-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/default-synthesize-2.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/default-synthesize-2.m (original)
+++ cfe/branches/tooling/test/SemaObjC/default-synthesize-2.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
 // rdar://8843851
 
 @interface StopAccessingIvarsDirectlyExample

Modified: cfe/branches/tooling/test/SemaObjC/default-synthesize-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/default-synthesize-3.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/default-synthesize-3.m (original)
+++ cfe/branches/tooling/test/SemaObjC/default-synthesize-3.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
 
 #if __has_attribute(objc_requires_property_definitions)
 __attribute ((objc_requires_property_definitions)) 

Modified: cfe/branches/tooling/test/SemaObjC/default-synthesize.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/default-synthesize.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/default-synthesize.m (original)
+++ cfe/branches/tooling/test/SemaObjC/default-synthesize.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
 
 @interface NSString @end
 

Modified: cfe/branches/tooling/test/SemaObjC/deref-interface.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/deref-interface.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/deref-interface.m (original)
+++ cfe/branches/tooling/test/SemaObjC/deref-interface.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
 
 @interface NSView 
   - (id)initWithView:(id)realView;

Modified: cfe/branches/tooling/test/SemaObjC/direct-synthesized-ivar-access.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/direct-synthesized-ivar-access.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/direct-synthesized-ivar-access.m (original)
+++ cfe/branches/tooling/test/SemaObjC/direct-synthesized-ivar-access.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wnonfragile-abi2 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -Wnonfragile-abi2 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
 // rdar://8673791
 // rdar://9943851
 

Modified: cfe/branches/tooling/test/SemaObjC/dist-object-modifiers.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/dist-object-modifiers.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/dist-object-modifiers.m (original)
+++ cfe/branches/tooling/test/SemaObjC/dist-object-modifiers.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://7076235
 
 @protocol P

Modified: cfe/branches/tooling/test/SemaObjC/enhanced-proto-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/enhanced-proto-2.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/enhanced-proto-2.m (original)
+++ cfe/branches/tooling/test/SemaObjC/enhanced-proto-2.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
 
 @protocol MyProto1 
 @optional

Modified: cfe/branches/tooling/test/SemaObjC/err-ivar-access-in-class-method.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/err-ivar-access-in-class-method.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/err-ivar-access-in-class-method.m (original)
+++ cfe/branches/tooling/test/SemaObjC/err-ivar-access-in-class-method.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://10593227
 
 @class UIWindow;

Modified: cfe/branches/tooling/test/SemaObjC/error-property-gc-attr.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/error-property-gc-attr.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/error-property-gc-attr.m (original)
+++ cfe/branches/tooling/test/SemaObjC/error-property-gc-attr.m Tue Apr 17 06:08:26 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface INTF
 {

Modified: cfe/branches/tooling/test/SemaObjC/format-strings-objc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/format-strings-objc.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/format-strings-objc.m (original)
+++ cfe/branches/tooling/test/SemaObjC/format-strings-objc.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wformat-nonliteral -fsyntax-only -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wformat-nonliteral -fsyntax-only -fblocks -verify -Wno-objc-root-class %s
 
 //===----------------------------------------------------------------------===//
 // The following code is reduced using delta-debugging from

Modified: cfe/branches/tooling/test/SemaObjC/forward-class-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/forward-class-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/forward-class-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/forward-class-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @class FOO, BAR; // expected-note {{forward declaration of class here}}
 @class FOO, BAR; 

Modified: cfe/branches/tooling/test/SemaObjC/gcc-cast-ext.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/gcc-cast-ext.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/gcc-cast-ext.m (original)
+++ cfe/branches/tooling/test/SemaObjC/gcc-cast-ext.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fms-extensions
+// RUN: %clang_cc1 -verify -fms-extensions -Wno-objc-root-class %s
 @class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
 typedef struct _NSRange { } NSRange;
 

Modified: cfe/branches/tooling/test/SemaObjC/ibaction.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/ibaction.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/ibaction.m (original)
+++ cfe/branches/tooling/test/SemaObjC/ibaction.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
 
 @interface Foo 
 {

Modified: cfe/branches/tooling/test/SemaObjC/idiomatic-parentheses.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/idiomatic-parentheses.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/idiomatic-parentheses.m (original)
+++ cfe/branches/tooling/test/SemaObjC/idiomatic-parentheses.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wparentheses %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wparentheses -Wno-objc-root-class %s
 
 // Don't warn about some common ObjC idioms unless we have -Widiomatic-parentheses on.
 // <rdar://problem/7382435>

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/incomplete-implementation.m (original)
+++ cfe/branches/tooling/test/SemaObjC/incomplete-implementation.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface I
 - Meth; // expected-note{{method definition for 'Meth' not found}} \

Modified: cfe/branches/tooling/test/SemaObjC/interface-scope-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/interface-scope-2.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/interface-scope-2.m (original)
+++ cfe/branches/tooling/test/SemaObjC/interface-scope-2.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin9  %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin9 -Wno-objc-root-class %s
 // FIXME: must also compile as Objective-C++ 
 
 // <rdar://problem/6487662>

Modified: cfe/branches/tooling/test/SemaObjC/invalid-code.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/invalid-code.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/invalid-code.m (original)
+++ cfe/branches/tooling/test/SemaObjC/invalid-code.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fobjc-exceptions
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s
 
 // rdar://6124613
 void test1() {

Modified: cfe/branches/tooling/test/SemaObjC/ivar-access-tests.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/ivar-access-tests.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/ivar-access-tests.m (original)
+++ cfe/branches/tooling/test/SemaObjC/ivar-access-tests.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface MySuperClass
 {

Modified: cfe/branches/tooling/test/SemaObjC/ivar-in-class-extension.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/ivar-in-class-extension.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/ivar-in-class-extension.m (original)
+++ cfe/branches/tooling/test/SemaObjC/ivar-in-class-extension.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface SomeClass  @end
 

Modified: cfe/branches/tooling/test/SemaObjC/ivar-in-implementations.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/ivar-in-implementations.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/ivar-in-implementations.m (original)
+++ cfe/branches/tooling/test/SemaObjC/ivar-in-implementations.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface Super @end
 

Modified: cfe/branches/tooling/test/SemaObjC/ivar-lookup-resolution-builtin.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/ivar-lookup-resolution-builtin.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/ivar-lookup-resolution-builtin.m (original)
+++ cfe/branches/tooling/test/SemaObjC/ivar-lookup-resolution-builtin.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
 // pr5986
 
 @interface Test {

Modified: cfe/branches/tooling/test/SemaObjC/ivar-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/ivar-lookup.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/ivar-lookup.m (original)
+++ cfe/branches/tooling/test/SemaObjC/ivar-lookup.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface Test {
    int x;

Modified: cfe/branches/tooling/test/SemaObjC/ivar-ref-misuse.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/ivar-ref-misuse.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/ivar-ref-misuse.m (original)
+++ cfe/branches/tooling/test/SemaObjC/ivar-ref-misuse.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface Sprite { // expected-note{{'Sprite' declared here}}
   int sprite, spree;

Modified: cfe/branches/tooling/test/SemaObjC/legacy-implementation-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/legacy-implementation-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/legacy-implementation-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/legacy-implementation-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @implementation INTF // expected-warning {{cannot find interface declaration for 'INTF'}}
 @end

Modified: cfe/branches/tooling/test/SemaObjC/message.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/message.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/message.m (original)
+++ cfe/branches/tooling/test/SemaObjC/message.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 typedef struct objc_object {
   Class isa;

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=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-attributes.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-attributes.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
 
 @class NSString;
 

Modified: cfe/branches/tooling/test/SemaObjC/method-bad-param.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-bad-param.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-bad-param.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-bad-param.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface foo
 @end

Modified: cfe/branches/tooling/test/SemaObjC/method-conflict-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-conflict-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-conflict-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-conflict-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 // This test case tests the default behavior.
 

Modified: cfe/branches/tooling/test/SemaObjC/method-conflict-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-conflict-2.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-conflict-2.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-conflict-2.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface A @end
 @interface B : A @end

Modified: cfe/branches/tooling/test/SemaObjC/method-conflict.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-conflict.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-conflict.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-conflict.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
 
 typedef signed char BOOL;
 typedef unsigned int NSUInteger;

Modified: cfe/branches/tooling/test/SemaObjC/method-def-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-def-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-def-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-def-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface foo
 - (int)meth;

Modified: cfe/branches/tooling/test/SemaObjC/method-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-lookup.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-lookup.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-lookup.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 typedef signed char BOOL;
 typedef int NSInteger;
 

Modified: cfe/branches/tooling/test/SemaObjC/method-prototype-scope.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-prototype-scope.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-prototype-scope.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-prototype-scope.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -Wduplicate-method-arg -verify %s
+// RUN: %clang_cc1  -fsyntax-only -Wduplicate-method-arg -verify -Wno-objc-root-class %s
 
 // rdar://8877730
 

Modified: cfe/branches/tooling/test/SemaObjC/method-typecheck-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-typecheck-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-typecheck-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-typecheck-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface A
 - (void) setMoo: (int) x;	//  expected-note {{previous definition is here}}

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=154919&r1=154918&r2=154919&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 Apr 17 06:08:26 2012
@@ -51,3 +51,24 @@
 
 @implementation NSObject (FooConformance)
 @end
+
+// rdar://11186449
+// Don't warn when a category does not implemented a method imported
+// by its protocol because another category has its declaration and
+// that category will implement it.
+ at interface NSOrderedSet @end
+
+ at interface NSOrderedSet(CoolectionImplements)
+- (unsigned char)containsObject:(id)object;
+ at end
+
+ at protocol Collection
+- (unsigned char)containsObject:(id)object;
+ at end
+
+ at interface NSOrderedSet (CollectionConformance) <Collection>
+ at end
+
+ at implementation NSOrderedSet (CollectionConformance)
+ at 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=154919&r1=154918&r2=154919&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 Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface MyClass // expected-note {{required for direct or indirect protocol 'P'}}
 @end

Modified: cfe/branches/tooling/test/SemaObjC/method-undefined-warn-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/method-undefined-warn-1.m?rev=154919&r1=154918&r2=154919&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/method-undefined-warn-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/method-undefined-warn-1.m Tue Apr 17 06:08:26 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface INTF
 - (void) meth;





More information about the llvm-branch-commits mailing list