aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt33
-rw-r--r--Makefile3
-rw-r--r--docs/DriverInternals.html6
-rw-r--r--docs/InternalsManual.html56
-rw-r--r--docs/LanguageExtensions.html118
-rw-r--r--docs/UsersManual.html104
-rw-r--r--docs/tools/clang.pod17
-rw-r--r--examples/CMakeLists.txt2
-rw-r--r--examples/Tooling/CMakeLists.txt6
-rw-r--r--examples/Tooling/ClangCheck.cpp108
-rw-r--r--examples/Tooling/Makefile24
-rw-r--r--examples/clang-interpreter/Makefile2
-rw-r--r--examples/clang-interpreter/main.cpp3
-rw-r--r--include/clang-c/Index.h78
-rw-r--r--include/clang/AST/ASTConsumer.h2
-rw-r--r--include/clang/AST/ASTContext.h76
-rw-r--r--include/clang/AST/ASTDiagnostic.h3
-rw-r--r--include/clang/AST/ASTMutationListener.h13
-rw-r--r--include/clang/AST/Attr.h15
-rw-r--r--include/clang/AST/CXXInheritance.h2
-rw-r--r--include/clang/AST/CanonicalType.h3
-rw-r--r--include/clang/AST/CharUnits.h16
-rw-r--r--include/clang/AST/Decl.h555
-rw-r--r--include/clang/AST/DeclBase.h87
-rw-r--r--include/clang/AST/DeclCXX.h351
-rw-r--r--include/clang/AST/DeclFriend.h11
-rw-r--r--include/clang/AST/DeclObjC.h46
-rw-r--r--include/clang/AST/DeclTemplate.h112
-rw-r--r--include/clang/AST/EvaluatedExprVisitor.h3
-rw-r--r--include/clang/AST/Expr.h508
-rw-r--r--include/clang/AST/ExprCXX.h280
-rw-r--r--include/clang/AST/ExprObjC.h40
-rw-r--r--include/clang/AST/ExternalASTSource.h67
-rw-r--r--include/clang/AST/NestedNameSpecifier.h140
-rw-r--r--include/clang/AST/PrettyPrinter.h26
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h118
-rw-r--r--include/clang/AST/Stmt.h168
-rw-r--r--include/clang/AST/StmtCXX.h82
-rw-r--r--include/clang/AST/StmtIterator.h1
-rw-r--r--include/clang/AST/TemplateBase.h27
-rw-r--r--include/clang/AST/Type.h325
-rw-r--r--include/clang/AST/TypeLoc.h157
-rw-r--r--include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h4
-rw-r--r--include/clang/Analysis/Analyses/UninitializedValues.h82
-rw-r--r--include/clang/Analysis/Analyses/UninitializedValuesV2.h40
-rw-r--r--include/clang/Analysis/AnalysisContext.h60
-rw-r--r--include/clang/Analysis/AnalysisDiagnostic.h3
-rw-r--r--include/clang/Analysis/CFG.h120
-rw-r--r--include/clang/Analysis/DomainSpecific/CocoaConventions.h2
-rw-r--r--include/clang/Analysis/FlowSensitive/DataflowSolver.h8
-rw-r--r--include/clang/Analysis/ProgramPoint.h13
-rw-r--r--include/clang/Analysis/Visitors/CFGStmtVisitor.h5
-rw-r--r--include/clang/Basic/AddressSpaces.h44
-rw-r--r--include/clang/Basic/Attr.td55
-rw-r--r--include/clang/Basic/AttrKinds.h1
-rw-r--r--include/clang/Basic/Builtins.def9
-rw-r--r--include/clang/Basic/BuiltinsPTX.def62
-rw-r--r--include/clang/Basic/BuiltinsX86.def41
-rw-r--r--include/clang/Basic/CMakeLists.txt4
-rw-r--r--include/clang/Basic/ConvertUTF.h5
-rw-r--r--include/clang/Basic/DeclNodes.td4
-rw-r--r--include/clang/Basic/Diagnostic.h5
-rw-r--r--include/clang/Basic/Diagnostic.td14
-rw-r--r--include/clang/Basic/DiagnosticCommonKinds.td2
-rw-r--r--include/clang/Basic/DiagnosticDriverKinds.td10
-rw-r--r--include/clang/Basic/DiagnosticFrontendKinds.td8
-rw-r--r--include/clang/Basic/DiagnosticGroups.td31
-rw-r--r--include/clang/Basic/DiagnosticIDs.h26
-rw-r--r--include/clang/Basic/DiagnosticLexKinds.td10
-rw-r--r--include/clang/Basic/DiagnosticParseKinds.td73
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td284
-rw-r--r--include/clang/Basic/ExceptionSpecificationType.h39
-rw-r--r--include/clang/Basic/ExpressionTraits.h25
-rw-r--r--include/clang/Basic/FileManager.h17
-rw-r--r--include/clang/Basic/IdentifierTable.h77
-rw-r--r--include/clang/Basic/LangOptions.h24
-rw-r--r--include/clang/Basic/Makefile6
-rw-r--r--include/clang/Basic/OpenCL.h28
-rw-r--r--include/clang/Basic/PartialDiagnostic.h2
-rw-r--r--include/clang/Basic/SourceLocation.h9
-rw-r--r--include/clang/Basic/SourceManager.h152
-rw-r--r--include/clang/Basic/Specifiers.h1
-rw-r--r--include/clang/Basic/StmtNodes.td9
-rw-r--r--include/clang/Basic/TargetBuiltins.h11
-rw-r--r--include/clang/Basic/TargetInfo.h25
-rw-r--r--include/clang/Basic/TokenKinds.def97
-rw-r--r--include/clang/Basic/TypeTraits.h45
-rw-r--r--include/clang/Basic/Version.h5
-rw-r--r--include/clang/Basic/VersionTuple.h126
-rw-r--r--include/clang/Basic/arm_neon.td7
-rw-r--r--include/clang/Driver/Arg.h1
-rw-r--r--include/clang/Driver/CC1AsOptions.td6
-rw-r--r--include/clang/Driver/CC1Options.td62
-rw-r--r--include/clang/Driver/Driver.h32
-rw-r--r--include/clang/Driver/DriverDiagnostic.h3
-rw-r--r--include/clang/Driver/OptParser.td2
-rw-r--r--include/clang/Driver/Options.td51
-rw-r--r--include/clang/Driver/ToolChain.h9
-rw-r--r--include/clang/Frontend/ASTConsumers.h8
-rw-r--r--include/clang/Frontend/ASTUnit.h42
-rw-r--r--include/clang/Frontend/Analyses.def11
-rw-r--r--include/clang/Frontend/AnalyzerOptions.h7
-rw-r--r--include/clang/Frontend/ChainedDiagnosticClient.h3
-rw-r--r--include/clang/Frontend/CodeGenOptions.h17
-rw-r--r--include/clang/Frontend/CompilerInstance.h79
-rw-r--r--include/clang/Frontend/CompilerInvocation.h3
-rw-r--r--include/clang/Frontend/DeclContextXML.def113
-rw-r--r--include/clang/Frontend/DeclXML.def372
-rw-r--r--include/clang/Frontend/DiagnosticOptions.h8
-rw-r--r--include/clang/Frontend/DocumentXML.def75
-rw-r--r--include/clang/Frontend/DocumentXML.h185
-rw-r--r--include/clang/Frontend/FrontendActions.h6
-rw-r--r--include/clang/Frontend/FrontendDiagnostic.h3
-rw-r--r--include/clang/Frontend/FrontendOptions.h1
-rw-r--r--include/clang/Frontend/LangStandard.h16
-rw-r--r--include/clang/Frontend/LangStandards.def14
-rw-r--r--include/clang/Frontend/LogDiagnosticPrinter.h77
-rw-r--r--include/clang/Frontend/MultiplexConsumer.h5
-rw-r--r--include/clang/Frontend/PreprocessorOptions.h8
-rw-r--r--include/clang/Frontend/StmtXML.def520
-rw-r--r--include/clang/Frontend/TextDiagnosticPrinter.h7
-rw-r--r--include/clang/Frontend/TypeXML.def304
-rw-r--r--include/clang/Frontend/Utils.h17
-rw-r--r--include/clang/Lex/DirectoryLookup.h22
-rw-r--r--include/clang/Lex/HeaderMap.h5
-rw-r--r--include/clang/Lex/HeaderSearch.h51
-rw-r--r--include/clang/Lex/LexDiagnostic.h3
-rw-r--r--include/clang/Lex/Lexer.h15
-rw-r--r--include/clang/Lex/LiteralSupport.h1
-rw-r--r--include/clang/Lex/MacroInfo.h1
-rw-r--r--include/clang/Lex/MultipleIncludeOpt.h2
-rw-r--r--include/clang/Lex/PPCallbacks.h28
-rw-r--r--include/clang/Lex/PTHLexer.h1
-rw-r--r--include/clang/Lex/Pragma.h1
-rw-r--r--include/clang/Lex/PreprocessingRecord.h4
-rw-r--r--include/clang/Lex/Preprocessor.h76
-rw-r--r--include/clang/Lex/PreprocessorLexer.h5
-rw-r--r--include/clang/Makefile16
-rw-r--r--include/clang/Parse/ParseDiagnostic.h3
-rw-r--r--include/clang/Parse/Parser.h205
-rw-r--r--include/clang/Rewrite/FrontendActions.h2
-rw-r--r--include/clang/Rewrite/Rewriter.h71
-rw-r--r--include/clang/Sema/AttributeList.h373
-rw-r--r--include/clang/Sema/DeclSpec.h342
-rw-r--r--include/clang/Sema/DelayedDiagnostic.h18
-rw-r--r--include/clang/Sema/IdentifierResolver.h18
-rw-r--r--include/clang/Sema/Initialization.h13
-rw-r--r--include/clang/Sema/Lookup.h1
-rw-r--r--include/clang/Sema/Overload.h3
-rw-r--r--include/clang/Sema/Ownership.h13
-rw-r--r--include/clang/Sema/ParsedTemplate.h13
-rw-r--r--include/clang/Sema/Scope.h76
-rw-r--r--include/clang/Sema/Sema.h673
-rw-r--r--include/clang/Sema/SemaDiagnostic.h3
-rw-r--r--include/clang/Sema/Template.h2
-rw-r--r--include/clang/Sema/TemplateDeduction.h2
-rw-r--r--include/clang/Serialization/ASTBitCodes.h20
-rw-r--r--include/clang/Serialization/ASTReader.h25
-rw-r--r--include/clang/Serialization/ASTWriter.h9
-rw-r--r--include/clang/Serialization/ChainedIncludesSource.h76
-rw-r--r--include/clang/StaticAnalyzer/Checkers/CheckerBase.td11
-rw-r--r--include/clang/StaticAnalyzer/Checkers/LocalCheckers.h2
-rw-r--r--include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h14
-rw-r--r--include/clang/StaticAnalyzer/Core/Checker.h (renamed from include/clang/StaticAnalyzer/Core/CheckerV2.h)126
-rw-r--r--include/clang/StaticAnalyzer/Core/CheckerManager.h206
-rw-r--r--include/clang/StaticAnalyzer/Core/CheckerProvider.h1
-rw-r--r--include/clang/StaticAnalyzer/Core/PathDiagnosticClients.h2
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h12
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/Checker.h166
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.def48
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h103
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h38
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h5
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h109
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h16
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h4
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h26
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h155
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/Store.h27
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h50
-rw-r--r--include/clang/Tooling/Tooling.h81
-rw-r--r--lib/AST/ASTContext.cpp296
-rw-r--r--lib/AST/ASTDiagnostic.cpp7
-rw-r--r--lib/AST/ASTImporter.cpp237
-rw-r--r--lib/AST/CMakeLists.txt1
-rw-r--r--lib/AST/CXXInheritance.cpp2
-rw-r--r--lib/AST/Decl.cpp417
-rw-r--r--lib/AST/DeclBase.cpp181
-rw-r--r--lib/AST/DeclCXX.cpp404
-rw-r--r--lib/AST/DeclObjC.cpp69
-rw-r--r--lib/AST/DeclPrinter.cpp59
-rw-r--r--lib/AST/DeclTemplate.cpp256
-rw-r--r--lib/AST/DumpXML.cpp19
-rw-r--r--lib/AST/Expr.cpp368
-rw-r--r--lib/AST/ExprCXX.cpp156
-rw-r--r--lib/AST/ExprClassification.cpp38
-rw-r--r--lib/AST/ExprConstant.cpp372
-rw-r--r--lib/AST/ExternalASTSource.cpp59
-rw-r--r--lib/AST/InheritViz.cpp39
-rw-r--r--lib/AST/ItaniumCXXABI.cpp2
-rw-r--r--lib/AST/ItaniumMangle.cpp558
-rw-r--r--lib/AST/MicrosoftCXXABI.cpp2
-rw-r--r--lib/AST/MicrosoftMangle.cpp15
-rw-r--r--lib/AST/NestedNameSpecifier.cpp246
-rw-r--r--lib/AST/RecordLayoutBuilder.cpp141
-rw-r--r--lib/AST/Stmt.cpp98
-rw-r--r--lib/AST/StmtDumper.cpp30
-rw-r--r--lib/AST/StmtIterator.cpp2
-rw-r--r--lib/AST/StmtPrinter.cpp148
-rw-r--r--lib/AST/StmtProfile.cpp58
-rw-r--r--lib/AST/TemplateBase.cpp12
-rw-r--r--lib/AST/TemplateName.cpp4
-rw-r--r--lib/AST/Type.cpp291
-rw-r--r--lib/AST/TypeLoc.cpp87
-rw-r--r--lib/AST/TypePrinter.cpp76
-rw-r--r--lib/Analysis/AnalysisContext.cpp118
-rw-r--r--lib/Analysis/CFG.cpp652
-rw-r--r--lib/Analysis/CFGReachabilityAnalysis.cpp6
-rw-r--r--lib/Analysis/CFGStmtMap.cpp6
-rw-r--r--lib/Analysis/CMakeLists.txt1
-rw-r--r--lib/Analysis/CocoaConventions.cpp92
-rw-r--r--lib/Analysis/PrintfFormatString.cpp43
-rw-r--r--lib/Analysis/ReachableCode.cpp10
-rw-r--r--lib/Analysis/UninitializedValues.cpp874
-rw-r--r--lib/Analysis/UninitializedValuesV2.cpp610
-rw-r--r--lib/Basic/CMakeLists.txt4
-rw-r--r--lib/Basic/Diagnostic.cpp23
-rw-r--r--lib/Basic/DiagnosticIDs.cpp144
-rw-r--r--lib/Basic/FileManager.cpp73
-rw-r--r--lib/Basic/IdentifierTable.cpp85
-rw-r--r--lib/Basic/SourceManager.cpp220
-rw-r--r--lib/Basic/TargetInfo.cpp12
-rw-r--r--lib/Basic/Targets.cpp227
-rw-r--r--lib/Basic/Version.cpp19
-rw-r--r--lib/Basic/VersionTuple.cpp36
-rw-r--r--lib/CMakeLists.txt1
-rw-r--r--lib/CodeGen/BackendUtil.cpp29
-rw-r--r--lib/CodeGen/CGBlocks.cpp586
-rw-r--r--lib/CodeGen/CGBlocks.h4
-rw-r--r--lib/CodeGen/CGBuiltin.cpp230
-rw-r--r--lib/CodeGen/CGCXX.cpp103
-rw-r--r--lib/CodeGen/CGCXXABI.cpp4
-rw-r--r--lib/CodeGen/CGCall.cpp164
-rw-r--r--lib/CodeGen/CGCall.h26
-rw-r--r--lib/CodeGen/CGClass.cpp156
-rw-r--r--lib/CodeGen/CGCleanup.cpp23
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp399
-rw-r--r--lib/CodeGen/CGDebugInfo.h32
-rw-r--r--lib/CodeGen/CGDecl.cpp353
-rw-r--r--lib/CodeGen/CGDeclCXX.cpp48
-rw-r--r--lib/CodeGen/CGException.cpp108
-rw-r--r--lib/CodeGen/CGException.h1
-rw-r--r--lib/CodeGen/CGExpr.cpp99
-rw-r--r--lib/CodeGen/CGExprAgg.cpp134
-rw-r--r--lib/CodeGen/CGExprCXX.cpp650
-rw-r--r--lib/CodeGen/CGExprComplex.cpp9
-rw-r--r--lib/CodeGen/CGExprConstant.cpp401
-rw-r--r--lib/CodeGen/CGExprScalar.cpp245
-rw-r--r--lib/CodeGen/CGObjC.cpp335
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp1416
-rw-r--r--lib/CodeGen/CGObjCMac.cpp364
-rw-r--r--lib/CodeGen/CGObjCRuntime.cpp310
-rw-r--r--lib/CodeGen/CGObjCRuntime.h24
-rw-r--r--lib/CodeGen/CGRTTI.cpp17
-rw-r--r--lib/CodeGen/CGRecordLayout.h5
-rw-r--r--lib/CodeGen/CGRecordLayoutBuilder.cpp188
-rw-r--r--lib/CodeGen/CGStmt.cpp360
-rw-r--r--lib/CodeGen/CGVTT.cpp45
-rw-r--r--lib/CodeGen/CGVTables.cpp539
-rw-r--r--lib/CodeGen/CGVTables.h26
-rw-r--r--lib/CodeGen/CMakeLists.txt2
-rw-r--r--lib/CodeGen/CodeGenAction.cpp2
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp138
-rw-r--r--lib/CodeGen/CodeGenFunction.h97
-rw-r--r--lib/CodeGen/CodeGenModule.cpp179
-rw-r--r--lib/CodeGen/CodeGenModule.h69
-rw-r--r--lib/CodeGen/CodeGenTBAA.cpp5
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp82
-rw-r--r--lib/CodeGen/CodeGenTypes.h14
-rw-r--r--lib/CodeGen/ItaniumCXXABI.cpp55
-rw-r--r--lib/CodeGen/MicrosoftCXXABI.cpp2
-rw-r--r--lib/CodeGen/TargetInfo.cpp178
-rw-r--r--lib/Driver/Compilation.cpp6
-rw-r--r--lib/Driver/Driver.cpp117
-rw-r--r--lib/Driver/HostInfo.cpp7
-rw-r--r--lib/Driver/OptTable.cpp4
-rw-r--r--lib/Driver/ToolChain.cpp16
-rw-r--r--lib/Driver/ToolChains.cpp475
-rw-r--r--lib/Driver/ToolChains.h82
-rw-r--r--lib/Driver/Tools.cpp504
-rw-r--r--lib/Driver/Tools.h3
-rw-r--r--lib/Frontend/ASTConsumers.cpp39
-rw-r--r--lib/Frontend/ASTUnit.cpp463
-rw-r--r--lib/Frontend/CMakeLists.txt6
-rw-r--r--lib/Frontend/CacheTokens.cpp6
-rw-r--r--lib/Frontend/CompilerInstance.cpp107
-rw-r--r--lib/Frontend/CompilerInvocation.cpp117
-rw-r--r--lib/Frontend/CreateInvocationFromCommandLine.cpp90
-rw-r--r--lib/Frontend/DeclXML.cpp183
-rw-r--r--lib/Frontend/DependencyFile.cpp2
-rw-r--r--lib/Frontend/DocumentXML.cpp381
-rw-r--r--lib/Frontend/FrontendAction.cpp31
-rw-r--r--lib/Frontend/FrontendActions.cpp7
-rw-r--r--lib/Frontend/HeaderIncludeGen.cpp32
-rw-r--r--lib/Frontend/InitHeaderSearch.cpp124
-rw-r--r--lib/Frontend/InitPreprocessor.cpp37
-rw-r--r--lib/Frontend/LogDiagnosticPrinter.cpp146
-rw-r--r--lib/Frontend/MultiplexConsumer.cpp19
-rw-r--r--lib/Frontend/PrintPreprocessedOutput.cpp2
-rw-r--r--lib/Frontend/StmtXML.cpp439
-rw-r--r--lib/Frontend/TextDiagnosticPrinter.cpp34
-rw-r--r--lib/Frontend/TypeXML.cpp119
-rw-r--r--lib/FrontendTool/ExecuteCompilerInvocation.cpp1
-rw-r--r--lib/Headers/CMakeLists.txt30
-rw-r--r--lib/Headers/avxintrin.h42
-rw-r--r--lib/Headers/emmintrin.h10
-rw-r--r--lib/Headers/mm3dnow.h161
-rw-r--r--lib/Headers/mm_malloc.h2
-rw-r--r--lib/Headers/stddef.h5
-rw-r--r--lib/Headers/stdint.h37
-rw-r--r--lib/Headers/xmmintrin.h2
-rw-r--r--lib/Index/DeclReferenceMap.cpp2
-rw-r--r--lib/Index/Entity.cpp2
-rw-r--r--lib/Lex/HeaderMap.cpp4
-rw-r--r--lib/Lex/HeaderSearch.cpp123
-rw-r--r--lib/Lex/Lexer.cpp104
-rw-r--r--lib/Lex/LiteralSupport.cpp2
-rw-r--r--lib/Lex/MacroArgs.cpp2
-rw-r--r--lib/Lex/PPDirectives.cpp128
-rw-r--r--lib/Lex/PPExpressions.cpp18
-rw-r--r--lib/Lex/PPLexerChange.cpp20
-rw-r--r--lib/Lex/PPMacroExpansion.cpp39
-rw-r--r--lib/Lex/PTHLexer.cpp4
-rw-r--r--lib/Lex/Pragma.cpp26
-rw-r--r--lib/Lex/PreprocessingRecord.cpp15
-rw-r--r--lib/Lex/Preprocessor.cpp52
-rw-r--r--lib/Lex/PreprocessorLexer.cpp2
-rw-r--r--lib/Lex/TokenLexer.cpp8
-rwxr-xr-xlib/Makefile3
-rw-r--r--lib/Parse/ParseAST.cpp23
-rw-r--r--lib/Parse/ParseCXXInlineMethods.cpp52
-rw-r--r--lib/Parse/ParseDecl.cpp832
-rw-r--r--lib/Parse/ParseDeclCXX.cpp440
-rw-r--r--lib/Parse/ParseExpr.cpp302
-rw-r--r--lib/Parse/ParseExprCXX.cpp322
-rw-r--r--lib/Parse/ParseInit.cpp2
-rw-r--r--lib/Parse/ParseObjc.cpp95
-rw-r--r--lib/Parse/ParsePragma.cpp44
-rw-r--r--lib/Parse/ParsePragma.h10
-rw-r--r--lib/Parse/ParseStmt.cpp438
-rw-r--r--lib/Parse/ParseTemplate.cpp151
-rw-r--r--lib/Parse/ParseTentative.cpp21
-rw-r--r--lib/Parse/Parser.cpp144
-rw-r--r--lib/Parse/RAIIObjectsForParser.h26
-rw-r--r--lib/Rewrite/RewriteObjC.cpp160
-rw-r--r--lib/Rewrite/Rewriter.cpp177
-rw-r--r--lib/Sema/AnalysisBasedWarnings.cpp279
-rw-r--r--lib/Sema/AttributeList.cpp100
-rw-r--r--lib/Sema/CMakeLists.txt2
-rw-r--r--lib/Sema/CodeCompleteConsumer.cpp17
-rw-r--r--lib/Sema/DeclSpec.cpp331
-rw-r--r--lib/Sema/DelayedDiagnostic.cpp51
-rw-r--r--lib/Sema/IdentifierResolver.cpp46
-rw-r--r--lib/Sema/JumpDiagnostics.cpp5
-rw-r--r--lib/Sema/Scope.cpp57
-rw-r--r--lib/Sema/Sema.cpp144
-rw-r--r--lib/Sema/SemaAccess.cpp16
-rw-r--r--lib/Sema/SemaAttr.cpp12
-rw-r--r--lib/Sema/SemaCXXCast.cpp366
-rw-r--r--lib/Sema/SemaCXXScopeSpec.cpp85
-rw-r--r--lib/Sema/SemaChecking.cpp314
-rw-r--r--lib/Sema/SemaCodeComplete.cpp166
-rw-r--r--lib/Sema/SemaDecl.cpp1222
-rw-r--r--lib/Sema/SemaDeclAttr.cpp361
-rw-r--r--lib/Sema/SemaDeclCXX.cpp710
-rw-r--r--lib/Sema/SemaDeclObjC.cpp105
-rw-r--r--lib/Sema/SemaExceptionSpec.cpp304
-rw-r--r--lib/Sema/SemaExpr.cpp2844
-rw-r--r--lib/Sema/SemaExprCXX.cpp1068
-rw-r--r--lib/Sema/SemaExprObjC.cpp219
-rw-r--r--lib/Sema/SemaInit.cpp240
-rw-r--r--lib/Sema/SemaLookup.cpp53
-rw-r--r--lib/Sema/SemaObjCProperty.cpp46
-rw-r--r--lib/Sema/SemaOverload.cpp801
-rw-r--r--lib/Sema/SemaStmt.cpp494
-rw-r--r--lib/Sema/SemaTemplate.cpp726
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp125
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp117
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp236
-rw-r--r--lib/Sema/SemaTemplateVariadic.cpp5
-rw-r--r--lib/Sema/SemaType.cpp396
-rw-r--r--lib/Sema/TargetAttributesSema.cpp2
-rw-r--r--lib/Sema/TreeTransform.h1475
-rw-r--r--lib/Sema/TypeLocBuilder.h3
-rw-r--r--lib/Serialization/ASTCommon.cpp2
-rw-r--r--lib/Serialization/ASTCommon.h4
-rw-r--r--lib/Serialization/ASTReader.cpp273
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp219
-rw-r--r--lib/Serialization/ASTReaderStmt.cpp195
-rw-r--r--lib/Serialization/ASTWriter.cpp215
-rw-r--r--lib/Serialization/ASTWriterDecl.cpp57
-rw-r--r--lib/Serialization/ASTWriterStmt.cpp119
-rw-r--r--lib/Serialization/CMakeLists.txt3
-rw-r--r--lib/Serialization/ChainedIncludesSource.cpp235
-rw-r--r--lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp29
-rw-r--r--lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp44
-rw-r--r--lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp90
-rw-r--r--lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp34
-rw-r--r--lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp204
-rw-r--r--lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.h35
-rw-r--r--lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp22
-rw-r--r--lib/StaticAnalyzer/Checkers/CMakeLists.txt3
-rw-r--r--lib/StaticAnalyzer/Checkers/CStringChecker.cpp309
-rw-r--r--lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp121
-rw-r--r--lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp216
-rw-r--r--lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp10
-rw-r--r--lib/StaticAnalyzer/Checkers/Checkers.td414
-rw-r--r--lib/StaticAnalyzer/Checkers/ChrootChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp118
-rw-r--r--lib/StaticAnalyzer/Checkers/ClangSACheckers.h2
-rw-r--r--lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp5
-rw-r--r--lib/StaticAnalyzer/Checkers/DebugCheckers.cpp8
-rw-r--r--lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp69
-rw-r--r--lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp33
-rw-r--r--lib/StaticAnalyzer/Checkers/ExperimentalChecks.cpp26
-rw-r--r--lib/StaticAnalyzer/Checkers/ExperimentalChecks.h31
-rw-r--r--lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp40
-rw-r--r--lib/StaticAnalyzer/Checkers/InternalChecks.h48
-rw-r--r--lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp582
-rw-r--r--lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp7
-rw-r--r--lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/MallocChecker.cpp187
-rw-r--r--lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp380
-rw-r--r--lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp23
-rw-r--r--lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp30
-rw-r--r--lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp15
-rw-r--r--lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp35
-rw-r--r--lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/StreamChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp38
-rw-r--r--lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp28
-rw-r--r--lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp28
-rw-r--r--lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp33
-rw-r--r--lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp39
-rw-r--r--lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp4
-rw-r--r--lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp14
-rw-r--r--lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp37
-rw-r--r--lib/StaticAnalyzer/Core/AggExprVisitor.cpp2
-rw-r--r--lib/StaticAnalyzer/Core/BasicStore.cpp15
-rw-r--r--lib/StaticAnalyzer/Core/BasicValueFactory.cpp8
-rw-r--r--lib/StaticAnalyzer/Core/BugReporter.cpp14
-rw-r--r--lib/StaticAnalyzer/Core/CFRefCount.cpp63
-rw-r--r--lib/StaticAnalyzer/Core/CMakeLists.txt9
-rw-r--r--lib/StaticAnalyzer/Core/CXXExprEngine.cpp300
-rw-r--r--lib/StaticAnalyzer/Core/CheckerContext.cpp (renamed from lib/StaticAnalyzer/Core/Checker.cpp)10
-rw-r--r--lib/StaticAnalyzer/Core/CheckerManager.cpp97
-rw-r--r--lib/StaticAnalyzer/Core/CoreEngine.cpp23
-rw-r--r--lib/StaticAnalyzer/Core/Environment.cpp19
-rw-r--r--lib/StaticAnalyzer/Core/ExplodedGraph.cpp2
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngine.cpp (renamed from lib/StaticAnalyzer/Checkers/ExprEngine.cpp)1099
-rw-r--r--lib/StaticAnalyzer/Core/FlatStore.cpp13
-rw-r--r--lib/StaticAnalyzer/Core/ObjCMessage.cpp56
-rw-r--r--lib/StaticAnalyzer/Core/RegionStore.cpp77
-rw-r--r--lib/StaticAnalyzer/Core/SValBuilder.cpp139
-rw-r--r--lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp1
-rw-r--r--lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp30
-rw-r--r--lib/StaticAnalyzer/Core/Store.cpp4
-rw-r--r--lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp91
-rw-r--r--lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp5
-rw-r--r--lib/Tooling/CMakeLists.txt6
-rw-r--r--lib/Tooling/JsonCompileCommandLineDatabase.cpp214
-rw-r--r--lib/Tooling/JsonCompileCommandLineDatabase.h107
-rw-r--r--lib/Tooling/Makefile15
-rw-r--r--lib/Tooling/Tooling.cpp322
-rw-r--r--runtime/CMakeLists.txt1
-rw-r--r--runtime/Makefile108
-rw-r--r--runtime/compiler-rt/Makefile114
-rw-r--r--runtime/libcxx/Makefile63
-rw-r--r--test/ASTMerge/var.c2
-rw-r--r--test/Analysis/CFDateGC.m10
-rw-r--r--test/Analysis/CFNumber.c8
-rw-r--r--test/Analysis/CFRetainRelease_NSAssertionHandler.m8
-rw-r--r--test/Analysis/CGColorSpace.c8
-rw-r--r--test/Analysis/CheckNSError.m8
-rw-r--r--test/Analysis/MissingDealloc.m2
-rw-r--r--test/Analysis/NSPanel.m8
-rw-r--r--test/Analysis/NSString.m23
-rw-r--r--test/Analysis/NSWindow.m8
-rw-r--r--test/Analysis/NoReturn.m8
-rw-r--r--test/Analysis/OSAtomic_mac.cpp19
-rw-r--r--test/Analysis/ObjCProperties.m8
-rw-r--r--test/Analysis/ObjCRetSigs.m2
-rw-r--r--test/Analysis/PR2599.m8
-rw-r--r--test/Analysis/PR2978.m2
-rw-r--r--test/Analysis/PR3991.m8
-rw-r--r--test/Analysis/PR7218.c2
-rw-r--r--test/Analysis/PR9741.cpp8
-rw-r--r--test/Analysis/additive-folding-range-constraints.c2
-rw-r--r--test/Analysis/additive-folding.c4
-rw-r--r--test/Analysis/analyzer-stats.c2
-rw-r--r--test/Analysis/array-struct-region.c4
-rw-r--r--test/Analysis/array-struct.c8
-rw-r--r--test/Analysis/auto-obj-dtors-cfg-output.cpp150
-rw-r--r--test/Analysis/base-init.cpp3
-rw-r--r--test/Analysis/blocks.m2
-rw-r--r--test/Analysis/bstring.c111
-rw-r--r--test/Analysis/casts.c4
-rw-r--r--test/Analysis/casts.m4
-rw-r--r--test/Analysis/cfref_PR2519.c8
-rw-r--r--test/Analysis/cfref_rdar6080742.c8
-rw-r--r--test/Analysis/chroot.c2
-rw-r--r--test/Analysis/complex.c8
-rw-r--r--test/Analysis/concrete-address.c4
-rw-r--r--test/Analysis/conditional-op-missing-lhs.c26
-rw-r--r--test/Analysis/constant-folding.c2
-rw-r--r--test/Analysis/cxx-crashes.cpp13
-rw-r--r--test/Analysis/dead-stores.c10
-rw-r--r--test/Analysis/dead-stores.cpp10
-rw-r--r--test/Analysis/dead-stores.m4
-rw-r--r--test/Analysis/delegates.m4
-rw-r--r--test/Analysis/derived-to-base.cpp2
-rw-r--r--test/Analysis/dtor.cpp2
-rw-r--r--test/Analysis/elementtype.c2
-rw-r--r--test/Analysis/exercise-ps.c4
-rw-r--r--test/Analysis/fields.c4
-rw-r--r--test/Analysis/flat-store.c2
-rw-r--r--test/Analysis/free.c2
-rw-r--r--test/Analysis/func.c4
-rw-r--r--test/Analysis/idempotent-operations-limited-loops.c6
-rw-r--r--test/Analysis/idempotent-operations.c9
-rw-r--r--test/Analysis/idempotent-operations.cpp21
-rw-r--r--test/Analysis/idempotent-operations.m14
-rw-r--r--test/Analysis/initializer.cpp2
-rw-r--r--test/Analysis/inline.c3
-rw-r--r--test/Analysis/inline2.c2
-rw-r--r--test/Analysis/inline3.c2
-rw-r--r--test/Analysis/inline4.c2
-rw-r--r--test/Analysis/iterators.cpp105
-rw-r--r--test/Analysis/lvalue.cpp2
-rw-r--r--test/Analysis/malloc.c28
-rw-r--r--test/Analysis/method-arg-decay.m (renamed from test/SemaObjC/method-arg-decay.m)2
-rw-r--r--test/Analysis/method-call.cpp2
-rw-r--r--test/Analysis/misc-ps-64.m8
-rw-r--r--test/Analysis/misc-ps-basic-store.m2
-rw-r--r--test/Analysis/misc-ps-eager-assume.m4
-rw-r--r--test/Analysis/misc-ps-flat-store.c2
-rw-r--r--test/Analysis/misc-ps-ranges.m4
-rw-r--r--test/Analysis/misc-ps-region-store-i386.m2
-rw-r--r--test/Analysis/misc-ps-region-store-x86_64.m2
-rw-r--r--test/Analysis/misc-ps-region-store.cpp159
-rw-r--r--test/Analysis/misc-ps-region-store.m66
-rw-r--r--test/Analysis/misc-ps-region-store.mm4
-rw-r--r--test/Analysis/misc-ps.m48
-rw-r--r--test/Analysis/new.cpp2
-rw-r--r--test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m2
-rw-r--r--test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m12
-rw-r--r--test/Analysis/no-exit-cfg.c4
-rw-r--r--test/Analysis/no-outofbounds.c8
-rw-r--r--test/Analysis/null-deref-ps-region.c2
-rw-r--r--test/Analysis/null-deref-ps.c8
-rw-r--r--test/Analysis/nullptr.cpp41
-rw-r--r--test/Analysis/operator-calls.cpp2
-rw-r--r--test/Analysis/out-of-bounds.c11
-rw-r--r--test/Analysis/outofbound.c2
-rw-r--r--test/Analysis/override-werror.c4
-rw-r--r--test/Analysis/plist-output-alternate.m2
-rw-r--r--test/Analysis/plist-output.m2
-rw-r--r--test/Analysis/pr4209.m4
-rw-r--r--test/Analysis/pr_2542_rdar_6793404.m4
-rw-r--r--test/Analysis/pr_4164.c4
-rw-r--r--test/Analysis/properties.m2
-rw-r--r--test/Analysis/ptr-arith.c4
-rw-r--r--test/Analysis/rdar-6442306-1.m4
-rw-r--r--test/Analysis/rdar-6540084.m2
-rw-r--r--test/Analysis/rdar-6541136-region.c2
-rw-r--r--test/Analysis/rdar-6541136.c2
-rw-r--r--test/Analysis/rdar-6562655.m4
-rw-r--r--test/Analysis/rdar-6582778-basic-store.c2
-rw-r--r--test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m4
-rw-r--r--test/Analysis/rdar-7168531.m4
-rw-r--r--test/Analysis/refcnt_naming.m4
-rw-r--r--test/Analysis/reference.cpp2
-rw-r--r--test/Analysis/region-1.m4
-rw-r--r--test/Analysis/retain-release-basic-store.m2
-rw-r--r--test/Analysis/retain-release-gc-only.m4
-rw-r--r--test/Analysis/retain-release-region-store.m2
-rw-r--r--test/Analysis/retain-release.m26
-rw-r--r--test/Analysis/security-syntax-checks-no-emit.c2
-rw-r--r--test/Analysis/security-syntax-checks.m63
-rw-r--r--test/Analysis/self-init.m2
-rw-r--r--test/Analysis/stack-addr-ps.c4
-rw-r--r--test/Analysis/stackaddrleak.c2
-rw-r--r--test/Analysis/stream.c2
-rw-r--r--test/Analysis/string.c448
-rw-r--r--test/Analysis/undef-buffers.c2
-rw-r--r--test/Analysis/uninit-msg-expr.m4
-rw-r--r--test/Analysis/uninit-ps-rdar6145427.m4
-rw-r--r--test/Analysis/uninit-vals-ps-region.m2
-rw-r--r--test/Analysis/uninit-vals-ps.c4
-rw-r--r--test/Analysis/uninit-vals.c53
-rw-r--r--test/Analysis/uninit-vals.m4
-rw-r--r--test/Analysis/unions-region.m2
-rw-r--r--test/Analysis/unix-fns.c4
-rw-r--r--test/Analysis/unreachable-code-path.c2
-rw-r--r--test/Analysis/unused-ivars.m2
-rw-r--r--test/Analysis/variadic-method-types.m93
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp2
-rw-r--r--test/CXX/basic/basic.scope/basic.scope.local/p4-0x.cpp68
-rw-r--r--test/CXX/basic/basic.scope/basic.scope.pdecl/p3.cpp26
-rw-r--r--test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp2
-rw-r--r--test/CXX/class.access/p4.cpp2
-rw-r--r--test/CXX/class.derived/p8-0x.cpp22
-rw-r--r--test/CXX/class/class.mem/p2.cpp31
-rw-r--r--test/CXX/class/class.mem/p8-0x-pedantic.cpp14
-rw-r--r--test/CXX/class/class.mem/p8-0x.cpp2
-rw-r--r--test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp17
-rw-r--r--test/CXX/class/class.union/p1.cpp34
-rw-r--r--test/CXX/class/p1-0x.cpp4
-rw-r--r--test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp21
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp2
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp2
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp7
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp44
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp161
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp2
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp2
-rw-r--r--test/CXX/except/except.handle/p16.cpp2
-rw-r--r--test/CXX/except/except.spec/p1.cpp60
-rw-r--r--test/CXX/except/except.spec/p11.cpp12
-rw-r--r--test/CXX/except/except.spec/p14.cpp2
-rw-r--r--test/CXX/except/except.spec/p15.cpp24
-rw-r--r--test/CXX/except/except.spec/p2-dynamic-types.cpp34
-rw-r--r--test/CXX/except/except.spec/p2-places.cpp63
-rw-r--r--test/CXX/except/except.spec/p3.cpp106
-rw-r--r--test/CXX/except/except.spec/p5-pointers.cpp85
-rw-r--r--test/CXX/except/except.spec/p5-virtual.cpp96
-rw-r--r--test/CXX/except/except.spec/p9-dynamic.cpp11
-rw-r--r--test/CXX/except/except.spec/p9-noexcept.cpp18
-rw-r--r--test/CXX/except/except.spec/template.cpp12
-rw-r--r--test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp6
-rw-r--r--test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp6
-rw-r--r--test/CXX/expr/expr.unary/expr.unary.op/p6.cpp6
-rw-r--r--test/CXX/lex/lex.pptoken/p3-0x.cpp11
-rw-r--r--test/CXX/over/over.over/p2-resolve-single-template-id.cpp102
-rw-r--r--test/CXX/special/class.copy/p33-0x.cpp2
-rw-r--r--test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp210
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp18
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/p4.cpp2
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/p5.cpp6
-rw-r--r--test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp6
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp63
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp12
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp8
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p3-0x.cpp65
-rw-r--r--test/CodeCompletion/PR9728.cpp9
-rw-r--r--test/CodeCompletion/ordinary-name.cpp58
-rw-r--r--test/CodeGen/2008-07-17-no-emit-on-error.c4
-rw-r--r--test/CodeGen/altivec.c31
-rw-r--r--test/CodeGen/arm-clear.c21
-rw-r--r--test/CodeGen/arm-pcs.c12
-rw-r--r--test/CodeGen/arm-vector-align.c19
-rw-r--r--test/CodeGen/atomic.c5
-rw-r--r--test/CodeGen/attr-availability.c31
-rw-r--r--test/CodeGen/block-byref-aggr.c17
-rw-r--r--test/CodeGen/builtin-attributes.c5
-rw-r--r--test/CodeGen/builtin-expect.c12
-rw-r--r--test/CodeGen/builtin-memfns.c35
-rw-r--r--test/CodeGen/builtinmemcpy.c3
-rw-r--r--test/CodeGen/builtins-ppc-altivec.c325
-rw-r--r--test/CodeGen/builtins-ptx.c99
-rw-r--r--test/CodeGen/builtins-x86.c31
-rw-r--r--test/CodeGen/builtins.c2
-rw-r--r--test/CodeGen/char-literal.c2
-rw-r--r--test/CodeGen/conditional.c21
-rw-r--r--test/CodeGen/const-init.c4
-rw-r--r--test/CodeGen/darwin-string-literals.c4
-rw-r--r--test/CodeGen/debug-info-line2.c17
-rw-r--r--test/CodeGen/decl.c2
-rw-r--r--test/CodeGen/ext-vector.c134
-rw-r--r--test/CodeGen/integer-overflow.c14
-rw-r--r--test/CodeGen/mangle.c9
-rw-r--r--test/CodeGen/mmx-inline-asm.c22
-rw-r--r--test/CodeGen/mrtd.c15
-rw-r--r--test/CodeGen/ms_struct-bitfield-init.c68
-rw-r--r--test/CodeGen/ms_struct-bitfield.c131
-rw-r--r--test/CodeGen/mult-alt-x86.c56
-rw-r--r--test/CodeGen/packed-arrays.c157
-rw-r--r--test/CodeGen/ptx-cc.c9
-rw-r--r--test/CodeGen/regparm-flag.c5
-rw-r--r--test/CodeGen/switch-dce.c247
-rw-r--r--test/CodeGen/union.c2
-rw-r--r--test/CodeGen/x86_64-arguments-darwin.c17
-rw-r--r--test/CodeGen/x86_64-arguments.c22
-rw-r--r--test/CodeGenCXX/PR5863-unreachable-block.cpp2
-rw-r--r--test/CodeGenCXX/anonymous-namespaces.cpp2
-rw-r--r--test/CodeGenCXX/anonymous-union-member-initializer.cpp19
-rw-r--r--test/CodeGenCXX/apple-kext-guard-variable.cpp9
-rw-r--r--test/CodeGenCXX/arm.cpp3
-rw-r--r--test/CodeGenCXX/blocks.cpp49
-rw-r--r--test/CodeGenCXX/class-layout.cpp28
-rw-r--r--test/CodeGenCXX/cxx0x-delegating-ctors.cpp48
-rw-r--r--test/CodeGenCXX/debug-info-byval.cpp2
-rw-r--r--test/CodeGenCXX/debug-info-cxx0x.cpp8
-rw-r--r--test/CodeGenCXX/debug-info-fn-template.cpp15
-rw-r--r--test/CodeGenCXX/debug-info-method-spec.cpp10
-rw-r--r--test/CodeGenCXX/debug-info-namespace.cpp2
-rw-r--r--test/CodeGenCXX/debug-info-template.cpp24
-rw-r--r--test/CodeGenCXX/debug-info-this.cpp15
-rw-r--r--test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp2
-rw-r--r--test/CodeGenCXX/destructors.cpp2
-rw-r--r--test/CodeGenCXX/devirtualize-virtual-function-calls.cpp10
-rw-r--r--test/CodeGenCXX/dynamic-cast-always-null.cpp19
-rw-r--r--test/CodeGenCXX/dynamic-cast.cpp2
-rw-r--r--test/CodeGenCXX/dyncast.cpp367
-rw-r--r--test/CodeGenCXX/eh.cpp2
-rw-r--r--test/CodeGenCXX/exceptions-no-rtti.cpp2
-rw-r--r--test/CodeGenCXX/exceptions.cpp87
-rw-r--r--test/CodeGenCXX/explicit-instantiation.cpp2
-rw-r--r--test/CodeGenCXX/for-range-temporaries.cpp131
-rw-r--r--test/CodeGenCXX/for-range.cpp128
-rw-r--r--test/CodeGenCXX/global-init.cpp21
-rw-r--r--test/CodeGenCXX/goto.cpp2
-rw-r--r--test/CodeGenCXX/mangle-exprs.cpp60
-rw-r--r--test/CodeGenCXX/mangle-subst-std.cpp4
-rw-r--r--test/CodeGenCXX/mangle.cpp67
-rw-r--r--test/CodeGenCXX/member-function-pointers.cpp23
-rw-r--r--test/CodeGenCXX/nrvo.cpp2
-rw-r--r--test/CodeGenCXX/pointers-to-data-members.cpp10
-rw-r--r--test/CodeGenCXX/pragma-pack.cpp4
-rw-r--r--test/CodeGenCXX/references.cpp11
-rw-r--r--test/CodeGenCXX/specialized-static-data-mem-init.cpp4
-rw-r--r--test/CodeGenCXX/static-data-member.cpp4
-rw-r--r--test/CodeGenCXX/static-init-3.cpp4
-rw-r--r--test/CodeGenCXX/static-init.cpp4
-rw-r--r--test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp2
-rw-r--r--test/CodeGenCXX/threadsafe-statics-exceptions.cpp2
-rw-r--r--test/CodeGenCXX/threadsafe-statics.cpp10
-rw-r--r--test/CodeGenCXX/throw-expression-dtor.cpp2
-rw-r--r--test/CodeGenCXX/throw-expressions.cpp2
-rw-r--r--test/CodeGenCXX/try-catch.cpp2
-rw-r--r--test/CodeGenCXX/typeid.cpp22
-rw-r--r--test/CodeGenCXX/unknown-anytype.cpp99
-rw-r--r--test/CodeGenCXX/value-init.cpp58
-rw-r--r--test/CodeGenCXX/visibility.cpp11
-rw-r--r--test/CodeGenCXX/vtable-debug-info.cpp5
-rw-r--r--test/CodeGenCXX/vtable-layout.cpp22
-rw-r--r--test/CodeGenCXX/vtable-linkage.cpp2
-rw-r--r--test/CodeGenCXX/x86_64-arguments.cpp6
-rw-r--r--test/CodeGenObjC/atomic-aggregate-property.m2
-rw-r--r--test/CodeGenObjC/attr-availability.m24
-rw-r--r--test/CodeGenObjC/bitfield-access.m9
-rw-r--r--test/CodeGenObjC/blocks.m13
-rw-r--r--test/CodeGenObjC/constant-strings.m16
-rw-r--r--test/CodeGenObjC/debug-info-foreach.m7
-rw-r--r--test/CodeGenObjC/debug-info-getter-name.m9
-rw-r--r--test/CodeGenObjC/debug-info-property.m12
-rw-r--r--test/CodeGenObjC/fpret.m2
-rw-r--r--test/CodeGenObjC/instance-method-metadata.m34
-rw-r--r--test/CodeGenObjC/messages.m20
-rw-r--r--test/CodeGenObjC/metadata-symbols-64.m6
-rw-r--r--test/CodeGenObjC/metadata_symbols.m4
-rw-r--r--test/CodeGenObjC/misc-atomic-property.m80
-rw-r--r--test/CodeGenObjC/missing-atend-metadata.m24
-rw-r--r--test/CodeGenObjC/no-vararg-messaging.m18
-rw-r--r--test/CodeGenObjC/property-agrr-getter.m8
-rw-r--r--test/CodeGenObjC/simplify-exceptions.mm18
-rw-r--r--test/CodeGenObjCXX/exceptions.mm2
-rw-r--r--test/CodeGenObjCXX/ivar-objects.mm18
-rw-r--r--test/CodeGenObjCXX/message-reference.mm20
-rw-r--r--test/CodeGenObjCXX/property-reference.mm34
-rw-r--r--test/CodeGenObjCXX/references.mm2
-rw-r--r--test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl12
-rw-r--r--test/CodeGenOpenCL/address-spaces.cl27
-rw-r--r--test/Coverage/ast-printing.c1
-rw-r--r--test/Coverage/ast-printing.cpp1
-rw-r--r--test/Coverage/html-diagnostics.c2
-rw-r--r--test/Driver/apple-kext-i386.cpp9
-rw-r--r--test/Driver/apple-kext-mkernel.c24
-rw-r--r--test/Driver/ast.c2
-rw-r--r--test/Driver/cc-log-diagnostics.c29
-rw-r--r--test/Driver/cc-print-options.c2
-rw-r--r--test/Driver/clang-exception-flags.cpp23
-rw-r--r--test/Driver/clang-translation.c2
-rw-r--r--test/Driver/clang_f_opts.c17
-rw-r--r--test/Driver/clang_wrapv_opts.c11
-rw-r--r--test/Driver/darwin-cc.c7
-rw-r--r--test/Driver/darwin-dsymutil.c7
-rw-r--r--test/Driver/darwin-ld.c4
-rw-r--r--test/Driver/darwin-version.c8
-rw-r--r--test/Driver/darwin-xarch.c4
-rw-r--r--test/Driver/exceptions.m19
-rw-r--r--test/Driver/hello.c6
-rw-r--r--test/Driver/sysroot-flags.c14
-rw-r--r--test/FixIt/fixit-cxx0x.cpp3
-rw-r--r--test/FixIt/fixit-unrecoverable.c2
-rw-r--r--test/FixIt/fixit.c6
-rw-r--r--test/FixIt/fixit.cpp19
-rw-r--r--test/FixIt/no-macro-fixit.c16
-rw-r--r--test/FixIt/typo.c14
-rw-r--r--test/FixIt/typo.cpp12
-rw-r--r--test/FixIt/typo.m18
-rw-r--r--test/Frontend/dependency-gen.c3
-rw-r--r--test/Frontend/dependency-generation-crash.c4
-rw-r--r--test/Frontend/diagnostic-name.c5
-rw-r--r--test/Index/TestClassDecl.m2
-rw-r--r--test/Index/annotate-context-sensitive.cpp42
-rw-r--r--test/Index/annotate-nested-name-specifier.cpp328
-rw-r--r--test/Index/annotate-tokens.c50
-rw-r--r--test/Index/annotate-tokens.cpp89
-rw-r--r--test/Index/annotate-tokens.m31
-rw-r--r--test/Index/blocks.c8
-rw-r--r--test/Index/c-index-api-loadTU-test.m14
-rw-r--r--test/Index/c-index-getCursor-test.m6
-rw-r--r--test/Index/cindex-on-invalid.m17
-rw-r--r--test/Index/complete-objc-message.m12
-rw-r--r--test/Index/complete-properties.m27
-rw-r--r--test/Index/index-templates.cpp58
-rw-r--r--test/Index/initializer-memory.cpp16
-rw-r--r--test/Index/invalid-rdar-8236270.cpp2
-rw-r--r--test/Index/load-classes.cpp4
-rw-r--r--test/Index/load-exprs.c20
-rw-r--r--test/Index/load-namespaces.cpp16
-rw-r--r--test/Index/load-stmts.cpp16
-rw-r--r--test/Index/local-symbols.m2
-rw-r--r--test/Index/nested-binaryoperators.cpp4
-rw-r--r--test/Index/overrides.cpp4
-rw-r--r--test/Index/pragma-diag-reparse.c13
-rw-r--r--test/Index/preamble-reparse-chained.c4
-rw-r--r--test/Index/preamble.c4
-rw-r--r--test/Index/rdar-8288645-invalid-code.mm2
-rw-r--r--test/Index/recursive-cxx-member-calls.cpp523
-rw-r--r--test/Index/recursive-member-access.c12
-rw-r--r--test/Index/remap-load.c2
-rw-r--r--test/Index/usrs-cxx0x.cpp2
-rw-r--r--test/Index/usrs.cpp50
-rw-r--r--test/Index/usrs.m44
-rw-r--r--test/Lexer/has_feature_cxx0x.cpp38
-rw-r--r--test/Lexer/pragma-message.c2
-rw-r--r--test/Makefile42
-rw-r--r--test/Misc/Inputs/include.h1
-rw-r--r--test/Misc/caret-diags-macros.c23
-rw-r--r--test/Misc/include-stack-for-note-flag.cpp18
-rw-r--r--test/Misc/warn-in-system-header.c4
-rw-r--r--test/Misc/warn-in-system-header.h4
-rw-r--r--test/PCH/Inputs/working-directory-1.h5
-rw-r--r--test/PCH/chain-cxx.cpp35
-rw-r--r--test/PCH/chain-empty-initial-namespace.cpp24
-rw-r--r--test/PCH/chain-implicit-definition.cpp39
-rw-r--r--test/PCH/chain-late-anonymous-namespace.cpp61
-rw-r--r--test/PCH/chain-pending-instantiations.cpp33
-rw-r--r--test/PCH/cxx-chain-function-template.cpp32
-rw-r--r--test/PCH/cxx-for-range.cpp19
-rw-r--r--test/PCH/cxx-for-range.h35
-rw-r--r--test/PCH/cxx-reference.cpp6
-rw-r--r--test/PCH/cxx-reference.h13
-rw-r--r--test/PCH/cxx-templates.cpp29
-rw-r--r--test/PCH/cxx-templates.h12
-rw-r--r--test/PCH/cxx_exprs.cpp6
-rw-r--r--test/PCH/exprs.c5
-rw-r--r--test/PCH/exprs.h6
-rw-r--r--test/PCH/headersearch.cpp6
-rw-r--r--test/PCH/modified-header-crash.c10
-rw-r--r--test/PCH/modified-header-crash.h1
-rw-r--r--test/PCH/objcxx-ivar-class.h1
-rw-r--r--test/PCH/pragma-diag-section.cpp5
-rw-r--r--test/PCH/pragma-diag.c3
-rw-r--r--test/PCH/rdar8852495.c3
-rw-r--r--test/PCH/reloc.c2
-rw-r--r--test/PCH/source-manager-stack.c4
-rw-r--r--test/PCH/working-directory.cpp12
-rw-r--r--test/PCH/working-directory.h1
-rw-r--r--test/Parser/DelayedTemplateParsing.cpp42
-rw-r--r--test/Parser/MicrosoftExtensions.c2
-rw-r--r--test/Parser/MicrosoftExtensions.cpp53
-rw-r--r--test/Parser/altivec.c8
-rw-r--r--test/Parser/attr-availability.c20
-rw-r--r--test/Parser/c1x-generic-selection.c10
-rw-r--r--test/Parser/cxx-casting.cpp34
-rw-r--r--test/Parser/cxx-decl.cpp4
-rw-r--r--test/Parser/cxx-exception-spec.cpp17
-rw-r--r--test/Parser/cxx-member-crash.cpp15
-rw-r--r--test/Parser/cxx-stmt.cpp2
-rw-r--r--test/Parser/cxx-throw.cpp2
-rw-r--r--test/Parser/cxx0x-attributes.cpp2
-rw-r--r--test/Parser/cxx0x-override-control-keywords.cpp3
-rw-r--r--test/Parser/expressions.c6
-rw-r--r--test/Parser/objc-missing-impl.m2
-rw-r--r--test/Parser/objcxx-at.mm15
-rw-r--r--test/Parser/opencl-image-access.cl16
-rw-r--r--test/Parser/recovery.m5
-rw-r--r--test/Parser/selector-1.m26
-rw-r--r--test/Parser/switch-recovery.cpp124
-rw-r--r--test/Preprocessor/init.c14
-rw-r--r--test/Preprocessor/pragma-pushpop-macro.c2
-rw-r--r--test/Preprocessor/pragma_diagnostic_sections.cpp8
-rw-r--r--test/Preprocessor/pragma_unknown.c2
-rw-r--r--test/Preprocessor/stdint.c12
-rw-r--r--test/Preprocessor/traditional-cpp.c12
-rw-r--r--test/Rewriter/rewrite-block-literal-1.mm32
-rw-r--r--test/Rewriter/rewrite-block-pointer.mm17
-rw-r--r--test/Sema/__try.c171
-rw-r--r--test/Sema/align-x86-64.c14
-rw-r--r--test/Sema/align-x86.c26
-rw-r--r--test/Sema/altivec-init.c12
-rw-r--r--test/Sema/annotate.c2
-rw-r--r--test/Sema/anonymous-struct-union.c2
-rw-r--r--test/Sema/arm-layout.c2
-rw-r--r--test/Sema/attr-args.c40
-rw-r--r--test/Sema/attr-availability-ios.c21
-rw-r--r--test/Sema/attr-availability-macosx.c17
-rw-r--r--test/Sema/attr-availability.c6
-rw-r--r--test/Sema/attr-cleanup.c4
-rw-r--r--test/Sema/attr-naked.c2
-rw-r--r--test/Sema/attr-nodebug.c2
-rw-r--r--test/Sema/attr-noinline.c2
-rw-r--r--test/Sema/attr-noreturn.c4
-rw-r--r--test/Sema/attr-regparm.c2
-rw-r--r--test/Sema/attr-unused.c2
-rw-r--r--test/Sema/block-args.c5
-rw-r--r--test/Sema/builtins-decl.c8
-rw-r--r--test/Sema/builtins.c2
-rw-r--r--test/Sema/c89.c2
-rw-r--r--test/Sema/callingconv.c4
-rw-r--r--test/Sema/const-eval.c2
-rw-r--r--test/Sema/constructor-attribute.c4
-rw-r--r--test/Sema/conversion.c4
-rw-r--r--test/Sema/expr-address-of.c11
-rw-r--r--test/Sema/exprs.c16
-rw-r--r--test/Sema/format-strings-fixit.c26
-rw-r--r--test/Sema/function-redecl.c2
-rw-r--r--test/Sema/generic-selection.c26
-rw-r--r--test/Sema/incomplete-call.c6
-rw-r--r--test/Sema/knr-def-call.c6
-rw-r--r--test/Sema/memset-invalid.c6
-rw-r--r--test/Sema/missing-field-initializers.c2
-rw-r--r--test/Sema/neon-vector-types.c2
-rw-r--r--test/Sema/overloaded-func-transparent-union.c28
-rw-r--r--test/Sema/parentheses.c3
-rw-r--r--test/Sema/pragma-ms_struct.c34
-rw-r--r--test/Sema/sentinel-attribute.c2
-rw-r--r--test/Sema/shift.c10
-rw-r--r--test/Sema/static-assert.c11
-rw-r--r--test/Sema/struct-decl.c11
-rw-r--r--test/Sema/uninit-variables-vectors.c17
-rw-r--r--test/Sema/uninit-variables.c123
-rw-r--r--test/Sema/vector-ops.c3
-rw-r--r--test/Sema/warn-gnu-designators.c2
-rw-r--r--test/Sema/warn-unused-function.c6
-rw-r--r--test/Sema/warn-unused-value.c9
-rw-r--r--test/Sema/warn-write-strings.c2
-rw-r--r--test/SemaCXX/MicrosoftExtensions.cpp86
-rw-r--r--test/SemaCXX/PR9459.cpp7
-rw-r--r--test/SemaCXX/PR9460.cpp19
-rw-r--r--test/SemaCXX/PR9461.cpp32
-rw-r--r--test/SemaCXX/PR9572.cpp15
-rw-r--r--test/SemaCXX/__try.cpp58
-rw-r--r--test/SemaCXX/addr-of-overloaded-function.cpp7
-rw-r--r--test/SemaCXX/address-space-conversion.cpp197
-rw-r--r--test/SemaCXX/address-space-newdelete.cpp24
-rw-r--r--test/SemaCXX/address-space-references.cpp19
-rw-r--r--test/SemaCXX/alignof-sizeof-reference.cpp6
-rw-r--r--test/SemaCXX/altivec.cpp30
-rw-r--r--test/SemaCXX/array-bounds.cpp53
-rw-r--r--test/SemaCXX/attr-nonnull.cpp6
-rw-r--r--test/SemaCXX/attr-unavailable.cpp2
-rw-r--r--test/SemaCXX/auto-subst-failure.cpp15
-rw-r--r--test/SemaCXX/conditional-expr.cpp2
-rw-r--r--test/SemaCXX/conversion-function.cpp25
-rw-r--r--test/SemaCXX/cxx0x-constexpr-const.cpp10
-rw-r--r--test/SemaCXX/cxx0x-delegating-ctors.cpp36
-rw-r--r--test/SemaCXX/cxx0x-return-init-list.cpp18
-rw-r--r--test/SemaCXX/decltype-98.cpp3
-rw-r--r--test/SemaCXX/decltype-overloaded-functions.cpp13
-rw-r--r--test/SemaCXX/destructor.cpp13
-rw-r--r--test/SemaCXX/enum-scoped.cpp6
-rw-r--r--test/SemaCXX/exception-spec-no-exceptions.cpp7
-rw-r--r--test/SemaCXX/exception-spec.cpp193
-rw-r--r--test/SemaCXX/exceptions.cpp2
-rw-r--r--test/SemaCXX/expression-traits.cpp620
-rw-r--r--test/SemaCXX/flexible-array-test.cpp16
-rw-r--r--test/SemaCXX/for-range-examples.cpp150
-rw-r--r--test/SemaCXX/for-range-no-std.cpp37
-rw-r--r--test/SemaCXX/friend.cpp4
-rw-r--r--test/SemaCXX/generic-selection.cpp46
-rw-r--r--test/SemaCXX/goto.cpp105
-rw-r--r--test/SemaCXX/goto2.cpp47
-rw-r--r--test/SemaCXX/init-priority-attr.cpp2
-rw-r--r--test/SemaCXX/libstdcxx_is_pod_hack.cpp16
-rw-r--r--test/SemaCXX/literal-type.cpp63
-rw-r--r--test/SemaCXX/member-expr.cpp5
-rw-r--r--test/SemaCXX/member-pointers-2.cpp15
-rw-r--r--test/SemaCXX/neon-vector-types.cpp27
-rw-r--r--test/SemaCXX/nested-name-spec-locations.cpp94
-rw-r--r--test/SemaCXX/nullptr.cpp2
-rw-r--r--test/SemaCXX/operator-arrow-temporary.cpp19
-rw-r--r--test/SemaCXX/overloaded-name.cpp12
-rw-r--r--test/SemaCXX/overloaded-operator.cpp15
-rw-r--r--test/SemaCXX/pascal-strings.cpp6
-rw-r--r--test/SemaCXX/pseudo-destructors.cpp7
-rw-r--r--test/SemaCXX/ptrtomember.cpp5
-rw-r--r--test/SemaCXX/reinterpret-cast.cpp16
-rw-r--r--test/SemaCXX/return-noreturn.cpp73
-rw-r--r--test/SemaCXX/return.cpp14
-rw-r--r--test/SemaCXX/rval-references.cpp2
-rw-r--r--test/SemaCXX/scope-check.cpp20
-rw-r--r--test/SemaCXX/short-enums.cpp17
-rw-r--r--test/SemaCXX/short-wchar-sign.cpp6
-rw-r--r--test/SemaCXX/sourceranges.cpp6
-rw-r--r--test/SemaCXX/static-cast.cpp6
-rw-r--r--test/SemaCXX/storage-class.cpp3
-rw-r--r--test/SemaCXX/type-traits.cpp1598
-rw-r--r--test/SemaCXX/uninit-variables-conditional.cpp23
-rw-r--r--test/SemaCXX/uninit-variables.cpp66
-rw-r--r--test/SemaCXX/uninitialized.cpp53
-rw-r--r--test/SemaCXX/unknown-anytype.cpp36
-rw-r--r--test/SemaCXX/unreachable-catch-clauses.cpp2
-rw-r--r--test/SemaCXX/unreachable-code.cpp2
-rw-r--r--test/SemaCXX/unused-functions.cpp4
-rw-r--r--test/SemaCXX/vtable-instantiation.cc26
-rw-r--r--test/SemaCXX/warn-assignment-condition.cpp13
-rw-r--r--test/SemaCXX/warn-bool-conversion.cpp24
-rw-r--r--test/SemaCXX/warn-deprecated-header.cpp6
-rw-r--r--test/SemaCXX/warn-exit-time-destructors.cpp27
-rw-r--r--test/SemaCXX/warn-global-constructors.cpp4
-rw-r--r--test/SemaCXX/warn-literal-conversion.cpp15
-rw-r--r--test/SemaCXX/warn-missing-prototypes.cpp6
-rw-r--r--test/SemaCXX/warn-non-pod-memset.cpp63
-rw-r--r--test/SemaCXX/warn-overloaded-virtual.cpp12
-rw-r--r--test/SemaCXX/warn-shadow.cpp11
-rw-r--r--test/SemaCXX/warn-unreachable.cpp2
-rw-r--r--test/SemaCXX/warn-unused-filescoped.cpp9
-rw-r--r--test/SemaCXX/warn-using-namespace-in-header.cpp54
-rw-r--r--test/SemaCXX/warn-using-namespace-in-header.h50
-rw-r--r--test/SemaCXX/warn_false_to_pointer.cpp10
-rw-r--r--test/SemaCXX/writable-strings-deprecated.cpp2
-rw-r--r--test/SemaObjC/assign-rvalue-message.m24
-rw-r--r--test/SemaObjC/attr-objc-gc.m26
-rw-r--r--test/SemaObjC/auto-objective-c.m33
-rw-r--r--test/SemaObjC/block-type-safety.m17
-rw-r--r--test/SemaObjC/call-super-2.m14
-rw-r--r--test/SemaObjC/class-message-protocol-lookup.m34
-rw-r--r--test/SemaObjC/class-unavail-warning.m24
-rw-r--r--test/SemaObjC/comptypes-4.m2
-rw-r--r--test/SemaObjC/conditional-expr-8.m25
-rw-r--r--test/SemaObjC/exprs.m4
-rw-r--r--test/SemaObjC/foreach.m30
-rw-r--r--test/SemaObjC/format-arg-attribute.m8
-rw-r--r--test/SemaObjC/iboutletcollection-attr.m4
-rw-r--r--test/SemaObjC/idiomatic-parentheses.m4
-rw-r--r--test/SemaObjC/ignore-weakimport-method.m1
-rw-r--r--test/SemaObjC/ivar-lookup.m12
-rw-r--r--test/SemaObjC/method-bad-param.m2
-rw-r--r--test/SemaObjC/method-not-defined.m6
-rw-r--r--test/SemaObjC/method-prototype-scope.m4
-rw-r--r--test/SemaObjC/method-sentinel-attr.m2
-rw-r--r--test/SemaObjC/missing-atend-metadata.m22
-rw-r--r--test/SemaObjC/nonnull.m27
-rw-r--r--test/SemaObjC/objc-qualified-property-lookup.m21
-rw-r--r--test/SemaObjC/property-13.m2
-rw-r--r--test/SemaObjC/property-lookup-in-id.m33
-rw-r--r--test/SemaObjC/protocol-attribute.m2
-rw-r--r--test/SemaObjC/self-declared-in-block.m51
-rw-r--r--test/SemaObjC/self-in-function.m26
-rw-r--r--test/SemaObjC/sizeof-interface.m2
-rw-r--r--test/SemaObjC/special-dep-unavail-warning.m8
-rw-r--r--test/SemaObjC/uninit-variables.m4
-rw-r--r--test/SemaObjC/unqualified-to-qualified-class-warn.m72
-rw-r--r--test/SemaObjC/warn-write-strings.m2
-rw-r--r--test/SemaObjC/weak-attr-ivar.m10
-rw-r--r--test/SemaObjCXX/argument-dependent-lookup.mm19
-rw-r--r--test/SemaObjCXX/exceptions-fragile.mm2
-rw-r--r--test/SemaObjCXX/goto.mm16
-rw-r--r--test/SemaObjCXX/objc-pointer-conv.mm2
-rw-r--r--test/SemaObjCXX/overload-gc.mm24
-rw-r--r--test/SemaObjCXX/overload.mm26
-rw-r--r--test/SemaObjCXX/parameters.mm5
-rw-r--r--test/SemaObjCXX/propert-dot-error.mm11
-rw-r--r--test/SemaObjCXX/property-reference.mm44
-rw-r--r--test/SemaObjCXX/references.mm6
-rw-r--r--test/SemaOpenCL/extension-fp64.cl8
-rw-r--r--test/SemaOpenCL/vec_step.cl32
-rw-r--r--test/SemaTemplate/address-spaces.cpp86
-rw-r--r--test/SemaTemplate/deduction-crash.cpp2
-rw-r--r--test/SemaTemplate/dependent-template-recover.cpp42
-rw-r--r--test/SemaTemplate/destructor-template.cpp7
-rw-r--r--test/SemaTemplate/explicit-instantiation.cpp9
-rw-r--r--test/SemaTemplate/instantiate-cast.cpp2
-rw-r--r--test/SemaTemplate/instantiate-expr-4.cpp2
-rw-r--r--test/SemaTemplate/instantiate-function-1.cpp2
-rw-r--r--test/SemaTemplate/instantiate-member-class.cpp23
-rw-r--r--test/SemaTemplate/instantiate-member-template.cpp44
-rw-r--r--test/SemaTemplate/instantiate-try-catch.cpp2
-rw-r--r--test/SemaTemplate/issue150.cpp107
-rw-r--r--test/SemaTemplate/nested-name-spec-template.cpp41
-rw-r--r--test/SemaTemplate/resolve-single-template-id.cpp80
-rw-r--r--test/SemaTemplate/temp_arg_template.cpp9
-rw-r--r--test/SemaTemplate/typename-specifier-4.cpp8
-rw-r--r--test/lit.cfg9
-rw-r--r--tools/c-index-test/Makefile3
-rw-r--r--tools/c-index-test/c-index-test.c39
-rw-r--r--tools/driver/CMakeLists.txt1
-rw-r--r--tools/driver/Makefile2
-rw-r--r--tools/driver/cc1_main.cpp2
-rw-r--r--tools/driver/cc1as_main.cpp9
-rw-r--r--tools/driver/driver.cpp105
-rw-r--r--tools/libclang/CIndex.cpp807
-rw-r--r--tools/libclang/CIndexCodeCompletion.cpp21
-rw-r--r--tools/libclang/CIndexInclusionStack.cpp10
-rw-r--r--tools/libclang/CIndexUSRs.cpp10
-rw-r--r--tools/libclang/CIndexer.cpp5
-rw-r--r--tools/libclang/CMakeLists.txt64
-rw-r--r--tools/libclang/CXCursor.cpp9
-rw-r--r--tools/libclang/libclang.darwin.exports6
-rw-r--r--tools/libclang/libclang.exports4
-rwxr-xr-xtools/scan-build/ccc-analyzer66
-rwxr-xr-xtools/scan-build/scan-build30
-rw-r--r--unittests/CMakeLists.txt10
-rw-r--r--unittests/Tooling/JsonCompileCommandLineDatabaseTest.cpp232
-rw-r--r--unittests/Tooling/ToolingTest.cpp175
-rwxr-xr-xutils/CmpDriver2
-rw-r--r--utils/OptionalTests/Extra/Runtime/darwin-clang_rt.c2
-rw-r--r--www/OpenProjects.html7
-rw-r--r--www/analyzer/latest_checker.html.incl2
-rw-r--r--www/analyzer/release_notes.html50
-rw-r--r--www/analyzer/scan-build.html2
-rw-r--r--www/cxx_status.html56
-rw-r--r--www/get_started.html15
-rw-r--r--www/hacking.html88
-rw-r--r--www/libstdc++4.4-clang0x.patch369
1142 files changed, 52310 insertions, 22408 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b1ab11de72df..7b54deaaf546 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,7 +30,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
include(AddLLVM)
include(TableGen)
- include("${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVM.cmake")
+ include("${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake")
include(HandleLLVMOptions)
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
@@ -40,9 +40,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories("${PATH_TO_LLVM_BUILD}/include" "${LLVM_MAIN_INCLUDE_DIR}")
- if( NOT PATH_TO_LLVM_BUILD STREQUAL LLVM_MAIN_SRC_DIR )
- include_directories("${LLVM_MAIN_INCLUDE_DIR}")
- endif()
link_directories("${PATH_TO_LLVM_BUILD}/lib")
set(LLVM_TABLEGEN_EXE "${PATH_TO_LLVM_BUILD}/bin/tblgen")
@@ -174,23 +171,12 @@ macro(add_clang_library name)
if( LLVM_COMMON_DEPENDS )
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
endif( LLVM_COMMON_DEPENDS )
- if( LLVM_USED_LIBS )
- foreach(lib ${LLVM_USED_LIBS})
- target_link_libraries( ${name} ${lib} )
- endforeach(lib)
- endif( LLVM_USED_LIBS )
- if( LLVM_LINK_COMPONENTS )
- llvm_config(${name} ${LLVM_LINK_COMPONENTS})
- endif( LLVM_LINK_COMPONENTS )
- if (LLVM_COMMON_LIBS)
- target_link_libraries(${name} ${LLVM_COMMON_LIBS})
- endif()
- if( NOT MINGW )
- get_system_libs(llvm_system_libs)
- if( llvm_system_libs )
- target_link_libraries(${name} ${llvm_system_libs})
- endif()
- endif()
+
+ target_link_libraries( ${name} ${LLVM_USED_LIBS} )
+ llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
+ target_link_libraries( ${name} ${LLVM_COMMON_LIBS} )
+ link_system_libs( ${name} )
+
add_dependencies(${name} ClangDiagnosticCommon)
if(MSVC)
get_target_property(cflag ${name} COMPILE_FLAGS)
@@ -211,9 +197,9 @@ macro(add_clang_executable name)
set_target_properties(${name} PROPERTIES FOLDER "Clang executables")
endmacro(add_clang_executable)
-include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}/include
+include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
)
install(DIRECTORY include/
@@ -221,7 +207,6 @@ install(DIRECTORY include/
FILES_MATCHING
PATTERN "*.def"
PATTERN "*.h"
- PATTERN "*.td"
PATTERN ".svn" EXCLUDE
)
diff --git a/Makefile b/Makefile
index 1216dadd297e..b6c630aa10af 100644
--- a/Makefile
+++ b/Makefile
@@ -46,6 +46,9 @@ CPP.Flags += -I$(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include -I$(PROJ_OBJ_DIR)/$(CLANG_
ifdef CLANG_VENDOR
CPP.Flags += -DCLANG_VENDOR='"$(CLANG_VENDOR) "'
endif
+ifdef CLANG_REPOSITORY_STRING
+CPP.Flags += -DCLANG_REPOSITORY_STRING='"$(CLANG_REPOSITORY_STRING)"'
+endif
# Disable -fstrict-aliasing. Darwin disables it by default (and LLVM doesn't
# work with it enabled with GCC), Clang/llvm-gcc don't support it yet, and newer
diff --git a/docs/DriverInternals.html b/docs/DriverInternals.html
index a7d2da37711e..4f5f0ae112f9 100644
--- a/docs/DriverInternals.html
+++ b/docs/DriverInternals.html
@@ -88,7 +88,7 @@
<h3 id="components">Flexible</h3>
<!--=======================================================================-->
- <p>The driver was designed to be flexible and easily accomodate
+ <p>The driver was designed to be flexible and easily accommodate
new uses as we grow the clang and LLVM infrastructure. As one
example, the driver can easily support the introduction of
tools which have an integrated assembler; something we hope to
@@ -218,7 +218,7 @@
<p>The clang driver can dump the results of this
stage using the <tt>-ccc-print-options</tt> flag (which
- must preceed any actual command line arguments). For
+ must precede any actual command line arguments). For
example:</p>
<pre>
$ <b>clang -ccc-print-options -Xarch_i386 -fomit-frame-pointer -Wa,-fast -Ifoo -I foo t.c</b>
@@ -490,7 +490,7 @@
<li>
<b>Specs</b>
- <p>The clang driver has no direct correspondant for
+ <p>The clang driver has no direct correspondent for
"specs". The majority of the functionality that is
embedded in specs is in the Tool specific argument
translation routines. The parts of specs which control the
diff --git a/docs/InternalsManual.html b/docs/InternalsManual.html
index 813015ecf659..961198938f20 100644
--- a/docs/InternalsManual.html
+++ b/docs/InternalsManual.html
@@ -412,7 +412,7 @@ it is rendered.
</p>
<!-- ==================================================== -->
-<h4 id="code-modification-hints">Code Modification Hints</h4>
+<h4 id="fix-it-hints">Fix-It Hints</h4>
<!-- ==================================================== -->
<p>In some cases, the front end emits diagnostics when it is clear
@@ -422,14 +422,14 @@ deprecated syntax that is easily rewritten into a more modern form.
Clang tries very hard to emit the diagnostic and recover gracefully
in these and other cases.</p>
-<p>However, for these cases where the fix is obvious, the diagnostic
-can be annotated with a code
-modification "hint" that describes how to change the code referenced
-by the diagnostic to fix the problem. For example, it might add the
-missing semicolon at the end of the statement or rewrite the use of a
-deprecated construct into something more palatable. Here is one such
-example C++ front end, where we warn about the right-shift operator
-changing meaning from C++98 to C++0x:</p>
+<p>However, for these cases where the fix is obvious, the diagnostic
+can be annotated with a hint (referred to as a "fix-it hint") that
+describes how to change the code referenced by the diagnostic to fix
+the problem. For example, it might add the missing semicolon at the
+end of the statement or rewrite the use of a deprecated construct
+into something more palatable. Here is one such example from the C++
+front end, where we warn about the right-shift operator changing
+meaning from C++98 to C++0x:</p>
<pre>
test.cpp:3:7: warning: use of right-shift operator ('&gt;&gt;') in template argument will require parentheses in C++0x
@@ -438,33 +438,31 @@ A&lt;100 &gt;&gt; 2&gt; *a;
( )
</pre>
-<p>Here, the code modification hint is suggesting that parentheses be
-added, and showing exactly where those parentheses would be inserted
-into the source code. The code modification hints themselves describe
-what changes to make to the source code in an abstract manner, which
-the text diagnostic printer renders as a line of "insertions" below
-the caret line. <a href="#DiagnosticClient">Other diagnostic
-clients</a> might choose to render the code differently (e.g., as
-markup inline) or even give the user the ability to automatically fix
-the problem.</p>
-
-<p>All code modification hints are described by the
-<code>CodeModificationHint</code> class, instances of which should be
-attached to the diagnostic using the &lt;&lt; operator in the same way
-that highlighted source ranges and arguments are passed to the
-diagnostic. Code modification hints can be created with one of three
-constructors:</p>
+<p>Here, the fix-it hint is suggesting that parentheses be added,
+and showing exactly where those parentheses would be inserted into the
+source code. The fix-it hints themselves describe what changes to make
+to the source code in an abstract manner, which the text diagnostic
+printer renders as a line of "insertions" below the caret line. <a
+href="#DiagnosticClient">Other diagnostic clients</a> might choose
+to render the code differently (e.g., as markup inline) or even give
+the user the ability to automatically fix the problem.</p>
+
+<p>All fix-it hints are described by the <code>FixItHint</code> class,
+instances of which should be attached to the diagnostic using the
+&lt;&lt; operator in the same way that highlighted source ranges and
+arguments are passed to the diagnostic. Fix-it hints can be created
+with one of three constructors:</p>
<dl>
- <dt><code>CodeModificationHint::CreateInsertion(Loc, Code)</code></dt>
+ <dt><code>FixItHint::CreateInsertion(Loc, Code)</code></dt>
<dd>Specifies that the given <code>Code</code> (a string) should be inserted
before the source location <code>Loc</code>.</dd>
- <dt><code>CodeModificationHint::CreateRemoval(Range)</code></dt>
+ <dt><code>FixItHint::CreateRemoval(Range)</code></dt>
<dd>Specifies that the code in the given source <code>Range</code>
should be removed.</dd>
- <dt><code>CodeModificationHint::CreateReplacement(Range, Code)</code></dt>
+ <dt><code>FixItHint::CreateReplacement(Range, Code)</code></dt>
<dd>Specifies that the code in the given source <code>Range</code>
should be removed, and replaced with the given <code>Code</code> string.</dd>
</dl>
@@ -821,7 +819,7 @@ code is vectorized on X86 and PowerPC hosts).</p>
within the filename.</li>
<li>When parsing a preprocessor directive (after "<tt>#</tt>") the
ParsingPreprocessorDirective mode is entered. This changes the parser to
- return EOM at a newline.</li>
+ return EOD at a newline.</li>
<li>The Lexer uses a LangOptions object to know whether trigraphs are enabled,
whether C++ or ObjC keywords are recognized, etc.</li>
</ul>
diff --git a/docs/LanguageExtensions.html b/docs/LanguageExtensions.html
index b0de13a91e9b..f86835a9d1df 100644
--- a/docs/LanguageExtensions.html
+++ b/docs/LanguageExtensions.html
@@ -38,6 +38,8 @@ td {
<li><a href="#cxx_deleted_functions">C++0x deleted functions</a></li>
<li><a href="#cxx_lambdas">C++0x lambdas</a></li>
<li><a href="#cxx_nullptr">C++0x nullptr</a></li>
+ <li><a href="#cxx_override_control">C++0x override control</a></li>
+ <li><a href="#cxx_range_for">C++0x range-based for loop</a></li>
<li><a href="#cxx_rvalue_references">C++0x rvalue references</a></li>
<li><a href="#cxx_reference_qualified_functions">C++0x reference-qualified functions</a></li>
<li><a href="#cxx_static_assert">C++0x <tt>static_assert()</tt></a></li>
@@ -46,14 +48,17 @@ td {
<li><a href="#cxx_inline_namespaces">C++0x inline namespaces</a></li>
<li><a href="#cxx_strong_enums">C++0x strongly-typed enumerations</a></li>
<li><a href="#cxx_trailing_return">C++0x trailing return type</a></li>
+ <li><a href="#cxx_noexcept">C++0x noexcept specification</a></li>
</ul>
<li><a href="#checking_type_traits">Checks for Type Traits</a></li>
<li><a href="#blocks">Blocks</a></li>
<li><a href="#overloading-in-c">Function Overloading in C</a></li>
+<li><a href="#generic-selections">Generic Selections</a></li>
<li><a href="#builtins">Builtin Functions</a>
<ul>
<li><a href="#__builtin_shufflevector">__builtin_shufflevector</a></li>
<li><a href="#__builtin_unreachable">__builtin_unreachable</a></li>
+ <li><a href="#__sync_swap">__sync_swap</a></li>
</ul>
</li>
<li><a href="#targetspecific">Target-Specific Extensions</a>
@@ -61,11 +66,7 @@ td {
<li><a href="#x86-specific">X86/X86-64 Language Extensions</a></li>
</ul>
</li>
-<li><a href="#analyzerspecific">Static Analysis-Specific Extensions</a>
- <ul>
- <li><a href="#analyzerattributes">Analyzer Attributes</a></li>
- </ul>
-</li>
+<li><a href="#analyzerspecific">Static Analysis-Specific Extensions</a></li>
</ul>
<!-- ======================================================================= -->
@@ -83,7 +84,7 @@ more information on these extensions.</p>
<!-- ======================================================================= -->
<p>Language extensions can be very useful, but only if you know you can depend
-on them. In order to allow fine-grain features checks, we support two builtin
+on them. In order to allow fine-grain features checks, we support three builtin
function-like macros. This allows you to directly test for a feature in your
code without having to resort to something like autoconf or fragile "compiler
version checks".</p>
@@ -402,9 +403,19 @@ lambdas is enabled. clang does not currently implement this feature.</p>
<tt>nullptr</tt> is enabled. clang does not yet fully implement this
feature.</p>
+<h3 id="cxx_override_control">C++0x <tt>override control</tt></h3>
+
+<p>Use <tt>__has_feature(cxx_override_control)</tt> to determine if support for
+the override control keywords is enabled.</p>
+
<h3 id="cxx_reference_qualified_functions">C++0x reference-qualified functions</h3>
<p>Use <tt>__has_feature(cxx_reference_qualified_functions)</tt> to determine if support for reference-qualified functions (e.g., member functions with <code>&amp;</code> or <code>&amp;&amp;</code> applied to <code>*this</code>) is enabled.</p>
+<h3 id="cxx_range_for">C++0x range-based for loop</tt></h3>
+
+<p>Use <tt>__has_feature(cxx_range_for)</tt> to determine if support for
+the range-based for loop is enabled. </p>
+
<h3 id="cxx_rvalue_references">C++0x rvalue references</tt></h3>
<p>Use <tt>__has_feature(cxx_rvalue_references)</tt> to determine if support for
@@ -436,6 +447,11 @@ inline namespaces is enabled.</p>
<p>Use <tt>__has_feature(cxx_trailing_return)</tt> to determine if support for
the alternate function declaration syntax with trailing return type is enabled.</p>
+<h3 id="cxx_noexcept">C++0x noexcept</h3>
+
+<p>Use <tt>__has_feature(cxx_noexcept)</tt> to determine if support for
+noexcept exception specifications is enabled.</p>
+
<h3 id="cxx_strong_enums">C++0x strongly typed enumerations</h3>
<p>Use <tt>__has_feature(cxx_strong_enums)</tt> to determine if support for
@@ -595,6 +611,20 @@ caveats to this use of name mangling:</p>
<!-- ======================================================================= -->
+<h2 id="generic-selections">Generic Selections</h2>
+<!-- ======================================================================= -->
+
+<p>The C1X generic selection expression is available in all languages
+supported by Clang. The syntax is the same as that given in the C1X draft
+standard.</p>
+
+<p>In C, type compatibility is decided according to the rules given in the
+appropriate standard, but in C++, which lacks the type compatibility rules
+used in C, types are considered compatible only if they are equivalent.</p>
+
+<p>Query for this feature with __has_feature(generic_selections).</p>
+
+<!-- ======================================================================= -->
<h2 id="builtins">Builtin Functions</h2>
<!-- ======================================================================= -->
@@ -703,6 +733,36 @@ no arguments and produces a void result.
<p>Query for this feature with __has_builtin(__builtin_unreachable).</p>
+<!-- ======================================================================= -->
+<h3 id="__sync_swap">__sync_swap</h3>
+<!-- ======================================================================= -->
+
+<p><tt>__sync_swap</tt> is used to atomically swap integers or pointers in
+memory.
+</p>
+
+<p><b>Syntax:</b></p>
+
+<pre>
+<i>type</i> __sync_swap(<i>type</i> *ptr, <i>type</i> value, ...)
+</pre>
+
+<p><b>Example of Use:</b></p>
+
+<pre>
+int old_value = __sync_swap(&value, new_value);
+</pre>
+
+<p><b>Description:</b></p>
+
+<p>The __sync_swap() builtin extends the existing __sync_*() family of atomic
+intrinsics to allow code to atomically swap the current value with the new
+value. More importantly, it helps developers write more efficient and correct
+code by avoiding expensive loops around __sync_bool_compare_and_swap() or
+relying on the platform specific implementation details of
+__sync_lock_test_and_set(). The __sync_swap() builtin is a full barrier.
+</p>
+
<!-- ======================================================================= -->
<h2 id="targetspecific">Target-Specific Extensions</h2>
@@ -754,11 +814,7 @@ are used by the <a
href="http://clang.llvm.org/StaticAnalysis.html">path-sensitive static analyzer
engine</a> that is part of Clang's Analysis library.</p>
-<!-- ======================================================================= -->
-<h3 id="analyzerattributes">Analyzer Attributes</h3>
-<!-- ======================================================================= -->
-
-<h4 id="attr_analyzer_noreturn"><tt>analyzer_noreturn</tt></h4>
+<h3 id="attr_analyzer_noreturn">The <tt>analyzer_noreturn</tt> attribute</h3>
<p>Clang's static analysis engine understands the standard <tt>noreturn</tt>
attribute. This attribute, which is typically affixed to a function prototype,
@@ -786,16 +842,47 @@ placed at the end of function prototypes:</p>
void foo() <b>__attribute__((analyzer_noreturn))</b>;
</pre>
-<p>Query for this feature with __has_feature(attribute_analyzer_noreturn).</p>
+<p>Query for this feature with
+<tt>__has_attribute(analyzer_noreturn)</tt>.</p>
+
+<h3 id="attr_method_family">The <tt>objc_method_family</tt> attribute</h3>
-<h4 id="attr_retain_release">Objective-C retaining behavior attributes</h4>
+<p>Many methods in Objective-C have conventional meanings determined
+by their selectors. For the purposes of static analysis, it is
+sometimes useful to be able to mark a method as having a particular
+conventional meaning despite not having the right selector, or as not
+having the conventional meaning that its selector would suggest.
+For these use cases, we provide an attribute to specifically describe
+the <q>method family</q> that a method belongs to.</p>
+
+<p><b>Usage</b>: <tt>__attribute__((objc_method_family(X)))</tt>,
+where <tt>X</tt> is one of <tt>none</tt>, <tt>alloc</tt>, <tt>copy</tt>,
+<tt>init</tt>, <tt>mutableCopy</tt>, or <tt>new</tt>. This attribute
+can only be placed at the end of a method declaration:</p>
+
+<pre>
+ - (NSString*) initMyStringValue <b>__attribute__((objc_method_family(none)))</b>;
+</pre>
+
+<p>Users who do not wish to change the conventional meaning of a
+method, and who merely want to document its non-standard retain and
+release semantics, should use the
+<a href="#attr_retain_release">retaining behavior attributes</a>
+described below.</p>
+
+<p>Query for this feature with
+<tt>__has_attribute(objc_method_family)</tt>.</p>
+
+<h3 id="attr_retain_release">Objective-C retaining behavior attributes</h3>
<p>In Objective-C, functions and methods are generally assumed to take
and return objects with +0 retain counts, with some exceptions for
special methods like <tt>+alloc</tt> and <tt>init</tt>. However,
there are exceptions, and so Clang provides attributes to allow these
exceptions to be documented, which helps the analyzer find leaks (and
-ignore non-leaks).</p>
+ignore non-leaks). Some exceptions may be better described using
+the <a href="#attr_method_family"><tt>objc_method_family</tt></a>
+attribute instead.</p>
<p><b>Usage</b>: The <tt>ns_returns_retained</tt>, <tt>ns_returns_not_retained</tt>,
<tt>ns_returns_autoreleased</tt>, <tt>cf_returns_retained</tt>,
@@ -834,6 +921,9 @@ balance in some way.</p>
- (void) baz: (id) <b>__attribute__((ns_consumed))</b> x;
</pre>
+<p>Query for these features with <tt>__has_attribute(ns_consumed)</tt>,
+<tt>__has_attribute(ns_returns_retained)</tt>, etc.</p>
+
</div>
</body>
</html>
diff --git a/docs/UsersManual.html b/docs/UsersManual.html
index 82c4fa27321e..73ca6c6980b3 100644
--- a/docs/UsersManual.html
+++ b/docs/UsersManual.html
@@ -32,7 +32,7 @@ td {
</li>
<li><a href="#general_features">Language and Target-Independent Features</a>
<ul>
- <li><a href="#diagnostics">Controlling Errors and Warnings</a></li>
+ <li><a href="#diagnostics">Controlling Errors and Warnings</a>
<ul>
<li><a href="#diagnostics_display">Controlling How Clang Displays Diagnostics</a></li>
<li><a href="#diagnostics_mappings">Diagnostic Mappings</a></li>
@@ -41,9 +41,10 @@ td {
<li><a href="#diagnostics_pragmas">Controlling Diagnostics via Pragmas</a></li>
<li><a href="#analyzer_diagnositics">Controlling Static Analyzer Diagnostics</a></li>
</ul>
+ </li>
<li><a href="#precompiledheaders">Precompiled Headers</a></li>
<li><a href="#codegen">Controlling Code Generation</a></li>
- </ul>
+ </ul>
</li>
<li><a href="#c">C Language Features</a>
<ul>
@@ -67,8 +68,8 @@ td {
<ul>
<li><a href="#target_os_darwin">Darwin (Mac OS/X)</a></li>
<li>Linux, etc.</li>
+ <li><a href="#target_os_win32">Windows</a></li>
</ul>
-
</li>
</ul>
</li>
@@ -205,7 +206,7 @@ diagnostics that it generates.</p>
diagnostic.</dt>
<dd>This option, which defaults to on, controls whether or not Clang prints the
column number of a diagnostic. For example, when this is enabled, Clang will
-print something like:</p>
+print something like:
<pre>
test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
@@ -223,7 +224,7 @@ column number.</p>
source file/line/column information in diagnostic.</dt>
<dd>This option, which defaults to on, controls whether or not Clang prints the
filename, line number and column number of a diagnostic. For example,
-when this is enabled, Clang will print something like:</p>
+when this is enabled, Clang will print something like:
<pre>
test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
@@ -240,7 +241,7 @@ when this is enabled, Clang will print something like:</p>
line and ranges from source code in diagnostic.</dt>
<dd>This option, which defaults to on, controls whether or not Clang prints the
source line, source ranges, and caret when emitting a diagnostic. For example,
-when this is enabled, Clang will print something like:</p>
+when this is enabled, Clang will print something like:
<pre>
test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
@@ -277,7 +278,7 @@ Enable <tt>[-Woption]</tt> information in diagnostic line.</dt>
<dd>This option, which defaults to on,
controls whether or not Clang prints the associated <A
href="#cl_diag_warning_groups">warning group</a> option name when outputting
-a warning diagnostic. For example, in this output:</p>
+a warning diagnostic. For example, in this output:
<pre>
test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
@@ -299,7 +300,7 @@ Enable printing category information in diagnostic line.</dt>
controls whether or not Clang prints the category associated with a diagnostic
when emitting it. Each diagnostic may or many not have an associated category,
if it has one, it is listed in the diagnostic categorization field of the
-diagnostic line (in the []'s).</p>
+diagnostic line (in the []'s).
<p>For example, a format string warning will produce these three renditions
based on the setting of this option:</p>
@@ -322,7 +323,7 @@ hundreds or thousands of them.</p>
Enable "FixIt" information in the diagnostics output.</dt>
<dd>This option, which defaults to on, controls whether or not Clang prints the
information on how to fix a specific diagnostic underneath it when it knows.
-For example, in this output:</p>
+For example, in this output:
<pre>
test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
@@ -345,7 +346,7 @@ Print machine parsable information about source ranges.</dt>
information about source ranges in a machine parsable format after the
file/line/column number information. The information is a simple sequence of
brace enclosed ranges, where each range lists the start and end line/column
-locations. For example, in this output:</p>
+locations. For example, in this output:
<pre>
exprs.c:47:15:{47:8-47:14}{47:17-47:24}: error: invalid operands to binary expression ('int *' and '_Complex float')
@@ -366,7 +367,14 @@ Print Fix-Its in a machine parseable form.</dt>
fix-it:"t.cpp":{7:25-7:29}:"Gamma"
</pre>
-<p>The range printed is a half-open range, so in this example the characters at column 25 up to but not including column 29 on line 7 in t.cpp should be replaced with the string "Gamma". Either the range or the replacement string may be empty (representing strict insertions and strict erasures, respectively). Both the file name and the insertion string escape backslash (as "\\"), tabs (as "\t"), newlines (as "\n"), double quotes(as "\"") and non-printable characters (as octal "\xxx").</p>
+<p>The range printed is a half-open range, so in this example the characters at
+column 25 up to but not including column 29 on line 7 in t.cpp should be
+replaced with the string &quot;Gamma&quot;. Either the range or the replacement
+string may be empty (representing strict insertions and strict erasures,
+respectively). Both the file name and the insertion string escape backslash (as
+&quot;\\&quot;), tabs (as &quot;\t&quot;), newlines (as &quot;\n&quot;), double
+quotes(as &quot;\&quot;&quot;) and non-printable characters (as octal
+&quot;\xxx&quot;).</p>
</dd>
</dl>
@@ -388,7 +396,7 @@ Print Fix-Its in a machine parseable form.</dt>
<dt id="opt_Wextra-tokens"><b>-Wextra-tokens</b>: Warn about excess tokens at
the end of a preprocessor directive.</dt>
<dd>This option, which defaults to on, enables warnings about extra tokens at
-the end of preprocessor directives. For example:</p>
+the end of preprocessor directives. For example:
<pre>
test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
@@ -408,7 +416,7 @@ by commenting them out.</p>
Warn about unqualified uses of a member template whose name resolves
to another template at the location of the use.</dt>
<dd>This option, which defaults to on, enables a warning in the
-following code:</p>
+following code:
<pre>
template&lt;typename T> struct set{};
@@ -432,7 +440,7 @@ an extension.</p>
an unusable copy constructor when binding a reference to a temporary.</dt>
<dd>This option, which defaults to on, enables warnings about binding a
reference to a temporary when the temporary doesn't have a usable copy
-constructor. For example:</p>
+constructor. For example:
<pre>
struct NonCopyable {
@@ -484,7 +492,6 @@ and gives you fine-grain control over which information is printed. Clang has
the ability to print this information, and these are the options that control
it:</p>
-<p>
<ol>
<li>A file/line/column indicator that shows exactly where the diagnostic occurs
in your code [<a href="#opt_fshow-column">-fshow-column</a>, <a
@@ -508,7 +515,7 @@ it:</p>
<li>A machine-parsable representation of the ranges involved (off by
default) [<a
href="opt_fdiagnostics-print-source-range-info">-fdiagnostics-print-source-range-info</a>].</li>
-</ol></p>
+</ol>
<p>For more information please see <a href="#cl_diag_formatting">Formatting of
Diagnostics</a>.</p>
@@ -518,14 +525,13 @@ Diagnostics</a>.</p>
<p>All diagnostics are mapped into one of these 5 classes:</p>
-<p>
<ul>
<li>Ignored</li>
<li>Note</li>
<li>Warning</li>
<li>Error</li>
<li>Fatal</li>
-</ul></p>
+</ul>
<h4 id="diagnostics_categories">Diagnostic Categories</h4>
@@ -735,6 +741,7 @@ likely to affect PCH files that reference a large number of headers.</p>
<p>Clang provides a number of ways to control code generation. The options are listed below.</p>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+<dl>
<dt id="opt_fcatch-undefined-behavior"><b>-fcatch-undefined-behavior</b>: Turn
on runtime code generation to check for undefined behavior.</dt>
@@ -742,7 +749,7 @@ on runtime code generation to check for undefined behavior.</dt>
adds runtime checks for undefined runtime behavior. If a check fails,
<tt>__builtin_trap()</tt> is used to indicate failure.
The checks are:
-<p>
+<ul>
<li>Subscripting where the static type of one operand is a variable
which is decayed from an array type and the other operand is
greater than the size of the array or less than zero.</li>
@@ -752,7 +759,7 @@ The checks are:
<li>When llvm implements more __builtin_object_size support, reads and
writes for objects that __builtin_object_size indicates we aren't
accessing valid memory. Bit-fields and vectors are not yet checked.
-</p>
+</ul>
</dd>
<dt id="opt_fno-assume-sane-operator-new"><b>-fno-assume-sane-operator-new</b>:
@@ -761,6 +768,19 @@ Don't assume that the C++'s new operator is sane.</dt>
operator will always return a pointer that does not
alias any other pointer when the function returns.</dd>
+<dt id="opt_ftrap-function"><b>-ftrap-function=[name]</b>: Instruct code
+generator to emit a function call to the specified function name for
+<tt>__builtin_trap()</tt>.</dt>
+
+<dd>LLVM code generator translates <tt>__builtin_trap()</tt> to a trap
+instruction if it is supported by the target ISA. Otherwise, the builtin is
+translated into a call to <tt>abort</tt>. If this option is set, then the code
+generator will always lower the builtin to a call to the specified function
+regardless of whether the target ISA has a trap instruction. This option is
+useful for environments (e.g. deeply embedded) where a trap cannot be properly
+handled, or when some custom behavior is desired.</dd>
+</dl>
+
<!-- ======================================================================= -->
<h2 id="c">C Language Features</h2>
<!-- ======================================================================= -->
@@ -917,6 +937,7 @@ support is incomplete; enabling Microsoft extensions will silently drop
certain constructs (including __declspec and Microsoft-style asm statements).
</p>
+<ul>
<li>clang allows setting _MSC_VER with -fmsc-version=. It defaults to 1300 which
is the same as Visual C/C++ 2003. Any number is supported and can greatly affect
what Windows SDK and c++stdlib headers clang can compile. This option will be
@@ -930,6 +951,7 @@ record members can be declared using user defined typedefs.</li>
controlling record layout. GCC also contains support for this feature,
however where MSVC and GCC are incompatible clang follows the MSVC
definition.</li>
+</ul>
<!-- ======================================================================= -->
<h2 id="target_features">Target-Specific Features and Limitations</h2>
@@ -948,6 +970,10 @@ definition.</li>
(Mac OS/X), Linux, FreeBSD, and Dragonfly BSD: it has been tested to correctly
compile many large C, C++, Objective-C, and Objective-C++ codebases.</p>
+<p>On x86_64-mingw32, passing i128(by value) is incompatible to Microsoft x64
+calling conversion. You might need to tweak WinX86_64ABIInfo::classify()
+in lib/CodeGen/TargetInfo.cpp.</p>
+
<!-- ======================== -->
<h4 id="target_arch_arm">ARM</h4>
<!-- ======================== -->
@@ -985,6 +1011,44 @@ Generating assembly requires a suitable LLVM backend.
<p>No __thread support, 64-bit ObjC support requires SL tools.</p>
+<!-- ======================================= -->
+<h4 id="target_os_win32">Windows</h4>
+<!-- ======================================= -->
+
+<p>Experimental supports are on Cygming.</p>
+
+<h5>Cygwin</h5>
+
+<p>Clang works on Cygwin-1.7.</p>
+
+<h5>MinGW32</h5>
+
+<p>Clang works on some mingw32 distributions.
+Clang assumes directories as below;</p>
+
+<ul>
+<li><tt>C:/mingw/include</tt></li>
+<li><tt>C:/mingw/lib</tt></li>
+<li><tt>C:/mingw/lib/gcc/mingw32/4.[3-5].0/include/c++</tt></li>
+</ul>
+
+<p>On MSYS, a few tests might fail. It is due to <a href="http://llvm.org/bugs/show_bug.cgi?id=8520">Bug 8520</a> and is fixed in <a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110314/118106.html">LLVM's r127724</a>.</p>
+
+<h5>MinGW-w64</h5>
+
+<p>For x32(i686-w64-mingw32), it is not supported yet.</p>
+
+<p>For x64(x86_64-w64-mingw32), <a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110321/118499.html">an essential patch(LLVM's r128206)</a> would be needed. It is incompatible to <a href="http://tdm-gcc.tdragon.net/development">TDM-GCC</a> due to the definition of symbol &quot;<code>___chkstk</code>&quot;. Clang assumes as below;<p>
+
+<ul>
+<li><tt>C:/mingw/x86_64-w64-mingw32/include</tt></li>
+<li><tt>C:/mingw/x86_64-w64-mingw32/include/c++/4.5.[23]</tt></li>
+<li>GCC driver &quot;gcc.exe&quot; to build x86_64-w64-mingw32 binary.</li>
+</ul>
+
+<p><a href="http://llvm.org/bugs/show_bug.cgi?id=8833">Some tests might fail</a>
+on x64.</p>
+
</div>
</body>
</html>
diff --git a/docs/tools/clang.pod b/docs/tools/clang.pod
index 9f7a4483019e..704cc8743ba6 100644
--- a/docs/tools/clang.pod
+++ b/docs/tools/clang.pod
@@ -7,7 +7,7 @@ clang - the Clang C, C++, and Objective-C compiler
=head1 SYNOPSIS
B<clang> [B<-c>|B<-S>|B<-E>] B<-std=>I<standard> B<-g>
- [B<-O0>|B<-O1>|B<-O2>|B<-Os>|B<-O3>|B<-O4>]
+ [B<-O0>|B<-O1>|B<-O2>|B<-Os>|B<-Oz>|B<-O3>|B<-O4>]
B<-W>I<warnings...> B<-pedantic>
B<-I>I<dir...> B<-L>I<dir...>
B<-D>I<macro[=defn]>
@@ -53,7 +53,7 @@ parse errors. The output of this stage is an "Abstract Syntax Tree" (AST).
This stage translates an AST into low-level intermediate code (known as "LLVM
IR") and ultimately to machine code. This phase is responsible for optimizing
-the generated code and handling target-specfic code generation. The output of
+the generated code and handling target-specific code generation. The output of
this stage is typically called a ".s" file or "assembly" file.
Clang also supports the use of an integrated assembler, in which the code
@@ -263,12 +263,13 @@ may not exist on earlier ones.
=over
-=item B<-O0> B<-O1> B<-O2> B<-Os> B<-O3> B<-O4>
+=item B<-O0> B<-O1> B<-O2> B<-Os> B<-Oz> B<-O3> B<-O4>
Specify which optimization level to use. B<-O0> means "no optimization": this
level compiles the fastest and generates the most debuggable code. B<-O2> is a
moderate level of optimization which enables most optimizations. B<-Os> is like
-B<-O2> with extra optimizations to reduce code size. B<-O3> is like B<-O2>,
+B<-O2> with extra optimizations to reduce code size. B<-Oz> is like B<-Os>
+(and thus B<-O2>), but reduces code size further. B<-O3> is like B<-O2>,
except that it enables optimizations that take longer to perform or that may
generate larger code (in an attempt to make the program run faster). On
supported platforms, B<-O4> enables link-time optimization; object files are
@@ -356,18 +357,10 @@ Pass I<arg> to the static analyzer.
Pass I<arg> to the assembler.
-=item B<-Xclang> I<arg>
-
-Pass I<arg> to the clang compiler frontend.
-
=item B<-Xlinker> I<arg>
Pass I<arg> to the linker.
-=item B<-mllvm> I<arg>
-
-Pass I<arg> to the LLVM backend.
-
=item B<-Xpreprocessor> I<arg>
Pass I<arg> to the preprocessor.
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 9a32ee406523..8e16ef1c6cfb 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,3 +1,3 @@
add_subdirectory(clang-interpreter)
add_subdirectory(PrintFunctionNames)
-
+add_subdirectory(Tooling)
diff --git a/examples/Tooling/CMakeLists.txt b/examples/Tooling/CMakeLists.txt
new file mode 100644
index 000000000000..257d3ea8eaa3
--- /dev/null
+++ b/examples/Tooling/CMakeLists.txt
@@ -0,0 +1,6 @@
+set(LLVM_USED_LIBS clangTooling clangBasic)
+
+add_clang_executable(clang-check
+ ClangCheck.cpp
+ )
+
diff --git a/examples/Tooling/ClangCheck.cpp b/examples/Tooling/ClangCheck.cpp
new file mode 100644
index 000000000000..41283759a104
--- /dev/null
+++ b/examples/Tooling/ClangCheck.cpp
@@ -0,0 +1,108 @@
+//===- examples/Tooling/ClangCheck.cpp - Clang check tool -----------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements a clang-check tool that runs the
+// clang::SyntaxOnlyAction over a number of translation units.
+//
+// Usage:
+// clang-check <cmake-output-dir> <file1> <file2> ...
+//
+// Where <cmake-output-dir> is a CMake build directory in which a file named
+// compile_commands.json exists (enable -DCMAKE_EXPORT_COMPILE_COMMANDS in
+// CMake to get this output).
+//
+// <file1> ... specify the paths of files in the CMake source tree. This path
+// is looked up in the compile command database. If the path of a file is
+// absolute, it needs to point into CMake's source tree. If the path is
+// relative, the current working directory needs to be in the CMake source
+// tree and the file must be in a subdirectory of the current working
+// directory. "./" prefixes in the relative files will be automatically
+// removed, but the rest of a relative path must be a suffix of a path in
+// the compile command line database.
+//
+// For example, to use clang-check on all files in a subtree of the source
+// tree, use:
+//
+// /path/in/subtree $ find . -name '*.cpp'| xargs clang-check /path/to/source
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/system_error.h"
+
+/// \brief Returns the absolute path of 'File', by prepending it with
+/// 'BaseDirectory' if 'File' is not absolute. Otherwise returns 'File'.
+/// If 'File' starts with "./", the returned path will not contain the "./".
+/// Otherwise, the returned path will contain the literal path-concatenation of
+/// 'BaseDirectory' and 'File'.
+///
+/// \param File Either an absolute or relative path.
+/// \param BaseDirectory An absolute path.
+///
+/// FIXME: Put this somewhere where it is more generally available.
+static std::string GetAbsolutePath(
+ llvm::StringRef File, llvm::StringRef BaseDirectory) {
+ assert(llvm::sys::path::is_absolute(BaseDirectory));
+ if (llvm::sys::path::is_absolute(File)) {
+ return File;
+ }
+ llvm::StringRef RelativePath(File);
+ if (RelativePath.startswith("./")) {
+ RelativePath = RelativePath.substr(strlen("./"));
+ }
+ llvm::SmallString<1024> AbsolutePath(BaseDirectory);
+ llvm::sys::path::append(AbsolutePath, RelativePath);
+ return AbsolutePath.str();
+}
+
+int main(int argc, char **argv) {
+ if (argc < 3) {
+ llvm::outs() << "Usage: " << argv[0] << " <cmake-output-dir> "
+ << "<file1> <file2> ...\n";
+ return 1;
+ }
+ // FIXME: We should pull how to find the database into the Tooling package.
+ llvm::OwningPtr<llvm::MemoryBuffer> JsonDatabase;
+ llvm::SmallString<1024> JsonDatabasePath(argv[1]);
+ llvm::sys::path::append(JsonDatabasePath, "compile_commands.json");
+ llvm::error_code Result =
+ llvm::MemoryBuffer::getFile(JsonDatabasePath, JsonDatabase);
+ if (Result != 0) {
+ llvm::outs() << "Error while opening JSON database: " << Result.message()
+ << "\n";
+ return 1;
+ }
+ llvm::StringRef BaseDirectory(::getenv("PWD"));
+ for (int I = 2; I < argc; ++I) {
+ llvm::SmallString<1024> File(GetAbsolutePath(argv[I], BaseDirectory));
+ llvm::outs() << "Processing " << File << ".\n";
+ std::string ErrorMessage;
+ clang::tooling::CompileCommand LookupResult =
+ clang::tooling::FindCompileArgsInJsonDatabase(
+ File.str(), JsonDatabase->getBuffer(), ErrorMessage);
+ if (!LookupResult.CommandLine.empty()) {
+ if (!clang::tooling::RunToolWithFlags(
+ new clang::SyntaxOnlyAction,
+ LookupResult.CommandLine.size(),
+ clang::tooling::CommandLineToArgv(
+ &LookupResult.CommandLine).data())) {
+ llvm::outs() << "Error while processing " << File << ".\n";
+ }
+ } else {
+ llvm::outs() << "Skipping " << File << ". Command line not found.\n";
+ }
+ }
+ return 0;
+}
diff --git a/examples/Tooling/Makefile b/examples/Tooling/Makefile
new file mode 100644
index 000000000000..66e86a03f1c6
--- /dev/null
+++ b/examples/Tooling/Makefile
@@ -0,0 +1,24 @@
+##===- examples/Tooling/Makefile ---------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+CLANG_LEVEL := ../..
+
+TOOLNAME = clang-check
+NO_INSTALL = 1
+
+# No plugins, optimize startup time.
+TOOL_NO_EXPORTS = 1
+
+LINK_COMPONENTS := support mc
+USEDLIBS = clangFrontend.a clangSerialization.a clangDriver.a \
+ clangTooling.a clangSema.a clangAnalysis.a \
+ clangAST.a clangParse.a clangLex.a clangBasic.a
+
+include $(CLANG_LEVEL)/Makefile
+
diff --git a/examples/clang-interpreter/Makefile b/examples/clang-interpreter/Makefile
index 6e762da708d2..3f020037e16f 100644
--- a/examples/clang-interpreter/Makefile
+++ b/examples/clang-interpreter/Makefile
@@ -16,7 +16,7 @@ NO_INSTALL = 1
TOOL_NO_EXPORTS = 1
LINK_COMPONENTS := jit interpreter nativecodegen bitreader bitwriter ipo \
- selectiondag asmparser
+ selectiondag asmparser instrumentation
USEDLIBS = clangFrontend.a clangSerialization.a clangDriver.a clangCodeGen.a \
clangSema.a clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a clangStaticAnalyzerCore.a clangAnalysis.a clangRewrite.a \
clangAST.a clangParse.a clangLex.a clangBasic.a
diff --git a/examples/clang-interpreter/main.cpp b/examples/clang-interpreter/main.cpp
index a99766f9a314..ad39ecec9bd3 100644
--- a/examples/clang-interpreter/main.cpp
+++ b/examples/clang-interpreter/main.cpp
@@ -85,8 +85,7 @@ int main(int argc, const char **argv, char * const *envp) {
// (basically, exactly one input, and the operation mode is hard wired).
llvm::SmallVector<const char *, 16> Args(argv, argv + argc);
Args.push_back("-fsyntax-only");
- llvm::OwningPtr<Compilation> C(TheDriver.BuildCompilation(Args.size(),
- Args.data()));
+ llvm::OwningPtr<Compilation> C(TheDriver.BuildCompilation(Args));
if (!C)
return 0;
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 722f6be538b4..d89a903e4112 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -1012,7 +1012,68 @@ CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
unsigned num_unsaved_files,
struct CXUnsavedFile *unsaved_files,
unsigned options);
-
+
+/**
+ * \brief Categorizes how memory is being used by a translation unit.
+ */
+enum CXTUResourceUsageKind {
+ CXTUResourceUsage_AST = 1,
+ CXTUResourceUsage_Identifiers = 2,
+ CXTUResourceUsage_Selectors = 3,
+ CXTUResourceUsage_GlobalCompletionResults = 4,
+ CXTUResourceUsage_SourceManagerContentCache = 5,
+ CXTUResourceUsage_AST_SideTables = 6,
+ CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
+ CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
+ CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
+ CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
+ CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
+ CXTUResourceUsage_MEMORY_IN_BYTES_END =
+ CXTUResourceUsage_ExternalASTSource_Membuffer_MMap,
+
+ CXTUResourceUsage_First = CXTUResourceUsage_AST,
+ CXTUResourceUsage_Last = CXTUResourceUsage_ExternalASTSource_Membuffer_MMap
+};
+
+/**
+ * \brief Returns the human-readable null-terminated C string that represents
+ * the name of the memory category. This string should never be freed.
+ */
+CINDEX_LINKAGE
+const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
+
+typedef struct CXTUResourceUsageEntry {
+ /* \brief The memory usage category. */
+ enum CXTUResourceUsageKind kind;
+ /* \brief Amount of resources used.
+ The units will depend on the resource kind. */
+ unsigned long amount;
+} CXTUResourceUsageEntry;
+
+/**
+ * \brief The memory usage of a CXTranslationUnit, broken into categories.
+ */
+typedef struct CXTUResourceUsage {
+ /* \brief Private data member, used for queries. */
+ void *data;
+
+ /* \brief The number of entries in the 'entries' array. */
+ unsigned numEntries;
+
+ /* \brief An array of key-value pairs, representing the breakdown of memory
+ usage. */
+ CXTUResourceUsageEntry *entries;
+
+} CXTUResourceUsage;
+
+/**
+ * \brief Return the memory usage of a translation unit. This object
+ * should be released with clang_disposeCXTUResourceUsage().
+ */
+CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
+
+CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
+
/**
* @}
*/
@@ -1101,10 +1162,12 @@ enum CXCursorKind {
CXCursor_NamespaceAlias = 33,
/** \brief A C++ using directive. */
CXCursor_UsingDirective = 34,
- /** \brief A using declaration. */
+ /** \brief A C++ using declaration. */
CXCursor_UsingDeclaration = 35,
+ /** \brief A C++ alias declaration */
+ CXCursor_TypeAliasDecl = 36,
CXCursor_FirstDecl = CXCursor_UnexposedDecl,
- CXCursor_LastDecl = CXCursor_UsingDeclaration,
+ CXCursor_LastDecl = CXCursor_TypeAliasDecl,
/* References */
CXCursor_FirstRef = 40, /* Decl references */
@@ -2871,6 +2934,15 @@ CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
*/
CINDEX_LINKAGE CXString clang_getClangVersion();
+
+/**
+ * \brief Enable/disable crash recovery.
+ *
+ * \param Flag to indicate if crash recovery is enabled. A non-zero value
+ * enables crash recovery, while 0 disables it.
+ */
+CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
+
/**
* \brief Visitor invoked for each file in a translation unit
* (used with clang_getInclusions()).
diff --git a/include/clang/AST/ASTConsumer.h b/include/clang/AST/ASTConsumer.h
index 08ee4ef40de0..fcc91768dac3 100644
--- a/include/clang/AST/ASTConsumer.h
+++ b/include/clang/AST/ASTConsumer.h
@@ -89,7 +89,7 @@ public:
/// \brief If the consumer is interested in entities getting modified after
/// their initial creation, it should return a pointer to
- /// a GetASTMutationListener here.
+ /// an ASTMutationListener here.
virtual ASTMutationListener *GetASTMutationListener() { return 0; }
/// \brief If the consumer is interested in entities being deserialized from
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index c0eeb5af3892..28ec8cf88d52 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -14,10 +14,12 @@
#ifndef LLVM_CLANG_AST_ASTCONTEXT_H
#define LLVM_CLANG_AST_ASTCONTEXT_H
+#include "clang/Basic/AddressSpaces.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/OperatorKinds.h"
#include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Basic/VersionTuple.h"
#include "clang/AST/Decl.h"
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/PrettyPrinter.h"
@@ -27,6 +29,7 @@
#include "clang/AST/UsuallyTinyPtrVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/Allocator.h"
@@ -68,7 +71,7 @@ namespace clang {
class TemplateTypeParmDecl;
class TranslationUnitDecl;
class TypeDecl;
- class TypedefDecl;
+ class TypedefNameDecl;
class UsingDecl;
class UsingShadowDecl;
class UnresolvedSetIterator;
@@ -77,7 +80,7 @@ namespace clang {
/// ASTContext - This class holds long-lived AST nodes (such as types and
/// decls) that can be referred to throughout the semantic analysis of a file.
-class ASTContext {
+class ASTContext : public llvm::RefCountedBase<ASTContext> {
ASTContext &this_() { return *this; }
mutable std::vector<Type*> Types;
@@ -96,7 +99,8 @@ class ASTContext {
DependentSizedExtVectorTypes;
mutable llvm::FoldingSet<VectorType> VectorTypes;
mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes;
- mutable llvm::FoldingSet<FunctionProtoType> FunctionProtoTypes;
+ mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&>
+ FunctionProtoTypes;
mutable llvm::FoldingSet<DependentTypeOfExprType> DependentTypeOfExprTypes;
mutable llvm::FoldingSet<DependentDecltypeType> DependentDecltypeTypes;
mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes;
@@ -310,6 +314,9 @@ class ASTContext {
llvm::OwningPtr<CXXABI> ABI;
CXXABI *createCXXABI(const TargetInfo &T);
+ /// \brief The logical -> physical address space map.
+ const LangAS::Map &AddrSpaceMap;
+
friend class ASTDeclReader;
public:
@@ -335,6 +342,14 @@ public:
}
void Deallocate(void *Ptr) const { }
+ /// Return the total amount of physical memory allocated for representing
+ /// AST nodes and type information.
+ size_t getASTAllocatedMemory() const {
+ return BumpAlloc.getTotalMemory();
+ }
+ /// Return the total memory used for various side tables.
+ size_t getSideTableAllocatedMemory() const;
+
PartialDiagnostic::StorageAllocator &getDiagAllocator() {
return DiagAllocator;
}
@@ -381,6 +396,16 @@ public:
FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field);
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl);
+
+ /// ZeroBitfieldFollowsNonBitfield - return 'true" if 'FD' is a zero-length
+ /// bitfield which follows the non-bitfield 'LastFD'.
+ bool ZeroBitfieldFollowsNonBitfield(const FieldDecl *FD,
+ const FieldDecl *LastFD) const;
+
+ /// ZeroBitfieldFollowsBitfield - return 'true" if 'FD' is a zero-length
+ /// bitfield which follows the bitfield 'LastFD'.
+ bool ZeroBitfieldFollowsBitfield(const FieldDecl *FD,
+ const FieldDecl *LastFD) const;
// Access to the set of methods overridden by the given C++ method.
typedef CXXMethodVector::iterator overridden_cxx_method_iterator;
@@ -413,10 +438,13 @@ public:
CanQualType FloatTy, DoubleTy, LongDoubleTy;
CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
CanQualType VoidPtrTy, NullPtrTy;
- CanQualType OverloadTy;
- CanQualType DependentTy;
+ CanQualType DependentTy, OverloadTy, BoundMemberTy, UnknownAnyTy;
CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy, ObjCBuiltinSelTy;
+ // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
+ mutable QualType AutoDeductTy; // Deduction against 'auto'.
+ mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
+
ASTContext(const LangOptions& LOpts, SourceManager &SM, const TargetInfo &t,
IdentifierTable &idents, SelectorTable &sels,
Builtin::Context &builtins,
@@ -654,9 +682,9 @@ public:
}
/// getTypedefType - Return the unique reference to the type for the
- /// specified typename decl.
- QualType getTypedefType(const TypedefDecl *Decl, QualType Canon = QualType())
- const;
+ /// specified typedef-name decl.
+ QualType getTypedefType(const TypedefNameDecl *Decl,
+ QualType Canon = QualType()) const;
QualType getRecordType(const RecordDecl *Decl) const;
@@ -676,7 +704,7 @@ public:
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index,
bool ParameterPack,
- IdentifierInfo *Name = 0) const;
+ TemplateTypeParmDecl *ParmDecl = 0) const;
QualType getTemplateSpecializationType(TemplateName T,
const TemplateArgument *Args,
@@ -739,6 +767,12 @@ public:
/// getAutoType - C++0x deduced auto type.
QualType getAutoType(QualType DeducedType) const;
+ /// getAutoDeductType - C++0x deduction pattern for 'auto' type.
+ QualType getAutoDeductType() const;
+
+ /// getAutoRRefDeductType - C++0x deduction pattern for 'auto &&' type.
+ QualType getAutoRRefDeductType() const;
+
/// getTagDeclType - Return the unique reference to the type for the
/// specified TagDecl (struct/union/class/enum) decl.
QualType getTagDeclType(const TagDecl *Decl) const;
@@ -1294,6 +1328,21 @@ public:
QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize,
QualType typeDomain) const;
+ unsigned getTargetAddressSpace(QualType T) const {
+ return getTargetAddressSpace(T.getQualifiers());
+ }
+
+ unsigned getTargetAddressSpace(Qualifiers Q) const {
+ return getTargetAddressSpace(Q.getAddressSpace());
+ }
+
+ unsigned getTargetAddressSpace(unsigned AS) const {
+ if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count)
+ return AS;
+ else
+ return AddrSpaceMap[AS - LangAS::Offset];
+ }
+
private:
// Helper for integer ordering
unsigned getIntegerRank(const Type *T) const;
@@ -1332,7 +1381,8 @@ public:
const ObjCObjectType *RHS);
bool canAssignObjCInterfacesInBlockPointer(
const ObjCObjectPointerType *LHSOPT,
- const ObjCObjectPointerType *RHSOPT);
+ const ObjCObjectPointerType *RHSOPT,
+ bool BlockReturnType);
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS);
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT,
const ObjCObjectPointerType *RHSOPT);
@@ -1340,7 +1390,7 @@ public:
// Functions for calculating composite types
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false,
- bool Unqualified = false);
+ bool Unqualified = false, bool BlockReturnType = false);
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false,
bool Unqualified = false);
QualType mergeFunctionArgumentTypes(QualType, QualType,
@@ -1528,13 +1578,13 @@ private:
};
/// @brief Utility function for constructing a nullary selector.
-static inline Selector GetNullarySelector(const char* name, ASTContext& Ctx) {
+static inline Selector GetNullarySelector(llvm::StringRef name, ASTContext& Ctx) {
IdentifierInfo* II = &Ctx.Idents.get(name);
return Ctx.Selectors.getSelector(0, &II);
}
/// @brief Utility function for constructing an unary selector.
-static inline Selector GetUnarySelector(const char* name, ASTContext& Ctx) {
+static inline Selector GetUnarySelector(llvm::StringRef name, ASTContext& Ctx) {
IdentifierInfo* II = &Ctx.Idents.get(name);
return Ctx.Selectors.getSelector(1, &II);
}
diff --git a/include/clang/AST/ASTDiagnostic.h b/include/clang/AST/ASTDiagnostic.h
index 1ab53b3e9148..1cb803a3396a 100644
--- a/include/clang/AST/ASTDiagnostic.h
+++ b/include/clang/AST/ASTDiagnostic.h
@@ -15,7 +15,8 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
+ SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM,
#define ASTSTART
#include "clang/Basic/DiagnosticASTKinds.inc"
#undef DIAG
diff --git a/include/clang/AST/ASTMutationListener.h b/include/clang/AST/ASTMutationListener.h
index 01e618024913..470cca8ee76e 100644
--- a/include/clang/AST/ASTMutationListener.h
+++ b/include/clang/AST/ASTMutationListener.h
@@ -20,6 +20,8 @@ namespace clang {
class CXXRecordDecl;
class ClassTemplateDecl;
class ClassTemplateSpecializationDecl;
+ class FunctionDecl;
+ class FunctionTemplateDecl;
/// \brief An abstract interface that should be implemented by listeners
/// that want to be notified when an AST entity gets modified after its
@@ -41,6 +43,17 @@ public:
/// template declaration.
virtual void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD,
const ClassTemplateSpecializationDecl *D) {}
+
+ /// \brief A template specialization (or partial one) was added to the
+ /// template declaration.
+ virtual void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
+ const FunctionDecl *D) {}
+
+ /// \brief An implicit member got a definition.
+ virtual void CompletedImplicitDefinition(const FunctionDecl *D) {}
+
+ /// \brief A static data member was implicitly instantiated.
+ virtual void StaticDataMemberInstantiated(const VarDecl *D) {}
};
} // end namespace clang
diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h
index 67968fde2d6b..719023926bae 100644
--- a/include/clang/AST/Attr.h
+++ b/include/clang/AST/Attr.h
@@ -17,9 +17,11 @@
#include "llvm/Support/Casting.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
#include "clang/Basic/AttrKinds.h"
#include "clang/AST/Type.h"
#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/VersionTuple.h"
#include <cassert>
#include <cstring>
#include <algorithm>
@@ -120,6 +122,19 @@ public:
static bool classof(const InheritableAttr *) { return true; }
};
+class InheritableParamAttr : public InheritableAttr {
+protected:
+ InheritableParamAttr(attr::Kind AK, SourceLocation L)
+ : InheritableAttr(AK, L) {}
+
+public:
+ // Implement isa/cast/dyncast/etc.
+ static bool classof(const Attr *A) {
+ return A->getKind() <= attr::LAST_INHERITABLE_PARAM;
+ }
+ static bool classof(const InheritableParamAttr *) { return true; }
+};
+
#include "clang/AST/Attrs.inc"
/// AttrVec - A vector of Attr, which is how they are stored on the AST.
diff --git a/include/clang/AST/CXXInheritance.h b/include/clang/AST/CXXInheritance.h
index 2d30cb3b8b62..d712e7d0c751 100644
--- a/include/clang/AST/CXXInheritance.h
+++ b/include/clang/AST/CXXInheritance.h
@@ -87,7 +87,7 @@ public:
/// BasePaths - Represents the set of paths from a derived class to
/// one of its (direct or indirect) bases. For example, given the
-/// following class hierachy:
+/// following class hierarchy:
///
/// @code
/// class A { };
diff --git a/include/clang/AST/CanonicalType.h b/include/clang/AST/CanonicalType.h
index 4d7fcfd1d121..b3550f877323 100644
--- a/include/clang/AST/CanonicalType.h
+++ b/include/clang/AST/CanonicalType.h
@@ -655,7 +655,8 @@ struct CanProxyAdaptor<TemplateTypeParmType>
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getDepth)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndex)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isParameterPack)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(IdentifierInfo *, getName)
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(TemplateTypeParmDecl *, getDecl)
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(IdentifierInfo *, getIdentifier)
};
template<>
diff --git a/include/clang/AST/CharUnits.h b/include/clang/AST/CharUnits.h
index cf909e88220f..d7cbd08e6c2e 100644
--- a/include/clang/AST/CharUnits.h
+++ b/include/clang/AST/CharUnits.h
@@ -34,7 +34,7 @@ namespace clang {
/// architectures where the two are the same size.
///
/// For portability, never assume that a target character is 8 bits wide. Use
- /// CharUnit values whereever you calculate sizes, offsets, or alignments
+ /// CharUnit values wherever you calculate sizes, offsets, or alignments
/// in character units.
class CharUnits {
public:
@@ -70,10 +70,24 @@ namespace clang {
Quantity += Other.Quantity;
return *this;
}
+ CharUnits& operator++ () {
+ ++Quantity;
+ return *this;
+ }
+ CharUnits operator++ (int) {
+ return CharUnits(Quantity++);
+ }
CharUnits& operator-= (const CharUnits &Other) {
Quantity -= Other.Quantity;
return *this;
}
+ CharUnits& operator-- () {
+ --Quantity;
+ return *this;
+ }
+ CharUnits operator-- (int) {
+ return CharUnits(Quantity--);
+ }
// Comparison operators.
bool operator== (const CharUnits &Other) const {
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 31cee24df993..ef4920520391 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -20,6 +20,7 @@
#include "clang/AST/DeclarationName.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/Basic/Linkage.h"
+#include "llvm/ADT/Optional.h"
namespace clang {
class CXXTemporary;
@@ -119,14 +120,6 @@ public:
return getIdentifier() ? getIdentifier()->getName() : "";
}
- llvm::StringRef getMessageUnavailableAttr(bool unavailable) const {
- if (!unavailable)
- return "";
- if (const UnavailableAttr *UA = getAttr<UnavailableAttr>())
- return UA->getMessage();
- return "";
- }
-
/// getNameAsString - Get a human-readable name for the declaration, even if
/// it is one of the special kinds of names (C++ constructor, Objective-C
/// selector, etc). Creating this name requires expensive string
@@ -281,6 +274,10 @@ public:
/// \brief Determines the linkage and visibility of this entity.
LinkageInfo getLinkageAndVisibility() const;
+ /// \brief If visibility was explicitly specified for this
+ /// declaration, return that visibility.
+ llvm::Optional<Visibility> getExplicitVisibility() const;
+
/// \brief Clear the linkage cache in response to a change
/// to the declaration.
void ClearLinkageCache();
@@ -310,16 +307,32 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
/// location is where the __label__ is.
class LabelDecl : public NamedDecl {
LabelStmt *TheStmt;
- LabelDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *II, LabelStmt *S)
- : NamedDecl(Label, DC, L, II), TheStmt(S) {}
-
+ /// LocStart - For normal labels, this is the same as the main declaration
+ /// label, i.e., the location of the identifier; for GNU local labels,
+ /// this is the location of the __label__ keyword.
+ SourceLocation LocStart;
+
+ LabelDecl(DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II,
+ LabelStmt *S, SourceLocation StartL)
+ : NamedDecl(Label, DC, IdentL, II), TheStmt(S), LocStart(StartL) {}
+
public:
static LabelDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, IdentifierInfo *II);
+ SourceLocation IdentL, IdentifierInfo *II);
+ static LabelDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation IdentL, IdentifierInfo *II,
+ SourceLocation GnuLabelL);
LabelStmt *getStmt() const { return TheStmt; }
void setStmt(LabelStmt *T) { TheStmt = T; }
-
+
+ bool isGnuLocal() const { return LocStart != getLocation(); }
+ void setLocStart(SourceLocation L) { LocStart = L; }
+
+ SourceRange getSourceRange() const {
+ return SourceRange(LocStart, getLocation());
+ }
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const LabelDecl *D) { return true; }
@@ -330,7 +343,11 @@ public:
class NamespaceDecl : public NamedDecl, public DeclContext {
bool IsInline : 1;
- SourceLocation LBracLoc, RBracLoc;
+ /// LocStart - The starting location of the source range, pointing
+ /// to either the namespace or the inline keyword.
+ SourceLocation LocStart;
+ /// RBraceLoc - The ending location of the source range.
+ SourceLocation RBraceLoc;
// For extended namespace definitions:
//
@@ -357,13 +374,16 @@ class NamespaceDecl : public NamedDecl, public DeclContext {
/// namespace declaration (which the boolean indicates).
llvm::PointerIntPair<NamespaceDecl *, 1, bool> OrigOrAnonNamespace;
- NamespaceDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id)
- : NamedDecl(Namespace, DC, L, Id), DeclContext(Namespace),
- IsInline(false), NextNamespace(), OrigOrAnonNamespace(0, true) { }
+ NamespaceDecl(DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id)
+ : NamedDecl(Namespace, DC, IdLoc, Id), DeclContext(Namespace),
+ IsInline(false), LocStart(StartLoc), RBraceLoc(),
+ NextNamespace(), OrigOrAnonNamespace(0, true) { }
public:
static NamespaceDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id);
+ SourceLocation StartLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id);
/// \brief Returns true if this is an anonymous namespace declaration.
///
@@ -427,7 +447,7 @@ public:
void setAnonymousNamespace(NamespaceDecl *D) {
assert(!D || D->isAnonymousNamespace());
- assert(!D || D->getParent() == this);
+ assert(!D || D->getParent()->getRedeclContext() == this);
getOriginalNamespace()->OrigOrAnonNamespace.setPointer(D);
}
@@ -437,14 +457,14 @@ public:
}
virtual SourceRange getSourceRange() const {
- return SourceRange(getLocation(), RBracLoc);
+ return SourceRange(LocStart, RBraceLoc);
}
- SourceLocation getLBracLoc() const { return LBracLoc; }
- SourceLocation getRBracLoc() const { return RBracLoc; }
- void setLBracLoc(SourceLocation L) { LBracLoc = L; }
- void setRBracLoc(SourceLocation R) { RBracLoc = R; }
-
+ SourceLocation getLocStart() const { return LocStart; }
+ SourceLocation getRBraceLoc() const { return RBraceLoc; }
+ void setLocStart(SourceLocation L) { LocStart = L; }
+ void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const NamespaceDecl *D) { return true; }
@@ -484,16 +504,24 @@ public:
/// name qualifier, to be used for the case of out-of-line declarations.
struct QualifierInfo {
NestedNameSpecifierLoc QualifierLoc;
- /// NumTemplParamLists - The number of template parameter lists
- /// that were matched against the template-ids occurring into the NNS.
+
+ /// NumTemplParamLists - The number of "outer" template parameter lists.
+ /// The count includes all of the template parameter lists that were matched
+ /// against the template-ids occurring into the NNS and possibly (in the
+ /// case of an explicit specialization) a final "template <>".
unsigned NumTemplParamLists;
+
/// TemplParamLists - A new-allocated array of size NumTemplParamLists,
- /// containing pointers to the matched template parameter lists.
+ /// containing pointers to the "outer" template parameter lists.
+ /// It includes all of the template parameter lists that were matched
+ /// against the template-ids occurring into the NNS and possibly (in the
+ /// case of an explicit specialization) a final "template <>".
TemplateParameterList** TemplParamLists;
/// Default constructor.
QualifierInfo() : QualifierLoc(), NumTemplParamLists(0), TemplParamLists(0) {}
- /// setTemplateParameterListsInfo - Sets info about matched template
+
+ /// setTemplateParameterListsInfo - Sets info about "outer" template
/// parameter lists.
void setTemplateParameterListsInfo(ASTContext &Context,
unsigned NumTPLists,
@@ -516,14 +544,20 @@ class DeclaratorDecl : public ValueDecl {
llvm::PointerUnion<TypeSourceInfo*, ExtInfo*> DeclInfo;
+ /// InnerLocStart - The start of the source range for this declaration,
+ /// ignoring outer template declarations.
+ SourceLocation InnerLocStart;
+
bool hasExtInfo() const { return DeclInfo.is<ExtInfo*>(); }
ExtInfo *getExtInfo() { return DeclInfo.get<ExtInfo*>(); }
const ExtInfo *getExtInfo() const { return DeclInfo.get<ExtInfo*>(); }
protected:
DeclaratorDecl(Kind DK, DeclContext *DC, SourceLocation L,
- DeclarationName N, QualType T, TypeSourceInfo *TInfo)
- : ValueDecl(DK, DC, L, N, T), DeclInfo(TInfo) {}
+ DeclarationName N, QualType T, TypeSourceInfo *TInfo,
+ SourceLocation StartL)
+ : ValueDecl(DK, DC, L, N, T), DeclInfo(TInfo), InnerLocStart(StartL) {
+ }
public:
TypeSourceInfo *getTypeSourceInfo() const {
@@ -540,14 +574,14 @@ public:
/// getInnerLocStart - Return SourceLocation representing start of source
/// range ignoring outer template declarations.
- virtual SourceLocation getInnerLocStart() const { return getLocation(); }
+ SourceLocation getInnerLocStart() const { return InnerLocStart; }
+ void setInnerLocStart(SourceLocation L) { InnerLocStart = L; }
/// getOuterLocStart - Return SourceLocation representing start of source
/// range taking into account any outer template declarations.
SourceLocation getOuterLocStart() const;
- SourceRange getSourceRange() const {
- return SourceRange(getOuterLocStart(), getLocation());
- }
+
+ virtual SourceRange getSourceRange() const;
/// \brief Retrieve the nested-name-specifier that qualifies the name of this
/// declaration, if it was present in the source.
@@ -574,9 +608,7 @@ public:
return getExtInfo()->TemplParamLists[index];
}
void setTemplateParameterListsInfo(ASTContext &Context, unsigned NumTPLists,
- TemplateParameterList **TPLists) {
- getExtInfo()->setTemplateParameterListsInfo(Context, NumTPLists, TPLists);
- }
+ TemplateParameterList **TPLists);
SourceLocation getTypeSpecStartLoc() const;
@@ -650,32 +682,77 @@ protected:
mutable InitType Init;
private:
- // FIXME: This can be packed into the bitfields in Decl.
- unsigned SClass : 3;
- unsigned SClassAsWritten : 3;
- bool ThreadSpecified : 1;
- bool HasCXXDirectInit : 1;
-
- /// \brief Whether this variable is the exception variable in a C++ catch
- /// or an Objective-C @catch statement.
- bool ExceptionVar : 1;
+ class VarDeclBitfields {
+ friend class VarDecl;
+ friend class ASTDeclReader;
+
+ unsigned SClass : 3;
+ unsigned SClassAsWritten : 3;
+ unsigned ThreadSpecified : 1;
+ unsigned HasCXXDirectInit : 1;
+
+ /// \brief Whether this variable is the exception variable in a C++ catch
+ /// or an Objective-C @catch statement.
+ unsigned ExceptionVar : 1;
- /// \brief Whether this local variable could be allocated in the return
- /// slot of its function, enabling the named return value optimization (NRVO).
- bool NRVOVariable : 1;
+ /// \brief Whether this local variable could be allocated in the return
+ /// slot of its function, enabling the named return value optimization (NRVO).
+ unsigned NRVOVariable : 1;
+
+ /// \brief Whether this variable is the for-range-declaration in a C++0x
+ /// for-range statement.
+ unsigned CXXForRangeDecl : 1;
+ };
+ enum { NumVarDeclBits = 13 }; // two reserved bits for now
- friend class StmtIteratorBase;
friend class ASTDeclReader;
+ friend class StmtIteratorBase;
protected:
- VarDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
+ class ParmVarDeclBitfields {
+ friend class ParmVarDecl;
+ friend class ASTDeclReader;
+
+ unsigned : NumVarDeclBits;
+
+ /// Whether this parameter inherits a default argument from a
+ /// prior declaration.
+ unsigned HasInheritedDefaultArg : 1;
+
+ /// Whether this parameter undergoes K&R argument promotion.
+ unsigned IsKNRPromoted : 1;
+
+ /// Whether this parameter is an ObjC method parameter or not.
+ unsigned IsObjCMethodParam : 1;
+
+ /// If IsObjCMethodParam, a Decl::ObjCDeclQualifier.
+ /// Otherwise, the number of function parameter scopes enclosing
+ /// the function parameter scope in which this parameter was
+ /// declared.
+ unsigned ScopeDepthOrObjCQuals : 8;
+
+ /// The number of parameters preceding this parameter in the
+ /// function parameter scope in which it was declared.
+ unsigned ParameterIndex : 8;
+ };
+
+ union {
+ unsigned AllBits;
+ VarDeclBitfields VarDeclBits;
+ ParmVarDeclBitfields ParmVarDeclBits;
+ };
+
+ VarDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id,
QualType T, TypeSourceInfo *TInfo, StorageClass SC,
StorageClass SCAsWritten)
- : DeclaratorDecl(DK, DC, L, Id, T, TInfo), Init(),
- ThreadSpecified(false), HasCXXDirectInit(false),
- ExceptionVar(false), NRVOVariable(false) {
- SClass = SC;
- SClassAsWritten = SCAsWritten;
+ : DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc), Init() {
+ assert(sizeof(VarDeclBitfields) <= sizeof(unsigned));
+ assert(sizeof(ParmVarDeclBitfields) <= sizeof(unsigned));
+ AllBits = 0;
+ VarDeclBits.SClass = SC;
+ VarDeclBits.SClassAsWritten = SCAsWritten;
+ // Everything else is implicitly initialized to false.
}
typedef Redeclarable<VarDecl> redeclarable_base;
@@ -691,26 +768,27 @@ public:
}
static VarDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
- QualType T, TypeSourceInfo *TInfo, StorageClass S,
- StorageClass SCAsWritten);
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo,
+ StorageClass S, StorageClass SCAsWritten);
- virtual SourceLocation getInnerLocStart() const;
virtual SourceRange getSourceRange() const;
- StorageClass getStorageClass() const { return (StorageClass)SClass; }
+ StorageClass getStorageClass() const {
+ return (StorageClass) VarDeclBits.SClass;
+ }
StorageClass getStorageClassAsWritten() const {
- return (StorageClass) SClassAsWritten;
+ return (StorageClass) VarDeclBits.SClassAsWritten;
}
void setStorageClass(StorageClass SC);
void setStorageClassAsWritten(StorageClass SC) {
assert(isLegalForVariable(SC));
- SClassAsWritten = SC;
+ VarDeclBits.SClassAsWritten = SC;
}
- void setThreadSpecified(bool T) { ThreadSpecified = T; }
+ void setThreadSpecified(bool T) { VarDeclBits.ThreadSpecified = T; }
bool isThreadSpecified() const {
- return ThreadSpecified;
+ return VarDeclBits.ThreadSpecified;
}
/// hasLocalStorage - Returns true if a variable with function scope
@@ -988,7 +1066,7 @@ public:
Eval->IsICE = IsICE;
}
- void setCXXDirectInitializer(bool T) { HasCXXDirectInit = T; }
+ void setCXXDirectInitializer(bool T) { VarDeclBits.HasCXXDirectInit = T; }
/// hasCXXDirectInitializer - If true, the initializer was a direct
/// initializer, e.g: "int x(1);". The Init expression will be the expression
@@ -997,15 +1075,15 @@ public:
/// by checking hasCXXDirectInitializer.
///
bool hasCXXDirectInitializer() const {
- return HasCXXDirectInit;
+ return VarDeclBits.HasCXXDirectInit;
}
/// \brief Determine whether this variable is the exception variable in a
/// C++ catch statememt or an Objective-C @catch statement.
bool isExceptionVariable() const {
- return ExceptionVar;
+ return VarDeclBits.ExceptionVar;
}
- void setExceptionVariable(bool EV) { ExceptionVar = EV; }
+ void setExceptionVariable(bool EV) { VarDeclBits.ExceptionVar = EV; }
/// \brief Determine whether this local variable can be used with the named
/// return value optimization (NRVO).
@@ -1017,8 +1095,13 @@ public:
/// return slot when returning from the function. Within the function body,
/// each return that returns the NRVO object will have this variable as its
/// NRVO candidate.
- bool isNRVOVariable() const { return NRVOVariable; }
- void setNRVOVariable(bool NRVO) { NRVOVariable = NRVO; }
+ bool isNRVOVariable() const { return VarDeclBits.NRVOVariable; }
+ void setNRVOVariable(bool NRVO) { VarDeclBits.NRVOVariable = NRVO; }
+
+ /// \brief Determine whether this variable is the for-range-declaration in
+ /// a C++0x for-range statement.
+ bool isCXXForRangeDecl() const { return VarDeclBits.CXXForRangeDecl; }
+ void setCXXForRangeDecl(bool FRD) { VarDeclBits.CXXForRangeDecl = FRD; }
/// \brief If this variable is an instantiated static data member of a
/// class template specialization, returns the templated static data member
@@ -1048,12 +1131,12 @@ public:
class ImplicitParamDecl : public VarDecl {
public:
static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
+ SourceLocation IdLoc, IdentifierInfo *Id,
QualType T);
- ImplicitParamDecl(DeclContext *DC, SourceLocation loc,
- IdentifierInfo *name, QualType type)
- : VarDecl(ImplicitParam, DC, loc, name, type,
+ ImplicitParamDecl(DeclContext *DC, SourceLocation IdLoc,
+ IdentifierInfo *Id, QualType Type)
+ : VarDecl(ImplicitParam, DC, IdLoc, IdLoc, Id, Type,
/*tinfo*/ 0, SC_None, SC_None) {
setImplicit();
}
@@ -1064,35 +1147,85 @@ public:
static bool classofKind(Kind K) { return K == ImplicitParam; }
};
-/// ParmVarDecl - Represent a parameter to a function.
+/// ParmVarDecl - Represents a parameter to a function.
class ParmVarDecl : public VarDecl {
- // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
- /// FIXME: Also can be paced into the bitfields in Decl.
- /// in, inout, etc.
- unsigned objcDeclQualifier : 6;
- bool HasInheritedDefaultArg : 1;
+public:
+ enum { MaxFunctionScopeDepth = 255 };
+ enum { MaxFunctionScopeIndex = 255 };
protected:
- ParmVarDecl(Kind DK, DeclContext *DC, SourceLocation L,
- IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo,
+ ParmVarDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id,
+ QualType T, TypeSourceInfo *TInfo,
StorageClass S, StorageClass SCAsWritten, Expr *DefArg)
- : VarDecl(DK, DC, L, Id, T, TInfo, S, SCAsWritten),
- objcDeclQualifier(OBJC_TQ_None), HasInheritedDefaultArg(false) {
+ : VarDecl(DK, DC, StartLoc, IdLoc, Id, T, TInfo, S, SCAsWritten) {
+ assert(ParmVarDeclBits.HasInheritedDefaultArg == false);
+ assert(ParmVarDeclBits.IsKNRPromoted == false);
+ assert(ParmVarDeclBits.IsObjCMethodParam == false);
setDefaultArg(DefArg);
}
public:
static ParmVarDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L,IdentifierInfo *Id,
+ SourceLocation StartLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id,
QualType T, TypeSourceInfo *TInfo,
StorageClass S, StorageClass SCAsWritten,
Expr *DefArg);
+ void setObjCMethodScopeInfo(unsigned parameterIndex) {
+ ParmVarDeclBits.IsObjCMethodParam = true;
+
+ ParmVarDeclBits.ParameterIndex = parameterIndex;
+ assert(ParmVarDeclBits.ParameterIndex == parameterIndex && "truncation!");
+ }
+
+ void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex) {
+ assert(!ParmVarDeclBits.IsObjCMethodParam);
+
+ ParmVarDeclBits.ScopeDepthOrObjCQuals = scopeDepth;
+ assert(ParmVarDeclBits.ScopeDepthOrObjCQuals == scopeDepth && "truncation!");
+
+ ParmVarDeclBits.ParameterIndex = parameterIndex;
+ assert(ParmVarDeclBits.ParameterIndex == parameterIndex && "truncation!");
+ }
+
+ bool isObjCMethodParameter() const {
+ return ParmVarDeclBits.IsObjCMethodParam;
+ }
+
+ unsigned getFunctionScopeDepth() const {
+ if (ParmVarDeclBits.IsObjCMethodParam) return 0;
+ return ParmVarDeclBits.ScopeDepthOrObjCQuals;
+ }
+
+ /// Returns the index of this parameter in its prototype or method scope.
+ unsigned getFunctionScopeIndex() const {
+ return ParmVarDeclBits.ParameterIndex;
+ }
+
ObjCDeclQualifier getObjCDeclQualifier() const {
- return ObjCDeclQualifier(objcDeclQualifier);
+ if (!ParmVarDeclBits.IsObjCMethodParam) return OBJC_TQ_None;
+ return ObjCDeclQualifier(ParmVarDeclBits.ScopeDepthOrObjCQuals);
}
void setObjCDeclQualifier(ObjCDeclQualifier QTVal) {
- objcDeclQualifier = QTVal;
+ assert(ParmVarDeclBits.IsObjCMethodParam);
+ ParmVarDeclBits.ScopeDepthOrObjCQuals = QTVal;
+ }
+
+ /// True if the value passed to this parameter must undergo
+ /// K&R-style default argument promotion:
+ ///
+ /// C99 6.5.2.2.
+ /// If the expression that denotes the called function has a type
+ /// that does not include a prototype, the integer promotions are
+ /// performed on each argument, and arguments that have type float
+ /// are promoted to double.
+ bool isKNRPromoted() const {
+ return ParmVarDeclBits.IsKNRPromoted;
+ }
+ void setKNRPromoted(bool promoted) {
+ ParmVarDeclBits.IsKNRPromoted = promoted;
}
Expr *getDefaultArg();
@@ -1158,11 +1291,11 @@ public:
}
bool hasInheritedDefaultArg() const {
- return HasInheritedDefaultArg;
+ return ParmVarDeclBits.HasInheritedDefaultArg;
}
void setHasInheritedDefaultArg(bool I = true) {
- HasInheritedDefaultArg = I;
+ ParmVarDeclBits.HasInheritedDefaultArg = I;
}
QualType getOriginalType() const {
@@ -1233,6 +1366,7 @@ private:
bool IsDeleted : 1;
bool IsTrivial : 1; // sunk from CXXMethodDecl
bool HasImplicitReturnZero : 1;
+ bool IsLateTemplateParsed : 1;
/// \brief End part of this FunctionDecl's source range.
///
@@ -1302,17 +1436,20 @@ private:
void setParams(ASTContext &C, ParmVarDecl **NewParamInfo, unsigned NumParams);
protected:
- FunctionDecl(Kind DK, DeclContext *DC, const DeclarationNameInfo &NameInfo,
+ FunctionDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc,
+ const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
StorageClass S, StorageClass SCAsWritten, bool isInlineSpecified)
- : DeclaratorDecl(DK, DC, NameInfo.getLoc(), NameInfo.getName(), T, TInfo),
+ : DeclaratorDecl(DK, DC, NameInfo.getLoc(), NameInfo.getName(), T, TInfo,
+ StartLoc),
DeclContext(DK),
ParamInfo(0), Body(),
- SClass(S), SClassAsWritten(SCAsWritten),
+ SClass(S), SClassAsWritten(SCAsWritten),
IsInline(isInlineSpecified), IsInlineSpecified(isInlineSpecified),
IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false),
HasWrittenPrototype(true), IsDeleted(false), IsTrivial(false),
- HasImplicitReturnZero(false), EndRangeLoc(NameInfo.getEndLoc()),
+ HasImplicitReturnZero(false), IsLateTemplateParsed(false),
+ EndRangeLoc(NameInfo.getEndLoc()),
TemplateOrSpecialization(),
DNLoc(NameInfo.getInfo()) {}
@@ -1328,22 +1465,25 @@ public:
return redeclarable_base::redecls_end();
}
- static FunctionDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
+ static FunctionDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation StartLoc, SourceLocation NLoc,
DeclarationName N, QualType T,
TypeSourceInfo *TInfo,
- StorageClass S = SC_None,
+ StorageClass SC = SC_None,
StorageClass SCAsWritten = SC_None,
bool isInlineSpecified = false,
bool hasWrittenPrototype = true) {
- DeclarationNameInfo NameInfo(N, L);
- return FunctionDecl::Create(C, DC, NameInfo, T, TInfo, S, SCAsWritten,
+ DeclarationNameInfo NameInfo(N, NLoc);
+ return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo,
+ SC, SCAsWritten,
isInlineSpecified, hasWrittenPrototype);
}
static FunctionDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
- StorageClass S = SC_None,
+ StorageClass SC = SC_None,
StorageClass SCAsWritten = SC_None,
bool isInlineSpecified = false,
bool hasWrittenPrototype = true);
@@ -1356,12 +1496,9 @@ public:
const PrintingPolicy &Policy,
bool Qualified) const;
- virtual SourceRange getSourceRange() const {
- return SourceRange(getOuterLocStart(), EndRangeLoc);
- }
- void setLocEnd(SourceLocation E) {
- EndRangeLoc = E;
- }
+ void setRangeEnd(SourceLocation E) { EndRangeLoc = E; }
+
+ virtual SourceRange getSourceRange() const;
/// \brief Returns true if the function has a body (definition). The
/// function body might be in any of the (re-)declarations of this
@@ -1395,7 +1532,9 @@ public:
/// previous definition); for that information, use getBody.
/// FIXME: Should return true if function is deleted or defaulted. However,
/// CodeGenModule.cpp uses it, and I don't know if this would break it.
- bool isThisDeclarationADefinition() const { return Body; }
+ bool isThisDeclarationADefinition() const {
+ return Body || IsLateTemplateParsed;
+ }
void setBody(Stmt *B);
void setLazyBody(uint64_t Offset) { Body = Offset; }
@@ -1412,6 +1551,14 @@ public:
bool isPure() const { return IsPure; }
void setPure(bool P = true);
+ /// Whether this is a constexpr function or constexpr constructor.
+ // FIXME: C++0x: Implement tracking of the constexpr specifier.
+ bool isConstExpr() const { return false; }
+
+ /// Whether this templated function will be late parsed.
+ bool isLateTemplateParsed() const { return IsLateTemplateParsed; }
+ void setLateTemplateParsed(bool ILT = true) { IsLateTemplateParsed = ILT; }
+
/// Whether this function is "trivial" in some specialized C++ senses.
/// Can only be true for default constructors, copy constructors,
/// copy assignment operators, and destructors. Not meaningful until
@@ -1757,16 +1904,17 @@ class FieldDecl : public DeclaratorDecl {
Expr *BitWidth;
protected:
- FieldDecl(Kind DK, DeclContext *DC, SourceLocation L,
- IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo,
- Expr *BW, bool Mutable)
- : DeclaratorDecl(DK, DC, L, Id, T, TInfo),
+ FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id,
+ QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable)
+ : DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc),
Mutable(Mutable), CachedFieldIndex(0), BitWidth(BW) {
}
public:
static FieldDecl *Create(const ASTContext &C, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id, QualType T,
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, QualType T,
TypeSourceInfo *TInfo, Expr *BW, bool Mutable);
/// getFieldIndex - Returns the index of this field within its record,
@@ -1803,7 +1951,9 @@ public:
RecordDecl *getParent() {
return cast<RecordDecl>(getDeclContext());
}
-
+
+ SourceRange getSourceRange() const;
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const FieldDecl *D) { return true; }
@@ -1895,6 +2045,8 @@ class TypeDecl : public NamedDecl {
/// ASTContext::getTypedefType, ASTContext::getTagDeclType, and
/// ASTContext::getTemplateTypeParmType, and TemplateTypeParmDecl.
mutable const Type *TypeForDecl;
+ /// LocStart - The start of the source range for this declaration.
+ SourceLocation LocStart;
friend class ASTContext;
friend class DeclContext;
friend class TagDecl;
@@ -1902,15 +2054,24 @@ class TypeDecl : public NamedDecl {
friend class TagType;
protected:
- TypeDecl(Kind DK, DeclContext *DC, SourceLocation L,
- IdentifierInfo *Id)
- : NamedDecl(DK, DC, L, Id), TypeForDecl(0) {}
+ TypeDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
+ SourceLocation StartL = SourceLocation())
+ : NamedDecl(DK, DC, L, Id), TypeForDecl(0), LocStart(StartL) {}
public:
// Low-level accessor
const Type *getTypeForDecl() const { return TypeForDecl; }
void setTypeForDecl(const Type *TD) { TypeForDecl = TD; }
+ SourceLocation getLocStart() const { return LocStart; }
+ void setLocStart(SourceLocation L) { LocStart = L; }
+ virtual SourceRange getSourceRange() const {
+ if (LocStart.isValid())
+ return SourceRange(LocStart, getLocation());
+ else
+ return SourceRange(getLocation());
+ }
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const TypeDecl *D) { return true; }
@@ -1918,17 +2079,21 @@ public:
};
-class TypedefDecl : public TypeDecl, public Redeclarable<TypedefDecl> {
+/// Base class for declarations which introduce a typedef-name.
+class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> {
/// UnderlyingType - This is the type the typedef is set to.
TypeSourceInfo *TInfo;
- TypedefDecl(DeclContext *DC, SourceLocation L,
- IdentifierInfo *Id, TypeSourceInfo *TInfo)
- : TypeDecl(Typedef, DC, L, Id), TInfo(TInfo) {}
-
protected:
- typedef Redeclarable<TypedefDecl> redeclarable_base;
- virtual TypedefDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
+ TypedefNameDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id,
+ TypeSourceInfo *TInfo)
+ : TypeDecl(DK, DC, IdLoc, Id, StartLoc), TInfo(TInfo) {}
+
+ typedef Redeclarable<TypedefNameDecl> redeclarable_base;
+ virtual TypedefNameDecl *getNextRedeclaration() {
+ return RedeclLink.getNext();
+ }
public:
typedef redeclarable_base::redecl_iterator redecl_iterator;
@@ -1939,19 +2104,15 @@ public:
return redeclarable_base::redecls_end();
}
- static TypedefDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
- TypeSourceInfo *TInfo);
-
TypeSourceInfo *getTypeSourceInfo() const {
return TInfo;
}
- /// Retrieves the canonical declaration of this typedef.
- TypedefDecl *getCanonicalDecl() {
+ /// Retrieves the canonical declaration of this typedef-name.
+ TypedefNameDecl *getCanonicalDecl() {
return getFirstDeclaration();
}
- const TypedefDecl *getCanonicalDecl() const {
+ const TypedefNameDecl *getCanonicalDecl() const {
return getFirstDeclaration();
}
@@ -1964,11 +2125,51 @@ public:
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
+ static bool classof(const TypedefNameDecl *D) { return true; }
+ static bool classofKind(Kind K) {
+ return K >= firstTypedefName && K <= lastTypedefName;
+ }
+};
+
+/// TypedefDecl - Represents the declaration of a typedef-name via the 'typedef'
+/// type specifier.
+class TypedefDecl : public TypedefNameDecl {
+ TypedefDecl(DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, TypeSourceInfo *TInfo)
+ : TypedefNameDecl(Typedef, DC, StartLoc, IdLoc, Id, TInfo) {}
+
+public:
+ static TypedefDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, TypeSourceInfo *TInfo);
+
+ SourceRange getSourceRange() const;
+
+ // Implement isa/cast/dyncast/etc.
+ static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const TypedefDecl *D) { return true; }
static bool classofKind(Kind K) { return K == Typedef; }
};
-class TypedefDecl;
+/// TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x
+/// alias-declaration.
+class TypeAliasDecl : public TypedefNameDecl {
+ TypeAliasDecl(DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, TypeSourceInfo *TInfo)
+ : TypedefNameDecl(TypeAlias, DC, StartLoc, IdLoc, Id, TInfo) {}
+
+public:
+ static TypeAliasDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, TypeSourceInfo *TInfo);
+
+ SourceRange getSourceRange() const;
+
+ // Implement isa/cast/dyncast/etc.
+ static bool classof(const Decl *D) { return classofKind(D->getKind()); }
+ static bool classof(const TypeAliasDecl *D) { return true; }
+ static bool classofKind(Kind K) { return K == TypeAlias; }
+};
/// TagDecl - Represents the declaration of a struct/union/class/enum.
class TagDecl
@@ -2013,32 +2214,31 @@ protected:
bool IsFixed : 1;
private:
- SourceLocation TagKeywordLoc;
SourceLocation RBraceLoc;
// A struct representing syntactic qualifier info,
// to be used for the (uncommon) case of out-of-line declarations.
typedef QualifierInfo ExtInfo;
- /// TypedefDeclOrQualifier - If the (out-of-line) tag declaration name
+ /// TypedefNameDeclOrQualifier - If the (out-of-line) tag declaration name
/// is qualified, it points to the qualifier info (nns and range);
/// otherwise, if the tag declaration is anonymous and it is part of
- /// a typedef, it points to the TypedefDecl (used for mangling);
- /// otherwise, it is a null (TypedefDecl) pointer.
- llvm::PointerUnion<TypedefDecl*, ExtInfo*> TypedefDeclOrQualifier;
+ /// a typedef or alias, it points to the TypedefNameDecl (used for mangling);
+ /// otherwise, it is a null (TypedefNameDecl) pointer.
+ llvm::PointerUnion<TypedefNameDecl*, ExtInfo*> TypedefNameDeclOrQualifier;
- bool hasExtInfo() const { return TypedefDeclOrQualifier.is<ExtInfo*>(); }
- ExtInfo *getExtInfo() { return TypedefDeclOrQualifier.get<ExtInfo*>(); }
+ bool hasExtInfo() const { return TypedefNameDeclOrQualifier.is<ExtInfo*>(); }
+ ExtInfo *getExtInfo() { return TypedefNameDeclOrQualifier.get<ExtInfo*>(); }
const ExtInfo *getExtInfo() const {
- return TypedefDeclOrQualifier.get<ExtInfo*>();
+ return TypedefNameDeclOrQualifier.get<ExtInfo*>();
}
protected:
TagDecl(Kind DK, TagKind TK, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
- TagDecl *PrevDecl, SourceLocation TKL = SourceLocation())
- : TypeDecl(DK, DC, L, Id), DeclContext(DK), TagKeywordLoc(TKL),
- TypedefDeclOrQualifier((TypedefDecl*) 0) {
+ TagDecl *PrevDecl, SourceLocation StartL)
+ : TypeDecl(DK, DC, L, Id, StartL), DeclContext(DK),
+ TypedefNameDeclOrQualifier((TypedefNameDecl*) 0) {
assert((DK != Enum || TK == TTK_Enum) &&
"EnumDecl not matched with TTK_Enum");
TagDeclKind = TK;
@@ -2068,12 +2268,9 @@ public:
SourceLocation getRBraceLoc() const { return RBraceLoc; }
void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
- SourceLocation getTagKeywordLoc() const { return TagKeywordLoc; }
- void setTagKeywordLoc(SourceLocation TKL) { TagKeywordLoc = TKL; }
-
/// getInnerLocStart - Return SourceLocation representing start of source
/// range ignoring outer template declarations.
- virtual SourceLocation getInnerLocStart() const { return TagKeywordLoc; }
+ SourceLocation getInnerLocStart() const { return getLocStart(); }
/// getOuterLocStart - Return SourceLocation representing start of source
/// range taking into account any outer template declarations.
@@ -2146,11 +2343,11 @@ public:
bool isUnion() const { return getTagKind() == TTK_Union; }
bool isEnum() const { return getTagKind() == TTK_Enum; }
- TypedefDecl *getTypedefForAnonDecl() const {
- return hasExtInfo() ? 0 : TypedefDeclOrQualifier.get<TypedefDecl*>();
+ TypedefNameDecl *getTypedefNameForAnonDecl() const {
+ return hasExtInfo() ? 0 : TypedefNameDeclOrQualifier.get<TypedefNameDecl*>();
}
- void setTypedefForAnonDecl(TypedefDecl *TDD);
+ void setTypedefNameForAnonDecl(TypedefNameDecl *TDD);
/// \brief Retrieve the nested-name-specifier that qualifies the name of this
/// declaration, if it was present in the source.
@@ -2177,9 +2374,7 @@ public:
return getExtInfo()->TemplParamLists[i];
}
void setTemplateParameterListsInfo(ASTContext &Context, unsigned NumTPLists,
- TemplateParameterList **TPLists) {
- getExtInfo()->setTemplateParameterListsInfo(Context, NumTPLists, TPLists);
- }
+ TemplateParameterList **TPLists);
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@@ -2235,18 +2430,19 @@ class EnumDecl : public TagDecl {
NumBitsMask = (1 << NumBitsWidth) - 1
};
- EnumDecl(DeclContext *DC, SourceLocation L,
- IdentifierInfo *Id, EnumDecl *PrevDecl, SourceLocation TKL,
+ EnumDecl(DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, EnumDecl *PrevDecl,
bool Scoped, bool ScopedUsingClassTag, bool Fixed)
- : TagDecl(Enum, TTK_Enum, DC, L, Id, PrevDecl, TKL), InstantiatedFrom(0) {
- assert(Scoped || !ScopedUsingClassTag);
- IntegerType = (const Type*)0;
- NumNegativeBits = 0;
- NumPositiveBits = 0;
- IsScoped = Scoped;
- IsScopedUsingClassTag = ScopedUsingClassTag;
- IsFixed = Fixed;
- }
+ : TagDecl(Enum, TTK_Enum, DC, IdLoc, Id, PrevDecl, StartLoc),
+ InstantiatedFrom(0) {
+ assert(Scoped || !ScopedUsingClassTag);
+ IntegerType = (const Type*)0;
+ NumNegativeBits = 0;
+ NumPositiveBits = 0;
+ IsScoped = Scoped;
+ IsScopedUsingClassTag = ScopedUsingClassTag;
+ IsFixed = Fixed;
+ }
public:
EnumDecl *getCanonicalDecl() {
return cast<EnumDecl>(TagDecl::getCanonicalDecl());
@@ -2263,8 +2459,8 @@ public:
}
static EnumDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
- SourceLocation TKL, EnumDecl *PrevDecl,
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, EnumDecl *PrevDecl,
bool IsScoped, bool IsScopedUsingClassTag,
bool IsFixed);
static EnumDecl *Create(ASTContext &C, EmptyShell Empty);
@@ -2326,7 +2522,7 @@ public:
return IntegerType.dyn_cast<TypeSourceInfo*>();
}
- /// \brief Returns the width in bits requred to store all the
+ /// \brief Returns the width in bits required to store all the
/// non-negative enumerators of this enum.
unsigned getNumPositiveBits() const {
return NumPositiveBits;
@@ -2336,7 +2532,7 @@ public:
assert(NumPositiveBits == Num && "can't store this bitcount");
}
- /// \brief Returns the width in bits requred to store all the
+ /// \brief Returns the width in bits required to store all the
/// negative enumerators of this enum. These widths include
/// the rightmost leading 1; that is:
///
@@ -2419,14 +2615,13 @@ class RecordDecl : public TagDecl {
protected:
RecordDecl(Kind DK, TagKind TK, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
- RecordDecl *PrevDecl, SourceLocation TKL);
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, RecordDecl *PrevDecl);
public:
static RecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
- SourceLocation TKL = SourceLocation(),
- RecordDecl* PrevDecl = 0);
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, RecordDecl* PrevDecl = 0);
static RecordDecl *Create(const ASTContext &C, EmptyShell Empty);
const RecordDecl *getPreviousDeclaration() const {
@@ -2519,11 +2714,21 @@ private:
class FileScopeAsmDecl : public Decl {
StringLiteral *AsmString;
- FileScopeAsmDecl(DeclContext *DC, SourceLocation L, StringLiteral *asmstring)
- : Decl(FileScopeAsm, DC, L), AsmString(asmstring) {}
+ SourceLocation RParenLoc;
+ FileScopeAsmDecl(DeclContext *DC, StringLiteral *asmstring,
+ SourceLocation StartL, SourceLocation EndL)
+ : Decl(FileScopeAsm, DC, StartL), AsmString(asmstring), RParenLoc(EndL) {}
public:
static FileScopeAsmDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, StringLiteral *Str);
+ StringLiteral *Str, SourceLocation AsmLoc,
+ SourceLocation RParenLoc);
+
+ SourceLocation getAsmLoc() const { return getLocation(); }
+ SourceLocation getRParenLoc() const { return RParenLoc; }
+ void setRParenLoc(SourceLocation L) { RParenLoc = L; }
+ SourceRange getSourceRange() const {
+ return SourceRange(getAsmLoc(), getRParenLoc());
+ }
const StringLiteral *getAsmString() const { return AsmString; }
StringLiteral *getAsmString() { return AsmString; }
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index b35d134d0534..ce48187f3ade 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -62,6 +62,15 @@ public:
namespace clang {
+ /// \brief Captures the result of checking the availability of a
+ /// declaration.
+ enum AvailabilityResult {
+ AR_Available = 0,
+ AR_NotYetIntroduced,
+ AR_Deprecated,
+ AR_Unavailable
+ };
+
/// Decl - This represents one declaration (or definition), e.g. a variable,
/// typedef, function, struct, etc.
///
@@ -147,9 +156,20 @@ public:
IDNS_NonMemberOperator = 0x0400
};
- /// ObjCDeclQualifier - Qualifier used on types in method declarations
- /// for remote messaging. They are meant for the arguments though and
- /// applied to the Decls (ObjCMethodDecl and ParmVarDecl).
+ /// ObjCDeclQualifier - 'Qualifiers' written next to the return and
+ /// parameter types in method declarations. Other than remembering
+ /// them and mangling them into the method's signature string, these
+ /// are ignored by the compiler; they are consumed by certain
+ /// remote-messaging frameworks.
+ ///
+ /// in, inout, and out are mutually exclusive and apply only to
+ /// method parameters. bycopy and byref are mutually exclusive and
+ /// apply only to method parameters (?). oneway applies only to
+ /// results. All of these expect their corresponding parameter to
+ /// have a particular type. None of this is currently enforced by
+ /// clang.
+ ///
+ /// This should be kept in sync with ObjCDeclSpec::ObjCDeclQualifier.
enum ObjCDeclQualifier {
OBJC_TQ_None = 0x0,
OBJC_TQ_In = 0x1,
@@ -218,6 +238,12 @@ private:
/// required.
unsigned Used : 1;
+ /// \brief Whether this declaration was "referenced".
+ /// The difference with 'Used' is whether the reference appears in a
+ /// evaluated context or not, e.g. functions used in uninstantiated templates
+ /// are regarded as "referenced" but not "used".
+ unsigned Referenced : 1;
+
protected:
/// Access - Used by C++ decls for the access specifier.
// NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum
@@ -252,7 +278,7 @@ protected:
Decl(Kind DK, DeclContext *DC, SourceLocation L)
: NextDeclInContext(0), DeclCtx(DC),
Loc(L), DeclKind(DK), InvalidDecl(0),
- HasAttrs(false), Implicit(false), Used(false),
+ HasAttrs(false), Implicit(false), Used(false), Referenced(false),
Access(AS_none), PCHLevel(0), ChangedAfterLoad(false),
IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
HasCachedLinkage(0)
@@ -262,7 +288,7 @@ protected:
Decl(Kind DK, EmptyShell Empty)
: NextDeclInContext(0), DeclKind(DK), InvalidDecl(0),
- HasAttrs(false), Implicit(false), Used(false),
+ HasAttrs(false), Implicit(false), Used(false), Referenced(false),
Access(AS_none), PCHLevel(0), ChangedAfterLoad(false),
IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
HasCachedLinkage(0)
@@ -399,6 +425,57 @@ public:
void setUsed(bool U = true) { Used = U; }
+ /// \brief Whether this declaration was referenced.
+ bool isReferenced() const;
+
+ void setReferenced(bool R = true) { Referenced = R; }
+
+ /// \brief Determine the availability of the given declaration.
+ ///
+ /// This routine will determine the most restrictive availability of
+ /// the given declaration (e.g., preferring 'unavailable' to
+ /// 'deprecated').
+ ///
+ /// \param Message If non-NULL and the result is not \c
+ /// AR_Available, will be set to a (possibly empty) message
+ /// describing why the declaration has not been introduced, is
+ /// deprecated, or is unavailable.
+ AvailabilityResult getAvailability(std::string *Message = 0) const;
+
+ /// \brief Determine whether this declaration is marked 'deprecated'.
+ ///
+ /// \param Message If non-NULL and the declaration is deprecated,
+ /// this will be set to the message describing why the declaration
+ /// was deprecated (which may be empty).
+ bool isDeprecated(std::string *Message = 0) const {
+ return getAvailability(Message) == AR_Deprecated;
+ }
+
+ /// \brief Determine whether this declaration is marked 'unavailable'.
+ ///
+ /// \param Message If non-NULL and the declaration is unavailable,
+ /// this will be set to the message describing why the declaration
+ /// was made unavailable (which may be empty).
+ bool isUnavailable(std::string *Message = 0) const {
+ return getAvailability(Message) == AR_Unavailable;
+ }
+
+ /// \brief Determine whether this is a weak-imported symbol.
+ ///
+ /// Weak-imported symbols are typically marked with the
+ /// 'weak_import' attribute, but may also be marked with an
+ /// 'availability' attribute where we're targing a platform prior to
+ /// the introduction of this feature.
+ bool isWeakImported() const;
+
+ /// \brief Determines whether this symbol can be weak-imported,
+ /// e.g., whether it would be well-formed to add the weak_import
+ /// attribute.
+ ///
+ /// \param IsDefinition Set to \c true to indicate that this
+ /// declaration cannot be weak-imported because it has a definition.
+ bool canBeWeakImported(bool &IsDefinition) const;
+
/// \brief Retrieve the level of precompiled header from which this
/// declaration was generated.
///
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 1656a7e9737c..8c819e38781d 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -306,6 +306,37 @@ class CXXRecordDecl : public RecordDecl {
/// one pure virtual function, (that can come from a base class).
bool Abstract : 1;
+ /// IsStandardLayout - True when this class has standard layout.
+ ///
+ /// C++0x [class]p7. A standard-layout class is a class that:
+ /// * has no non-static data members of type non-standard-layout class (or
+ /// array of such types) or reference,
+ /// * has no virtual functions (10.3) and no virtual base classes (10.1),
+ /// * has the same access control (Clause 11) for all non-static data members
+ /// * has no non-standard-layout base classes,
+ /// * either has no non-static data members in the most derived class and at
+ /// most one base class with non-static data members, or has no base
+ /// classes with non-static data members, and
+ /// * has no base classes of the same type as the first non-static data
+ /// member.
+ bool IsStandardLayout : 1;
+
+ /// HasNoNonEmptyBases - True when there are no non-empty base classes.
+ ///
+ /// This is a helper bit of state used to implement IsStandardLayout more
+ /// efficiently.
+ bool HasNoNonEmptyBases : 1;
+
+ /// HasPrivateFields - True when there are private non-static data members.
+ bool HasPrivateFields : 1;
+
+ /// HasProtectedFields - True when there are protected non-static data
+ /// members.
+ bool HasProtectedFields : 1;
+
+ /// HasPublicFields - True when there are private non-static data members.
+ bool HasPublicFields : 1;
+
/// HasTrivialConstructor - True when this class has a trivial constructor.
///
/// C++ [class.ctor]p5. A constructor is trivial if it is an
@@ -316,31 +347,71 @@ class CXXRecordDecl : public RecordDecl {
/// (or array thereof), each such class has a trivial constructor.
bool HasTrivialConstructor : 1;
+ /// HasConstExprNonCopyMoveConstructor - True when this class has at least
+ /// one constexpr constructor which is neither the copy nor move
+ /// constructor.
+ bool HasConstExprNonCopyMoveConstructor : 1;
+
/// HasTrivialCopyConstructor - True when this class has a trivial copy
/// constructor.
///
- /// C++ [class.copy]p6. A copy constructor for class X is trivial
- /// if it is implicitly declared and if
- /// * class X has no virtual functions and no virtual base classes, and
- /// * each direct base class of X has a trivial copy constructor, and
- /// * for all the nonstatic data members of X that are of class type (or
- /// array thereof), each such class type has a trivial copy constructor;
- /// otherwise the copy constructor is non-trivial.
+ /// C++0x [class.copy]p13:
+ /// A copy/move constructor for class X is trivial if it is neither
+ /// user-provided nor deleted and if
+ /// -- class X has no virtual functions and no virtual base classes, and
+ /// -- the constructor selected to copy/move each direct base class
+ /// subobject is trivial, and
+ /// -- for each non-static data member of X that is of class type (or an
+ /// array thereof), the constructor selected to copy/move that member
+ /// is trivial;
+ /// otherwise the copy/move constructor is non-trivial.
bool HasTrivialCopyConstructor : 1;
+ /// HasTrivialMoveConstructor - True when this class has a trivial move
+ /// constructor.
+ ///
+ /// C++0x [class.copy]p13:
+ /// A copy/move constructor for class X is trivial if it is neither
+ /// user-provided nor deleted and if
+ /// -- class X has no virtual functions and no virtual base classes, and
+ /// -- the constructor selected to copy/move each direct base class
+ /// subobject is trivial, and
+ /// -- for each non-static data member of X that is of class type (or an
+ /// array thereof), the constructor selected to copy/move that member
+ /// is trivial;
+ /// otherwise the copy/move constructor is non-trivial.
+ bool HasTrivialMoveConstructor : 1;
+
/// HasTrivialCopyAssignment - True when this class has a trivial copy
/// assignment operator.
///
- /// C++ [class.copy]p11. A copy assignment operator for class X is
- /// trivial if it is implicitly declared and if
- /// * class X has no virtual functions and no virtual base classes, and
- /// * each direct base class of X has a trivial copy assignment operator, and
- /// * for all the nonstatic data members of X that are of class type (or
- /// array thereof), each such class type has a trivial copy assignment
- /// operator;
- /// otherwise the copy assignment operator is non-trivial.
+ /// C++0x [class.copy]p27:
+ /// A copy/move assignment operator for class X is trivial if it is
+ /// neither user-provided nor deleted and if
+ /// -- class X has no virtual functions and no virtual base classes, and
+ /// -- the assignment operator selected to copy/move each direct base
+ /// class subobject is trivial, and
+ /// -- for each non-static data member of X that is of class type (or an
+ /// array thereof), the assignment operator selected to copy/move
+ /// that member is trivial;
+ /// otherwise the copy/move assignment operator is non-trivial.
bool HasTrivialCopyAssignment : 1;
+ /// HasTrivialMoveAssignment - True when this class has a trivial move
+ /// assignment operator.
+ ///
+ /// C++0x [class.copy]p27:
+ /// A copy/move assignment operator for class X is trivial if it is
+ /// neither user-provided nor deleted and if
+ /// -- class X has no virtual functions and no virtual base classes, and
+ /// -- the assignment operator selected to copy/move each direct base
+ /// class subobject is trivial, and
+ /// -- for each non-static data member of X that is of class type (or an
+ /// array thereof), the assignment operator selected to copy/move
+ /// that member is trivial;
+ /// otherwise the copy/move assignment operator is non-trivial.
+ bool HasTrivialMoveAssignment : 1;
+
/// HasTrivialDestructor - True when this class has a trivial destructor.
///
/// C++ [class.dtor]p3. A destructor is trivial if it is an
@@ -351,6 +422,10 @@ class CXXRecordDecl : public RecordDecl {
/// type (or array thereof), each such class has a trivial destructor.
bool HasTrivialDestructor : 1;
+ /// HasNonLiteralTypeFieldsOrBases - True when this class contains at least
+ /// one non-static data member or base class of non literal type.
+ bool HasNonLiteralTypeFieldsOrBases : 1;
+
/// ComputedVisibleConversions - True when visible conversion functions are
/// already computed and are available.
bool ComputedVisibleConversions : 1;
@@ -449,9 +524,8 @@ class CXXRecordDecl : public RecordDecl {
protected:
CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
- CXXRecordDecl *PrevDecl,
- SourceLocation TKL = SourceLocation());
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, CXXRecordDecl *PrevDecl);
public:
/// base_class_iterator - Iterator that traverses the base classes
@@ -494,9 +568,8 @@ public:
bool hasDefinition() const { return DefinitionData != 0; }
static CXXRecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
- SourceLocation TKL = SourceLocation(),
- CXXRecordDecl* PrevDecl=0,
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, CXXRecordDecl* PrevDecl=0,
bool DelayTypeCreation = false);
static CXXRecordDecl *Create(const ASTContext &C, EmptyShell Empty);
@@ -723,26 +796,58 @@ public:
/// which means that the class contains or inherits a pure virtual function.
bool isAbstract() const { return data().Abstract; }
+ /// isStandardLayout - Whether this class has standard layout
+ /// (C++ [class]p7)
+ bool isStandardLayout() const { return data().IsStandardLayout; }
+
// hasTrivialConstructor - Whether this class has a trivial constructor
// (C++ [class.ctor]p5)
bool hasTrivialConstructor() const { return data().HasTrivialConstructor; }
+ // hasConstExprNonCopyMoveConstructor - Whether this class has at least one
+ // constexpr constructor other than the copy or move constructors
+ bool hasConstExprNonCopyMoveConstructor() const {
+ return data().HasConstExprNonCopyMoveConstructor;
+ }
+
// hasTrivialCopyConstructor - Whether this class has a trivial copy
- // constructor (C++ [class.copy]p6)
+ // constructor (C++ [class.copy]p6, C++0x [class.copy]p13)
bool hasTrivialCopyConstructor() const {
return data().HasTrivialCopyConstructor;
}
+ // hasTrivialMoveConstructor - Whether this class has a trivial move
+ // constructor (C++0x [class.copy]p13)
+ bool hasTrivialMoveConstructor() const {
+ return data().HasTrivialMoveConstructor;
+ }
+
// hasTrivialCopyAssignment - Whether this class has a trivial copy
- // assignment operator (C++ [class.copy]p11)
+ // assignment operator (C++ [class.copy]p11, C++0x [class.copy]p27)
bool hasTrivialCopyAssignment() const {
return data().HasTrivialCopyAssignment;
}
+ // hasTrivialMoveAssignment - Whether this class has a trivial move
+ // assignment operator (C++0x [class.copy]p27)
+ bool hasTrivialMoveAssignment() const {
+ return data().HasTrivialMoveAssignment;
+ }
+
// hasTrivialDestructor - Whether this class has a trivial destructor
// (C++ [class.dtor]p3)
bool hasTrivialDestructor() const { return data().HasTrivialDestructor; }
+ // hasNonLiteralTypeFieldsOrBases - Whether this class has a non-literal type
+ // non-static data member or base class.
+ bool hasNonLiteralTypeFieldsOrBases() const {
+ return data().HasNonLiteralTypeFieldsOrBases;
+ }
+
+ // isTriviallyCopyable - Whether this class is considered trivially copyable
+ // (C++0x [class]p5).
+ bool isTriviallyCopyable() const;
+
/// \brief If this record is an instantiation of a member class,
/// retrieves the member class from which it was instantiated.
///
@@ -1034,20 +1139,27 @@ public:
/// struct/union/class.
class CXXMethodDecl : public FunctionDecl {
protected:
- CXXMethodDecl(Kind DK, CXXRecordDecl *RD,
+ CXXMethodDecl(Kind DK, CXXRecordDecl *RD, SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
- bool isStatic, StorageClass SCAsWritten, bool isInline)
- : FunctionDecl(DK, RD, NameInfo, T, TInfo, (isStatic ? SC_Static : SC_None),
- SCAsWritten, isInline) {}
+ bool isStatic, StorageClass SCAsWritten, bool isInline,
+ SourceLocation EndLocation)
+ : FunctionDecl(DK, RD, StartLoc, NameInfo, T, TInfo,
+ (isStatic ? SC_Static : SC_None),
+ SCAsWritten, isInline) {
+ if (EndLocation.isValid())
+ setRangeEnd(EndLocation);
+ }
public:
static CXXMethodDecl *Create(ASTContext &C, CXXRecordDecl *RD,
+ SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
- bool isStatic = false,
- StorageClass SCAsWritten = SC_None,
- bool isInline = false);
+ bool isStatic,
+ StorageClass SCAsWritten,
+ bool isInline,
+ SourceLocation EndLocation);
bool isStatic() const { return getStorageClass() == SC_Static; }
bool isInstance() const { return !isStatic(); }
@@ -1148,13 +1260,16 @@ public:
/// @endcode
class CXXCtorInitializer {
/// \brief Either the base class name (stored as a TypeSourceInfo*), an normal
- /// field (FieldDecl) or an anonymous field (IndirectFieldDecl*) being
- /// initialized.
- llvm::PointerUnion3<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *>
+ /// field (FieldDecl), anonymous field (IndirectFieldDecl*), or target
+ /// constructor (CXXConstructorDecl*) being initialized.
+ llvm::PointerUnion4<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *,
+ CXXConstructorDecl *>
Initializee;
/// \brief The source location for the field name or, for a base initializer
- /// pack expansion, the location of the ellipsis.
+ /// pack expansion, the location of the ellipsis. In the case of a delegating
+ /// constructor, it will still include the type's source location as the
+ /// Initializee points to the CXXConstructorDecl (to allow loop detection).
SourceLocation MemberOrEllipsisLocation;
/// \brief The argument used to initialize the base or member, which may
@@ -1199,11 +1314,17 @@ public:
SourceLocation MemberLoc, SourceLocation L, Expr *Init,
SourceLocation R);
+ /// CXXCtorInitializer - Creates a new anonymous field initializer.
explicit
CXXCtorInitializer(ASTContext &Context, IndirectFieldDecl *Member,
SourceLocation MemberLoc, SourceLocation L, Expr *Init,
SourceLocation R);
+ /// CXXCtorInitializer - Creates a new delegating Initializer.
+ explicit
+ CXXCtorInitializer(ASTContext &Context, SourceLocation D, SourceLocation L,
+ CXXConstructorDecl *Target, Expr *Init, SourceLocation R);
+
/// \brief Creates a new member initializer that optionally contains
/// array indices used to describe an elementwise initialization.
static CXXCtorInitializer *Create(ASTContext &Context, FieldDecl *Member,
@@ -1227,6 +1348,12 @@ public:
return Initializee.is<IndirectFieldDecl*>();
}
+ /// isDelegatingInitializer - Returns true when this initializer is creating
+ /// a delegating constructor.
+ bool isDelegatingInitializer() const {
+ return Initializee.is<CXXConstructorDecl *>();
+ }
+
/// \brief Determine whether this initializer is a pack expansion.
bool isPackExpansion() const {
return isBaseInitializer() && MemberOrEllipsisLocation.isValid();
@@ -1284,6 +1411,13 @@ public:
return 0;
}
+ CXXConstructorDecl *getTargetConstructor() const {
+ if (isDelegatingInitializer())
+ return Initializee.get<CXXConstructorDecl*>();
+ else
+ return 0;
+ }
+
SourceLocation getMemberLocation() const {
return MemberOrEllipsisLocation;
}
@@ -1373,12 +1507,13 @@ class CXXConstructorDecl : public CXXMethodDecl {
CXXCtorInitializer **CtorInitializers;
unsigned NumCtorInitializers;
- CXXConstructorDecl(CXXRecordDecl *RD, const DeclarationNameInfo &NameInfo,
+ CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation StartLoc,
+ const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
bool isExplicitSpecified, bool isInline,
bool isImplicitlyDeclared)
- : CXXMethodDecl(CXXConstructor, RD, NameInfo, T, TInfo, false,
- SC_None, isInline),
+ : CXXMethodDecl(CXXConstructor, RD, StartLoc, NameInfo, T, TInfo, false,
+ SC_None, isInline, SourceLocation()),
IsExplicitSpecified(isExplicitSpecified), ImplicitlyDefined(false),
CtorInitializers(0), NumCtorInitializers(0) {
setImplicit(isImplicitlyDeclared);
@@ -1387,6 +1522,7 @@ class CXXConstructorDecl : public CXXMethodDecl {
public:
static CXXConstructorDecl *Create(ASTContext &C, EmptyShell Empty);
static CXXConstructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
+ SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
bool isExplicit,
@@ -1472,6 +1608,23 @@ public:
void setCtorInitializers(CXXCtorInitializer ** initializers) {
CtorInitializers = initializers;
}
+
+ /// isDelegatingConstructor - Whether this constructor is a
+ /// delegating constructor
+ bool isDelegatingConstructor() const {
+ return (getNumCtorInitializers() == 1) &&
+ CtorInitializers[0]->isDelegatingInitializer();
+ }
+
+ /// getTargetConstructor - When this constructor delegates to
+ /// another, retrieve the target
+ CXXConstructorDecl *getTargetConstructor() const {
+ if (isDelegatingConstructor())
+ return CtorInitializers[0]->getTargetConstructor();
+ else
+ return 0;
+ }
+
/// isDefaultConstructor - Whether this constructor is a default
/// constructor (C++ [class.ctor]p5), which can be used to
/// default-initialize a class of this type.
@@ -1508,8 +1661,11 @@ public:
/// \brief Determine whether this constructor is a move constructor
/// (C++0x [class.copy]p3), which can be used to move values of the class.
- bool isMoveConstructor() const;
-
+ bool isMoveConstructor() const {
+ unsigned TypeQuals = 0;
+ return isMoveConstructor(TypeQuals);
+ }
+
/// \brief Determine whether this is a copy or move constructor.
///
/// \param TypeQuals Will be set to the type qualifiers on the reference
@@ -1567,11 +1723,12 @@ class CXXDestructorDecl : public CXXMethodDecl {
FunctionDecl *OperatorDelete;
- CXXDestructorDecl(CXXRecordDecl *RD, const DeclarationNameInfo &NameInfo,
+ CXXDestructorDecl(CXXRecordDecl *RD, SourceLocation StartLoc,
+ const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
bool isInline, bool isImplicitlyDeclared)
- : CXXMethodDecl(CXXDestructor, RD, NameInfo, T, TInfo, false,
- SC_None, isInline),
+ : CXXMethodDecl(CXXDestructor, RD, StartLoc, NameInfo, T, TInfo, false,
+ SC_None, isInline, SourceLocation()),
ImplicitlyDefined(false), OperatorDelete(0) {
setImplicit(isImplicitlyDeclared);
}
@@ -1579,6 +1736,7 @@ class CXXDestructorDecl : public CXXMethodDecl {
public:
static CXXDestructorDecl *Create(ASTContext& C, EmptyShell Empty);
static CXXDestructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
+ SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo* TInfo,
bool isInline,
@@ -1629,19 +1787,23 @@ class CXXConversionDecl : public CXXMethodDecl {
/// explicitly wrote a cast. This is a C++0x feature.
bool IsExplicitSpecified : 1;
- CXXConversionDecl(CXXRecordDecl *RD, const DeclarationNameInfo &NameInfo,
+ CXXConversionDecl(CXXRecordDecl *RD, SourceLocation StartLoc,
+ const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
- bool isInline, bool isExplicitSpecified)
- : CXXMethodDecl(CXXConversion, RD, NameInfo, T, TInfo, false,
- SC_None, isInline),
+ bool isInline, bool isExplicitSpecified,
+ SourceLocation EndLocation)
+ : CXXMethodDecl(CXXConversion, RD, StartLoc, NameInfo, T, TInfo, false,
+ SC_None, isInline, EndLocation),
IsExplicitSpecified(isExplicitSpecified) { }
public:
static CXXConversionDecl *Create(ASTContext &C, EmptyShell Empty);
static CXXConversionDecl *Create(ASTContext &C, CXXRecordDecl *RD,
+ SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
- bool isInline, bool isExplicit);
+ bool isInline, bool isExplicit,
+ SourceLocation EndLocation);
/// IsExplicitSpecified - Whether this conversion function declaration is
/// marked "explicit", meaning that it can only be applied when the user
@@ -1688,33 +1850,48 @@ public:
private:
/// Language - The language for this linkage specification.
LanguageIDs Language;
+ /// ExternLoc - The source location for the extern keyword.
+ SourceLocation ExternLoc;
+ /// RBraceLoc - The source location for the right brace (if valid).
+ SourceLocation RBraceLoc;
- /// HadBraces - Whether this linkage specification had curly braces or not.
- bool HadBraces : 1;
-
- LinkageSpecDecl(DeclContext *DC, SourceLocation L, LanguageIDs lang,
- bool Braces)
- : Decl(LinkageSpec, DC, L),
- DeclContext(LinkageSpec), Language(lang), HadBraces(Braces) { }
+ LinkageSpecDecl(DeclContext *DC, SourceLocation ExternLoc,
+ SourceLocation LangLoc, LanguageIDs lang,
+ SourceLocation RBLoc)
+ : Decl(LinkageSpec, DC, LangLoc), DeclContext(LinkageSpec),
+ Language(lang), ExternLoc(ExternLoc), RBraceLoc(RBLoc) { }
public:
static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, LanguageIDs Lang,
- bool Braces);
+ SourceLocation ExternLoc,
+ SourceLocation LangLoc, LanguageIDs Lang,
+ SourceLocation RBraceLoc = SourceLocation());
/// \brief Return the language specified by this linkage specification.
LanguageIDs getLanguage() const { return Language; }
-
/// \brief Set the language specified by this linkage specification.
void setLanguage(LanguageIDs L) { Language = L; }
/// \brief Determines whether this linkage specification had braces in
/// its syntactic form.
- bool hasBraces() const { return HadBraces; }
+ bool hasBraces() const { return RBraceLoc.isValid(); }
- /// \brief Set whether this linkage specification has braces in its
- /// syntactic form.
- void setHasBraces(bool B) { HadBraces = B; }
+ SourceLocation getExternLoc() const { return ExternLoc; }
+ SourceLocation getRBraceLoc() const { return RBraceLoc; }
+ void setExternLoc(SourceLocation L) { ExternLoc = L; }
+ void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
+
+ SourceLocation getLocEnd() const {
+ if (hasBraces())
+ return getRBraceLoc();
+ // No braces: get the end location of the (only) declaration in context
+ // (if present).
+ return decls_empty() ? getLocation() : decls_begin()->getLocEnd();
+ }
+
+ SourceRange getSourceRange() const {
+ return SourceRange(ExternLoc, getLocEnd());
+ }
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const LinkageSpecDecl *D) { return true; }
@@ -2023,12 +2200,6 @@ public:
return QualifierLoc.getNestedNameSpecifier();
}
- /// \brief Retrieve the source range of the nested-name-specifier
- /// that qualifies the name.
- SourceRange getQualifierRange() const {
- return QualifierLoc.getSourceRange();
- }
-
DeclarationNameInfo getNameInfo() const {
return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
}
@@ -2154,12 +2325,6 @@ public:
return QualifierLoc.getNestedNameSpecifier();
}
- /// \brief Retrieve the source range of the nested-name-specifier
- /// that qualifies the name.
- SourceRange getQualifierRange() const {
- return QualifierLoc.getSourceRange();
- }
-
DeclarationNameInfo getNameInfo() const {
return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
}
@@ -2205,15 +2370,15 @@ class UnresolvedUsingTypenameDecl : public TypeDecl {
NestedNameSpecifierLoc QualifierLoc,
SourceLocation TargetNameLoc,
IdentifierInfo *TargetName)
- : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName),
- UsingLocation(UsingLoc), TypenameLocation(TypenameLoc),
- QualifierLoc(QualifierLoc) { }
+ : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName,
+ UsingLoc),
+ TypenameLocation(TypenameLoc), QualifierLoc(QualifierLoc) { }
friend class ASTDeclReader;
public:
/// \brief Returns the source location of the 'using' keyword.
- SourceLocation getUsingLoc() const { return UsingLocation; }
+ SourceLocation getUsingLoc() const { return getLocStart(); }
/// \brief Returns the source location of the 'typename' keyword.
SourceLocation getTypenameLoc() const { return TypenameLocation; }
@@ -2227,22 +2392,11 @@ public:
return QualifierLoc.getNestedNameSpecifier();
}
- /// \brief Retrieve the source range of the nested-name-specifier
- /// that qualifies the name.
- SourceRange getQualifierRange() const {
- return QualifierLoc.getSourceRange();
- }
-
- // FIXME: DeclarationNameInfo
static UnresolvedUsingTypenameDecl *
Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc,
SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc,
SourceLocation TargetNameLoc, DeclarationName TargetName);
- SourceRange getSourceRange() const {
- return SourceRange(UsingLocation, getLocation());
- }
-
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const UnresolvedUsingTypenameDecl *D) { return true; }
static bool classofKind(Kind K) { return K == UnresolvedUsingTypename; }
@@ -2252,15 +2406,19 @@ public:
class StaticAssertDecl : public Decl {
Expr *AssertExpr;
StringLiteral *Message;
+ SourceLocation RParenLoc;
- StaticAssertDecl(DeclContext *DC, SourceLocation L,
- Expr *assertexpr, StringLiteral *message)
- : Decl(StaticAssert, DC, L), AssertExpr(assertexpr), Message(message) { }
+ StaticAssertDecl(DeclContext *DC, SourceLocation StaticAssertLoc,
+ Expr *assertexpr, StringLiteral *message,
+ SourceLocation RParenLoc)
+ : Decl(StaticAssert, DC, StaticAssertLoc), AssertExpr(assertexpr),
+ Message(message), RParenLoc(RParenLoc) { }
public:
static StaticAssertDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, Expr *AssertExpr,
- StringLiteral *Message);
+ SourceLocation StaticAssertLoc,
+ Expr *AssertExpr, StringLiteral *Message,
+ SourceLocation RParenLoc);
Expr *getAssertExpr() { return AssertExpr; }
const Expr *getAssertExpr() const { return AssertExpr; }
@@ -2268,6 +2426,13 @@ public:
StringLiteral *getMessage() { return Message; }
const StringLiteral *getMessage() const { return Message; }
+ SourceLocation getRParenLoc() const { return RParenLoc; }
+ void setRParenLoc(SourceLocation L) { RParenLoc = L; }
+
+ SourceRange getSourceRange() const {
+ return SourceRange(getLocation(), getRParenLoc());
+ }
+
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(StaticAssertDecl *D) { return true; }
static bool classofKind(Kind K) { return K == StaticAssert; }
diff --git a/include/clang/AST/DeclFriend.h b/include/clang/AST/DeclFriend.h
index 20d6da19b8ca..b84e5bba86b7 100644
--- a/include/clang/AST/DeclFriend.h
+++ b/include/clang/AST/DeclFriend.h
@@ -98,6 +98,17 @@ public:
return FriendLoc;
}
+ /// Retrieves the source range for the friend declaration.
+ SourceRange getSourceRange() const {
+ /* FIXME: consider the case of templates wrt start of range. */
+ if (NamedDecl *ND = getFriendDecl())
+ return SourceRange(getFriendLoc(), ND->getLocEnd());
+ else if (TypeSourceInfo *TInfo = getFriendType())
+ return SourceRange(getFriendLoc(), TInfo->getTypeLoc().getEndLoc());
+ else
+ return SourceRange(getFriendLoc(), getLocation());
+ }
+
/// Determines if this friend kind is unsupported.
bool isUnsupportedFriend() const {
return UnsupportedFriend;
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index b3ca474fcc19..0a4d864cd867 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -112,17 +112,20 @@ class ObjCMethodDecl : public NamedDecl, public DeclContext {
public:
enum ImplementationControl { None, Required, Optional };
private:
- /// Bitfields must be first fields in this class so they pack with those
- /// declared in class Decl.
+ // The conventional meaning of this method; an ObjCMethodFamily.
+ // This is not serialized; instead, it is computed on demand and
+ // cached.
+ mutable unsigned Family : ObjCMethodFamilyBitWidth;
+
/// instance (true) or class (false) method.
- bool IsInstance : 1;
- bool IsVariadic : 1;
+ unsigned IsInstance : 1;
+ unsigned IsVariadic : 1;
// Synthesized declaration method for a property setter/getter
- bool IsSynthesized : 1;
+ unsigned IsSynthesized : 1;
// Method has a definition.
- bool IsDefined : 1;
+ unsigned IsDefined : 1;
// NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
/// @required/@optional
@@ -170,7 +173,7 @@ private:
ImplementationControl impControl = None,
unsigned numSelectorArgs = 0)
: NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
- DeclContext(ObjCMethod),
+ DeclContext(ObjCMethod), Family(InvalidObjCMethodFamily),
IsInstance(isInstance), IsVariadic(isVariadic),
IsSynthesized(isSynthesized),
IsDefined(isDefined),
@@ -279,6 +282,9 @@ public:
ImplicitParamDecl * getCmdDecl() const { return CmdDecl; }
void setCmdDecl(ImplicitParamDecl *CD) { CmdDecl = CD; }
+ /// Determines the family of this method.
+ ObjCMethodFamily getMethodFamily() const;
+
bool isInstanceMethod() const { return IsInstance; }
void setInstanceMethod(bool isInst) { IsInstance = isInst; }
bool isVariadic() const { return IsVariadic; }
@@ -453,7 +459,7 @@ class ObjCInterfaceDecl : public ObjCContainerDecl {
///
/// Categories are stored as a linked list in the AST, since the categories
/// and class extensions come long after the initial interface declaration,
- /// and we avoid dynamically-resized arrays in the AST whereever possible.
+ /// and we avoid dynamically-resized arrays in the AST wherever possible.
ObjCCategoryDecl *CategoryList;
/// IvarList - List of all ivars defined by this class; including class
@@ -701,15 +707,18 @@ public:
};
private:
- ObjCIvarDecl(ObjCContainerDecl *DC, SourceLocation L, IdentifierInfo *Id,
+ ObjCIvarDecl(ObjCContainerDecl *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id,
QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW,
bool synthesized)
- : FieldDecl(ObjCIvar, DC, L, Id, T, TInfo, BW, /*Mutable=*/false),
- NextIvar(0), DeclAccess(ac), Synthesized(synthesized) {}
+ : FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW,
+ /*Mutable=*/false),
+ NextIvar(0), DeclAccess(ac), Synthesized(synthesized) {}
public:
static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC,
- SourceLocation L, IdentifierInfo *Id, QualType T,
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, QualType T,
TypeSourceInfo *TInfo,
AccessControl ac, Expr *BW = NULL,
bool synthesized=false);
@@ -753,17 +762,18 @@ private:
/// @defs(...).
class ObjCAtDefsFieldDecl : public FieldDecl {
private:
- ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
+ ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id,
QualType T, Expr *BW)
- : FieldDecl(ObjCAtDefsField, DC, L, Id, T,
+ : FieldDecl(ObjCAtDefsField, DC, StartLoc, IdLoc, Id, T,
/*TInfo=*/0, // FIXME: Do ObjCAtDefs have declarators ?
BW, /*Mutable=*/false) {}
public:
static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L,
- IdentifierInfo *Id, QualType T,
- Expr *BW);
+ SourceLocation StartLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id,
+ QualType T, Expr *BW);
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@@ -773,7 +783,7 @@ public:
/// ObjCProtocolDecl - Represents a protocol declaration. ObjC protocols
/// declare a pure abstract type (i.e no instance variables are permitted).
-/// Protocols orginally drew inspiration from C++ pure virtual functions (a C++
+/// Protocols originally drew inspiration from C++ pure virtual functions (a C++
/// feature with nice semantics and lousy syntax:-). Here is an example:
///
/// @protocol NSDraggingInfo <refproto1, refproto2>
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index f41859c85790..ddbe344cdffd 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -771,9 +771,20 @@ protected:
/// \brief Data that is common to all of the declarations of a given
/// function template.
struct Common : CommonBase {
+ Common() : InjectedArgs(0) { }
+
/// \brief The function template specializations for this function
/// template, including explicit specializations and instantiations.
llvm::FoldingSet<FunctionTemplateSpecializationInfo> Specializations;
+
+ /// \brief The set of "injected" template arguments used within this
+ /// function template.
+ ///
+ /// This pointer refers to the template arguments (there are as
+ /// many template arguments as template parameaters) for the function
+ /// template, and is allocated lazily, since most function templates do not
+ /// require the use of this information.
+ TemplateArgument *InjectedArgs;
};
FunctionTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name,
@@ -793,6 +804,13 @@ protected:
llvm::FoldingSet<FunctionTemplateSpecializationInfo> &getSpecializations() {
return getCommonPtr()->Specializations;
}
+
+ /// \brief Add a specialization of this function template.
+ ///
+ /// \param InsertPos Insert position in the FoldingSet, must have been
+ /// retrieved by an earlier call to findSpecialization().
+ void addSpecialization(FunctionTemplateSpecializationInfo* Info,
+ void *InsertPos);
public:
/// Get the underlying function declaration of the template.
@@ -844,13 +862,25 @@ public:
return makeSpecIterator(getSpecializations(), true);
}
- /// Create a template function node.
+ /// \brief Retrieve the "injected" template arguments that correspond to the
+ /// template parameters of this function template.
+ ///
+ /// Although the C++ standard has no notion of the "injected" template
+ /// arguments for a function template, the notion is convenient when
+ /// we need to perform substitutions inside the definition of a function
+ /// template.
+ std::pair<const TemplateArgument *, unsigned> getInjectedTemplateArgs();
+
+ /// \brief Create a function template node.
static FunctionTemplateDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
DeclarationName Name,
TemplateParameterList *Params,
NamedDecl *Decl);
+ /// \brief Create an empty function template node.
+ static FunctionTemplateDecl *Create(ASTContext &C, EmptyShell);
+
// Implement isa/cast/dyncast support
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const FunctionTemplateDecl *D) { return true; }
@@ -915,25 +945,23 @@ class TemplateTypeParmDecl : public TypeDecl {
/// default argument.
bool InheritedDefault : 1;
- /// \brief Whether this is a parameter pack.
- bool ParameterPack : 1;
-
/// \brief The default template argument, if any.
TypeSourceInfo *DefaultArgument;
- TemplateTypeParmDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
- bool Typename, QualType Type, bool ParameterPack)
- : TypeDecl(TemplateTypeParm, DC, L, Id), Typename(Typename),
- InheritedDefault(false), ParameterPack(ParameterPack), DefaultArgument() {
- TypeForDecl = Type.getTypePtrOrNull();
- }
+ TemplateTypeParmDecl(DeclContext *DC, SourceLocation KeyLoc,
+ SourceLocation IdLoc, IdentifierInfo *Id,
+ bool Typename)
+ : TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename),
+ InheritedDefault(false), DefaultArgument() { }
/// Sema creates these on the stack during auto type deduction.
friend class Sema;
public:
static TemplateTypeParmDecl *Create(const ASTContext &C, DeclContext *DC,
- SourceLocation L, unsigned D, unsigned P,
+ SourceLocation KeyLoc,
+ SourceLocation NameLoc,
+ unsigned D, unsigned P,
IdentifierInfo *Id, bool Typename,
bool ParameterPack);
static TemplateTypeParmDecl *Create(const ASTContext &C, EmptyShell Empty);
@@ -978,9 +1006,6 @@ public:
/// the 'typename' or 'class' keyword.
void setDeclaredWithTypename(bool withTypename) { Typename = withTypename; }
- /// \brief Set whether this is a parameter pack.
- void setParameterPack(bool isParamPack) { ParameterPack = isParamPack; }
-
/// \brief Retrieve the depth of the template parameter.
unsigned getDepth() const;
@@ -988,7 +1013,9 @@ public:
unsigned getIndex() const;
/// \brief Returns whether this is a parameter pack.
- bool isParameterPack() const { return ParameterPack; }
+ bool isParameterPack() const;
+
+ SourceRange getSourceRange() const;
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@@ -1021,17 +1048,19 @@ class NonTypeTemplateParmDecl
/// \brief The number of types in an expanded parameter pack.
unsigned NumExpandedTypes;
- NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D,
- unsigned P, IdentifierInfo *Id, QualType T,
+ NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, unsigned D, unsigned P,
+ IdentifierInfo *Id, QualType T,
bool ParameterPack, TypeSourceInfo *TInfo)
- : DeclaratorDecl(NonTypeTemplateParm, DC, L, Id, T, TInfo),
+ : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
TemplateParmPosition(D, P), DefaultArgumentAndInherited(0, false),
ParameterPack(ParameterPack), ExpandedParameterPack(false),
NumExpandedTypes(0)
{ }
- NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D,
- unsigned P, IdentifierInfo *Id, QualType T,
+ NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, unsigned D, unsigned P,
+ IdentifierInfo *Id, QualType T,
TypeSourceInfo *TInfo,
const QualType *ExpandedTypes,
unsigned NumExpandedTypes,
@@ -1041,13 +1070,14 @@ class NonTypeTemplateParmDecl
public:
static NonTypeTemplateParmDecl *
- Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D,
- unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack,
- TypeSourceInfo *TInfo);
+ Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id,
+ QualType T, bool ParameterPack, TypeSourceInfo *TInfo);
static NonTypeTemplateParmDecl *
- Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D,
- unsigned P, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo,
+ Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id,
+ QualType T, TypeSourceInfo *TInfo,
const QualType *ExpandedTypes, unsigned NumExpandedTypes,
TypeSourceInfo **ExpandedTInfos);
@@ -1057,7 +1087,6 @@ public:
using TemplateParmPosition::setPosition;
using TemplateParmPosition::getIndex;
- SourceLocation getInnerLocStart() const;
SourceRange getSourceRange() const;
/// \brief Determine whether this template parameter has a default
@@ -1316,7 +1345,8 @@ class ClassTemplateSpecializationDecl
protected:
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK,
- DeclContext *DC, SourceLocation L,
+ DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc,
ClassTemplateDecl *SpecializedTemplate,
const TemplateArgument *Args,
unsigned NumArgs,
@@ -1326,7 +1356,8 @@ protected:
public:
static ClassTemplateSpecializationDecl *
- Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation L,
+ Create(ASTContext &Context, TagKind TK, DeclContext *DC,
+ SourceLocation StartLoc, SourceLocation IdLoc,
ClassTemplateDecl *SpecializedTemplate,
const TemplateArgument *Args,
unsigned NumArgs,
@@ -1488,7 +1519,7 @@ public:
return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
}
- SourceLocation getInnerLocStart() const { return getTemplateKeywordLoc(); }
+ SourceRange getSourceRange() const;
void Profile(llvm::FoldingSetNodeID &ID) const {
Profile(ID, TemplateArgs->data(), TemplateArgs->size(), getASTContext());
@@ -1544,7 +1575,9 @@ class ClassTemplatePartialSpecializationDecl
InstantiatedFromMember;
ClassTemplatePartialSpecializationDecl(ASTContext &Context, TagKind TK,
- DeclContext *DC, SourceLocation L,
+ DeclContext *DC,
+ SourceLocation StartLoc,
+ SourceLocation IdLoc,
TemplateParameterList *Params,
ClassTemplateDecl *SpecializedTemplate,
const TemplateArgument *Args,
@@ -1552,14 +1585,7 @@ class ClassTemplatePartialSpecializationDecl
TemplateArgumentLoc *ArgInfos,
unsigned NumArgInfos,
ClassTemplatePartialSpecializationDecl *PrevDecl,
- unsigned SequenceNumber)
- : ClassTemplateSpecializationDecl(Context,
- ClassTemplatePartialSpecialization,
- TK, DC, L, SpecializedTemplate,
- Args, NumArgs, PrevDecl),
- TemplateParams(Params), ArgsAsWritten(ArgInfos),
- NumArgsAsWritten(NumArgInfos), SequenceNumber(SequenceNumber),
- InstantiatedFromMember(0, false) { }
+ unsigned SequenceNumber);
ClassTemplatePartialSpecializationDecl()
: ClassTemplateSpecializationDecl(ClassTemplatePartialSpecialization),
@@ -1569,7 +1595,8 @@ class ClassTemplatePartialSpecializationDecl
public:
static ClassTemplatePartialSpecializationDecl *
- Create(ASTContext &Context, TagKind TK,DeclContext *DC, SourceLocation L,
+ Create(ASTContext &Context, TagKind TK,DeclContext *DC,
+ SourceLocation StartLoc, SourceLocation IdLoc,
TemplateParameterList *Params,
ClassTemplateDecl *SpecializedTemplate,
const TemplateArgument *Args,
@@ -1742,6 +1769,10 @@ protected:
TemplateParameterList *Params, NamedDecl *Decl)
: RedeclarableTemplateDecl(ClassTemplate, DC, L, Name, Params, Decl) { }
+ ClassTemplateDecl(EmptyShell Empty)
+ : RedeclarableTemplateDecl(ClassTemplate, 0, SourceLocation(),
+ DeclarationName(), 0, 0) { }
+
CommonBase *newCommon(ASTContext &C);
Common *getCommonPtr() {
@@ -1768,6 +1799,9 @@ public:
NamedDecl *Decl,
ClassTemplateDecl *PrevDecl);
+ /// Create an empty class template node.
+ static ClassTemplateDecl *Create(ASTContext &C, EmptyShell);
+
/// \brief Return the specialization with the provided arguments if it exists,
/// otherwise return the insertion point.
ClassTemplateSpecializationDecl *
diff --git a/include/clang/AST/EvaluatedExprVisitor.h b/include/clang/AST/EvaluatedExprVisitor.h
index 035f57c12ea7..bab1606dcee4 100644
--- a/include/clang/AST/EvaluatedExprVisitor.h
+++ b/include/clang/AST/EvaluatedExprVisitor.h
@@ -37,7 +37,8 @@ public:
// other sub-expressions).
void VisitDeclRefExpr(DeclRefExpr *E) { }
void VisitOffsetOfExpr(OffsetOfExpr *E) { }
- void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { }
+ void VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) { }
+ void VisitExpressionTraitExpr(ExpressionTraitExpr *E) { }
void VisitBlockExpr(BlockExpr *E) { }
void VisitCXXUuidofExpr(CXXUuidofExpr *E) { }
void VisitCXXNoexceptExpr(CXXNoexceptExpr *E) { }
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 95bfad5a16c2..5f2d144eb544 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -21,12 +21,12 @@
#include "clang/AST/OperationKinds.h"
#include "clang/AST/ASTVector.h"
#include "clang/AST/UsuallyTinyPtrVector.h"
+#include "clang/Basic/TypeTraits.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include <cctype>
-#include <vector>
namespace clang {
class ASTContext;
@@ -172,6 +172,7 @@ public:
LV_IncompleteVoidType,
LV_DuplicateVectorComponents,
LV_InvalidExpression,
+ LV_InvalidMessageExpression,
LV_MemberFunction,
LV_SubObjCPropertySetting,
LV_ClassTemporary
@@ -203,6 +204,7 @@ public:
MLV_NoSetterProperty,
MLV_MemberFunction,
MLV_SubObjCPropertySetting,
+ MLV_InvalidMessageExpression,
MLV_ClassTemporary
};
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx,
@@ -218,10 +220,12 @@ public:
CL_XValue,
CL_Function, // Functions cannot be lvalues in C.
CL_Void, // Void cannot be an lvalue in C.
+ CL_AddressableVoid, // Void expression whose address can be taken in C.
CL_DuplicateVectorComponents, // A vector shuffle with dupes.
CL_MemberFunction, // An expression referring to a member function
CL_SubObjCPropertySetting,
CL_ClassTemporary, // A prvalue of class type
+ CL_ObjCMessageRValue, // ObjC message is an rvalue
CL_PRValue // A prvalue for any other reason, of any other type
};
/// \brief The results of modification testing.
@@ -482,6 +486,11 @@ public:
/// \brief Returns true if this expression is a bound member function.
bool isBoundMemberFunction(ASTContext &Ctx) const;
+ /// \brief Given an expression of bound-member type, find the type
+ /// of the member. Returns null if this is an *overloaded* bound
+ /// member expression.
+ static QualType findBoundMemberType(const Expr *expr);
+
/// \brief Result type of CanThrow().
enum CanThrowResult {
CT_Cannot,
@@ -536,6 +545,9 @@ public:
/// temporary object of the given class type.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const;
+ /// \brief Whether this expression is an implicit reference to 'this' in C++.
+ bool isImplicitCXXThis() const;
+
const Expr *IgnoreParens() const {
return const_cast<Expr*>(this)->IgnoreParens();
}
@@ -618,16 +630,6 @@ public:
static bool classof(const OpaqueValueExpr *) { return true; }
};
-/// \brief Represents the qualifier that may precede a C++ name, e.g., the
-/// "std::" in "std::sort".
-struct NameQualifier {
- /// \brief The nested name specifier.
- NestedNameSpecifier *NNS;
-
- /// \brief The source range covered by the nested name specifier.
- SourceRange Range;
-};
-
/// \brief Represents an explicit template argument list in C++, e.g.,
/// the "<int>" in "sort<int>".
struct ExplicitTemplateArgumentList {
@@ -659,95 +661,118 @@ struct ExplicitTemplateArgumentList {
static std::size_t sizeFor(unsigned NumTemplateArgs);
static std::size_t sizeFor(const TemplateArgumentListInfo &List);
};
-
-/// DeclRefExpr - [C99 6.5.1p2] - A reference to a declared variable, function,
-/// enum, etc.
+
+/// \brief A reference to a declared variable, function, enum, etc.
+/// [C99 6.5.1p2]
+///
+/// This encodes all the information about how a declaration is referenced
+/// within an expression.
+///
+/// There are several optional constructs attached to DeclRefExprs only when
+/// they apply in order to conserve memory. These are laid out past the end of
+/// the object, and flags in the DeclRefExprBitfield track whether they exist:
+///
+/// DeclRefExprBits.HasQualifier:
+/// Specifies when this declaration reference expression has a C++
+/// nested-name-specifier.
+/// DeclRefExprBits.HasFoundDecl:
+/// Specifies when this declaration reference expression has a record of
+/// a NamedDecl (different from the referenced ValueDecl) which was found
+/// during name lookup and/or overload resolution.
+/// DeclRefExprBits.HasExplicitTemplateArgs:
+/// Specifies when this declaration reference expression has an explicit
+/// C++ template argument list.
class DeclRefExpr : public Expr {
- enum {
- // Flag on DecoratedD that specifies when this declaration reference
- // expression has a C++ nested-name-specifier.
- HasQualifierFlag = 0x01,
- // Flag on DecoratedD that specifies when this declaration reference
- // expression has an explicit C++ template argument list.
- HasExplicitTemplateArgumentListFlag = 0x02
- };
-
- // DecoratedD - The declaration that we are referencing, plus two bits to
- // indicate whether (1) the declaration's name was explicitly qualified and
- // (2) the declaration's name was followed by an explicit template
- // argument list.
- llvm::PointerIntPair<ValueDecl *, 2> DecoratedD;
+ /// \brief The declaration that we are referencing.
+ ValueDecl *D;
- // Loc - The location of the declaration name itself.
+ /// \brief The location of the declaration name itself.
SourceLocation Loc;
- /// DNLoc - Provides source/type location info for the
- /// declaration name embedded in DecoratedD.
+ /// \brief Provides source/type location info for the declaration name
+ /// embedded in D.
DeclarationNameLoc DNLoc;
- /// \brief Retrieve the qualifier that preceded the declaration name, if any.
- NameQualifier *getNameQualifier() {
- if ((DecoratedD.getInt() & HasQualifierFlag) == 0)
- return 0;
-
- return reinterpret_cast<NameQualifier *> (this + 1);
+ /// \brief Helper to retrieve the optional NestedNameSpecifierLoc.
+ NestedNameSpecifierLoc &getInternalQualifierLoc() {
+ assert(hasQualifier());
+ return *reinterpret_cast<NestedNameSpecifierLoc *>(this + 1);
}
-
- /// \brief Retrieve the qualifier that preceded the member name, if any.
- const NameQualifier *getNameQualifier() const {
- return const_cast<DeclRefExpr *>(this)->getNameQualifier();
+
+ /// \brief Helper to retrieve the optional NestedNameSpecifierLoc.
+ const NestedNameSpecifierLoc &getInternalQualifierLoc() const {
+ return const_cast<DeclRefExpr *>(this)->getInternalQualifierLoc();
}
- DeclRefExpr(NestedNameSpecifier *Qualifier, SourceRange QualifierRange,
- ValueDecl *D, SourceLocation NameLoc,
- const TemplateArgumentListInfo *TemplateArgs,
- QualType T, ExprValueKind VK);
+ /// \brief Test whether there is a distinct FoundDecl attached to the end of
+ /// this DRE.
+ bool hasFoundDecl() const { return DeclRefExprBits.HasFoundDecl; }
- DeclRefExpr(NestedNameSpecifier *Qualifier, SourceRange QualifierRange,
+ /// \brief Helper to retrieve the optional NamedDecl through which this
+ /// reference occured.
+ NamedDecl *&getInternalFoundDecl() {
+ assert(hasFoundDecl());
+ if (hasQualifier())
+ return *reinterpret_cast<NamedDecl **>(&getInternalQualifierLoc() + 1);
+ return *reinterpret_cast<NamedDecl **>(this + 1);
+ }
+
+ /// \brief Helper to retrieve the optional NamedDecl through which this
+ /// reference occured.
+ NamedDecl *getInternalFoundDecl() const {
+ return const_cast<DeclRefExpr *>(this)->getInternalFoundDecl();
+ }
+
+ DeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
ValueDecl *D, const DeclarationNameInfo &NameInfo,
+ NamedDecl *FoundD,
const TemplateArgumentListInfo *TemplateArgs,
QualType T, ExprValueKind VK);
/// \brief Construct an empty declaration reference expression.
explicit DeclRefExpr(EmptyShell Empty)
: Expr(DeclRefExprClass, Empty) { }
-
+
/// \brief Computes the type- and value-dependence flags for this
/// declaration reference expression.
void computeDependence();
public:
- DeclRefExpr(ValueDecl *d, QualType t, ExprValueKind VK, SourceLocation l) :
- Expr(DeclRefExprClass, t, VK, OK_Ordinary, false, false, false),
- DecoratedD(d, 0), Loc(l) {
+ DeclRefExpr(ValueDecl *D, QualType T, ExprValueKind VK, SourceLocation L)
+ : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false),
+ D(D), Loc(L) {
+ DeclRefExprBits.HasQualifier = 0;
+ DeclRefExprBits.HasExplicitTemplateArgs = 0;
+ DeclRefExprBits.HasFoundDecl = 0;
computeDependence();
}
static DeclRefExpr *Create(ASTContext &Context,
- NestedNameSpecifier *Qualifier,
- SourceRange QualifierRange,
+ NestedNameSpecifierLoc QualifierLoc,
ValueDecl *D,
SourceLocation NameLoc,
QualType T, ExprValueKind VK,
+ NamedDecl *FoundD = 0,
const TemplateArgumentListInfo *TemplateArgs = 0);
static DeclRefExpr *Create(ASTContext &Context,
- NestedNameSpecifier *Qualifier,
- SourceRange QualifierRange,
+ NestedNameSpecifierLoc QualifierLoc,
ValueDecl *D,
const DeclarationNameInfo &NameInfo,
QualType T, ExprValueKind VK,
+ NamedDecl *FoundD = 0,
const TemplateArgumentListInfo *TemplateArgs = 0);
/// \brief Construct an empty declaration reference expression.
static DeclRefExpr *CreateEmpty(ASTContext &Context,
- bool HasQualifier,
+ bool HasQualifier,
+ bool HasFoundDecl,
bool HasExplicitTemplateArgs,
unsigned NumTemplateArgs);
-
- ValueDecl *getDecl() { return DecoratedD.getPointer(); }
- const ValueDecl *getDecl() const { return DecoratedD.getPointer(); }
- void setDecl(ValueDecl *NewD) { DecoratedD.setPointer(NewD); }
+
+ ValueDecl *getDecl() { return D; }
+ const ValueDecl *getDecl() const { return D; }
+ void setDecl(ValueDecl *NewD) { D = NewD; }
DeclarationNameInfo getNameInfo() const {
return DeclarationNameInfo(getDecl()->getDeclName(), Loc, DNLoc);
@@ -759,43 +784,62 @@ public:
/// \brief Determine whether this declaration reference was preceded by a
/// C++ nested-name-specifier, e.g., \c N::foo.
- bool hasQualifier() const { return DecoratedD.getInt() & HasQualifierFlag; }
-
- /// \brief If the name was qualified, retrieves the source range of
- /// the nested-name-specifier that precedes the name. Otherwise,
- /// returns an empty source range.
- SourceRange getQualifierRange() const {
- if (!hasQualifier())
- return SourceRange();
-
- return getNameQualifier()->Range;
- }
-
- /// \brief If the name was qualified, retrieves the nested-name-specifier
+ bool hasQualifier() const { return DeclRefExprBits.HasQualifier; }
+
+ /// \brief If the name was qualified, retrieves the nested-name-specifier
/// that precedes the name. Otherwise, returns NULL.
NestedNameSpecifier *getQualifier() const {
if (!hasQualifier())
return 0;
-
- return getNameQualifier()->NNS;
+
+ return getInternalQualifierLoc().getNestedNameSpecifier();
}
-
+
+ /// \brief If the name was qualified, retrieves the nested-name-specifier
+ /// that precedes the name, with source-location information.
+ NestedNameSpecifierLoc getQualifierLoc() const {
+ if (!hasQualifier())
+ return NestedNameSpecifierLoc();
+
+ return getInternalQualifierLoc();
+ }
+
+ /// \brief Get the NamedDecl through which this reference occured.
+ ///
+ /// This Decl may be different from the ValueDecl actually referred to in the
+ /// presence of using declarations, etc. It always returns non-NULL, and may
+ /// simple return the ValueDecl when appropriate.
+ NamedDecl *getFoundDecl() {
+ return hasFoundDecl() ? getInternalFoundDecl() : D;
+ }
+
+ /// \brief Get the NamedDecl through which this reference occurred.
+ /// See non-const variant.
+ const NamedDecl *getFoundDecl() const {
+ return hasFoundDecl() ? getInternalFoundDecl() : D;
+ }
+
+ /// \brief Determines whether this declaration reference was followed by an
+ /// explict template argument list.
bool hasExplicitTemplateArgs() const {
- return (DecoratedD.getInt() & HasExplicitTemplateArgumentListFlag);
+ return DeclRefExprBits.HasExplicitTemplateArgs;
}
-
+
/// \brief Retrieve the explicit template argument list that followed the
/// member template name.
ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
assert(hasExplicitTemplateArgs());
+ if (hasFoundDecl())
+ return *reinterpret_cast<ExplicitTemplateArgumentList *>(
+ &getInternalFoundDecl() + 1);
- if ((DecoratedD.getInt() & HasQualifierFlag) == 0)
- return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
-
- return *reinterpret_cast<ExplicitTemplateArgumentList *>(
- getNameQualifier() + 1);
+ if (hasQualifier())
+ return *reinterpret_cast<ExplicitTemplateArgumentList *>(
+ &getInternalQualifierLoc() + 1);
+
+ return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
}
-
+
/// \brief Retrieve the explicit template argument list that followed the
/// member template name.
const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
@@ -809,50 +853,50 @@ public:
if (!hasExplicitTemplateArgs()) return 0;
return &getExplicitTemplateArgs();
}
-
+
/// \brief Copies the template arguments (if present) into the given
/// structure.
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
if (hasExplicitTemplateArgs())
getExplicitTemplateArgs().copyInto(List);
}
-
+
/// \brief Retrieve the location of the left angle bracket following the
/// member name ('<'), if any.
SourceLocation getLAngleLoc() const {
if (!hasExplicitTemplateArgs())
return SourceLocation();
-
+
return getExplicitTemplateArgs().LAngleLoc;
}
-
+
/// \brief Retrieve the template arguments provided as part of this
/// template-id.
const TemplateArgumentLoc *getTemplateArgs() const {
if (!hasExplicitTemplateArgs())
return 0;
-
+
return getExplicitTemplateArgs().getTemplateArgs();
}
-
+
/// \brief Retrieve the number of template arguments provided as part of this
/// template-id.
unsigned getNumTemplateArgs() const {
if (!hasExplicitTemplateArgs())
return 0;
-
+
return getExplicitTemplateArgs().NumTemplateArgs;
}
-
+
/// \brief Retrieve the location of the right angle bracket following the
/// template arguments ('>').
SourceLocation getRAngleLoc() const {
if (!hasExplicitTemplateArgs())
return SourceLocation();
-
+
return getExplicitTemplateArgs().RAngleLoc;
}
-
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == DeclRefExprClass;
}
@@ -860,7 +904,7 @@ public:
// Iterators
child_range children() { return child_range(); }
-
+
friend class ASTStmtReader;
friend class ASTStmtWriter;
};
@@ -1133,9 +1177,12 @@ public:
/// In this case, getByteLength() will return 6, but the string literal will
/// have type "char[2]".
class StringLiteral : public Expr {
+ friend class ASTStmtReader;
+
const char *StrData;
unsigned ByteLength;
bool IsWide;
+ bool IsPascal;
unsigned NumConcatenated;
SourceLocation TokLocs[1];
@@ -1146,14 +1193,15 @@ public:
/// This is the "fully general" constructor that allows representation of
/// strings formed from multiple concatenated tokens.
static StringLiteral *Create(ASTContext &C, const char *StrData,
- unsigned ByteLength, bool Wide, QualType Ty,
+ unsigned ByteLength, bool Wide, bool Pascal,
+ QualType Ty,
const SourceLocation *Loc, unsigned NumStrs);
/// Simple constructor for string literals made from one token.
static StringLiteral *Create(ASTContext &C, const char *StrData,
- unsigned ByteLength,
- bool Wide, QualType Ty, SourceLocation Loc) {
- return Create(C, StrData, ByteLength, Wide, Ty, &Loc, 1);
+ unsigned ByteLength, bool Wide,
+ bool Pascal, QualType Ty, SourceLocation Loc) {
+ return Create(C, StrData, ByteLength, Wide, Pascal, Ty, &Loc, 1);
}
/// \brief Construct an empty string literal.
@@ -1169,8 +1217,8 @@ public:
void setString(ASTContext &C, llvm::StringRef Str);
bool isWide() const { return IsWide; }
- void setWide(bool W) { IsWide = W; }
-
+ bool isPascal() const { return IsPascal; }
+
bool containsNonAsciiOrNull() const {
llvm::StringRef Str = getString();
for (unsigned i = 0, e = Str.size(); i != e; ++i)
@@ -1458,7 +1506,7 @@ public:
/// the square brackets. For a field or identifier node, the source range
/// contains the location of the period (if there is one) and the
/// identifier.
- SourceRange getRange() const { return Range; }
+ SourceRange getSourceRange() const { return Range; }
};
private:
@@ -1556,10 +1604,11 @@ public:
}
};
-/// SizeOfAlignOfExpr - [C99 6.5.3.4] - This is for sizeof/alignof, both of
-/// types and expressions.
-class SizeOfAlignOfExpr : public Expr {
- bool isSizeof : 1; // true if sizeof, false if alignof.
+/// UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated)
+/// expression operand. Used for sizeof/alignof (C99 6.5.3.4) and
+/// vec_step (OpenCL 1.1 6.11.12).
+class UnaryExprOrTypeTraitExpr : public Expr {
+ unsigned Kind : 2;
bool isType : 1; // true if operand is a type, false if an expression
union {
TypeSourceInfo *Ty;
@@ -1568,36 +1617,38 @@ class SizeOfAlignOfExpr : public Expr {
SourceLocation OpLoc, RParenLoc;
public:
- SizeOfAlignOfExpr(bool issizeof, TypeSourceInfo *TInfo,
- QualType resultType, SourceLocation op,
- SourceLocation rp) :
- Expr(SizeOfAlignOfExprClass, resultType, VK_RValue, OK_Ordinary,
+ UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo,
+ QualType resultType, SourceLocation op,
+ SourceLocation rp) :
+ Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, OK_Ordinary,
false, // Never type-dependent (C++ [temp.dep.expr]p3).
// Value-dependent if the argument is type-dependent.
TInfo->getType()->isDependentType(),
TInfo->getType()->containsUnexpandedParameterPack()),
- isSizeof(issizeof), isType(true), OpLoc(op), RParenLoc(rp) {
+ Kind(ExprKind), isType(true), OpLoc(op), RParenLoc(rp) {
Argument.Ty = TInfo;
}
- SizeOfAlignOfExpr(bool issizeof, Expr *E,
- QualType resultType, SourceLocation op,
- SourceLocation rp) :
- Expr(SizeOfAlignOfExprClass, resultType, VK_RValue, OK_Ordinary,
+ UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, Expr *E,
+ QualType resultType, SourceLocation op,
+ SourceLocation rp) :
+ Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, OK_Ordinary,
false, // Never type-dependent (C++ [temp.dep.expr]p3).
// Value-dependent if the argument is type-dependent.
E->isTypeDependent(),
E->containsUnexpandedParameterPack()),
- isSizeof(issizeof), isType(false), OpLoc(op), RParenLoc(rp) {
+ Kind(ExprKind), isType(false), OpLoc(op), RParenLoc(rp) {
Argument.Ex = E;
}
/// \brief Construct an empty sizeof/alignof expression.
- explicit SizeOfAlignOfExpr(EmptyShell Empty)
- : Expr(SizeOfAlignOfExprClass, Empty) { }
+ explicit UnaryExprOrTypeTraitExpr(EmptyShell Empty)
+ : Expr(UnaryExprOrTypeTraitExprClass, Empty) { }
- bool isSizeOf() const { return isSizeof; }
- void setSizeof(bool S) { isSizeof = S; }
+ UnaryExprOrTypeTrait getKind() const {
+ return static_cast<UnaryExprOrTypeTrait>(Kind);
+ }
+ void setKind(UnaryExprOrTypeTrait K) { Kind = K; }
bool isArgumentType() const { return isType; }
QualType getArgumentType() const {
@@ -1612,7 +1663,7 @@ public:
return static_cast<Expr*>(Argument.Ex);
}
const Expr *getArgumentExpr() const {
- return const_cast<SizeOfAlignOfExpr*>(this)->getArgumentExpr();
+ return const_cast<UnaryExprOrTypeTraitExpr*>(this)->getArgumentExpr();
}
void setArgument(Expr *E) { Argument.Ex = E; isType = false; }
@@ -1638,9 +1689,9 @@ public:
}
static bool classof(const Stmt *T) {
- return T->getStmtClass() == SizeOfAlignOfExprClass;
+ return T->getStmtClass() == UnaryExprOrTypeTraitExprClass;
}
- static bool classof(const SizeOfAlignOfExpr *) { return true; }
+ static bool classof(const UnaryExprOrTypeTraitExpr *) { return true; }
// Iterators
child_range children();
@@ -1862,7 +1913,13 @@ public:
///
class MemberExpr : public Expr {
/// Extra data stored in some member expressions.
- struct MemberNameQualifier : public NameQualifier {
+ struct MemberNameQualifier {
+ /// \brief The nested-name-specifier that qualifies the name, including
+ /// source-location information.
+ NestedNameSpecifierLoc QualifierLoc;
+
+ /// \brief The DeclAccessPair through which the MemberDecl was found due to
+ /// name qualifiers.
DeclAccessPair FoundDecl;
};
@@ -1936,7 +1993,7 @@ public:
HasQualifierOrFoundDecl(false), HasExplicitTemplateArgumentList(false) {}
static MemberExpr *Create(ASTContext &C, Expr *base, bool isarrow,
- NestedNameSpecifier *qual, SourceRange qualrange,
+ NestedNameSpecifierLoc QualifierLoc,
ValueDecl *memberdecl, DeclAccessPair founddecl,
DeclarationNameInfo MemberNameInfo,
const TemplateArgumentListInfo *targs,
@@ -1965,16 +2022,6 @@ public:
/// x->Base::foo.
bool hasQualifier() const { return getQualifier() != 0; }
- /// \brief If the member name was qualified, retrieves the source range of
- /// the nested-name-specifier that precedes the member name. Otherwise,
- /// returns an empty source range.
- SourceRange getQualifierRange() const {
- if (!HasQualifierOrFoundDecl)
- return SourceRange();
-
- return getMemberQualifier()->Range;
- }
-
/// \brief If the member name was qualified, retrieves the
/// nested-name-specifier that precedes the member name. Otherwise, returns
/// NULL.
@@ -1982,7 +2029,17 @@ public:
if (!HasQualifierOrFoundDecl)
return 0;
- return getMemberQualifier()->NNS;
+ return getMemberQualifier()->QualifierLoc.getNestedNameSpecifier();
+ }
+
+ /// \brief If the member name was qualified, retrieves the
+ /// nested-name-specifier that precedes the member name, with source-location
+ /// information.
+ NestedNameSpecifierLoc getQualifierLoc() const {
+ if (!hasQualifier())
+ return NestedNameSpecifierLoc();
+
+ return getMemberQualifier()->QualifierLoc;
}
/// \brief Determines whether this member expression actually had a C++
@@ -2075,20 +2132,15 @@ public:
SourceLocation getMemberLoc() const { return MemberLoc; }
void setMemberLoc(SourceLocation L) { MemberLoc = L; }
- SourceRange getSourceRange() const {
- // If we have an implicit base (like a C++ implicit this),
- // make sure not to return its location
- SourceLocation EndLoc = (HasExplicitTemplateArgumentList)
- ? getRAngleLoc() : getMemberNameInfo().getEndLoc();
-
- SourceLocation BaseLoc = getBase()->getLocStart();
- if (BaseLoc.isInvalid())
- return SourceRange(MemberLoc, EndLoc);
- return SourceRange(BaseLoc, EndLoc);
- }
-
+ SourceRange getSourceRange() const;
+
SourceLocation getExprLoc() const { return MemberLoc; }
+ /// \brief Determine whether the base of this explicit is implicit.
+ bool isImplicitAccess() const {
+ return getBase() && getBase()->isImplicitCXXThis();
+ }
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == MemberExprClass;
}
@@ -2234,6 +2286,12 @@ private:
}
CXXBaseSpecifier **path_buffer();
+ void setBasePathSize(unsigned basePathSize) {
+ CastExprBits.BasePathSize = basePathSize;
+ assert(CastExprBits.BasePathSize == basePathSize &&
+ "basePathSize doesn't fit in bits of CastExprBits.BasePathSize!");
+ }
+
protected:
CastExpr(StmtClass SC, QualType ty, ExprValueKind VK,
const CastKind kind, Expr *op, unsigned BasePathSize) :
@@ -2249,14 +2307,14 @@ protected:
Op(op) {
assert(kind != CK_Invalid && "creating cast with invalid cast kind");
CastExprBits.Kind = kind;
- CastExprBits.BasePathSize = BasePathSize;
+ setBasePathSize(BasePathSize);
CheckCastConsistency();
}
/// \brief Construct an empty cast.
CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
: Expr(SC, Empty) {
- CastExprBits.BasePathSize = BasePathSize;
+ setBasePathSize(BasePathSize);
}
public:
@@ -3173,9 +3231,14 @@ class InitListExpr : public Expr {
/// written in the source code.
InitListExpr *SyntacticForm;
- /// If this initializer list initializes a union, specifies which
- /// field within the union will be initialized.
- FieldDecl *UnionFieldInit;
+ /// \brief Either:
+ /// If this initializer list initializes an array with more elements than
+ /// there are initializers in the list, specifies an expression to be used
+ /// for value initialization of the rest of the elements.
+ /// Or
+ /// If this initializer list initializes a union, specifies which
+ /// field within the union will be initialized.
+ llvm::PointerUnion<Expr *, FieldDecl *> ArrayFillerOrUnionFieldInit;
/// Whether this initializer list originally had a GNU array-range
/// designator in it. This is a temporary marker used by CodeGen.
@@ -3227,17 +3290,29 @@ public:
///
/// When @p Init is out of range for this initializer list, the
/// initializer list will be extended with NULL expressions to
- /// accomodate the new entry.
+ /// accommodate the new entry.
Expr *updateInit(ASTContext &C, unsigned Init, Expr *expr);
+ /// \brief If this initializer list initializes an array with more elements
+ /// than there are initializers in the list, specifies an expression to be
+ /// used for value initialization of the rest of the elements.
+ Expr *getArrayFiller() {
+ return ArrayFillerOrUnionFieldInit.dyn_cast<Expr *>();
+ }
+ void setArrayFiller(Expr *filler);
+
/// \brief If this initializes a union, specifies which field in the
/// union to initialize.
///
/// Typically, this field is the first named field within the
/// union. However, a designated initializer can specify the
/// initialization of a different field within the union.
- FieldDecl *getInitializedFieldInUnion() { return UnionFieldInit; }
- void setInitializedFieldInUnion(FieldDecl *FD) { UnionFieldInit = FD; }
+ FieldDecl *getInitializedFieldInUnion() {
+ return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
+ }
+ void setInitializedFieldInUnion(FieldDecl *FD) {
+ ArrayFillerOrUnionFieldInit = FD;
+ }
// Explicit InitListExpr's originate from source code (and have valid source
// locations). Implicit InitListExpr's are created by the semantic analyzer.
@@ -3288,6 +3363,9 @@ public:
const_reverse_iterator rbegin() const { return InitExprs.rbegin(); }
reverse_iterator rend() { return InitExprs.rend(); }
const_reverse_iterator rend() const { return InitExprs.rend(); }
+
+ friend class ASTStmtReader;
+ friend class ASTStmtWriter;
};
/// @brief Represents a C99 designated initializer expression.
@@ -3492,6 +3570,12 @@ public:
else
return getLBracketLoc();
}
+ SourceLocation getEndLocation() const {
+ return Kind == FieldDesignator ? getFieldLoc() : getRBracketLoc();
+ }
+ SourceRange getSourceRange() const {
+ return SourceRange(getStartLocation(), getEndLocation());
+ }
};
static DesignatedInitExpr *Create(ASTContext &C, Designator *Designators,
@@ -3574,6 +3658,8 @@ public:
void ExpandDesignator(ASTContext &C, unsigned Idx, const Designator *First,
const Designator *Last);
+ SourceRange getDesignatorsSourceRange() const;
+
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
@@ -3667,6 +3753,118 @@ public:
};
+/// \brief Represents a C1X generic selection.
+///
+/// A generic selection (C1X 6.5.1.1) contains an unevaluated controlling
+/// expression, followed by one or more generic associations. Each generic
+/// association specifies a type name and an expression, or "default" and an
+/// expression (in which case it is known as a default generic association).
+/// The type and value of the generic selection are identical to those of its
+/// result expression, which is defined as the expression in the generic
+/// association with a type name that is compatible with the type of the
+/// controlling expression, or the expression in the default generic association
+/// if no types are compatible. For example:
+///
+/// @code
+/// _Generic(X, double: 1, float: 2, default: 3)
+/// @endcode
+///
+/// The above expression evaluates to 1 if 1.0 is substituted for X, 2 if 1.0f
+/// or 3 if "hello".
+///
+/// As an extension, generic selections are allowed in C++, where the following
+/// additional semantics apply:
+///
+/// Any generic selection whose controlling expression is type-dependent or
+/// which names a dependent type in its association list is result-dependent,
+/// which means that the choice of result expression is dependent.
+/// Result-dependent generic associations are both type- and value-dependent.
+class GenericSelectionExpr : public Expr {
+ enum { CONTROLLING, END_EXPR };
+ TypeSourceInfo **AssocTypes;
+ Stmt **SubExprs;
+ unsigned NumAssocs, ResultIndex;
+ SourceLocation GenericLoc, DefaultLoc, RParenLoc;
+
+public:
+ GenericSelectionExpr(ASTContext &Context,
+ SourceLocation GenericLoc, Expr *ControllingExpr,
+ TypeSourceInfo **AssocTypes, Expr **AssocExprs,
+ unsigned NumAssocs, SourceLocation DefaultLoc,
+ SourceLocation RParenLoc,
+ bool ContainsUnexpandedParameterPack,
+ unsigned ResultIndex);
+
+ /// This constructor is used in the result-dependent case.
+ GenericSelectionExpr(ASTContext &Context,
+ SourceLocation GenericLoc, Expr *ControllingExpr,
+ TypeSourceInfo **AssocTypes, Expr **AssocExprs,
+ unsigned NumAssocs, SourceLocation DefaultLoc,
+ SourceLocation RParenLoc,
+ bool ContainsUnexpandedParameterPack);
+
+ explicit GenericSelectionExpr(EmptyShell Empty)
+ : Expr(GenericSelectionExprClass, Empty) { }
+
+ unsigned getNumAssocs() const { return NumAssocs; }
+
+ SourceLocation getGenericLoc() const { return GenericLoc; }
+ SourceLocation getDefaultLoc() const { return DefaultLoc; }
+ SourceLocation getRParenLoc() const { return RParenLoc; }
+
+ const Expr *getAssocExpr(unsigned i) const {
+ return cast<Expr>(SubExprs[END_EXPR+i]);
+ }
+ Expr *getAssocExpr(unsigned i) { return cast<Expr>(SubExprs[END_EXPR+i]); }
+
+ const TypeSourceInfo *getAssocTypeSourceInfo(unsigned i) const {
+ return AssocTypes[i];
+ }
+ TypeSourceInfo *getAssocTypeSourceInfo(unsigned i) { return AssocTypes[i]; }
+
+ QualType getAssocType(unsigned i) const {
+ if (const TypeSourceInfo *TS = getAssocTypeSourceInfo(i))
+ return TS->getType();
+ else
+ return QualType();
+ }
+
+ const Expr *getControllingExpr() const {
+ return cast<Expr>(SubExprs[CONTROLLING]);
+ }
+ Expr *getControllingExpr() { return cast<Expr>(SubExprs[CONTROLLING]); }
+
+ /// Whether this generic selection is result-dependent.
+ bool isResultDependent() const { return ResultIndex == -1U; }
+
+ /// The zero-based index of the result expression's generic association in
+ /// the generic selection's association list. Defined only if the
+ /// generic selection is not result-dependent.
+ unsigned getResultIndex() const {
+ assert(!isResultDependent() && "Generic selection is result-dependent");
+ return ResultIndex;
+ }
+
+ /// The generic selection's result expression. Defined only if the
+ /// generic selection is not result-dependent.
+ const Expr *getResultExpr() const { return getAssocExpr(getResultIndex()); }
+ Expr *getResultExpr() { return getAssocExpr(getResultIndex()); }
+
+ SourceRange getSourceRange() const {
+ return SourceRange(GenericLoc, RParenLoc);
+ }
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == GenericSelectionExprClass;
+ }
+ static bool classof(const GenericSelectionExpr *) { return true; }
+
+ child_range children() {
+ return child_range(SubExprs, SubExprs+END_EXPR+NumAssocs);
+ }
+
+ friend class ASTStmtReader;
+};
+
//===----------------------------------------------------------------------===//
// Clang Extensions
//===----------------------------------------------------------------------===//
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index 225db3c11fd0..a97057973745 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -15,6 +15,7 @@
#define LLVM_CLANG_AST_EXPRCXX_H
#include "clang/Basic/TypeTraits.h"
+#include "clang/Basic/ExpressionTraits.h"
#include "clang/AST/Expr.h"
#include "clang/AST/UnresolvedSet.h"
#include "clang/AST/TemplateBase.h"
@@ -99,7 +100,10 @@ public:
/// getImplicitObjectArgument - Retrieves the implicit object
/// argument for the member call. For example, in "x.f(5)", this
/// operation would return "x".
- Expr *getImplicitObjectArgument();
+ Expr *getImplicitObjectArgument() const;
+
+ /// Retrieves the declaration of the called method.
+ CXXMethodDecl *getMethodDecl() const;
/// getRecordDecl - Retrieves the CXXRecordDecl for the underlying type of
/// the implicit object argument. Note that this is may not be the same
@@ -250,6 +254,8 @@ public:
static CXXDynamicCastExpr *CreateEmpty(ASTContext &Context,
unsigned pathSize);
+ bool isAlwaysNull() const;
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXDynamicCastExprClass;
}
@@ -774,7 +780,8 @@ public:
enum ConstructionKind {
CK_Complete,
CK_NonVirtualBase,
- CK_VirtualBase
+ CK_VirtualBase,
+ CK_Delegating
};
private:
@@ -1080,6 +1087,17 @@ public:
TypeSourceInfo *getAllocatedTypeSourceInfo() const {
return AllocatedTypeInfo;
}
+
+ /// \brief True if the allocation result needs to be null-checked.
+ /// C++0x [expr.new]p13:
+ /// If the allocation function returns null, initialization shall
+ /// not be done, the deallocation function shall not be called,
+ /// and the value of the new-expression shall be null.
+ /// An allocation function is not allowed to return null unless it
+ /// has a non-throwing exception-specification. The '03 rule is
+ /// identical except that the definition of a non-throwing
+ /// exception specification is just "is it throw()?".
+ bool shouldNullCheckAllocation(ASTContext &Ctx) const;
FunctionDecl *getOperatorNew() const { return OperatorNew; }
void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
@@ -1577,6 +1595,122 @@ public:
friend class ASTStmtReader;
};
+/// ArrayTypeTraitExpr - An Embarcadero array type trait, as used in the
+/// implementation of __array_rank and __array_extent.
+/// Example:
+/// __array_rank(int[10][20]) == 2
+/// __array_extent(int, 1) == 20
+class ArrayTypeTraitExpr : public Expr {
+ /// ATT - The trait. An ArrayTypeTrait enum in MSVC compat unsigned.
+ unsigned ATT : 2;
+
+ /// The value of the type trait. Unspecified if dependent.
+ uint64_t Value;
+
+ /// The array dimension being queried, or -1 if not used
+ Expr *Dimension;
+
+ /// Loc - The location of the type trait keyword.
+ SourceLocation Loc;
+
+ /// RParen - The location of the closing paren.
+ SourceLocation RParen;
+
+ /// The type being queried.
+ TypeSourceInfo *QueriedType;
+
+public:
+ ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att,
+ TypeSourceInfo *queried, uint64_t value,
+ Expr *dimension, SourceLocation rparen, QualType ty)
+ : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
+ false, queried->getType()->isDependentType(),
+ queried->getType()->containsUnexpandedParameterPack()),
+ ATT(att), Value(value), Dimension(dimension),
+ Loc(loc), RParen(rparen), QueriedType(queried) { }
+
+
+ explicit ArrayTypeTraitExpr(EmptyShell Empty)
+ : Expr(ArrayTypeTraitExprClass, Empty), ATT(0), Value(false),
+ QueriedType() { }
+
+ virtual ~ArrayTypeTraitExpr() { }
+
+ virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen); }
+
+ ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); }
+
+ QualType getQueriedType() const { return QueriedType->getType(); }
+
+ TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
+
+ uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
+
+ Expr *getDimensionExpression() const { return Dimension; }
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ArrayTypeTraitExprClass;
+ }
+ static bool classof(const ArrayTypeTraitExpr *) { return true; }
+
+ // Iterators
+ child_range children() { return child_range(); }
+
+ friend class ASTStmtReader;
+};
+
+/// ExpressionTraitExpr - An expression trait intrinsic
+/// Example:
+/// __is_lvalue_expr(std::cout) == true
+/// __is_lvalue_expr(1) == false
+class ExpressionTraitExpr : public Expr {
+ /// ET - The trait. A ExpressionTrait enum in MSVC compat unsigned.
+ unsigned ET : 31;
+ /// The value of the type trait. Unspecified if dependent.
+ bool Value : 1;
+
+ /// Loc - The location of the type trait keyword.
+ SourceLocation Loc;
+
+ /// RParen - The location of the closing paren.
+ SourceLocation RParen;
+
+ Expr* QueriedExpression;
+public:
+ ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et,
+ Expr *queried, bool value,
+ SourceLocation rparen, QualType resultType)
+ : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary,
+ false, // Not type-dependent
+ // Value-dependent if the argument is type-dependent.
+ queried->isTypeDependent(),
+ queried->containsUnexpandedParameterPack()),
+ ET(et), Value(value), Loc(loc), RParen(rparen), QueriedExpression(queried) { }
+
+ explicit ExpressionTraitExpr(EmptyShell Empty)
+ : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false),
+ QueriedExpression() { }
+
+ SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
+
+ ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
+
+ Expr *getQueriedExpression() const { return QueriedExpression; }
+
+ bool getValue() const { return Value; }
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ExpressionTraitExprClass;
+ }
+ static bool classof(const ExpressionTraitExpr *) { return true; }
+
+ // Iterators
+ child_range children() { return child_range(); }
+
+ friend class ASTStmtReader;
+};
+
+
/// \brief A reference to an overloaded function set, either an
/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
class OverloadExpr : public Expr {
@@ -1590,18 +1724,15 @@ class OverloadExpr : public Expr {
/// The common name of these declarations.
DeclarationNameInfo NameInfo;
- /// The scope specifier, if any.
- NestedNameSpecifier *Qualifier;
-
- /// The source range of the scope specifier.
- SourceRange QualifierRange;
+ /// \brief The nested-name-specifier that qualifies the name, if any.
+ NestedNameSpecifierLoc QualifierLoc;
protected:
/// True if the name was a template-id.
bool HasExplicitTemplateArgs;
OverloadExpr(StmtClass K, ASTContext &C,
- NestedNameSpecifier *Qualifier, SourceRange QRange,
+ NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo,
const TemplateArgumentListInfo *TemplateArgs,
UnresolvedSetIterator Begin, UnresolvedSetIterator End,
@@ -1610,7 +1741,7 @@ protected:
OverloadExpr(StmtClass K, EmptyShell Empty)
: Expr(K, Empty), Results(0), NumResults(0),
- Qualifier(0), HasExplicitTemplateArgs(false) { }
+ QualifierLoc(), HasExplicitTemplateArgs(false) { }
void initializeResults(ASTContext &C,
UnresolvedSetIterator Begin,
@@ -1665,23 +1796,21 @@ public:
/// Gets the full name info.
const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
- void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; }
/// Gets the name looked up.
DeclarationName getName() const { return NameInfo.getName(); }
- void setName(DeclarationName N) { NameInfo.setName(N); }
/// Gets the location of the name.
SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
- void setNameLoc(SourceLocation Loc) { NameInfo.setLoc(Loc); }
/// Fetches the nested-name qualifier, if one was given.
- NestedNameSpecifier *getQualifier() const { return Qualifier; }
- void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
+ NestedNameSpecifier *getQualifier() const {
+ return QualifierLoc.getNestedNameSpecifier();
+ }
- /// Fetches the range of the nested-name qualifier.
- SourceRange getQualifierRange() const { return QualifierRange; }
- void setQualifierRange(SourceRange R) { QualifierRange = R; }
+ /// Fetches the nested-name qualifier with source-location information, if
+ /// one was given.
+ NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
/// \brief Determines whether this expression had an explicit
/// template argument list, e.g. f<int>.
@@ -1727,6 +1856,10 @@ class UnresolvedLookupExpr : public OverloadExpr {
/// call.
bool RequiresADL;
+ /// True if namespace ::std should be considered an associated namespace
+ /// for the purposes of argument-dependent lookup. See C++0x [stmt.ranged]p1.
+ bool StdIsAssociatedNamespace;
+
/// True if these lookup results are overloaded. This is pretty
/// trivially rederivable if we urgently need to kill this field.
bool Overloaded;
@@ -1740,39 +1873,46 @@ class UnresolvedLookupExpr : public OverloadExpr {
UnresolvedLookupExpr(ASTContext &C,
CXXRecordDecl *NamingClass,
- NestedNameSpecifier *Qualifier, SourceRange QRange,
+ NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo,
bool RequiresADL, bool Overloaded,
const TemplateArgumentListInfo *TemplateArgs,
- UnresolvedSetIterator Begin, UnresolvedSetIterator End)
- : OverloadExpr(UnresolvedLookupExprClass, C, Qualifier, QRange, NameInfo,
+ UnresolvedSetIterator Begin, UnresolvedSetIterator End,
+ bool StdIsAssociatedNamespace)
+ : OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, NameInfo,
TemplateArgs, Begin, End),
- RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
+ RequiresADL(RequiresADL),
+ StdIsAssociatedNamespace(StdIsAssociatedNamespace),
+ Overloaded(Overloaded), NamingClass(NamingClass)
{}
UnresolvedLookupExpr(EmptyShell Empty)
: OverloadExpr(UnresolvedLookupExprClass, Empty),
- RequiresADL(false), Overloaded(false), NamingClass(0)
+ RequiresADL(false), StdIsAssociatedNamespace(false), Overloaded(false),
+ NamingClass(0)
{}
+ friend class ASTStmtReader;
+
public:
static UnresolvedLookupExpr *Create(ASTContext &C,
CXXRecordDecl *NamingClass,
- NestedNameSpecifier *Qualifier,
- SourceRange QualifierRange,
+ NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo,
bool ADL, bool Overloaded,
UnresolvedSetIterator Begin,
- UnresolvedSetIterator End) {
- return new(C) UnresolvedLookupExpr(C, NamingClass, Qualifier,
- QualifierRange, NameInfo, ADL,
- Overloaded, 0, Begin, End);
+ UnresolvedSetIterator End,
+ bool StdIsAssociatedNamespace = false) {
+ assert((ADL || !StdIsAssociatedNamespace) &&
+ "std considered associated namespace when not performing ADL");
+ return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, NameInfo,
+ ADL, Overloaded, 0, Begin, End,
+ StdIsAssociatedNamespace);
}
static UnresolvedLookupExpr *Create(ASTContext &C,
CXXRecordDecl *NamingClass,
- NestedNameSpecifier *Qualifier,
- SourceRange QualifierRange,
+ NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo,
bool ADL,
const TemplateArgumentListInfo &Args,
@@ -1786,17 +1926,18 @@ public:
/// True if this declaration should be extended by
/// argument-dependent lookup.
bool requiresADL() const { return RequiresADL; }
- void setRequiresADL(bool V) { RequiresADL = V; }
+
+ /// True if namespace ::std should be artificially added to the set of
+ /// associated namespaecs for argument-dependent lookup purposes.
+ bool isStdAssociatedNamespace() const { return StdIsAssociatedNamespace; }
/// True if this lookup is overloaded.
bool isOverloaded() const { return Overloaded; }
- void setOverloaded(bool V) { Overloaded = V; }
/// Gets the 'naming class' (in the sense of C++0x
/// [class.access.base]p5) of the lookup. This is the scope
/// that was looked in to find these results.
CXXRecordDecl *getNamingClass() const { return NamingClass; }
- void setNamingClass(CXXRecordDecl *D) { NamingClass = D; }
// Note that, inconsistently with the explicit-template-argument AST
// nodes, users are *forbidden* from calling these methods on objects
@@ -1845,8 +1986,10 @@ public:
SourceRange getSourceRange() const {
SourceRange Range(getNameInfo().getSourceRange());
- if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
- if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
+ if (getQualifierLoc())
+ Range.setBegin(getQualifierLoc().getBeginLoc());
+ if (hasExplicitTemplateArgs())
+ Range.setEnd(getRAngleLoc());
return Range;
}
@@ -2186,16 +2329,13 @@ class CXXDependentScopeMemberExpr : public Expr {
SourceLocation OperatorLoc;
/// \brief The nested-name-specifier that precedes the member name, if any.
- NestedNameSpecifier *Qualifier;
-
- /// \brief The source range covering the nested name specifier.
- SourceRange QualifierRange;
+ NestedNameSpecifierLoc QualifierLoc;
/// \brief In a qualified member access expression such as t->Base::f, this
/// member stores the resolves of name lookup in the context of the member
/// access expression, to be used at instantiation time.
///
- /// FIXME: This member, along with the Qualifier and QualifierRange, could
+ /// FIXME: This member, along with the QualifierLoc, could
/// be stuck into a structure that is optionally allocated at the end of
/// the CXXDependentScopeMemberExpr, to save space in the common case.
NamedDecl *FirstQualifierFoundInScope;
@@ -2208,8 +2348,7 @@ class CXXDependentScopeMemberExpr : public Expr {
CXXDependentScopeMemberExpr(ASTContext &C,
Expr *Base, QualType BaseType, bool IsArrow,
SourceLocation OperatorLoc,
- NestedNameSpecifier *Qualifier,
- SourceRange QualifierRange,
+ NestedNameSpecifierLoc QualifierLoc,
NamedDecl *FirstQualifierFoundInScope,
DeclarationNameInfo MemberNameInfo,
const TemplateArgumentListInfo *TemplateArgs);
@@ -2219,8 +2358,7 @@ public:
Expr *Base, QualType BaseType,
bool IsArrow,
SourceLocation OperatorLoc,
- NestedNameSpecifier *Qualifier,
- SourceRange QualifierRange,
+ NestedNameSpecifierLoc QualifierLoc,
NamedDecl *FirstQualifierFoundInScope,
DeclarationNameInfo MemberNameInfo);
@@ -2228,8 +2366,7 @@ public:
Create(ASTContext &C,
Expr *Base, QualType BaseType, bool IsArrow,
SourceLocation OperatorLoc,
- NestedNameSpecifier *Qualifier,
- SourceRange QualifierRange,
+ NestedNameSpecifierLoc QualifierLoc,
NamedDecl *FirstQualifierFoundInScope,
DeclarationNameInfo MemberNameInfo,
const TemplateArgumentListInfo *TemplateArgs);
@@ -2241,7 +2378,7 @@ public:
/// \brief True if this is an implicit access, i.e. one in which the
/// member being accessed was not written in the source. The source
/// location of the operator is invalid in this case.
- bool isImplicitAccess() const { return Base == 0; }
+ bool isImplicitAccess() const;
/// \brief Retrieve the base object of this member expressions,
/// e.g., the \c x in \c x.m.
@@ -2249,30 +2386,27 @@ public:
assert(!isImplicitAccess());
return cast<Expr>(Base);
}
- void setBase(Expr *E) { Base = E; }
QualType getBaseType() const { return BaseType; }
- void setBaseType(QualType T) { BaseType = T; }
/// \brief Determine whether this member expression used the '->'
/// operator; otherwise, it used the '.' operator.
bool isArrow() const { return IsArrow; }
- void setArrow(bool A) { IsArrow = A; }
/// \brief Retrieve the location of the '->' or '.' operator.
SourceLocation getOperatorLoc() const { return OperatorLoc; }
- void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
/// \brief Retrieve the nested-name-specifier that qualifies the member
/// name.
- NestedNameSpecifier *getQualifier() const { return Qualifier; }
- void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
-
- /// \brief Retrieve the source range covering the nested-name-specifier
- /// that qualifies the member name.
- SourceRange getQualifierRange() const { return QualifierRange; }
- void setQualifierRange(SourceRange R) { QualifierRange = R; }
+ NestedNameSpecifier *getQualifier() const {
+ return QualifierLoc.getNestedNameSpecifier();
+ }
+ /// \brief Retrieve the nested-name-specifier that qualifies the member
+ /// name, with source location information.
+ NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
+
+
/// \brief Retrieve the first part of the nested-name-specifier that was
/// found in the scope of the member access expression when the member access
/// was initially parsed.
@@ -2287,26 +2421,20 @@ public:
NamedDecl *getFirstQualifierFoundInScope() const {
return FirstQualifierFoundInScope;
}
- void setFirstQualifierFoundInScope(NamedDecl *D) {
- FirstQualifierFoundInScope = D;
- }
/// \brief Retrieve the name of the member that this expression
/// refers to.
const DeclarationNameInfo &getMemberNameInfo() const {
return MemberNameInfo;
}
- void setMemberNameInfo(const DeclarationNameInfo &N) { MemberNameInfo = N; }
/// \brief Retrieve the name of the member that this expression
/// refers to.
DeclarationName getMember() const { return MemberNameInfo.getName(); }
- void setMember(DeclarationName N) { MemberNameInfo.setName(N); }
// \brief Retrieve the location of the name of the member that this
// expression refers to.
SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
- void setMemberLoc(SourceLocation L) { MemberNameInfo.setLoc(L); }
/// \brief Determines whether this member expression actually had a C++
/// template argument list explicitly specified, e.g., x.f<int>.
@@ -2376,7 +2504,7 @@ public:
if (!isImplicitAccess())
Range.setBegin(Base->getSourceRange().getBegin());
else if (getQualifier())
- Range.setBegin(getQualifierRange().getBegin());
+ Range.setBegin(getQualifierLoc().getBeginLoc());
else
Range.setBegin(MemberNameInfo.getBeginLoc());
@@ -2438,8 +2566,7 @@ class UnresolvedMemberExpr : public OverloadExpr {
UnresolvedMemberExpr(ASTContext &C, bool HasUnresolvedUsing,
Expr *Base, QualType BaseType, bool IsArrow,
SourceLocation OperatorLoc,
- NestedNameSpecifier *Qualifier,
- SourceRange QualifierRange,
+ NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &MemberNameInfo,
const TemplateArgumentListInfo *TemplateArgs,
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
@@ -2448,13 +2575,14 @@ class UnresolvedMemberExpr : public OverloadExpr {
: OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
HasUnresolvedUsing(false), Base(0) { }
+ friend class ASTStmtReader;
+
public:
static UnresolvedMemberExpr *
Create(ASTContext &C, bool HasUnresolvedUsing,
Expr *Base, QualType BaseType, bool IsArrow,
SourceLocation OperatorLoc,
- NestedNameSpecifier *Qualifier,
- SourceRange QualifierRange,
+ NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &MemberNameInfo,
const TemplateArgumentListInfo *TemplateArgs,
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
@@ -2466,7 +2594,7 @@ public:
/// \brief True if this is an implicit access, i.e. one in which the
/// member being accessed was not written in the source. The source
/// location of the operator is invalid in this case.
- bool isImplicitAccess() const { return Base == 0; }
+ bool isImplicitAccess() const;
/// \brief Retrieve the base object of this member expressions,
/// e.g., the \c x in \c x.m.
@@ -2478,24 +2606,19 @@ public:
assert(!isImplicitAccess());
return cast<Expr>(Base);
}
- void setBase(Expr *E) { Base = E; }
QualType getBaseType() const { return BaseType; }
- void setBaseType(QualType T) { BaseType = T; }
/// \brief Determine whether the lookup results contain an unresolved using
/// declaration.
bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
- void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; }
/// \brief Determine whether this member expression used the '->'
/// operator; otherwise, it used the '.' operator.
bool isArrow() const { return IsArrow; }
- void setArrow(bool A) { IsArrow = A; }
/// \brief Retrieve the location of the '->' or '.' operator.
SourceLocation getOperatorLoc() const { return OperatorLoc; }
- void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
/// \brief Retrieves the naming class of this lookup.
CXXRecordDecl *getNamingClass() const;
@@ -2503,17 +2626,14 @@ public:
/// \brief Retrieve the full name info for the member that this expression
/// refers to.
const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
- void setMemberNameInfo(const DeclarationNameInfo &N) { setNameInfo(N); }
/// \brief Retrieve the name of the member that this expression
/// refers to.
DeclarationName getMemberName() const { return getName(); }
- void setMemberName(DeclarationName N) { setName(N); }
// \brief Retrieve the location of the name of the member that this
// expression refers to.
SourceLocation getMemberLoc() const { return getNameLoc(); }
- void setMemberLoc(SourceLocation L) { setNameLoc(L); }
/// \brief Retrieve the explicit template argument list that followed the
/// member template name.
@@ -2570,8 +2690,8 @@ public:
SourceRange Range = getMemberNameInfo().getSourceRange();
if (!isImplicitAccess())
Range.setBegin(Base->getSourceRange().getBegin());
- else if (getQualifier())
- Range.setBegin(getQualifierRange().getBegin());
+ else if (getQualifierLoc())
+ Range.setBegin(getQualifierLoc().getBeginLoc());
if (hasExplicitTemplateArgs())
Range.setEnd(getRAngleLoc());
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h
index 285efb757bbb..8163923d62d1 100644
--- a/include/clang/AST/ExprObjC.h
+++ b/include/clang/AST/ExprObjC.h
@@ -337,6 +337,39 @@ public:
QualType getSuperReceiverType() const {
return QualType(Receiver.get<const Type*>(), 0);
}
+ QualType getGetterResultType() const {
+ QualType ResultType;
+ if (isExplicitProperty()) {
+ const ObjCPropertyDecl *PDecl = getExplicitProperty();
+ if (const ObjCMethodDecl *Getter = PDecl->getGetterMethodDecl())
+ ResultType = Getter->getResultType();
+ else
+ ResultType = getType();
+ } else {
+ const ObjCMethodDecl *Getter = getImplicitPropertyGetter();
+ ResultType = Getter->getResultType(); // with reference!
+ }
+ return ResultType;
+ }
+
+ QualType getSetterArgType() const {
+ QualType ArgType;
+ if (isImplicitProperty()) {
+ const ObjCMethodDecl *Setter = getImplicitPropertySetter();
+ ObjCMethodDecl::param_iterator P = Setter->param_begin();
+ ArgType = (*P)->getType();
+ } else {
+ if (ObjCPropertyDecl *PDecl = getExplicitProperty())
+ if (const ObjCMethodDecl *Setter = PDecl->getSetterMethodDecl()) {
+ ObjCMethodDecl::param_iterator P = Setter->param_begin();
+ ArgType = (*P)->getType();
+ }
+ if (ArgType.isNull())
+ ArgType = getType();
+ }
+ return ArgType;
+ }
+
ObjCInterfaceDecl *getClassReceiver() const {
return Receiver.get<ObjCInterfaceDecl*>();
}
@@ -741,6 +774,11 @@ public:
SelectorOrMethod = reinterpret_cast<uintptr_t>(MD);
}
+ ObjCMethodFamily getMethodFamily() const {
+ if (HasMethod) return getMethodDecl()->getMethodFamily();
+ return getSelector().getMethodFamily();
+ }
+
/// \brief Return the number of actual arguments in this message,
/// not counting the receiver.
unsigned getNumArgs() const { return NumArgs; }
@@ -808,7 +846,7 @@ public:
};
/// ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
-/// (similiar in spirit to MemberExpr).
+/// (similar in spirit to MemberExpr).
class ObjCIsaExpr : public Expr {
/// Base - the expression for the base object pointer.
Stmt *Base;
diff --git a/include/clang/AST/ExternalASTSource.h b/include/clang/AST/ExternalASTSource.h
index 7b23766b0714..6db233641220 100644
--- a/include/clang/AST/ExternalASTSource.h
+++ b/include/clang/AST/ExternalASTSource.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//
// This file defines the ExternalASTSource interface, which enables
-// construction of AST nodes from some external source.x
+// construction of AST nodes from some external source.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
@@ -16,7 +16,6 @@
#include "clang/AST/DeclBase.h"
#include <cassert>
-#include <vector>
namespace llvm {
template <class T> class SmallVectorImpl;
@@ -26,9 +25,6 @@ namespace clang {
class ASTConsumer;
class CXXBaseSpecifier;
-class Decl;
-class DeclContext;
-class DeclContextLookupResult;
class DeclarationName;
class ExternalSemaSource; // layering violation required for downcasting
class NamedDecl;
@@ -74,17 +70,23 @@ public:
///
/// This method only needs to be implemented if the AST source ever
/// passes back decl sets as VisibleDeclaration objects.
- virtual Decl *GetExternalDecl(uint32_t ID) = 0;
+ ///
+ /// The default implementation of this method is a no-op.
+ virtual Decl *GetExternalDecl(uint32_t ID);
/// \brief Resolve a selector ID into a selector.
///
/// This operation only needs to be implemented if the AST source
/// returns non-zero for GetNumKnownSelectors().
- virtual Selector GetExternalSelector(uint32_t ID) = 0;
+ ///
+ /// The default implementation of this method is a no-op.
+ virtual Selector GetExternalSelector(uint32_t ID);
/// \brief Returns the number of selectors known to the external AST
/// source.
- virtual uint32_t GetNumExternalSelectors() = 0;
+ ///
+ /// The default implementation of this method is a no-op.
+ virtual uint32_t GetNumExternalSelectors();
/// \brief Resolve the offset of a statement in the decl stream into
/// a statement.
@@ -92,21 +94,26 @@ public:
/// This operation is meant to be used via a LazyOffsetPtr. It only
/// needs to be implemented if the AST source uses methods like
/// FunctionDecl::setLazyBody when building decls.
- virtual Stmt *GetExternalDeclStmt(uint64_t Offset) = 0;
+ ///
+ /// The default implementation of this method is a no-op.
+ virtual Stmt *GetExternalDeclStmt(uint64_t Offset);
/// \brief Resolve the offset of a set of C++ base specifiers in the decl
/// stream into an array of specifiers.
- virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset) = 0;
-
+ ///
+ /// The default implementation of this method is a no-op.
+ virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);
+
/// \brief Finds all declarations with the given name in the
/// given context.
///
/// Generally the final step of this method is either to call
/// SetExternalVisibleDeclsForName or to recursively call lookup on
/// the DeclContext after calling SetExternalVisibleDecls.
+ ///
+ /// The default implementation of this method is a no-op.
virtual DeclContextLookupResult
- FindExternalVisibleDeclsByName(const DeclContext *DC,
- DeclarationName Name) = 0;
+ FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name);
/// \brief Deserialize all the visible declarations from external storage.
///
@@ -114,7 +121,9 @@ public:
/// may not have a complete name lookup table. This function deserializes
/// the rest of visible declarations from the external storage and completes
/// the name lookup table of the DeclContext.
- virtual void MaterializeVisibleDecls(const DeclContext *DC) = 0;
+ ///
+ /// The default implementation of this method is a no-op.
+ virtual void MaterializeVisibleDecls(const DeclContext *DC);
/// \brief Finds all declarations lexically contained within the given
/// DeclContext, after applying an optional filter predicate.
@@ -124,9 +133,11 @@ public:
/// are returned.
///
/// \return true if an error occurred
+ ///
+ /// The default implementation of this method is a no-op.
virtual bool FindExternalLexicalDecls(const DeclContext *DC,
bool (*isKindWeWant)(Decl::Kind),
- llvm::SmallVectorImpl<Decl*> &Result) = 0;
+ llvm::SmallVectorImpl<Decl*> &Result);
/// \brief Finds all declarations lexically contained within the given
/// DeclContext.
@@ -154,7 +165,7 @@ public:
/// set on the ObjCInterfaceDecl via the function
/// \c ObjCInterfaceDecl::setExternallyCompleted().
virtual void CompleteType(ObjCInterfaceDecl *Class) { }
-
+
/// \brief Notify ExternalASTSource that we started deserialization of
/// a decl or type so until FinishedDeserializing is called there may be
/// decls that are initializing. Must be paired with FinishedDeserializing.
@@ -179,6 +190,28 @@ public:
///
/// The default implementation of this method is a no-op.
virtual void PrintStats();
+
+ //===--------------------------------------------------------------------===//
+ // Queries for performance analysis.
+ //===--------------------------------------------------------------------===//
+
+ struct MemoryBufferSizes {
+ size_t malloc_bytes;
+ size_t mmap_bytes;
+
+ MemoryBufferSizes(size_t malloc_bytes, size_t mmap_bytes)
+ : malloc_bytes(malloc_bytes), mmap_bytes(mmap_bytes) {}
+ };
+
+ /// Return the amount of memory used by memory buffers, breaking down
+ /// by heap-backed versus mmap'ed memory.
+ MemoryBufferSizes getMemoryBufferSizes() const {
+ MemoryBufferSizes sizes(0, 0);
+ getMemoryBufferSizes(sizes);
+ return sizes;
+ }
+
+ virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const = 0;
protected:
static DeclContextLookupResult
@@ -270,7 +303,7 @@ typedef LazyOffsetPtr<Decl, uint32_t, &ExternalASTSource::GetExternalDecl>
typedef LazyOffsetPtr<CXXBaseSpecifier, uint64_t,
&ExternalASTSource::GetExternalCXXBaseSpecifiers>
LazyCXXBaseSpecifiersPtr;
-
+
} // end namespace clang
#endif // LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
diff --git a/include/clang/AST/NestedNameSpecifier.h b/include/clang/AST/NestedNameSpecifier.h
index 024bf402894b..c21c76b006ff 100644
--- a/include/clang/AST/NestedNameSpecifier.h
+++ b/include/clang/AST/NestedNameSpecifier.h
@@ -312,6 +312,146 @@ public:
}
};
+/// \brief Class that aids in the construction of nested-name-specifiers along
+/// with source-location information for all of the components of the
+/// nested-name-specifier.
+class NestedNameSpecifierLocBuilder {
+ /// \brief The current representation of the nested-name-specifier we're
+ /// building.
+ NestedNameSpecifier *Representation;
+
+ /// \brief Buffer used to store source-location information for the
+ /// nested-name-specifier.
+ ///
+ /// Note that we explicitly manage the buffer (rather than using a
+ /// SmallVector) because \c Declarator expects it to be possible to memcpy()
+ /// a \c CXXScopeSpec, and CXXScopeSpec uses a NestedNameSpecifierLocBuilder.
+ char *Buffer;
+
+ /// \brief The size of the buffer used to store source-location information
+ /// for the nested-name-specifier.
+ unsigned BufferSize;
+
+ /// \brief The capacity of the buffer used to store source-location
+ /// information for the nested-name-specifier.
+ unsigned BufferCapacity;
+
+public:
+ NestedNameSpecifierLocBuilder();
+
+ NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other);
+
+ NestedNameSpecifierLocBuilder &
+ operator=(const NestedNameSpecifierLocBuilder &Other);
+
+ ~NestedNameSpecifierLocBuilder();
+
+ /// \brief Retrieve the representation of the nested-name-specifier.
+ NestedNameSpecifier *getRepresentation() const { return Representation; }
+
+ /// \brief Extend the current nested-name-specifier by another
+ /// nested-name-specifier component of the form 'type::'.
+ ///
+ /// \param Context The AST context in which this nested-name-specifier
+ /// resides.
+ ///
+ /// \param TemplateKWLoc The location of the 'template' keyword, if present.
+ ///
+ /// \param TL The TypeLoc that describes the type preceding the '::'.
+ ///
+ /// \param ColonColonLoc The location of the trailing '::'.
+ void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL,
+ SourceLocation ColonColonLoc);
+
+ /// \brief Extend the current nested-name-specifier by another
+ /// nested-name-specifier component of the form 'identifier::'.
+ ///
+ /// \param Context The AST context in which this nested-name-specifier
+ /// resides.
+ ///
+ /// \param Identifier The identifier.
+ ///
+ /// \param IdentifierLoc The location of the identifier.
+ ///
+ /// \param ColonColonLoc The location of the trailing '::'.
+ void Extend(ASTContext &Context, IdentifierInfo *Identifier,
+ SourceLocation IdentifierLoc, SourceLocation ColonColonLoc);
+
+ /// \brief Extend the current nested-name-specifier by another
+ /// nested-name-specifier component of the form 'namespace::'.
+ ///
+ /// \param Context The AST context in which this nested-name-specifier
+ /// resides.
+ ///
+ /// \param Namespace The namespace.
+ ///
+ /// \param NamespaceLoc The location of the namespace name.
+ ///
+ /// \param ColonColonLoc The location of the trailing '::'.
+ void Extend(ASTContext &Context, NamespaceDecl *Namespace,
+ SourceLocation NamespaceLoc, SourceLocation ColonColonLoc);
+
+ /// \brief Extend the current nested-name-specifier by another
+ /// nested-name-specifier component of the form 'namespace-alias::'.
+ ///
+ /// \param Context The AST context in which this nested-name-specifier
+ /// resides.
+ ///
+ /// \param Alias The namespace alias.
+ ///
+ /// \param AliasLoc The location of the namespace alias
+ /// name.
+ ///
+ /// \param ColonColonLoc The location of the trailing '::'.
+ void Extend(ASTContext &Context, NamespaceAliasDecl *Alias,
+ SourceLocation AliasLoc, SourceLocation ColonColonLoc);
+
+ /// \brief Turn this (empty) nested-name-specifier into the global
+ /// nested-name-specifier '::'.
+ void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc);
+
+ /// \brief Make a new nested-name-specifier from incomplete source-location
+ /// information.
+ ///
+ /// This routine should be used very, very rarely, in cases where we
+ /// need to synthesize a nested-name-specifier. Most code should instead use
+ /// \c Adopt() with a proper \c NestedNameSpecifierLoc.
+ void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier,
+ SourceRange R);
+
+ /// \brief Adopt an existing nested-name-specifier (with source-range
+ /// information).
+ void Adopt(NestedNameSpecifierLoc Other);
+
+ /// \brief Retrieve the source range covered by this nested-name-specifier.
+ SourceRange getSourceRange() const {
+ return NestedNameSpecifierLoc(Representation, Buffer).getSourceRange();
+ }
+
+ /// \brief Retrieve a nested-name-specifier with location information,
+ /// copied into the given AST context.
+ ///
+ /// \param Context The context into which this nested-name-specifier will be
+ /// copied.
+ NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const;
+
+ /// \brief Clear out this builder, and prepare it to build another
+ /// nested-name-specifier with source-location information.
+ void Clear() {
+ Representation = 0;
+ BufferSize = 0;
+ }
+
+ /// \brief Retrieve the underlying buffer.
+ ///
+ /// \returns A pair containing a pointer to the buffer of source-location
+ /// data and the size of the source-location data that resides in that
+ /// buffer.
+ std::pair<char *, unsigned> getBuffer() const {
+ return std::make_pair(Buffer, BufferSize);
+ }
+};
+
/// Insertion operator for diagnostics. This allows sending NestedNameSpecifiers
/// into a diagnostic with <<.
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
diff --git a/include/clang/AST/PrettyPrinter.h b/include/clang/AST/PrettyPrinter.h
index a59c302ffc1e..cf5fadbd1850 100644
--- a/include/clang/AST/PrettyPrinter.h
+++ b/include/clang/AST/PrettyPrinter.h
@@ -38,7 +38,8 @@ struct PrintingPolicy {
/// \brief Create a default printing policy for C.
PrintingPolicy(const LangOptions &LO)
: Indentation(2), LangOpts(LO), SuppressSpecifiers(false),
- SuppressTag(false), SuppressScope(false),
+ SuppressTagKeyword(false), SuppressTag(false), SuppressScope(false),
+ SuppressInitializers(false),
Dump(false), ConstantArraySizeAsWritten(false),
AnonymousTagLocations(true) { }
@@ -64,6 +65,16 @@ struct PrintingPolicy {
/// "const int" type specifier and instead only print the "*y".
bool SuppressSpecifiers : 1;
+ /// \brief Whether type printing should skip printing the tag keyword.
+ ///
+ /// This is used when printing the inner type of elaborated types,
+ /// (as the tag keyword is part of the elaborated type):
+ ///
+ /// \code
+ /// struct Geometry::Point;
+ /// \endcode
+ bool SuppressTagKeyword : 1;
+
/// \brief Whether type printing should skip printing the actual tag type.
///
/// This is used when the caller needs to print a tag definition in front
@@ -77,6 +88,19 @@ struct PrintingPolicy {
/// \brief Suppresses printing of scope specifiers.
bool SuppressScope : 1;
+ /// \brief Suppress printing of variable initializers.
+ ///
+ /// This flag is used when printing the loop variable in a for-range
+ /// statement. For example, given:
+ ///
+ /// \code
+ /// for (auto x : coll)
+ /// \endcode
+ ///
+ /// SuppressInitializers will be true when printing "auto x", so that the
+ /// internal initializer constructed for x will not be printed.
+ bool SuppressInitializers : 1;
+
/// \brief True when we are "dumping" rather than "pretty-printing",
/// where dumping involves printing the internal details of the AST
/// and pretty-printing involves printing something similar to
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index e85b6dcd279a..930d19373cdc 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -600,12 +600,15 @@ bool RecursiveASTVisitor<Derived>::TraverseTemplateArgumentLoc(
// FIXME: how can TSI ever be NULL?
if (TypeSourceInfo *TSI = ArgLoc.getTypeSourceInfo())
return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
- else
- return true;
+ else
+ return getDerived().TraverseType(Arg.getAsType());
}
case TemplateArgument::Template:
case TemplateArgument::TemplateExpansion:
+ if (ArgLoc.getTemplateQualifierLoc())
+ TRY_TO(getDerived().TraverseNestedNameSpecifierLoc(
+ ArgLoc.getTemplateQualifierLoc()));
return getDerived().TraverseTemplateName(
Arg.getAsTemplateOrTemplatePattern());
@@ -933,7 +936,11 @@ DEF_TRAVERSE_TYPELOC(FunctionProtoType, {
const FunctionProtoType *T = TL.getTypePtr();
for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
- TRY_TO(TraverseDecl(TL.getArg(I)));
+ if (TL.getArg(I)) {
+ TRY_TO(TraverseDecl(TL.getArg(I)));
+ } else if (I < T->getNumArgs()) {
+ TRY_TO(TraverseType(T->getArgType(I)));
+ }
}
for (FunctionProtoType::exception_iterator E = T->exception_begin(),
@@ -987,21 +994,22 @@ DEF_TRAVERSE_TYPELOC(AttributedType, {
TRY_TO(TraverseTypeLoc(TL.getModifiedLoc()));
})
-// FIXME: use the sourceloc on qualifier?
DEF_TRAVERSE_TYPELOC(ElaboratedType, {
- if (TL.getTypePtr()->getQualifier()) {
- TRY_TO(TraverseNestedNameSpecifier(TL.getTypePtr()->getQualifier()));
+ if (TL.getQualifierLoc()) {
+ TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
}
TRY_TO(TraverseTypeLoc(TL.getNamedTypeLoc()));
})
-// FIXME: use the sourceloc on qualifier?
DEF_TRAVERSE_TYPELOC(DependentNameType, {
- TRY_TO(TraverseNestedNameSpecifier(TL.getTypePtr()->getQualifier()));
+ TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
})
DEF_TRAVERSE_TYPELOC(DependentTemplateSpecializationType, {
- TRY_TO(TraverseNestedNameSpecifier(TL.getTypePtr()->getQualifier()));
+ if (TL.getQualifierLoc()) {
+ TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
+ }
+
for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
}
@@ -1041,7 +1049,9 @@ bool RecursiveASTVisitor<Derived>::TraverseDeclContextHelper(DeclContext *DC) {
for (DeclContext::decl_iterator Child = DC->decls_begin(),
ChildEnd = DC->decls_end();
Child != ChildEnd; ++Child) {
- TRY_TO(TraverseDecl(*Child));
+ // BlockDecls are traversed through BlockExprs.
+ if (!isa<BlockDecl>(*Child))
+ TRY_TO(TraverseDecl(*Child));
}
return true;
@@ -1060,10 +1070,12 @@ bool RecursiveASTVisitor<Derived>::Traverse##DECL (DECL *D) { \
DEF_TRAVERSE_DECL(AccessSpecDecl, { })
DEF_TRAVERSE_DECL(BlockDecl, {
- // We don't traverse nodes in param_begin()/param_end(), as they
- // appear in decls_begin()/decls_end() and thus are handled by the
- // DEF_TRAVERSE_DECL macro already.
+ TRY_TO(TraverseTypeLoc(D->getSignatureAsWritten()->getTypeLoc()));
TRY_TO(TraverseStmt(D->getBody()));
+ // This return statement makes sure the traversal of nodes in
+ // decls_begin()/decls_end() (done in the DEF_TRAVERSE_DECL macro)
+ // is skipped - don't remove it.
+ return true;
})
DEF_TRAVERSE_DECL(FileScopeAsmDecl, {
@@ -1164,9 +1176,17 @@ DEF_TRAVERSE_DECL(ObjCProtocolDecl, {
})
DEF_TRAVERSE_DECL(ObjCMethodDecl, {
- // We don't traverse nodes in param_begin()/param_end(), as they
- // appear in decls_begin()/decls_end() and thus are handled.
- TRY_TO(TraverseStmt(D->getBody()));
+ if (D->getResultTypeSourceInfo()) {
+ TRY_TO(TraverseTypeLoc(D->getResultTypeSourceInfo()->getTypeLoc()));
+ }
+ for (ObjCMethodDecl::param_iterator
+ I = D->param_begin(), E = D->param_end(); I != E; ++I) {
+ TRY_TO(TraverseDecl(*I));
+ }
+ if (D->isThisDeclarationADefinition()) {
+ TRY_TO(TraverseStmt(D->getBody()));
+ }
+ return true;
})
DEF_TRAVERSE_DECL(ObjCPropertyDecl, {
@@ -1341,6 +1361,13 @@ DEF_TRAVERSE_DECL(TypedefDecl, {
// source.
})
+DEF_TRAVERSE_DECL(TypeAliasDecl, {
+ TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
+ // We shouldn't traverse D->getTypeForDecl(); it's a result of
+ // declaring the type alias, not something that was written in the
+ // source.
+ })
+
DEF_TRAVERSE_DECL(UnresolvedUsingTypenameDecl, {
// A dependent using declaration which was marked with 'typename'.
// template<class T> class A : public B<T> { using typename B<T>::foo; };
@@ -1354,7 +1381,7 @@ DEF_TRAVERSE_DECL(EnumDecl, {
if (D->getTypeForDecl())
TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
- TRY_TO(TraverseNestedNameSpecifier(D->getQualifier()));
+ TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
// The enumerators are already traversed by
// decls_begin()/decls_end().
})
@@ -1367,7 +1394,7 @@ bool RecursiveASTVisitor<Derived>::TraverseRecordHelper(
// We shouldn't traverse D->getTypeForDecl(); it's a result of
// declaring the type, not something that was written in the source.
- TRY_TO(TraverseNestedNameSpecifier(D->getQualifier()));
+ TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
return true;
}
@@ -1464,9 +1491,11 @@ DEF_TRAVERSE_DECL(IndirectFieldDecl, {})
template<typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseDeclaratorHelper(DeclaratorDecl *D) {
- TRY_TO(TraverseNestedNameSpecifier(D->getQualifier()));
+ TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
if (D->getTypeSourceInfo())
TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
+ else
+ TRY_TO(TraverseType(D->getType()));
return true;
}
@@ -1492,7 +1521,7 @@ DEF_TRAVERSE_DECL(ObjCIvarDecl, {
template<typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) {
- TRY_TO(TraverseNestedNameSpecifier(D->getQualifier()));
+ TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
// If we're an explicit template specialization, iterate over the
// template args that were explicitly specified. If we were doing
@@ -1678,13 +1707,14 @@ DEF_TRAVERSE_STMT(ObjCAtSynchronizedStmt, { })
DEF_TRAVERSE_STMT(ObjCAtThrowStmt, { })
DEF_TRAVERSE_STMT(ObjCAtTryStmt, { })
DEF_TRAVERSE_STMT(ObjCForCollectionStmt, { })
+DEF_TRAVERSE_STMT(CXXForRangeStmt, { })
DEF_TRAVERSE_STMT(ReturnStmt, { })
DEF_TRAVERSE_STMT(SwitchStmt, { })
DEF_TRAVERSE_STMT(WhileStmt, { })
DEF_TRAVERSE_STMT(CXXDependentScopeMemberExpr, {
- TRY_TO(TraverseNestedNameSpecifier(S->getQualifier()));
+ TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
if (S->hasExplicitTemplateArgs()) {
TRY_TO(TraverseTemplateArgumentLocsHelper(
S->getTemplateArgs(), S->getNumTemplateArgs()));
@@ -1692,7 +1722,7 @@ DEF_TRAVERSE_STMT(CXXDependentScopeMemberExpr, {
})
DEF_TRAVERSE_STMT(DeclRefExpr, {
- TRY_TO(TraverseNestedNameSpecifier(S->getQualifier()));
+ TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
TRY_TO(TraverseTemplateArgumentLocsHelper(
S->getTemplateArgs(), S->getNumTemplateArgs()));
})
@@ -1707,10 +1737,9 @@ DEF_TRAVERSE_STMT(DependentScopeDeclRefExpr, {
})
DEF_TRAVERSE_STMT(MemberExpr, {
+ TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
TRY_TO(TraverseTemplateArgumentLocsHelper(
S->getTemplateArgs(), S->getNumTemplateArgs()));
- // FIXME: Should we be recursing on the qualifier?
- TRY_TO(TraverseNestedNameSpecifier(S->getQualifier()));
})
DEF_TRAVERSE_STMT(ImplicitCastExpr, {
@@ -1759,6 +1788,22 @@ bool RecursiveASTVisitor<Derived>::TraverseInitListExpr(InitListExpr *S) {
return true;
}
+// GenericSelectionExpr is a special case because the types and expressions
+// are interleaved. We also need to watch out for null types (default
+// generic associations).
+template<typename Derived>
+bool RecursiveASTVisitor<Derived>::
+TraverseGenericSelectionExpr(GenericSelectionExpr *S) {
+ TRY_TO(WalkUpFromGenericSelectionExpr(S));
+ TRY_TO(TraverseStmt(S->getControllingExpr()));
+ for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
+ if (TypeSourceInfo *TS = S->getAssocTypeSourceInfo(i))
+ TRY_TO(TraverseTypeLoc(TS->getTypeLoc()));
+ TRY_TO(TraverseStmt(S->getAssocExpr(i)));
+ }
+ return true;
+}
+
DEF_TRAVERSE_STMT(CXXScalarValueInitExpr, {
// This is called for code like 'return T()' where T is a built-in
// (i.e. non-class) type.
@@ -1778,7 +1823,7 @@ DEF_TRAVERSE_STMT(OffsetOfExpr, {
TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
})
-DEF_TRAVERSE_STMT(SizeOfAlignOfExpr, {
+DEF_TRAVERSE_STMT(UnaryExprOrTypeTraitExpr, {
// The child-iterator will pick up the arg if it's an expression,
// but not if it's a type.
if (S->isArgumentType())
@@ -1808,6 +1853,14 @@ DEF_TRAVERSE_STMT(BinaryTypeTraitExpr, {
TRY_TO(TraverseTypeLoc(S->getRhsTypeSourceInfo()->getTypeLoc()));
})
+DEF_TRAVERSE_STMT(ArrayTypeTraitExpr, {
+ TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
+ })
+
+DEF_TRAVERSE_STMT(ExpressionTraitExpr, {
+ TRY_TO(TraverseStmt(S->getQueriedExpression()));
+ })
+
DEF_TRAVERSE_STMT(VAArgExpr, {
// The child-iterator will pick up the expression argument.
TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
@@ -1834,7 +1887,10 @@ DEF_TRAVERSE_STMT(CXXMemberCallExpr, { })
DEF_TRAVERSE_STMT(AddrLabelExpr, { })
DEF_TRAVERSE_STMT(ArraySubscriptExpr, { })
DEF_TRAVERSE_STMT(BlockDeclRefExpr, { })
-DEF_TRAVERSE_STMT(BlockExpr, { })
+DEF_TRAVERSE_STMT(BlockExpr, {
+ TRY_TO(TraverseDecl(S->getBlockDecl()));
+ return true; // no child statements to loop through.
+})
DEF_TRAVERSE_STMT(ChooseExpr, { })
DEF_TRAVERSE_STMT(CompoundLiteralExpr, { })
DEF_TRAVERSE_STMT(CXXBindTemporaryExpr, { })
@@ -1869,7 +1925,7 @@ DEF_TRAVERSE_STMT(PredefinedExpr, { })
DEF_TRAVERSE_STMT(ShuffleVectorExpr, { })
DEF_TRAVERSE_STMT(StmtExpr, { })
DEF_TRAVERSE_STMT(UnresolvedLookupExpr, {
- TRY_TO(TraverseNestedNameSpecifier(S->getQualifier()));
+ TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
if (S->hasExplicitTemplateArgs()) {
TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
S->getNumTemplateArgs()));
@@ -1877,13 +1933,17 @@ DEF_TRAVERSE_STMT(UnresolvedLookupExpr, {
})
DEF_TRAVERSE_STMT(UnresolvedMemberExpr, {
- TRY_TO(TraverseNestedNameSpecifier(S->getQualifier()));
+ TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
if (S->hasExplicitTemplateArgs()) {
TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
S->getNumTemplateArgs()));
}
})
+DEF_TRAVERSE_STMT(SEHTryStmt, {})
+DEF_TRAVERSE_STMT(SEHExceptStmt, {})
+DEF_TRAVERSE_STMT(SEHFinallyStmt,{})
+
DEF_TRAVERSE_STMT(CXXOperatorCallExpr, { })
DEF_TRAVERSE_STMT(OpaqueValueExpr, { })
DEF_TRAVERSE_STMT(CUDAKernelCallExpr, { })
@@ -1921,7 +1981,7 @@ DEF_TRAVERSE_STMT(ObjCStringLiteral, { })
// Candidates:
//
// http://clang.llvm.org/doxygen/classclang_1_1CXXTypeidExpr.html
-// http://clang.llvm.org/doxygen/classclang_1_1SizeOfAlignOfExpr.html
+// http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
// http://clang.llvm.org/doxygen/classclang_1_1TypesCompatibleExpr.html
// Every class that has getQualifier.
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index d1f7d667f33d..695fb0403ead 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -158,6 +158,16 @@ protected:
};
enum { NumExprBits = 15 };
+ class DeclRefExprBitfields {
+ friend class DeclRefExpr;
+ friend class ASTStmtReader; // deserialization
+ unsigned : NumExprBits;
+
+ unsigned HasQualifier : 1;
+ unsigned HasExplicitTemplateArgs : 1;
+ unsigned HasFoundDecl : 1;
+ };
+
class CastExprBitfields {
friend class CastExpr;
unsigned : NumExprBits;
@@ -180,6 +190,7 @@ protected:
StmtBitfields StmtBits;
CompoundStmtBitfields CompoundStmtBits;
ExprBitfields ExprBits;
+ DeclRefExprBitfields DeclRefExprBits;
CastExprBitfields CastExprBits;
CallExprBitfields CallExprBits;
};
@@ -383,14 +394,15 @@ public:
class NullStmt : public Stmt {
SourceLocation SemiLoc;
- /// \brief Whether the null statement was preceded by an empty macro, e.g:
+ /// \brief If the null statement was preceded by an empty macro this is
+ /// its instantiation source location, e.g:
/// @code
/// #define CALL(x)
/// CALL(0);
/// @endcode
- bool LeadingEmptyMacro;
+ SourceLocation LeadingEmptyMacro;
public:
- NullStmt(SourceLocation L, bool LeadingEmptyMacro = false)
+ NullStmt(SourceLocation L, SourceLocation LeadingEmptyMacro =SourceLocation())
: Stmt(NullStmtClass), SemiLoc(L), LeadingEmptyMacro(LeadingEmptyMacro) {}
/// \brief Build an empty null statement.
@@ -399,7 +411,8 @@ public:
SourceLocation getSemiLoc() const { return SemiLoc; }
void setSemiLoc(SourceLocation L) { SemiLoc = L; }
- bool hasLeadingEmptyMacro() const { return LeadingEmptyMacro; }
+ bool hasLeadingEmptyMacro() const { return LeadingEmptyMacro.isValid(); }
+ SourceLocation getLeadingEmptyMacroLoc() const { return LeadingEmptyMacro; }
SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
@@ -424,6 +437,8 @@ public:
SourceLocation LB, SourceLocation RB)
: Stmt(CompoundStmtClass), LBracLoc(LB), RBracLoc(RB) {
CompoundStmtBits.NumStmts = NumStmts;
+ assert(CompoundStmtBits.NumStmts == NumStmts &&
+ "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
if (NumStmts == 0) {
Body = 0;
@@ -516,6 +531,9 @@ public:
void setNextSwitchCase(SwitchCase *SC) { NextSwitchCase = SC; }
Stmt *getSubStmt();
+ const Stmt *getSubStmt() const {
+ return const_cast<SwitchCase*>(this)->getSubStmt();
+ }
SourceRange getSourceRange() const { return SourceRange(); }
@@ -527,7 +545,7 @@ public:
};
class CaseStmt : public SwitchCase {
- enum { SUBSTMT, LHS, RHS, END_EXPR };
+ enum { LHS, RHS, SUBSTMT, END_EXPR };
Stmt* SubExprs[END_EXPR]; // The expression for the RHS is Non-null for
// GNU "case 1 ... 4" extension
SourceLocation CaseLoc;
@@ -688,6 +706,12 @@ public:
VarDecl *getConditionVariable() const;
void setConditionVariable(ASTContext &C, VarDecl *V);
+ /// If this IfStmt has a condition variable, return the faux DeclStmt
+ /// associated with the creation of that condition variable.
+ const DeclStmt *getConditionVariableDeclStmt() const {
+ return reinterpret_cast<DeclStmt*>(SubExprs[VAR]);
+ }
+
const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
const Stmt *getThen() const { return SubExprs[THEN]; }
@@ -754,6 +778,12 @@ public:
/// \endcode
VarDecl *getConditionVariable() const;
void setConditionVariable(ASTContext &C, VarDecl *V);
+
+ /// If this SwitchStmt has a condition variable, return the faux DeclStmt
+ /// associated with the creation of that condition variable.
+ const DeclStmt *getConditionVariableDeclStmt() const {
+ return reinterpret_cast<DeclStmt*>(SubExprs[VAR]);
+ }
const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
const Stmt *getBody() const { return SubExprs[BODY]; }
@@ -835,6 +865,12 @@ public:
VarDecl *getConditionVariable() const;
void setConditionVariable(ASTContext &C, VarDecl *V);
+ /// If this WhileStmt has a condition variable, return the faux DeclStmt
+ /// associated with the creation of that condition variable.
+ const DeclStmt *getConditionVariableDeclStmt() const {
+ return reinterpret_cast<DeclStmt*>(SubExprs[VAR]);
+ }
+
Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
@@ -939,6 +975,12 @@ public:
VarDecl *getConditionVariable() const;
void setConditionVariable(ASTContext &C, VarDecl *V);
+ /// If this ForStmt has a condition variable, return the faux DeclStmt
+ /// associated with the creation of that condition variable.
+ const DeclStmt *getConditionVariableDeclStmt() const {
+ return reinterpret_cast<DeclStmt*>(SubExprs[CONDVAR]);
+ }
+
Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
Expr *getInc() { return reinterpret_cast<Expr*>(SubExprs[INC]); }
Stmt *getBody() { return SubExprs[BODY]; }
@@ -1406,6 +1448,122 @@ public:
}
};
+class SEHExceptStmt : public Stmt {
+ SourceLocation Loc;
+ Stmt *Children[2];
+
+ enum { FILTER_EXPR, BLOCK };
+
+ SEHExceptStmt(SourceLocation Loc,
+ Expr *FilterExpr,
+ Stmt *Block);
+
+public:
+ static SEHExceptStmt* Create(ASTContext &C,
+ SourceLocation ExceptLoc,
+ Expr *FilterExpr,
+ Stmt *Block);
+ SourceRange getSourceRange() const {
+ return SourceRange(getExceptLoc(), getEndLoc());
+ }
+
+ SourceLocation getExceptLoc() const { return Loc; }
+ SourceLocation getEndLoc() const { return getBlock()->getLocEnd(); }
+
+ Expr *getFilterExpr() const { return reinterpret_cast<Expr*>(Children[FILTER_EXPR]); }
+ CompoundStmt *getBlock() const { return llvm::cast<CompoundStmt>(Children[BLOCK]); }
+
+ child_range children() {
+ return child_range(Children,Children+2);
+ }
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == SEHExceptStmtClass;
+ }
+
+ static bool classof(SEHExceptStmt *) { return true; }
+
+};
+
+class SEHFinallyStmt : public Stmt {
+ SourceLocation Loc;
+ Stmt *Block;
+
+ SEHFinallyStmt(SourceLocation Loc,
+ Stmt *Block);
+
+public:
+ static SEHFinallyStmt* Create(ASTContext &C,
+ SourceLocation FinallyLoc,
+ Stmt *Block);
+
+ SourceRange getSourceRange() const {
+ return SourceRange(getFinallyLoc(), getEndLoc());
+ }
+
+ SourceLocation getFinallyLoc() const { return Loc; }
+ SourceLocation getEndLoc() const { return Block->getLocEnd(); }
+
+ CompoundStmt *getBlock() const { return llvm::cast<CompoundStmt>(Block); }
+
+ child_range children() {
+ return child_range(&Block,&Block+1);
+ }
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == SEHFinallyStmtClass;
+ }
+
+ static bool classof(SEHFinallyStmt *) { return true; }
+
+};
+
+class SEHTryStmt : public Stmt {
+ bool IsCXXTry;
+ SourceLocation TryLoc;
+ Stmt *Children[2];
+
+ enum { TRY = 0, HANDLER = 1 };
+
+ SEHTryStmt(bool isCXXTry, // true if 'try' otherwise '__try'
+ SourceLocation TryLoc,
+ Stmt *TryBlock,
+ Stmt *Handler);
+
+public:
+ static SEHTryStmt* Create(ASTContext &C,
+ bool isCXXTry,
+ SourceLocation TryLoc,
+ Stmt *TryBlock,
+ Stmt *Handler);
+
+ SourceRange getSourceRange() const {
+ return SourceRange(getTryLoc(), getEndLoc());
+ }
+
+ SourceLocation getTryLoc() const { return TryLoc; }
+ SourceLocation getEndLoc() const { return Children[HANDLER]->getLocEnd(); }
+
+ bool getIsCXXTry() const { return IsCXXTry; }
+ CompoundStmt* getTryBlock() const { return llvm::cast<CompoundStmt>(Children[TRY]); }
+ Stmt *getHandler() const { return Children[HANDLER]; }
+
+ /// Returns 0 if not defined
+ SEHExceptStmt *getExceptHandler() const;
+ SEHFinallyStmt *getFinallyHandler() const;
+
+ child_range children() {
+ return child_range(Children,Children+2);
+ }
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == SEHTryStmtClass;
+ }
+
+ static bool classof(SEHTryStmt *) { return true; }
+
+};
+
} // end namespace clang
#endif
diff --git a/include/clang/AST/StmtCXX.h b/include/clang/AST/StmtCXX.h
index f08815fd562d..42dcf2bb7b79 100644
--- a/include/clang/AST/StmtCXX.h
+++ b/include/clang/AST/StmtCXX.h
@@ -119,6 +119,88 @@ public:
friend class ASTStmtReader;
};
+/// CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for
+/// statement, represented as 'for (range-declarator : range-expression)'.
+///
+/// This is stored in a partially-desugared form to allow full semantic
+/// analysis of the constituent components. The original syntactic components
+/// can be extracted using getLoopVariable and getRangeInit.
+class CXXForRangeStmt : public Stmt {
+ enum { RANGE, BEGINEND, COND, INC, LOOPVAR, BODY, END };
+ // SubExprs[RANGE] is an expression or declstmt.
+ // SubExprs[COND] and SubExprs[INC] are expressions.
+ Stmt *SubExprs[END];
+ SourceLocation ForLoc;
+ SourceLocation ColonLoc;
+ SourceLocation RParenLoc;
+public:
+ CXXForRangeStmt(DeclStmt *Range, DeclStmt *BeginEnd,
+ Expr *Cond, Expr *Inc, DeclStmt *LoopVar, Stmt *Body,
+ SourceLocation FL, SourceLocation CL, SourceLocation RPL);
+ CXXForRangeStmt(EmptyShell Empty) : Stmt(CXXForRangeStmtClass, Empty) { }
+
+
+ VarDecl *getLoopVariable();
+ Expr *getRangeInit();
+
+ const VarDecl *getLoopVariable() const;
+ const Expr *getRangeInit() const;
+
+
+ DeclStmt *getRangeStmt() { return cast<DeclStmt>(SubExprs[RANGE]); }
+ DeclStmt *getBeginEndStmt() { return cast_or_null<DeclStmt>(SubExprs[BEGINEND]); }
+ Expr *getCond() { return cast_or_null<Expr>(SubExprs[COND]); }
+ Expr *getInc() { return cast_or_null<Expr>(SubExprs[INC]); }
+ DeclStmt *getLoopVarStmt() { return cast<DeclStmt>(SubExprs[LOOPVAR]); }
+ Stmt *getBody() { return SubExprs[BODY]; }
+
+ const DeclStmt *getRangeStmt() const {
+ return cast<DeclStmt>(SubExprs[RANGE]);
+ }
+ const DeclStmt *getBeginEndStmt() const {
+ return cast_or_null<DeclStmt>(SubExprs[BEGINEND]);
+ }
+ const Expr *getCond() const {
+ return cast_or_null<Expr>(SubExprs[COND]);
+ }
+ const Expr *getInc() const {
+ return cast_or_null<Expr>(SubExprs[INC]);
+ }
+ const DeclStmt *getLoopVarStmt() const {
+ return cast<DeclStmt>(SubExprs[LOOPVAR]);
+ }
+ const Stmt *getBody() const { return SubExprs[BODY]; }
+
+ void setRangeInit(Expr *E) { SubExprs[RANGE] = reinterpret_cast<Stmt*>(E); }
+ void setRangeStmt(Stmt *S) { SubExprs[RANGE] = S; }
+ void setBeginEndStmt(Stmt *S) { SubExprs[BEGINEND] = S; }
+ void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
+ void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast<Stmt*>(E); }
+ void setLoopVarStmt(Stmt *S) { SubExprs[LOOPVAR] = S; }
+ void setBody(Stmt *S) { SubExprs[BODY] = S; }
+
+
+ SourceLocation getForLoc() const { return ForLoc; }
+ void setForLoc(SourceLocation Loc) { ForLoc = Loc; }
+ SourceLocation getColonLoc() const { return ColonLoc; }
+ void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
+ SourceLocation getRParenLoc() const { return RParenLoc; }
+ void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
+
+ SourceRange getSourceRange() const {
+ return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
+ }
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CXXForRangeStmtClass;
+ }
+ static bool classof(const CXXForRangeStmt *) { return true; }
+
+ // Iterators
+ child_range children() {
+ return child_range(&SubExprs[0], &SubExprs[END]);
+ }
+};
+
} // end namespace clang
diff --git a/include/clang/AST/StmtIterator.h b/include/clang/AST/StmtIterator.h
index 851c001adc54..05b50db7def7 100644
--- a/include/clang/AST/StmtIterator.h
+++ b/include/clang/AST/StmtIterator.h
@@ -18,6 +18,7 @@
#include <cassert>
#include <cstddef>
#include <iterator>
+#include <utility>
namespace clang {
diff --git a/include/clang/AST/TemplateBase.h b/include/clang/AST/TemplateBase.h
index a4e074e083f6..821b4fcbb168 100644
--- a/include/clang/AST/TemplateBase.h
+++ b/include/clang/AST/TemplateBase.h
@@ -362,7 +362,10 @@ private:
Expr *Expression;
TypeSourceInfo *Declarator;
struct {
- unsigned QualifierRange[2];
+ // FIXME: We'd like to just use the qualifier in the TemplateName,
+ // but template arguments get canonicalized too quickly.
+ NestedNameSpecifier *Qualifier;
+ void *QualifierLocData;
unsigned TemplateNameLoc;
unsigned EllipsisLoc;
} Template;
@@ -375,12 +378,12 @@ public:
TemplateArgumentLocInfo(Expr *E) : Expression(E) {}
- TemplateArgumentLocInfo(SourceRange QualifierRange,
+ TemplateArgumentLocInfo(NestedNameSpecifierLoc QualifierLoc,
SourceLocation TemplateNameLoc,
SourceLocation EllipsisLoc)
{
- Template.QualifierRange[0] = QualifierRange.getBegin().getRawEncoding();
- Template.QualifierRange[1] = QualifierRange.getEnd().getRawEncoding();
+ Template.Qualifier = QualifierLoc.getNestedNameSpecifier();
+ Template.QualifierLocData = QualifierLoc.getOpaqueData();
Template.TemplateNameLoc = TemplateNameLoc.getRawEncoding();
Template.EllipsisLoc = EllipsisLoc.getRawEncoding();
}
@@ -393,10 +396,9 @@ public:
return Expression;
}
- SourceRange getTemplateQualifierRange() const {
- return SourceRange(
- SourceLocation::getFromRawEncoding(Template.QualifierRange[0]),
- SourceLocation::getFromRawEncoding(Template.QualifierRange[1]));
+ NestedNameSpecifierLoc getTemplateQualifierLoc() const {
+ return NestedNameSpecifierLoc(Template.Qualifier,
+ Template.QualifierLocData);
}
SourceLocation getTemplateNameLoc() const {
@@ -433,11 +435,10 @@ public:
}
TemplateArgumentLoc(const TemplateArgument &Argument,
- SourceRange QualifierRange,
+ NestedNameSpecifierLoc QualifierLoc,
SourceLocation TemplateNameLoc,
SourceLocation EllipsisLoc = SourceLocation())
- : Argument(Argument),
- LocInfo(QualifierRange, TemplateNameLoc, EllipsisLoc) {
+ : Argument(Argument), LocInfo(QualifierLoc, TemplateNameLoc, EllipsisLoc) {
assert(Argument.getKind() == TemplateArgument::Template ||
Argument.getKind() == TemplateArgument::TemplateExpansion);
}
@@ -477,10 +478,10 @@ public:
return LocInfo.getAsExpr();
}
- SourceRange getTemplateQualifierRange() const {
+ NestedNameSpecifierLoc getTemplateQualifierLoc() const {
assert(Argument.getKind() == TemplateArgument::Template ||
Argument.getKind() == TemplateArgument::TemplateExpansion);
- return LocInfo.getTemplateQualifierRange();
+ return LocInfo.getTemplateQualifierLoc();
}
SourceLocation getTemplateNameLoc() const {
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 9b177cceed96..975a66fefa89 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -15,6 +15,7 @@
#define LLVM_CLANG_AST_TYPE_H
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/ExceptionSpecificationType.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/Linkage.h"
#include "clang/Basic/PartialDiagnostic.h"
@@ -72,7 +73,7 @@ namespace llvm {
namespace clang {
class ASTContext;
- class TypedefDecl;
+ class TypedefNameDecl;
class TemplateDecl;
class TemplateTypeParmDecl;
class NonTypeTemplateParmDecl;
@@ -212,6 +213,11 @@ public:
assert(type);
setObjCGCAttr(type);
}
+ Qualifiers withoutObjCGCAttr() const {
+ Qualifiers qs = *this;
+ qs.removeObjCGCAttr();
+ return qs;
+ }
bool hasAddressSpace() const { return Mask & AddressSpaceMask; }
unsigned getAddressSpace() const { return Mask >> AddressSpaceShift; }
@@ -293,8 +299,10 @@ public:
(((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask));
}
- bool isSupersetOf(Qualifiers Other) const;
-
+ /// \brief Determine whether this set of qualifiers is a strict superset of
+ /// another set of qualifiers, not considering qualifier compatibility.
+ bool isStrictSupersetOf(Qualifiers Other) const;
+
bool operator==(Qualifiers Other) const { return Mask == Other.Mask; }
bool operator!=(Qualifiers Other) const { return Mask != Other.Mask; }
@@ -354,7 +362,9 @@ enum CallingConv {
CC_X86StdCall, // __attribute__((stdcall))
CC_X86FastCall, // __attribute__((fastcall))
CC_X86ThisCall, // __attribute__((thiscall))
- CC_X86Pascal // __attribute__((pascal))
+ CC_X86Pascal, // __attribute__((pascal))
+ CC_AAPCS, // __attribute__((pcs("aapcs")))
+ CC_AAPCS_VFP // __attribute__((pcs("aapcs-vfp")))
};
typedef std::pair<const Type*, Qualifiers> SplitQualType;
@@ -598,8 +608,14 @@ public:
/// ASTContext::getUnqualifiedArrayType.
inline SplitQualType getSplitUnqualifiedType() const;
+ /// \brief Determine whether this type is more qualified than the other
+ /// given type, requiring exact equality for non-CVR qualifiers.
bool isMoreQualifiedThan(QualType Other) const;
+
+ /// \brief Determine whether this type is at least as qualified as the other
+ /// given type, requiring exact equality for non-CVR qualifiers.
bool isAtLeastAsQualifiedAs(QualType Other) const;
+
QualType getNonReferenceType() const;
/// \brief Determine the type of a (typically non-lvalue) expression with the
@@ -1163,6 +1179,20 @@ public:
/// (C++0x [basic.types]p10)
bool isLiteralType() const;
+ /// isTrivialType - Return true if this is a trivial type
+ /// (C++0x [basic.types]p9)
+ bool isTrivialType() const;
+
+ /// \brief Test if this type is a standard-layout type.
+ /// (C++0x [basic.type]p9)
+ bool isStandardLayoutType() const;
+
+ /// isCXX11PODType() - Return true if this is a POD type according to the
+ /// more relaxed rules of the C++11 standard, regardless of the current
+ /// compilation's language.
+ /// (C++0x [basic.types]p9)
+ bool isCXX11PODType() const;
+
/// Helper methods to distinguish type categories. All type predicates
/// operate on the canonical type, ignoring typedefs and qualifiers.
@@ -1178,6 +1208,9 @@ public:
/// BuiltinTypes.
bool isPlaceholderType() const;
+ /// isSpecificPlaceholderType - Test for a specific placeholder type.
+ bool isSpecificPlaceholderType(unsigned K) const;
+
/// isIntegerType() does *not* include complex integers (a GCC extension).
/// isComplexIntegerType() can be used to test for complex integers.
bool isIntegerType() const; // C99 6.2.5p17 (int, char, bool, enum)
@@ -1207,6 +1240,8 @@ public:
bool isDerivedType() const; // C99 6.2.5p20
bool isScalarType() const; // C99 6.2.5p21 (arithmetic + pointers)
bool isAggregateType() const;
+ bool isFundamentalType() const;
+ bool isCompoundType() const;
// Type Predicates: Check to see if this type is structurally the specified
// type, ignoring typedefs and qualifiers.
@@ -1321,6 +1356,7 @@ public:
// for object declared using an interface.
const ObjCObjectPointerType *getAsObjCInterfacePointerType() const;
const ObjCObjectPointerType *getAsObjCQualifiedIdType() const;
+ const ObjCObjectPointerType *getAsObjCQualifiedClassType() const;
const ObjCObjectType *getAsObjCQualifiedInterfaceType() const;
const CXXRecordDecl *getCXXRecordDeclForPointerType() const;
@@ -1475,25 +1511,52 @@ public:
NullPtr, // This is the type of C++0x 'nullptr'.
+ /// The primitive Objective C 'id' type. The user-visible 'id'
+ /// type is a typedef of an ObjCObjectPointerType to an
+ /// ObjCObjectType with this as its base. In fact, this only ever
+ /// shows up in an AST as the base type of an ObjCObjectType.
+ ObjCId,
+
+ /// The primitive Objective C 'Class' type. The user-visible
+ /// 'Class' type is a typedef of an ObjCObjectPointerType to an
+ /// ObjCObjectType with this as its base. In fact, this only ever
+ /// shows up in an AST as the base type of an ObjCObjectType.
+ ObjCClass,
+
+ /// The primitive Objective C 'SEL' type. The user-visible 'SEL'
+ /// type is a typedef of a PointerType to this.
+ ObjCSel,
+
/// This represents the type of an expression whose type is
/// totally unknown, e.g. 'T::foo'. It is permitted for this to
/// appear in situations where the structure of the type is
/// theoretically deducible.
Dependent,
- Overload, // This represents the type of an overloaded function declaration.
-
- /// The primitive Objective C 'id' type. The type pointed to by the
- /// user-visible 'id' type. Only ever shows up in an AST as the base
- /// type of an ObjCObjectType.
- ObjCId,
-
- /// The primitive Objective C 'Class' type. The type pointed to by the
- /// user-visible 'Class' type. Only ever shows up in an AST as the
- /// base type of an ObjCObjectType.
- ObjCClass,
-
- ObjCSel // This represents the ObjC 'SEL' type.
+ /// The type of an unresolved overload set. A placeholder type.
+ /// Expressions with this type have one of the following basic
+ /// forms, with parentheses generally permitted:
+ /// foo # possibly qualified, not if an implicit access
+ /// foo # possibly qualified, not if an implicit access
+ /// &foo # possibly qualified, not if an implicit access
+ /// x->foo # only if might be a static member function
+ /// &x->foo # only if might be a static member function
+ /// &Class::foo # when a pointer-to-member; sub-expr also has this type
+ /// OverloadExpr::find can be used to analyze the expression.
+ Overload,
+
+ /// The type of a bound C++ non-static member function.
+ /// A placeholder type. Expressions with this type have one of the
+ /// following basic forms:
+ /// foo # if an implicit access
+ /// x->foo # if only contains non-static members
+ BoundMember,
+
+ /// __builtin_any_type. A placeholder type. Useful for clients
+ /// like debuggers that don't know what type to give something.
+ /// Only a small number of operations are valid on expressions of
+ /// unknown type, most notably explicit casts.
+ UnknownAny
};
public:
@@ -1526,11 +1589,11 @@ public:
return getKind() >= Float && getKind() <= LongDouble;
}
- /// Determines whether this type is a "forbidden" placeholder type,
- /// i.e. a type which cannot appear in arbitrary positions in a
- /// fully-formed expression.
+ /// Determines whether this type is a placeholder type, i.e. a type
+ /// which cannot appear in arbitrary positions in a fully-formed
+ /// expression.
bool isPlaceholderType() const {
- return getKind() == Overload;
+ return getKind() >= Overload;
}
static bool classof(const Type *T) { return T->getTypeClass() == Builtin; }
@@ -1991,7 +2054,7 @@ public:
friend class StmtIteratorBase;
void Profile(llvm::FoldingSetNodeID &ID) {
- assert(0 && "Cannnot unique VariableArrayTypes.");
+ assert(0 && "Cannot unique VariableArrayTypes.");
}
};
@@ -2257,12 +2320,13 @@ class FunctionType : public Type {
// you'll need to adjust both the Bits field below and
// Type::FunctionTypeBitfields.
- // | CC |noreturn|regparm
- // |0 .. 2| 3 |4 .. 6
+ // | CC |noreturn|hasregparm|regparm
+ // |0 .. 2| 3 | 4 |5 .. 7
enum { CallConvMask = 0x7 };
enum { NoReturnMask = 0x8 };
+ enum { HasRegParmMask = 0x10 };
enum { RegParmMask = ~(CallConvMask | NoReturnMask),
- RegParmOffset = 4 };
+ RegParmOffset = 5 };
unsigned char Bits;
@@ -2273,9 +2337,10 @@ class FunctionType : public Type {
public:
// Constructor with no defaults. Use this when you know that you
// have all the elements (when reading an AST file for example).
- ExtInfo(bool noReturn, unsigned regParm, CallingConv cc) {
+ ExtInfo(bool noReturn, bool hasRegParm, unsigned regParm, CallingConv cc) {
Bits = ((unsigned) cc) |
(noReturn ? NoReturnMask : 0) |
+ (hasRegParm ? HasRegParmMask : 0) |
(regParm << RegParmOffset);
}
@@ -2284,6 +2349,7 @@ class FunctionType : public Type {
ExtInfo() : Bits(0) {}
bool getNoReturn() const { return Bits & NoReturnMask; }
+ bool getHasRegParm() const { return Bits & HasRegParmMask; }
unsigned getRegParm() const { return Bits >> RegParmOffset; }
CallingConv getCC() const { return CallingConv(Bits & CallConvMask); }
@@ -2305,7 +2371,7 @@ class FunctionType : public Type {
}
ExtInfo withRegParm(unsigned RegParm) const {
- return ExtInfo((Bits & ~RegParmMask) | (RegParm << RegParmOffset));
+ return ExtInfo(HasRegParmMask | (Bits & ~RegParmMask) | (RegParm << RegParmOffset));
}
ExtInfo withCallingConv(CallingConv cc) const {
@@ -2341,7 +2407,8 @@ protected:
public:
QualType getResultType() const { return ResultType; }
-
+
+ bool getHasRegParm() const { return getExtInfo().getHasRegParm(); }
unsigned getRegParmType() const { return getExtInfo().getRegParm(); }
bool getNoReturnAttr() const { return getExtInfo().getNoReturn(); }
CallingConv getCallConv() const { return getExtInfo().getCC(); }
@@ -2403,17 +2470,17 @@ public:
/// ExtProtoInfo - Extra information about a function prototype.
struct ExtProtoInfo {
ExtProtoInfo() :
- Variadic(false), HasExceptionSpec(false), HasAnyExceptionSpec(false),
- TypeQuals(0), RefQualifier(RQ_None), NumExceptions(0), Exceptions(0) {}
+ Variadic(false), ExceptionSpecType(EST_None), TypeQuals(0),
+ RefQualifier(RQ_None), NumExceptions(0), Exceptions(0), NoexceptExpr(0) {}
FunctionType::ExtInfo ExtInfo;
bool Variadic;
- bool HasExceptionSpec;
- bool HasAnyExceptionSpec;
+ ExceptionSpecificationType ExceptionSpecType;
unsigned char TypeQuals;
RefQualifierKind RefQualifier;
unsigned NumExceptions;
const QualType *Exceptions;
+ Expr *NoexceptExpr;
};
private:
@@ -2435,13 +2502,10 @@ private:
unsigned NumArgs : 20;
/// NumExceptions - The number of types in the exception spec, if any.
- unsigned NumExceptions : 10;
+ unsigned NumExceptions : 9;
- /// HasExceptionSpec - Whether this function has an exception spec at all.
- unsigned HasExceptionSpec : 1;
-
- /// HasAnyExceptionSpec - Whether this function has a throw(...) spec.
- unsigned HasAnyExceptionSpec : 1;
+ /// ExceptionSpecType - The type of exception specification this function has.
+ unsigned ExceptionSpecType : 3;
/// ArgInfo - There is an variable size array after the class in memory that
/// holds the argument types.
@@ -2449,6 +2513,9 @@ private:
/// Exceptions - There is another variable size array after ArgInfo that
/// holds the exception types.
+ /// NoexceptExpr - Instead of Exceptions, there may be a single Expr* pointing
+ /// to the expression in the noexcept() specifier.
+
friend class ASTContext; // ASTContext creates these.
public:
@@ -2462,29 +2529,66 @@ public:
ExtProtoInfo EPI;
EPI.ExtInfo = getExtInfo();
EPI.Variadic = isVariadic();
- EPI.HasExceptionSpec = hasExceptionSpec();
- EPI.HasAnyExceptionSpec = hasAnyExceptionSpec();
+ EPI.ExceptionSpecType = getExceptionSpecType();
EPI.TypeQuals = static_cast<unsigned char>(getTypeQuals());
EPI.RefQualifier = getRefQualifier();
- EPI.NumExceptions = NumExceptions;
- EPI.Exceptions = exception_begin();
+ if (EPI.ExceptionSpecType == EST_Dynamic) {
+ EPI.NumExceptions = NumExceptions;
+ EPI.Exceptions = exception_begin();
+ } else if (EPI.ExceptionSpecType == EST_ComputedNoexcept) {
+ EPI.NoexceptExpr = getNoexceptExpr();
+ }
return EPI;
}
- bool hasExceptionSpec() const { return HasExceptionSpec; }
- bool hasAnyExceptionSpec() const { return HasAnyExceptionSpec; }
+ /// \brief Get the kind of exception specification on this function.
+ ExceptionSpecificationType getExceptionSpecType() const {
+ return static_cast<ExceptionSpecificationType>(ExceptionSpecType);
+ }
+ /// \brief Return whether this function has any kind of exception spec.
+ bool hasExceptionSpec() const {
+ return getExceptionSpecType() != EST_None;
+ }
+ /// \brief Return whether this function has a dynamic (throw) exception spec.
+ bool hasDynamicExceptionSpec() const {
+ return isDynamicExceptionSpec(getExceptionSpecType());
+ }
+ /// \brief Return whether this function has a noexcept exception spec.
+ bool hasNoexceptExceptionSpec() const {
+ return isNoexceptExceptionSpec(getExceptionSpecType());
+ }
+ /// \brief Result type of getNoexceptSpec().
+ enum NoexceptResult {
+ NR_NoNoexcept, ///< There is no noexcept specifier.
+ NR_BadNoexcept, ///< The noexcept specifier has a bad expression.
+ NR_Dependent, ///< The noexcept specifier is dependent.
+ NR_Throw, ///< The noexcept specifier evaluates to false.
+ NR_Nothrow ///< The noexcept specifier evaluates to true.
+ };
+ /// \brief Get the meaning of the noexcept spec on this function, if any.
+ NoexceptResult getNoexceptSpec(ASTContext &Ctx) const;
unsigned getNumExceptions() const { return NumExceptions; }
QualType getExceptionType(unsigned i) const {
assert(i < NumExceptions && "Invalid exception number!");
return exception_begin()[i];
}
- bool hasEmptyExceptionSpec() const {
- return hasExceptionSpec() && !hasAnyExceptionSpec() &&
- getNumExceptions() == 0;
+ Expr *getNoexceptExpr() const {
+ if (getExceptionSpecType() != EST_ComputedNoexcept)
+ return 0;
+ // NoexceptExpr sits where the arguments end.
+ return *reinterpret_cast<Expr *const *>(arg_type_end());
+ }
+ bool isNothrow(ASTContext &Ctx) const {
+ ExceptionSpecificationType EST = getExceptionSpecType();
+ if (EST == EST_DynamicNone || EST == EST_BasicNoexcept)
+ return true;
+ if (EST != EST_ComputedNoexcept)
+ return false;
+ return getNoexceptSpec(Ctx) == NR_Nothrow;
}
using FunctionType::isVariadic;
-
+
/// \brief Determines whether this function prototype contains a
/// parameter pack at the end.
///
@@ -2513,6 +2617,8 @@ public:
return arg_type_end();
}
exception_iterator exception_end() const {
+ if (getExceptionSpecType() != EST_Dynamic)
+ return exception_begin();
return exception_begin() + NumExceptions;
}
@@ -2524,10 +2630,10 @@ public:
}
static bool classof(const FunctionProtoType *) { return true; }
- void Profile(llvm::FoldingSetNodeID &ID);
+ void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx);
static void Profile(llvm::FoldingSetNodeID &ID, QualType Result,
arg_type_iterator ArgTys, unsigned NumArgs,
- const ExtProtoInfo &EPI);
+ const ExtProtoInfo &EPI, const ASTContext &Context);
};
@@ -2566,18 +2672,18 @@ public:
class TypedefType : public Type {
- TypedefDecl *Decl;
+ TypedefNameDecl *Decl;
protected:
- TypedefType(TypeClass tc, const TypedefDecl *D, QualType can)
+ TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType can)
: Type(tc, can, can->isDependentType(), can->isVariablyModifiedType(),
/*ContainsUnexpandedParameterPack=*/false),
- Decl(const_cast<TypedefDecl*>(D)) {
+ Decl(const_cast<TypedefNameDecl*>(D)) {
assert(!isa<TypedefType>(can) && "Invalid canonical type");
}
friend class ASTContext; // ASTContext creates these.
public:
- TypedefDecl *getDecl() const { return Decl; }
+ TypedefNameDecl *getDecl() const { return Decl; }
bool isSugared() const { return true; }
QualType desugar() const;
@@ -2807,9 +2913,10 @@ public:
// Enumerated operand (string or keyword).
attr_objc_gc,
+ attr_pcs,
FirstEnumOperandKind = attr_objc_gc,
- LastEnumOperandKind = attr_objc_gc,
+ LastEnumOperandKind = attr_pcs,
// No operand.
attr_noreturn,
@@ -2864,44 +2971,68 @@ public:
};
class TemplateTypeParmType : public Type, public llvm::FoldingSetNode {
- unsigned Depth : 15;
- unsigned ParameterPack : 1;
- unsigned Index : 16;
- IdentifierInfo *Name;
+ // Helper data collector for canonical types.
+ struct CanonicalTTPTInfo {
+ unsigned Depth : 15;
+ unsigned ParameterPack : 1;
+ unsigned Index : 16;
+ };
+
+ union {
+ // Info for the canonical type.
+ CanonicalTTPTInfo CanTTPTInfo;
+ // Info for the non-canonical type.
+ TemplateTypeParmDecl *TTPDecl;
+ };
- TemplateTypeParmType(unsigned D, unsigned I, bool PP, IdentifierInfo *N,
- QualType Canon)
+ /// Build a non-canonical type.
+ TemplateTypeParmType(TemplateTypeParmDecl *TTPDecl, QualType Canon)
: Type(TemplateTypeParm, Canon, /*Dependent=*/true,
- /*VariablyModified=*/false, PP),
- Depth(D), ParameterPack(PP), Index(I), Name(N) { }
+ /*VariablyModified=*/false,
+ Canon->containsUnexpandedParameterPack()),
+ TTPDecl(TTPDecl) { }
+ /// Build the canonical type.
TemplateTypeParmType(unsigned D, unsigned I, bool PP)
: Type(TemplateTypeParm, QualType(this, 0), /*Dependent=*/true,
- /*VariablyModified=*/false, PP),
- Depth(D), ParameterPack(PP), Index(I), Name(0) { }
+ /*VariablyModified=*/false, PP) {
+ CanTTPTInfo.Depth = D;
+ CanTTPTInfo.Index = I;
+ CanTTPTInfo.ParameterPack = PP;
+ }
friend class ASTContext; // ASTContext creates these
+ const CanonicalTTPTInfo& getCanTTPTInfo() const {
+ QualType Can = getCanonicalTypeInternal();
+ return Can->castAs<TemplateTypeParmType>()->CanTTPTInfo;
+ }
+
public:
- unsigned getDepth() const { return Depth; }
- unsigned getIndex() const { return Index; }
- bool isParameterPack() const { return ParameterPack; }
- IdentifierInfo *getName() const { return Name; }
+ unsigned getDepth() const { return getCanTTPTInfo().Depth; }
+ unsigned getIndex() const { return getCanTTPTInfo().Index; }
+ bool isParameterPack() const { return getCanTTPTInfo().ParameterPack; }
+
+ TemplateTypeParmDecl *getDecl() const {
+ return isCanonicalUnqualified() ? 0 : TTPDecl;
+ }
+
+ IdentifierInfo *getIdentifier() const;
bool isSugared() const { return false; }
QualType desugar() const { return QualType(this, 0); }
void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, Depth, Index, ParameterPack, Name);
+ Profile(ID, getDepth(), getIndex(), isParameterPack(), getDecl());
}
static void Profile(llvm::FoldingSetNodeID &ID, unsigned Depth,
unsigned Index, bool ParameterPack,
- IdentifierInfo *Name) {
+ TemplateTypeParmDecl *TTPDecl) {
ID.AddInteger(Depth);
ID.AddInteger(Index);
ID.AddBoolean(ParameterPack);
- ID.AddPointer(Name);
+ ID.AddPointer(TTPDecl);
}
static bool classof(const Type *T) {
@@ -2930,8 +3061,6 @@ class SubstTemplateTypeParmType : public Type, public llvm::FoldingSetNode {
friend class ASTContext;
public:
- IdentifierInfo *getName() const { return Replaced->getName(); }
-
/// Gets the template parameter that was substituted for.
const TemplateTypeParmType *getReplacedParameter() const {
return Replaced;
@@ -2992,7 +3121,7 @@ class SubstTemplateTypeParmPackType : public Type, public llvm::FoldingSetNode {
friend class ASTContext;
public:
- IdentifierInfo *getName() const { return Replaced->getName(); }
+ IdentifierInfo *getIdentifier() const { return Replaced->getIdentifier(); }
/// Gets the template parameter that was substituted for.
const TemplateTypeParmType *getReplacedParameter() const {
@@ -4064,12 +4193,6 @@ inline FunctionType::ExtInfo getFunctionExtInfo(QualType t) {
return getFunctionExtInfo(*t);
}
-/// \brief Determine whether this set of qualifiers is a superset of the given
-/// set of qualifiers.
-inline bool Qualifiers::isSupersetOf(Qualifiers Other) const {
- return Mask != Other.Mask && (Mask | Other.Mask) == Mask;
-}
-
/// isMoreQualifiedThan - Determine whether this type is more
/// qualified than the Other type. For example, "const volatile int"
/// is more qualified than "const int", "volatile int", and
@@ -4105,6 +4228,40 @@ inline QualType QualType::getNonReferenceType() const {
return *this;
}
+/// \brief Tests whether the type is categorized as a fundamental type.
+///
+/// \returns True for types specified in C++0x [basic.fundamental].
+inline bool Type::isFundamentalType() const {
+ return isVoidType() ||
+ // FIXME: It's really annoying that we don't have an
+ // 'isArithmeticType()' which agrees with the standard definition.
+ (isArithmeticType() && !isEnumeralType());
+}
+
+/// \brief Tests whether the type is categorized as a compound type.
+///
+/// \returns True for types specified in C++0x [basic.compound].
+inline bool Type::isCompoundType() const {
+ // C++0x [basic.compound]p1:
+ // Compound types can be constructed in the following ways:
+ // -- arrays of objects of a given type [...];
+ return isArrayType() ||
+ // -- functions, which have parameters of given types [...];
+ isFunctionType() ||
+ // -- pointers to void or objects or functions [...];
+ isPointerType() ||
+ // -- references to objects or functions of a given type. [...]
+ isReferenceType() ||
+ // -- classes containing a sequence of objects of various types, [...];
+ isRecordType() ||
+ // -- unions, which ar classes capable of containing objects of different types at different times;
+ isUnionType() ||
+ // -- enumerations, which comprise a set of named constant values. [...];
+ isEnumeralType() ||
+ // -- pointers to non-static class members, [...].
+ isMemberPointerType();
+}
+
inline bool Type::isFunctionType() const {
return isa<FunctionType>(CanonicalType);
}
@@ -4236,6 +4393,12 @@ inline bool Type::isPlaceholderType() const {
return false;
}
+inline bool Type::isSpecificPlaceholderType(unsigned K) const {
+ if (const BuiltinType *BT = dyn_cast<BuiltinType>(this))
+ return (BT->getKind() == (BuiltinType::Kind) K);
+ return false;
+}
+
/// \brief Determines whether this is a type for which one can define
/// an overloaded operator.
inline bool Type::isOverloadableType() const {
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h
index c7f5ee76330c..a1df744c2a72 100644
--- a/include/clang/AST/TypeLoc.h
+++ b/include/clang/AST/TypeLoc.h
@@ -527,7 +527,7 @@ class TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
TypedefTypeLoc,
TypedefType> {
public:
- TypedefDecl *getTypedefDecl() const {
+ TypedefNameDecl *getTypedefNameDecl() const {
return getTypePtr()->getDecl();
}
};
@@ -584,6 +584,8 @@ class TemplateTypeParmTypeLoc :
public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
TemplateTypeParmTypeLoc,
TemplateTypeParmType> {
+public:
+ TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); }
};
/// \brief Wrapper for substituted template type parameters.
@@ -943,10 +945,14 @@ public:
}
};
+struct MemberPointerLocInfo : public PointerLikeLocInfo {
+ TypeSourceInfo *ClassTInfo;
+};
/// \brief Wrapper for source info for member pointers.
class MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
- MemberPointerType> {
+ MemberPointerType,
+ MemberPointerLocInfo> {
public:
SourceLocation getStarLoc() const {
return getSigilLoc();
@@ -954,6 +960,28 @@ public:
void setStarLoc(SourceLocation Loc) {
setSigilLoc(Loc);
}
+
+ const Type *getClass() const {
+ return getTypePtr()->getClass();
+ }
+ TypeSourceInfo *getClassTInfo() const {
+ return getLocalData()->ClassTInfo;
+ }
+ void setClassTInfo(TypeSourceInfo* TI) {
+ getLocalData()->ClassTInfo = TI;
+ }
+
+ void initializeLocal(ASTContext &Context, SourceLocation Loc) {
+ setSigilLoc(Loc);
+ setClassTInfo(0);
+ }
+
+ SourceRange getLocalSourceRange() const {
+ if (TypeSourceInfo *TI = getClassTInfo())
+ return SourceRange(TI->getTypeLoc().getBeginLoc(), getStarLoc());
+ else
+ return SourceRange(getStarLoc());
+ }
};
/// Wraps an ObjCPointerType with source location information.
@@ -1007,7 +1035,8 @@ public:
struct FunctionLocInfo {
- SourceLocation LParenLoc, RParenLoc;
+ SourceLocation LocalRangeBegin;
+ SourceLocation LocalRangeEnd;
bool TrailingReturn;
};
@@ -1017,18 +1046,18 @@ class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
FunctionType,
FunctionLocInfo> {
public:
- SourceLocation getLParenLoc() const {
- return getLocalData()->LParenLoc;
+ SourceLocation getLocalRangeBegin() const {
+ return getLocalData()->LocalRangeBegin;
}
- void setLParenLoc(SourceLocation Loc) {
- getLocalData()->LParenLoc = Loc;
+ void setLocalRangeBegin(SourceLocation L) {
+ getLocalData()->LocalRangeBegin = L;
}
- SourceLocation getRParenLoc() const {
- return getLocalData()->RParenLoc;
+ SourceLocation getLocalRangeEnd() const {
+ return getLocalData()->LocalRangeEnd;
}
- void setRParenLoc(SourceLocation Loc) {
- getLocalData()->RParenLoc = Loc;
+ void setLocalRangeEnd(SourceLocation L) {
+ getLocalData()->LocalRangeEnd = L;
}
bool getTrailingReturn() const {
@@ -1056,12 +1085,12 @@ public:
}
SourceRange getLocalSourceRange() const {
- return SourceRange(getLParenLoc(), getRParenLoc());
+ return SourceRange(getLocalRangeBegin(), getLocalRangeEnd());
}
void initializeLocal(ASTContext &Context, SourceLocation Loc) {
- setLParenLoc(Loc);
- setRParenLoc(Loc);
+ setLocalRangeBegin(Loc);
+ setLocalRangeEnd(Loc);
setTrailingReturn(false);
for (unsigned i = 0, e = getNumArgs(); i != e; ++i)
setArg(i, NULL);
@@ -1388,7 +1417,10 @@ class AutoTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
struct ElaboratedLocInfo {
SourceLocation KeywordLoc;
- SourceRange QualifierRange;
+
+ /// \brief Opaque data pointer used to reconstruct a nested-name-specifier
+ /// from
+ void *QualifierData;
};
class ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
@@ -1403,27 +1435,29 @@ public:
this->getLocalData()->KeywordLoc = Loc;
}
- SourceRange getQualifierRange() const {
- return this->getLocalData()->QualifierRange;
+ NestedNameSpecifierLoc getQualifierLoc() const {
+ return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
+ getLocalData()->QualifierData);
}
- void setQualifierRange(SourceRange Range) {
- this->getLocalData()->QualifierRange = Range;
+
+ void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) {
+ assert(QualifierLoc.getNestedNameSpecifier()
+ == getTypePtr()->getQualifier() &&
+ "Inconsistent nested-name-specifier pointer");
+ getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
}
SourceRange getLocalSourceRange() const {
if (getKeywordLoc().isValid())
- if (getQualifierRange().getEnd().isValid())
- return SourceRange(getKeywordLoc(), getQualifierRange().getEnd());
+ if (getQualifierLoc())
+ return SourceRange(getKeywordLoc(), getQualifierLoc().getEndLoc());
else
return SourceRange(getKeywordLoc());
else
- return getQualifierRange();
+ return getQualifierLoc().getSourceRange();
}
- void initializeLocal(ASTContext &Context, SourceLocation Loc) {
- setKeywordLoc(Loc);
- setQualifierRange(SourceRange(Loc));
- }
+ void initializeLocal(ASTContext &Context, SourceLocation Loc);
TypeLoc getNamedTypeLoc() const {
return getInnerTypeLoc();
@@ -1444,6 +1478,9 @@ public:
// type is some sort of TypeDeclTypeLoc.
struct DependentNameLocInfo : ElaboratedLocInfo {
SourceLocation NameLoc;
+
+ /// \brief Data associated with the nested-name-specifier location.
+ void *QualifierData;
};
class DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
@@ -1458,13 +1495,18 @@ public:
this->getLocalData()->KeywordLoc = Loc;
}
- SourceRange getQualifierRange() const {
- return this->getLocalData()->QualifierRange;
+ NestedNameSpecifierLoc getQualifierLoc() const {
+ return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
+ getLocalData()->QualifierData);
}
- void setQualifierRange(SourceRange Range) {
- this->getLocalData()->QualifierRange = Range;
+
+ void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) {
+ assert(QualifierLoc.getNestedNameSpecifier()
+ == getTypePtr()->getQualifier() &&
+ "Inconsistent nested-name-specifier pointer");
+ getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
}
-
+
SourceLocation getNameLoc() const {
return this->getLocalData()->NameLoc;
}
@@ -1476,7 +1518,7 @@ public:
if (getKeywordLoc().isValid())
return SourceRange(getKeywordLoc(), getNameLoc());
else
- return SourceRange(getQualifierRange().getBegin(), getNameLoc());
+ return SourceRange(getQualifierLoc().getBeginLoc(), getNameLoc());
}
void copy(DependentNameTypeLoc Loc) {
@@ -1485,16 +1527,11 @@ public:
memcpy(Data, Loc.Data, size);
}
- void initializeLocal(ASTContext &Context, SourceLocation Loc) {
- setKeywordLoc(Loc);
- setQualifierRange(SourceRange(Loc));
- setNameLoc(Loc);
- }
+ void initializeLocal(ASTContext &Context, SourceLocation Loc);
};
-// This is exactly the structure of an ElaboratedTypeLoc whose inner
-// type is some sort of TemplateSpecializationTypeLoc.
struct DependentTemplateSpecializationLocInfo : DependentNameLocInfo {
+ SourceLocation KeywordLoc;
SourceLocation LAngleLoc;
SourceLocation RAngleLoc;
// followed by a TemplateArgumentLocInfo[]
@@ -1513,11 +1550,28 @@ public:
this->getLocalData()->KeywordLoc = Loc;
}
- SourceRange getQualifierRange() const {
- return this->getLocalData()->QualifierRange;
- }
- void setQualifierRange(SourceRange Range) {
- this->getLocalData()->QualifierRange = Range;
+ NestedNameSpecifierLoc getQualifierLoc() const {
+ if (!getLocalData()->QualifierData)
+ return NestedNameSpecifierLoc();
+
+ return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
+ getLocalData()->QualifierData);
+ }
+
+ void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) {
+ if (!QualifierLoc) {
+ // Even if we have a nested-name-specifier in the dependent
+ // template specialization type, we won't record the nested-name-specifier
+ // location information when this type-source location information is
+ // part of a nested-name-specifier.
+ getLocalData()->QualifierData = 0;
+ return;
+ }
+
+ assert(QualifierLoc.getNestedNameSpecifier()
+ == getTypePtr()->getQualifier() &&
+ "Inconsistent nested-name-specifier pointer");
+ getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
}
SourceLocation getNameLoc() const {
@@ -1559,8 +1613,10 @@ public:
SourceRange getLocalSourceRange() const {
if (getKeywordLoc().isValid())
return SourceRange(getKeywordLoc(), getRAngleLoc());
+ else if (getQualifierLoc())
+ return SourceRange(getQualifierLoc().getBeginLoc(), getRAngleLoc());
else
- return SourceRange(getQualifierRange().getBegin(), getRAngleLoc());
+ return SourceRange(getNameLoc(), getRAngleLoc());
}
void copy(DependentTemplateSpecializationTypeLoc Loc) {
@@ -1569,16 +1625,7 @@ public:
memcpy(Data, Loc.Data, size);
}
- void initializeLocal(ASTContext &Context, SourceLocation Loc) {
- setKeywordLoc(Loc);
- setQualifierRange(SourceRange(Loc));
- setNameLoc(Loc);
- setLAngleLoc(Loc);
- setRAngleLoc(Loc);
- TemplateSpecializationTypeLoc::initializeArgLocs(Context, getNumArgs(),
- getTypePtr()->getArgs(),
- getArgInfos(), Loc);
- }
+ void initializeLocal(ASTContext &Context, SourceLocation Loc);
unsigned getExtraLocalDataSize() const {
return getNumArgs() * sizeof(TemplateArgumentLocInfo);
diff --git a/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h b/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h
index 72f644aaf028..a61d9e47881d 100644
--- a/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h
+++ b/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h
@@ -29,13 +29,13 @@ class CFGBlock;
// tend to have a common destination, so we lazily do a predecessor search
// from the destination node and cache the results to prevent work
// duplication.
-class CFGReachabilityAnalysis {
+class CFGReverseBlockReachabilityAnalysis {
typedef llvm::BitVector ReachableSet;
typedef llvm::DenseMap<unsigned, ReachableSet> ReachableMap;
ReachableSet analyzed;
ReachableMap reachable;
public:
- CFGReachabilityAnalysis(const CFG &cfg);
+ CFGReverseBlockReachabilityAnalysis(const CFG &cfg);
/// Returns true if the block 'Dst' can be reached from block 'Src'.
bool isReachable(const CFGBlock *Src, const CFGBlock *Dst);
diff --git a/include/clang/Analysis/Analyses/UninitializedValues.h b/include/clang/Analysis/Analyses/UninitializedValues.h
index cd771acb06a5..b966f3a90fff 100644
--- a/include/clang/Analysis/Analyses/UninitializedValues.h
+++ b/include/clang/Analysis/Analyses/UninitializedValues.h
@@ -1,4 +1,4 @@
-//===- UninitializedValues.h - unintialized values analysis ----*- C++ --*-===//
+//= UninitializedValues.h - Finding uses of uninitialized values --*- C++ -*-==//
//
// The LLVM Compiler Infrastructure
//
@@ -7,71 +7,35 @@
//
//===----------------------------------------------------------------------===//
//
-// This file provides the interface for the Unintialized Values analysis,
-// a flow-sensitive analysis that detects when variable values are unintialized.
+// This file defines APIs for invoking and reported uninitialized values
+// warnings.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_UNITVALS_H
-#define LLVM_CLANG_UNITVALS_H
-
-#include "clang/Analysis/Support/BlkExprDeclBitVector.h"
-#include "clang/Analysis/FlowSensitive/DataflowValues.h"
+#ifndef LLVM_CLANG_UNINIT_VALS_H
+#define LLVM_CLANG_UNINIT_VALS_H
namespace clang {
- class BlockVarDecl;
- class Expr;
- class DeclRefExpr;
- class VarDecl;
-
-/// UninitializedValues_ValueTypes - Utility class to wrap type declarations
-/// for dataflow values and dataflow analysis state for the
-/// Unitialized Values analysis.
-class UninitializedValues_ValueTypes {
-public:
-
- struct ObserverTy;
-
- struct AnalysisDataTy : public StmtDeclBitVector_Types::AnalysisDataTy {
- AnalysisDataTy() : Observer(NULL), FullUninitTaint(true) {}
- virtual ~AnalysisDataTy() {}
-
- ObserverTy* Observer;
- bool FullUninitTaint;
- };
-
- typedef StmtDeclBitVector_Types::ValTy ValTy;
-
- //===--------------------------------------------------------------------===//
- // ObserverTy - Observer for querying DeclRefExprs that use an uninitalized
- // value.
- //===--------------------------------------------------------------------===//
-
- struct ObserverTy {
- virtual ~ObserverTy();
- virtual void ObserveDeclRefExpr(ValTy& Val, AnalysisDataTy& AD,
- DeclRefExpr* DR, VarDecl* VD) = 0;
- };
-};
-
-/// UninitializedValues - Objects of this class encapsulate dataflow analysis
-/// information regarding what variable declarations in a function are
-/// potentially unintialized.
-class UninitializedValues :
- public DataflowValues<UninitializedValues_ValueTypes> {
+class AnalysisContext;
+class CFG;
+class DeclContext;
+class Expr;
+class VarDecl;
+
+class UninitVariablesHandler {
public:
- typedef UninitializedValues_ValueTypes::ObserverTy ObserverTy;
-
- UninitializedValues(CFG &cfg) { getAnalysisData().setCFG(cfg); }
-
- /// IntializeValues - Create initial dataflow values and meta data for
- /// a given CFG. This is intended to be called by the dataflow solver.
- void InitializeValues(const CFG& cfg);
+ UninitVariablesHandler() {}
+ virtual ~UninitVariablesHandler();
+
+ virtual void handleUseOfUninitVariable(const Expr *ex,
+ const VarDecl *vd,
+ bool isAlwaysUninit) {}
};
+
+void runUninitializedVariablesAnalysis(const DeclContext &dc, const CFG &cfg,
+ AnalysisContext &ac,
+ UninitVariablesHandler &handler);
-
-void CheckUninitializedValues(CFG& cfg, ASTContext& Ctx, Diagnostic& Diags,
- bool FullUninitTaint=false);
-} // end namespace clang
+}
#endif
diff --git a/include/clang/Analysis/Analyses/UninitializedValuesV2.h b/include/clang/Analysis/Analyses/UninitializedValuesV2.h
deleted file mode 100644
index c1fe040793e1..000000000000
--- a/include/clang/Analysis/Analyses/UninitializedValuesV2.h
+++ /dev/null
@@ -1,40 +0,0 @@
-//= UninitializedValuesV2.h - Finding uses of uninitialized values --*- C++ -*-=
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines APIs for invoking and reported uninitialized values
-// warnings.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_UNINIT_VALS_H
-#define LLVM_CLANG_UNINIT_VALS_H
-
-namespace clang {
-
-class AnalysisContext;
-class CFG;
-class DeclContext;
-class Expr;
-class VarDecl;
-
-class UninitVariablesHandler {
-public:
- UninitVariablesHandler() {}
- virtual ~UninitVariablesHandler();
-
- virtual void handleUseOfUninitVariable(const Expr *ex,
- const VarDecl *vd) {}
-};
-
-void runUninitializedVariablesAnalysis(const DeclContext &dc, const CFG &cfg,
- AnalysisContext &ac,
- UninitVariablesHandler &handler);
-
-}
-#endif
diff --git a/include/clang/Analysis/AnalysisContext.h b/include/clang/Analysis/AnalysisContext.h
index 851451457881..66c12a5384d4 100644
--- a/include/clang/Analysis/AnalysisContext.h
+++ b/include/clang/Analysis/AnalysisContext.h
@@ -17,6 +17,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
+#include "clang/Analysis/CFG.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/PointerUnion.h"
@@ -27,9 +28,7 @@ namespace clang {
class Decl;
class Stmt;
-class CFG;
-class CFGBlock;
-class CFGReachabilityAnalysis;
+class CFGReverseBlockReachabilityAnalysis;
class CFGStmtMap;
class LiveVariables;
class ParentMap;
@@ -48,33 +47,32 @@ class AnalysisContext {
// TranslationUnit is NULL if we don't have multiple translation units.
idx::TranslationUnit *TU;
- // AnalysisContext owns the following data.
- CFG *cfg, *completeCFG;
- CFGStmtMap *cfgStmtMap;
+ llvm::OwningPtr<CFG> cfg, completeCFG;
+ llvm::OwningPtr<CFGStmtMap> cfgStmtMap;
+
+ CFG::BuildOptions cfgBuildOptions;
+ CFG::BuildOptions::ForcedBlkExprs *forcedBlkExprs;
+
bool builtCFG, builtCompleteCFG;
- LiveVariables *liveness;
- LiveVariables *relaxedLiveness;
- ParentMap *PM;
- PseudoConstantAnalysis *PCA;
- CFGReachabilityAnalysis *CFA;
- llvm::DenseMap<const BlockDecl*,void*> *ReferencedBlockVars;
+ const bool useUnoptimizedCFG;
+
+ llvm::OwningPtr<LiveVariables> liveness;
+ llvm::OwningPtr<LiveVariables> relaxedLiveness;
+ llvm::OwningPtr<ParentMap> PM;
+ llvm::OwningPtr<PseudoConstantAnalysis> PCA;
+ llvm::OwningPtr<CFGReverseBlockReachabilityAnalysis> CFA;
+
llvm::BumpPtrAllocator A;
- bool UseUnoptimizedCFG;
- bool AddEHEdges;
- bool AddImplicitDtors;
- bool AddInitializers;
+
+ // FIXME: remove.
+ llvm::DenseMap<const BlockDecl*,void*> *ReferencedBlockVars;
+
public:
AnalysisContext(const Decl *d, idx::TranslationUnit *tu,
bool useUnoptimizedCFG = false,
bool addehedges = false,
bool addImplicitDtors = false,
- bool addInitializers = false)
- : D(d), TU(tu), cfg(0), completeCFG(0), cfgStmtMap(0),
- builtCFG(false), builtCompleteCFG(false),
- liveness(0), relaxedLiveness(0), PM(0), PCA(0), CFA(0),
- ReferencedBlockVars(0), UseUnoptimizedCFG(useUnoptimizedCFG),
- AddEHEdges(addehedges), AddImplicitDtors(addImplicitDtors),
- AddInitializers(addInitializers) {}
+ bool addInitializers = false);
~AnalysisContext();
@@ -87,18 +85,22 @@ public:
/// callExprs. If this is false, then try/catch statements and blocks
/// reachable from them can appear to be dead in the CFG, analysis passes must
/// cope with that.
- bool getAddEHEdges() const { return AddEHEdges; }
-
- bool getUseUnoptimizedCFG() const { return UseUnoptimizedCFG; }
- bool getAddImplicitDtors() const { return AddImplicitDtors; }
- bool getAddInitializers() const { return AddInitializers; }
+ bool getAddEHEdges() const { return cfgBuildOptions.AddEHEdges; }
+ bool getUseUnoptimizedCFG() const {
+ return cfgBuildOptions.PruneTriviallyFalseEdges;
+ }
+ bool getAddImplicitDtors() const { return cfgBuildOptions.AddImplicitDtors; }
+ bool getAddInitializers() const { return cfgBuildOptions.AddInitializers; }
+ void registerForcedBlockExpression(const Stmt *stmt);
+ const CFGBlock *getBlockForRegisteredExpression(const Stmt *stmt);
+
Stmt *getBody();
CFG *getCFG();
CFGStmtMap *getCFGStmtMap();
- CFGReachabilityAnalysis *getCFGReachablityAnalysis();
+ CFGReverseBlockReachabilityAnalysis *getCFGReachablityAnalysis();
/// Return a version of the CFG without any edges pruned.
CFG *getUnoptimizedCFG();
diff --git a/include/clang/Analysis/AnalysisDiagnostic.h b/include/clang/Analysis/AnalysisDiagnostic.h
index 295d0a2133d3..dbf4e4c9aefe 100644
--- a/include/clang/Analysis/AnalysisDiagnostic.h
+++ b/include/clang/Analysis/AnalysisDiagnostic.h
@@ -15,7 +15,8 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
+ SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM,
#define ANALYSISSTART
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
#undef DIAG
diff --git a/include/clang/Analysis/CFG.h b/include/clang/Analysis/CFG.h
index b337d74495c9..ca46459afd9a 100644
--- a/include/clang/Analysis/CFG.h
+++ b/include/clang/Analysis/CFG.h
@@ -19,6 +19,8 @@
#include "llvm/ADT/GraphTraits.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Casting.h"
+#include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/DenseMap.h"
#include "clang/Analysis/Support/BumpVector.h"
#include "clang/Basic/SourceLocation.h"
#include <cassert>
@@ -29,6 +31,7 @@ namespace llvm {
}
namespace clang {
+ class CXXDestructorDecl;
class Decl;
class Stmt;
class Expr;
@@ -47,45 +50,45 @@ class CFGElement {
public:
enum Kind {
// main kind
+ Invalid,
Statement,
Initializer,
- ImplicitDtor,
// dtor kind
AutomaticObjectDtor,
BaseDtor,
MemberDtor,
TemporaryDtor,
- DTOR_BEGIN = AutomaticObjectDtor
+ DTOR_BEGIN = AutomaticObjectDtor,
+ DTOR_END = TemporaryDtor
};
protected:
- // The int bits are used to mark the main kind.
+ // The int bits are used to mark the kind.
llvm::PointerIntPair<void *, 2> Data1;
- // The int bits are used to mark the dtor kind.
llvm::PointerIntPair<void *, 2> Data2;
- CFGElement(void *Ptr, unsigned Int) : Data1(Ptr, Int) {}
- CFGElement(void *Ptr1, unsigned Int1, void *Ptr2, unsigned Int2)
- : Data1(Ptr1, Int1), Data2(Ptr2, Int2) {}
+ CFGElement(Kind kind, const void *Ptr1, const void *Ptr2 = 0)
+ : Data1(const_cast<void*>(Ptr1), ((unsigned) kind) & 0x3),
+ Data2(const_cast<void*>(Ptr2), (((unsigned) kind) >> 2) & 0x3) {}
public:
CFGElement() {}
- Kind getKind() const { return static_cast<Kind>(Data1.getInt()); }
-
- Kind getDtorKind() const {
- assert(getKind() == ImplicitDtor);
- return static_cast<Kind>(Data2.getInt() + DTOR_BEGIN);
+ Kind getKind() const {
+ unsigned x = Data2.getInt();
+ x <<= 2;
+ x |= Data1.getInt();
+ return (Kind) x;
}
-
- bool isValid() const { return Data1.getPointer(); }
+
+ bool isValid() const { return getKind() != Invalid; }
operator bool() const { return isValid(); }
-
- template<class ElemTy> ElemTy getAs() const {
+
+ template<class ElemTy> const ElemTy *getAs() const {
if (llvm::isa<ElemTy>(this))
- return *static_cast<const ElemTy*>(this);
- return ElemTy();
+ return static_cast<const ElemTy*>(this);
+ return 0;
}
static bool classof(const CFGElement *E) { return true; }
@@ -93,13 +96,10 @@ public:
class CFGStmt : public CFGElement {
public:
- CFGStmt() {}
- CFGStmt(Stmt *S) : CFGElement(S, 0) {}
+ CFGStmt(Stmt *S) : CFGElement(Statement, S) {}
Stmt *getStmt() const { return static_cast<Stmt *>(Data1.getPointer()); }
- operator Stmt*() const { return getStmt(); }
-
static bool classof(const CFGElement *E) {
return E->getKind() == Statement;
}
@@ -109,14 +109,12 @@ public:
/// constructor's initialization list.
class CFGInitializer : public CFGElement {
public:
- CFGInitializer() {}
- CFGInitializer(CXXCtorInitializer* I)
- : CFGElement(I, Initializer) {}
+ CFGInitializer(CXXCtorInitializer *initializer)
+ : CFGElement(Initializer, initializer) {}
CXXCtorInitializer* getInitializer() const {
return static_cast<CXXCtorInitializer*>(Data1.getPointer());
}
- operator CXXCtorInitializer*() const { return getInitializer(); }
static bool classof(const CFGElement *E) {
return E->getKind() == Initializer;
@@ -127,14 +125,18 @@ public:
/// by compiler on various occasions.
class CFGImplicitDtor : public CFGElement {
protected:
- CFGImplicitDtor(unsigned K, void* P, void* S)
- : CFGElement(P, ImplicitDtor, S, K - DTOR_BEGIN) {}
+ CFGImplicitDtor(Kind kind, const void *data1, const void *data2 = 0)
+ : CFGElement(kind, data1, data2) {
+ assert(kind >= DTOR_BEGIN && kind <= DTOR_END);
+ }
public:
- CFGImplicitDtor() {}
+ const CXXDestructorDecl *getDestructorDecl(ASTContext &astContext) const;
+ bool isNoReturn(ASTContext &astContext) const;
static bool classof(const CFGElement *E) {
- return E->getKind() == ImplicitDtor;
+ Kind kind = E->getKind();
+ return kind >= DTOR_BEGIN && kind <= DTOR_END;
}
};
@@ -143,22 +145,20 @@ public:
/// of leaving its local scope.
class CFGAutomaticObjDtor: public CFGImplicitDtor {
public:
- CFGAutomaticObjDtor() {}
- CFGAutomaticObjDtor(VarDecl* VD, Stmt* S)
- : CFGImplicitDtor(AutomaticObjectDtor, VD, S) {}
+ CFGAutomaticObjDtor(const VarDecl *var, const Stmt *stmt)
+ : CFGImplicitDtor(AutomaticObjectDtor, var, stmt) {}
- VarDecl* getVarDecl() const {
+ const VarDecl *getVarDecl() const {
return static_cast<VarDecl*>(Data1.getPointer());
}
// Get statement end of which triggered the destructor call.
- Stmt* getTriggerStmt() const {
+ const Stmt *getTriggerStmt() const {
return static_cast<Stmt*>(Data2.getPointer());
}
- static bool classof(const CFGElement *E) {
- return E->getKind() == ImplicitDtor &&
- E->getDtorKind() == AutomaticObjectDtor;
+ static bool classof(const CFGElement *elem) {
+ return elem->getKind() == AutomaticObjectDtor;
}
};
@@ -166,16 +166,15 @@ public:
/// base object in destructor.
class CFGBaseDtor : public CFGImplicitDtor {
public:
- CFGBaseDtor() {}
- CFGBaseDtor(const CXXBaseSpecifier *BS)
- : CFGImplicitDtor(BaseDtor, const_cast<CXXBaseSpecifier*>(BS), NULL) {}
+ CFGBaseDtor(const CXXBaseSpecifier *base)
+ : CFGImplicitDtor(BaseDtor, base) {}
const CXXBaseSpecifier *getBaseSpecifier() const {
return static_cast<const CXXBaseSpecifier*>(Data1.getPointer());
}
static bool classof(const CFGElement *E) {
- return E->getKind() == ImplicitDtor && E->getDtorKind() == BaseDtor;
+ return E->getKind() == BaseDtor;
}
};
@@ -183,16 +182,15 @@ public:
/// member object in destructor.
class CFGMemberDtor : public CFGImplicitDtor {
public:
- CFGMemberDtor() {}
- CFGMemberDtor(FieldDecl *FD)
- : CFGImplicitDtor(MemberDtor, FD, NULL) {}
+ CFGMemberDtor(const FieldDecl *field)
+ : CFGImplicitDtor(MemberDtor, field, 0) {}
- FieldDecl *getFieldDecl() const {
- return static_cast<FieldDecl*>(Data1.getPointer());
+ const FieldDecl *getFieldDecl() const {
+ return static_cast<const FieldDecl*>(Data1.getPointer());
}
static bool classof(const CFGElement *E) {
- return E->getKind() == ImplicitDtor && E->getDtorKind() == MemberDtor;
+ return E->getKind() == MemberDtor;
}
};
@@ -200,16 +198,15 @@ public:
/// at the end of full expression for temporary object.
class CFGTemporaryDtor : public CFGImplicitDtor {
public:
- CFGTemporaryDtor() {}
- CFGTemporaryDtor(CXXBindTemporaryExpr *E)
- : CFGImplicitDtor(TemporaryDtor, E, NULL) {}
+ CFGTemporaryDtor(CXXBindTemporaryExpr *expr)
+ : CFGImplicitDtor(TemporaryDtor, expr, 0) {}
- CXXBindTemporaryExpr *getBindTemporaryExpr() const {
- return static_cast<CXXBindTemporaryExpr *>(Data1.getPointer());
+ const CXXBindTemporaryExpr *getBindTemporaryExpr() const {
+ return static_cast<const CXXBindTemporaryExpr *>(Data1.getPointer());
}
static bool classof(const CFGElement *E) {
- return E->getKind() == ImplicitDtor && E->getDtorKind() == TemporaryDtor;
+ return E->getKind() == TemporaryDtor;
}
};
@@ -267,6 +264,8 @@ public:
/// ? operator LHS expression; RHS expression
/// &&, || expression that uses result of && or ||, RHS
///
+/// But note that any of that may be NULL in case of optimized-out edges.
+///
class CFGBlock {
class ElementList {
typedef BumpVector<CFGElement> ImplTy;
@@ -471,8 +470,6 @@ public:
const Stmt *getLoopTarget() const { return LoopTarget; }
- bool hasBinaryBranchTerminator() const;
-
Stmt* getLabel() { return Label; }
const Stmt* getLabel() const { return Label; }
@@ -537,13 +534,16 @@ public:
class BuildOptions {
public:
+ typedef llvm::DenseMap<const Stmt *, const CFGBlock*> ForcedBlkExprs;
+ ForcedBlkExprs **forcedBlkExprs;
+
bool PruneTriviallyFalseEdges:1;
bool AddEHEdges:1;
bool AddInitializers:1;
bool AddImplicitDtors:1;
BuildOptions()
- : PruneTriviallyFalseEdges(true)
+ : forcedBlkExprs(0), PruneTriviallyFalseEdges(true)
, AddEHEdges(false)
, AddInitializers(false)
, AddImplicitDtors(false) {}
@@ -552,7 +552,7 @@ public:
/// buildCFG - Builds a CFG from an AST. The responsibility to free the
/// constructed CFG belongs to the caller.
static CFG* buildCFG(const Decl *D, Stmt* AST, ASTContext *C,
- BuildOptions BO = BuildOptions());
+ const BuildOptions &BO);
/// createBlock - Create a new block in the CFG. The CFG owns the block;
/// the caller should not directly free it.
@@ -607,8 +607,8 @@ public:
for (const_iterator I=begin(), E=end(); I != E; ++I)
for (CFGBlock::const_iterator BI=(*I)->begin(), BE=(*I)->end();
BI != BE; ++BI) {
- if (CFGStmt S = BI->getAs<CFGStmt>())
- O(S);
+ if (const CFGStmt *stmt = BI->getAs<CFGStmt>())
+ O(stmt->getStmt());
}
}
diff --git a/include/clang/Analysis/DomainSpecific/CocoaConventions.h b/include/clang/Analysis/DomainSpecific/CocoaConventions.h
index 7e6e3815400c..18e81fed79f8 100644
--- a/include/clang/Analysis/DomainSpecific/CocoaConventions.h
+++ b/include/clang/Analysis/DomainSpecific/CocoaConventions.h
@@ -22,7 +22,7 @@ namespace cocoa {
enum NamingConvention { NoConvention, CreateRule, InitRule };
- NamingConvention deriveNamingConvention(Selector S, bool ignorePrefix = true);
+ NamingConvention deriveNamingConvention(Selector S);
static inline bool followsFundamentalRule(Selector S) {
return deriveNamingConvention(S) == CreateRule;
diff --git a/include/clang/Analysis/FlowSensitive/DataflowSolver.h b/include/clang/Analysis/FlowSensitive/DataflowSolver.h
index d75d333db6b6..9561b964b5f8 100644
--- a/include/clang/Analysis/FlowSensitive/DataflowSolver.h
+++ b/include/clang/Analysis/FlowSensitive/DataflowSolver.h
@@ -277,8 +277,8 @@ private:
for (StmtItr I=ItrTraits::StmtBegin(B), E=ItrTraits::StmtEnd(B); I!=E;++I) {
CFGElement El = *I;
- if (CFGStmt S = El.getAs<CFGStmt>())
- ProcessStmt(S, recordStmtValues, AnalysisDirTag());
+ if (const CFGStmt *S = El.getAs<CFGStmt>())
+ ProcessStmt(S->getStmt(), recordStmtValues, AnalysisDirTag());
}
TF.VisitTerminator(const_cast<CFGBlock*>(B));
@@ -293,8 +293,8 @@ private:
for (StmtItr I=ItrTraits::StmtBegin(B), E=ItrTraits::StmtEnd(B); I!=E;++I) {
CFGElement El = *I;
- if (CFGStmt S = El.getAs<CFGStmt>())
- ProcessStmt(S, recordStmtValues, AnalysisDirTag());
+ if (const CFGStmt *S = El.getAs<CFGStmt>())
+ ProcessStmt(S->getStmt(), recordStmtValues, AnalysisDirTag());
}
}
diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h
index 54cfc3dc0db6..07b4dea987de 100644
--- a/include/clang/Analysis/ProgramPoint.h
+++ b/include/clang/Analysis/ProgramPoint.h
@@ -43,6 +43,7 @@ public:
PostStoreKind,
PostPurgeDeadSymbolsKind,
PostStmtCustomKind,
+ PostConditionKind,
PostLValueKind,
PostInitializerKind,
CallEnterKind,
@@ -221,7 +222,17 @@ public:
}
};
-
+// PostCondition represents the post program point of a branch condition.
+class PostCondition : public PostStmt {
+public:
+ PostCondition(const Stmt* S, const LocationContext *L, const void *tag = 0)
+ : PostStmt(S, PostConditionKind, L, tag) {}
+
+ static bool classof(const ProgramPoint* Location) {
+ return Location->getKind() == PostConditionKind;
+ }
+};
+
class LocationCheck : public StmtPoint {
protected:
LocationCheck(const Stmt *S, const LocationContext *L,
diff --git a/include/clang/Analysis/Visitors/CFGStmtVisitor.h b/include/clang/Analysis/Visitors/CFGStmtVisitor.h
index d197e69babde..7fb4ab3ebad9 100644
--- a/include/clang/Analysis/Visitors/CFGStmtVisitor.h
+++ b/include/clang/Analysis/Visitors/CFGStmtVisitor.h
@@ -82,6 +82,7 @@ public:
DISPATCH_CASE(ConditionalOperator)
DISPATCH_CASE(BinaryConditionalOperator)
DISPATCH_CASE(ObjCForCollectionStmt)
+ DISPATCH_CASE(CXXForRangeStmt)
case Stmt::BinaryOperatorClass: {
BinaryOperator* B = cast<BinaryOperator>(S);
@@ -109,6 +110,10 @@ public:
return static_cast<ImplClass*>(this)->BlockStmt_VisitStmt(S);
}
+ RetTy BlockStmt_VisitCXXForRangeStmt(CXXForRangeStmt* S) {
+ return static_cast<ImplClass*>(this)->BlockStmt_VisitStmt(S);
+ }
+
RetTy BlockStmt_VisitImplicitControlFlowExpr(Expr* E) {
return static_cast<ImplClass*>(this)->BlockStmt_VisitExpr(E);
}
diff --git a/include/clang/Basic/AddressSpaces.h b/include/clang/Basic/AddressSpaces.h
new file mode 100644
index 000000000000..d44a9c3b0361
--- /dev/null
+++ b/include/clang/Basic/AddressSpaces.h
@@ -0,0 +1,44 @@
+//===--- AddressSpaces.h - Language-specific address spaces -----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides definitions for the various language-specific address
+// spaces.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_BASIC_ADDRESSSPACES_H
+#define LLVM_CLANG_BASIC_ADDRESSSPACES_H
+
+namespace clang {
+
+namespace LangAS {
+
+/// This enum defines the set of possible language-specific address spaces.
+/// It uses a high starting offset so as not to conflict with any address
+/// space used by a target.
+enum ID {
+ Offset = 0xFFFF00,
+
+ opencl_global = Offset,
+ opencl_local,
+ opencl_constant,
+
+ Last,
+ Count = Last-Offset
+};
+
+/// The type of a lookup table which maps from language-specific address spaces
+/// to target-specific ones.
+typedef unsigned Map[Count];
+
+}
+
+}
+
+#endif
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
index 3e62d411d51a..e4c6722e8378 100644
--- a/include/clang/Basic/Attr.td
+++ b/include/clang/Basic/Attr.td
@@ -46,6 +46,7 @@ class Argument<string name> {
string Name = name;
}
+class BoolArgument<string name> : Argument<name>;
class IdentifierArgument<string name> : Argument<name>;
class IntArgument<string name> : Argument<name>;
class StringArgument<string name> : Argument<name>;
@@ -55,6 +56,9 @@ class TypeArgument<string name> : Argument<name>;
class UnsignedArgument<string name> : Argument<name>;
class VariadicUnsignedArgument<string name> : Argument<name>;
+// A version of the form major.minor[.subminor].
+class VersionArgument<string name> : Argument<name>;
+
// This one's a doozy, so it gets its own special type
// It can be an unsigned integer, or a type. Either can
// be dependent.
@@ -89,8 +93,13 @@ class Attr {
code AdditionalMembers = [{}];
}
+/// An inheritable attribute is inherited by later redeclarations.
class InheritableAttr : Attr;
+/// An inheritable parameter attribute is inherited by later
+/// redeclarations, even when it's written on a parameter.
+class InheritableParamAttr : InheritableAttr;
+
//
// Attributes begin here
//
@@ -129,12 +138,26 @@ def AsmLabel : InheritableAttr {
let Args = [StringArgument<"Label">];
}
+def Availability : InheritableAttr {
+ let Spellings = ["availability"];
+ let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
+ VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
+ BoolArgument<"unavailable">];
+ let AdditionalMembers =
+[{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
+ return llvm::StringSwitch<llvm::StringRef>(Platform)
+ .Case("ios", "iOS")
+ .Case("macosx", "Mac OS X")
+ .Default(llvm::StringRef());
+} }];
+}
+
def Blocks : InheritableAttr {
let Spellings = ["blocks"];
let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
}
-def CarriesDependency : InheritableAttr {
+def CarriesDependency : InheritableParamAttr {
let Spellings = ["carries_dependency"];
let Subjects = [ParmVar, Function];
let Namespaces = ["", "std"];
@@ -154,7 +177,7 @@ def CFReturnsNotRetained : InheritableAttr {
let Subjects = [ObjCMethod, Function];
}
-def CFConsumed : InheritableAttr {
+def CFConsumed : InheritableParamAttr {
let Spellings = ["cf_consumed"];
let Subjects = [ParmVar];
}
@@ -224,10 +247,6 @@ def DLLImport : InheritableAttr {
let Spellings = ["dllimport"];
}
-def Explicit : InheritableAttr {
- let Spellings = [];
-}
-
def FastCall : InheritableAttr {
let Spellings = ["fastcall", "__fastcall"];
}
@@ -236,6 +255,10 @@ def Final : InheritableAttr {
let Spellings = [];
}
+def MsStruct : InheritableAttr {
+ let Spellings = ["__ms_struct__"];
+}
+
def Format : InheritableAttr {
let Spellings = ["format"];
let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">,
@@ -261,7 +284,7 @@ def IBOutlet : InheritableAttr {
def IBOutletCollection : InheritableAttr {
let Spellings = ["iboutletcollection"];
- let Args = [TypeArgument<"Interface">];
+ let Args = [TypeArgument<"InterFace">];
}
def Malloc : InheritableAttr {
@@ -355,7 +378,7 @@ def NSConsumesSelf : InheritableAttr {
let Subjects = [ObjCMethod];
}
-def NSConsumed : InheritableAttr {
+def NSConsumed : InheritableParamAttr {
let Spellings = ["ns_consumed"];
let Subjects = [ParmVar];
}
@@ -364,6 +387,15 @@ def ObjCException : InheritableAttr {
let Spellings = ["objc_exception"];
}
+def ObjCMethodFamily : InheritableAttr {
+ let Spellings = ["objc_method_family"];
+ let Subjects = [ObjCMethod];
+ let Args = [EnumArgument<"Family", "FamilyKind",
+ ["none", "alloc", "copy", "init", "mutableCopy", "new"],
+ ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
+ "OMF_mutableCopy", "OMF_new"]>];
+}
+
def ObjCNSObject : InheritableAttr {
let Spellings = ["NSObject"];
}
@@ -388,6 +420,13 @@ def Packed : InheritableAttr {
let Spellings = ["packed"];
}
+def Pcs : InheritableAttr {
+ let Spellings = ["pcs"];
+ let Args = [EnumArgument<"PCS", "PCSType",
+ ["aapcs", "aapcs-vfp"],
+ ["AAPCS", "AAPCS_VFP"]>];
+}
+
def Pure : InheritableAttr {
let Spellings = ["pure"];
}
diff --git a/include/clang/Basic/AttrKinds.h b/include/clang/Basic/AttrKinds.h
index 65c4f98c952c..9d5ae588c50f 100644
--- a/include/clang/Basic/AttrKinds.h
+++ b/include/clang/Basic/AttrKinds.h
@@ -22,6 +22,7 @@ namespace attr {
enum Kind {
#define ATTR(X) X,
#define LAST_INHERITABLE_ATTR(X) X, LAST_INHERITABLE = X,
+#define LAST_INHERITABLE_PARAM_ATTR(X) X, LAST_INHERITABLE_PARAM = X,
#include "clang/Basic/AttrList.inc"
NUM_ATTRS
};
diff --git a/include/clang/Basic/Builtins.def b/include/clang/Basic/Builtins.def
index b73ac1f4dd45..9a4c768dc649 100644
--- a/include/clang/Basic/Builtins.def
+++ b/include/clang/Basic/Builtins.def
@@ -443,7 +443,7 @@ BUILTIN(__builtin_dwarf_sp_column, "Ui", "n")
BUILTIN(__builtin_extend_pointer, "ULLiv*", "n") // _Unwind_Word == uint64_t
// GCC Object size checking builtins
-BUILTIN(__builtin_object_size, "zv*i", "n")
+BUILTIN(__builtin_object_size, "zvC*i", "n")
BUILTIN(__builtin___memcpy_chk, "v*v*vC*zz", "nF")
BUILTIN(__builtin___memmove_chk, "v*v*vC*zz", "nF")
BUILTIN(__builtin___mempcpy_chk, "v*v*vC*zz", "nF")
@@ -577,6 +577,13 @@ BUILTIN(__sync_lock_release_4, "viD*.", "n")
BUILTIN(__sync_lock_release_8, "vLLiD*.", "n")
BUILTIN(__sync_lock_release_16, "vLLLiD*.", "n")
+BUILTIN(__sync_swap, "v.", "")
+BUILTIN(__sync_swap_1, "ccD*c.", "n")
+BUILTIN(__sync_swap_2, "ssD*s.", "n")
+BUILTIN(__sync_swap_4, "iiD*i.", "n")
+BUILTIN(__sync_swap_8, "LLiLLiD*LLi.", "n")
+BUILTIN(__sync_swap_16, "LLLiLLLiD*LLLi.", "n")
+
// Non-overloaded atomic builtins.
diff --git a/include/clang/Basic/BuiltinsPTX.def b/include/clang/Basic/BuiltinsPTX.def
new file mode 100644
index 000000000000..f90a43f7f404
--- /dev/null
+++ b/include/clang/Basic/BuiltinsPTX.def
@@ -0,0 +1,62 @@
+//===--- BuiltinsPTX.def - PTX Builtin function database ----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the PTX-specific builtin function database. Users of
+// this file must define the BUILTIN macro to make use of this information.
+//
+//===----------------------------------------------------------------------===//
+
+// The format of this database matches clang/Basic/Builtins.def.
+
+BUILTIN(__builtin_ptx_read_tid_x, "i", "nc")
+BUILTIN(__builtin_ptx_read_tid_y, "i", "nc")
+BUILTIN(__builtin_ptx_read_tid_z, "i", "nc")
+BUILTIN(__builtin_ptx_read_tid_w, "i", "nc")
+
+BUILTIN(__builtin_ptx_read_ntid_x, "i", "nc")
+BUILTIN(__builtin_ptx_read_ntid_y, "i", "nc")
+BUILTIN(__builtin_ptx_read_ntid_z, "i", "nc")
+BUILTIN(__builtin_ptx_read_ntid_w, "i", "nc")
+
+BUILTIN(__builtin_ptx_read_ctaid_x, "i", "nc")
+BUILTIN(__builtin_ptx_read_ctaid_y, "i", "nc")
+BUILTIN(__builtin_ptx_read_ctaid_z, "i", "nc")
+BUILTIN(__builtin_ptx_read_ctaid_w, "i", "nc")
+
+BUILTIN(__builtin_ptx_read_nctaid_x, "i", "nc")
+BUILTIN(__builtin_ptx_read_nctaid_y, "i", "nc")
+BUILTIN(__builtin_ptx_read_nctaid_z, "i", "nc")
+BUILTIN(__builtin_ptx_read_nctaid_w, "i", "nc")
+
+BUILTIN(__builtin_ptx_read_laneid, "i", "nc")
+BUILTIN(__builtin_ptx_read_warpid, "i", "nc")
+BUILTIN(__builtin_ptx_read_nwarpid, "i", "nc")
+
+BUILTIN(__builtin_ptx_read_smid, "i", "nc")
+BUILTIN(__builtin_ptx_read_nsmid, "i", "nc")
+BUILTIN(__builtin_ptx_read_gridid, "i", "nc")
+
+BUILTIN(__builtin_ptx_read_lanemask_eq, "i", "nc")
+BUILTIN(__builtin_ptx_read_lanemask_le, "i", "nc")
+BUILTIN(__builtin_ptx_read_lanemask_lt, "i", "nc")
+BUILTIN(__builtin_ptx_read_lanemask_ge, "i", "nc")
+BUILTIN(__builtin_ptx_read_lanemask_gt, "i", "nc")
+
+BUILTIN(__builtin_ptx_read_clock, "i", "n")
+BUILTIN(__builtin_ptx_read_clock64, "Li", "n")
+
+BUILTIN(__builtin_ptx_read_pm0, "i", "n")
+BUILTIN(__builtin_ptx_read_pm1, "i", "n")
+BUILTIN(__builtin_ptx_read_pm2, "i", "n")
+BUILTIN(__builtin_ptx_read_pm3, "i", "n")
+
+BUILTIN(__builtin_ptx_bar_sync, "vi", "n")
+
+
+#undef BUILTIN
diff --git a/include/clang/Basic/BuiltinsX86.def b/include/clang/Basic/BuiltinsX86.def
index da106daf26ec..2c2a84ab30ae 100644
--- a/include/clang/Basic/BuiltinsX86.def
+++ b/include/clang/Basic/BuiltinsX86.def
@@ -24,6 +24,37 @@
// FIXME: Are these nothrow/const?
+// 3DNow!
+//
+BUILTIN(__builtin_ia32_pavgusb, "V8cV8cV8c", "nc")
+BUILTIN(__builtin_ia32_pf2id, "V2iV2f", "nc")
+BUILTIN(__builtin_ia32_pfacc, "V2fV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfadd, "V2fV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfcmpeq, "V2iV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfcmpge, "V2iV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfcmpgt, "V2iV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfmax, "V2fV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfmin, "V2fV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfmul, "V2fV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfrcp, "V2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfrcpit1, "V2fV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfrcpit2, "V2fV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfrsqrt, "V2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfrsqit1, "V2fV2fV2f", "nc")
+// GCC has pfrsqrtit1, even though this is not the name of the instruction.
+BUILTIN(__builtin_ia32_pfrsqrtit1, "V2fV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfsub, "V2fV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pfsubr, "V2fV2fV2f", "nc")
+BUILTIN(__builtin_ia32_pi2fd, "V2fV2i", "nc")
+BUILTIN(__builtin_ia32_pmulhrw, "V4sV4sV4s", "nc