From 4ba675006b5a8edfc48b6a9bd3dcf54a70cc08f2 Mon Sep 17 00:00:00 2001 From: Roman Divacky Date: Tue, 13 Jul 2010 17:21:42 +0000 Subject: Update clang to r108243. --- CMakeLists.txt | 35 +- Makefile | 57 +- NOTES.txt | 3 +- README.txt | 2 +- clang.xcodeproj/project.pbxproj | 265 +- docs/InternalsManual.html | 8 +- docs/Makefile | 4 +- docs/PCHInternals.html | 30 + docs/UsersManual.html | 135 +- docs/tools/Makefile | 7 +- examples/Makefile | 4 +- examples/PrintFunctionNames/CMakeLists.txt | 22 +- examples/PrintFunctionNames/Makefile | 12 +- examples/PrintFunctionNames/PrintFunctionNames.cpp | 15 +- examples/clang-interpreter/CMakeLists.txt | 2 + examples/clang-interpreter/Makefile | 12 +- examples/clang-interpreter/main.cpp | 2 +- examples/wpa/CMakeLists.txt | 2 + examples/wpa/Makefile | 17 +- examples/wpa/clang-wpa.cpp | 101 +- include/Makefile | 4 +- include/clang-c/Index.h | 21 +- include/clang-c/Makefile | 4 +- include/clang/AST/ASTContext.h | 121 +- include/clang/AST/Attr.h | 229 +- include/clang/AST/CMakeLists.txt | 15 +- include/clang/AST/CanonicalType.h | 3 + include/clang/AST/Decl.h | 243 +- include/clang/AST/DeclBase.h | 50 +- include/clang/AST/DeclCXX.h | 206 +- include/clang/AST/DeclFriend.h | 7 + include/clang/AST/DeclObjC.h | 42 +- include/clang/AST/DeclTemplate.h | 310 +- include/clang/AST/DeclVisitor.h | 17 +- include/clang/AST/Expr.h | 143 +- include/clang/AST/ExprCXX.h | 220 +- include/clang/AST/ExternalASTSource.h | 103 +- include/clang/AST/Makefile | 20 +- include/clang/AST/RecursiveASTVisitor.h | 1913 +++++-- include/clang/AST/Redeclarable.h | 5 + include/clang/AST/Stmt.h | 75 +- include/clang/AST/StmtIterator.h | 1 + include/clang/AST/StmtNodes.td | 127 - include/clang/AST/TemplateBase.h | 26 + include/clang/AST/TemplateName.h | 11 + include/clang/AST/Type.h | 212 +- include/clang/AST/TypeLoc.h | 126 +- include/clang/AST/TypeLocBuilder.h | 9 +- include/clang/AST/TypeNodes.def | 1 + include/clang/AST/UsuallyTinyPtrVector.h | 11 +- .../clang/Analysis/Analyses/PrintfFormatString.h | 214 +- include/clang/Analysis/Support/BumpVector.h | 1 + .../Analysis/Visitors/CFGRecStmtDeclVisitor.h | 62 +- include/clang/Basic/Attr.td | 382 ++ include/clang/Basic/AttrKinds.h | 31 + include/clang/Basic/Builtins.def | 1 + include/clang/Basic/BuiltinsARM.def | 8 +- include/clang/Basic/BuiltinsPPC.def | 111 +- include/clang/Basic/CMakeLists.txt | 12 + include/clang/Basic/DeclNodes.td | 70 + include/clang/Basic/Diagnostic.h | 56 +- include/clang/Basic/DiagnosticCommonKinds.td | 1 + include/clang/Basic/DiagnosticFrontendKinds.td | 8 +- include/clang/Basic/DiagnosticGroups.td | 13 +- include/clang/Basic/DiagnosticLexKinds.td | 5 +- include/clang/Basic/DiagnosticParseKinds.td | 19 +- include/clang/Basic/DiagnosticSemaKinds.td | 183 +- include/clang/Basic/IdentifierTable.h | 6 +- include/clang/Basic/LangOptions.h | 47 +- include/clang/Basic/Makefile | 41 +- include/clang/Basic/PartialDiagnostic.h | 12 +- include/clang/Basic/SourceLocation.h | 50 + include/clang/Basic/StmtNodes.td | 130 + include/clang/Basic/TargetInfo.h | 29 +- include/clang/Basic/TargetOptions.h | 8 + include/clang/Basic/Version.h | 10 +- include/clang/Basic/Version.inc.in | 6 + include/clang/Basic/arm_neon.td | 341 ++ include/clang/Checker/AnalysisConsumer.h | 35 + include/clang/Checker/BugReporter/BugReporter.h | 1 + include/clang/Checker/FrontendActions.h | 29 + include/clang/Checker/PathDiagnosticClients.h | 32 + include/clang/Checker/PathSensitive/Checker.h | 30 +- .../clang/Checker/PathSensitive/CheckerVisitor.h | 9 +- include/clang/Checker/PathSensitive/Environment.h | 2 +- .../clang/Checker/PathSensitive/ExplodedGraph.h | 10 +- include/clang/Checker/PathSensitive/GRCoreEngine.h | 18 +- include/clang/Checker/PathSensitive/GRExprEngine.h | 31 +- include/clang/Checker/PathSensitive/GRState.h | 27 +- include/clang/Checker/PathSensitive/GRSubEngine.h | 28 +- .../clang/Checker/PathSensitive/GRTransferFuncs.h | 2 +- include/clang/Checker/PathSensitive/MemRegion.h | 77 +- include/clang/Checker/PathSensitive/SVals.h | 4 +- include/clang/Checker/PathSensitive/SValuator.h | 8 +- include/clang/Checker/PathSensitive/Store.h | 31 +- .../clang/Checker/PathSensitive/SymbolManager.h | 43 +- include/clang/CodeGen/BackendUtil.h | 37 + include/clang/CodeGen/CodeGenAction.h | 79 + include/clang/CodeGen/CodeGenOptions.h | 131 - include/clang/CodeGen/ModuleBuilder.h | 3 + include/clang/Driver/Action.h | 13 +- include/clang/Driver/Arg.h | 181 +- include/clang/Driver/ArgList.h | 97 +- include/clang/Driver/CC1Options.td | 24 +- include/clang/Driver/Compilation.h | 13 +- include/clang/Driver/Driver.h | 6 + include/clang/Driver/HostInfo.h | 2 + include/clang/Driver/Makefile | 4 +- include/clang/Driver/OptTable.h | 3 +- include/clang/Driver/Option.h | 49 +- include/clang/Driver/Options.td | 104 +- include/clang/Driver/ToolChain.h | 9 +- include/clang/Driver/Types.def | 10 +- include/clang/Driver/Types.h | 4 + include/clang/Frontend/ASTConsumers.h | 16 +- include/clang/Frontend/AnalysisConsumer.h | 104 - include/clang/Frontend/AnalyzerOptions.h | 98 + include/clang/Frontend/CodeGenAction.h | 70 - include/clang/Frontend/CodeGenOptions.h | 141 + include/clang/Frontend/CompilerInstance.h | 7 + include/clang/Frontend/CompilerInvocation.h | 4 +- include/clang/Frontend/DiagnosticOptions.h | 5 + include/clang/Frontend/FixItRewriter.h | 104 - include/clang/Frontend/FrontendAction.h | 67 +- include/clang/Frontend/FrontendActions.h | 54 +- include/clang/Frontend/FrontendOptions.h | 23 +- include/clang/Frontend/FrontendPluginRegistry.h | 2 +- include/clang/Frontend/PCHBitCodes.h | 59 +- include/clang/Frontend/PCHReader.h | 144 +- include/clang/Frontend/PCHWriter.h | 54 +- include/clang/Frontend/PathDiagnosticClients.h | 32 - include/clang/Frontend/TextDiagnosticPrinter.h | 9 +- include/clang/Frontend/TypeXML.def | 5 + include/clang/Frontend/Utils.h | 6 - include/clang/Index/CallGraph.h | 4 +- include/clang/Index/Entity.h | 4 + include/clang/Index/Indexer.h | 7 + include/clang/Index/TranslationUnit.h | 2 + include/clang/Lex/PPCallbacks.h | 12 + include/clang/Lex/Pragma.h | 33 +- include/clang/Lex/Preprocessor.h | 17 +- include/clang/Lex/Token.h | 8 +- include/clang/Makefile | 4 +- include/clang/Parse/Action.h | 305 +- include/clang/Parse/AttributeList.h | 1 + include/clang/Parse/DeclSpec.h | 10 + include/clang/Parse/Parser.h | 14 +- include/clang/Parse/Template.h | 2 +- include/clang/Rewrite/ASTConsumers.h | 45 + include/clang/Rewrite/FixItRewriter.h | 104 + include/clang/Rewrite/FrontendActions.h | 69 + include/clang/Rewrite/RewriteRope.h | 1 + include/clang/Rewrite/Rewriter.h | 1 + include/clang/Rewrite/Rewriters.h | 31 + include/clang/Sema/CodeCompleteConsumer.h | 24 +- include/clang/Sema/ExternalSemaSource.h | 2 + lib/AST/ASTContext.cpp | 569 +- lib/AST/ASTImporter.cpp | 93 +- lib/AST/AttrImpl.cpp | 9 +- lib/AST/CMakeLists.txt | 4 +- lib/AST/CXXInheritance.cpp | 38 +- lib/AST/Decl.cpp | 161 +- lib/AST/DeclBase.cpp | 282 +- lib/AST/DeclCXX.cpp | 124 +- lib/AST/DeclFriend.cpp | 4 + lib/AST/DeclObjC.cpp | 23 +- lib/AST/DeclPrinter.cpp | 47 +- lib/AST/DeclTemplate.cpp | 117 +- lib/AST/Expr.cpp | 427 +- lib/AST/ExprCXX.cpp | 101 +- lib/AST/ExprClassification.cpp | 471 ++ lib/AST/ExprConstant.cpp | 88 +- lib/AST/Makefile | 6 +- lib/AST/RecordLayoutBuilder.cpp | 972 ++-- lib/AST/Stmt.cpp | 132 +- lib/AST/StmtPrinter.cpp | 34 +- lib/AST/StmtProfile.cpp | 13 +- lib/AST/TemplateBase.cpp | 27 + lib/AST/TemplateName.cpp | 11 + lib/AST/Type.cpp | 133 +- lib/AST/TypePrinter.cpp | 51 +- lib/Analysis/CFG.cpp | 29 +- lib/Analysis/CMakeLists.txt | 3 +- lib/Analysis/LiveVariables.cpp | 22 +- lib/Analysis/Makefile | 6 +- lib/Analysis/PrintfFormatString.cpp | 672 ++- lib/Basic/CMakeLists.txt | 3 + lib/Basic/Diagnostic.cpp | 19 +- lib/Basic/Makefile | 9 +- lib/Basic/TargetInfo.cpp | 6 + lib/Basic/Targets.cpp | 166 +- lib/Checker/AnalysisConsumer.cpp | 592 ++ lib/Checker/AttrNonNullChecker.cpp | 5 +- lib/Checker/BasicConstraintManager.cpp | 124 +- lib/Checker/BasicObjCFoundationChecks.cpp | 93 +- lib/Checker/BasicObjCFoundationChecks.h | 3 - lib/Checker/BasicStore.cpp | 99 +- lib/Checker/BugReporter.cpp | 4 +- lib/Checker/BuiltinFunctionChecker.cpp | 15 +- lib/Checker/CFRefCount.cpp | 201 +- lib/Checker/CMakeLists.txt | 30 +- lib/Checker/CStringChecker.cpp | 525 ++ lib/Checker/CallInliner.cpp | 2 +- lib/Checker/CastSizeChecker.cpp | 21 +- lib/Checker/CheckSecuritySyntaxOnly.cpp | 4 +- lib/Checker/Environment.cpp | 4 +- lib/Checker/FlatStore.cpp | 18 +- lib/Checker/FrontendActions.cpp | 21 + lib/Checker/GRCoreEngine.cpp | 6 +- lib/Checker/GRExprEngine.cpp | 176 +- lib/Checker/GRExprEngineExperimentalChecks.cpp | 3 + lib/Checker/GRExprEngineExperimentalChecks.h | 3 + lib/Checker/GRExprEngineInternalChecks.h | 2 +- lib/Checker/GRState.cpp | 31 +- lib/Checker/HTMLDiagnostics.cpp | 577 ++ lib/Checker/IdempotentOperationChecker.cpp | 454 ++ lib/Checker/LLVMConventionsChecker.cpp | 50 +- lib/Checker/Makefile | 6 +- lib/Checker/MallocChecker.cpp | 256 +- lib/Checker/MemRegion.cpp | 179 +- lib/Checker/OSAtomicChecker.cpp | 8 +- lib/Checker/PathDiagnostic.cpp | 13 +- lib/Checker/PlistDiagnostics.cpp | 471 ++ lib/Checker/RangeConstraintManager.cpp | 301 +- lib/Checker/RegionStore.cpp | 339 +- lib/Checker/ReturnStackAddressChecker.cpp | 125 - lib/Checker/SVals.cpp | 10 +- lib/Checker/SValuator.cpp | 8 +- lib/Checker/SimpleConstraintManager.cpp | 166 +- lib/Checker/SimpleConstraintManager.h | 26 +- lib/Checker/SimpleSValuator.cpp | 619 ++- lib/Checker/StackAddrLeakChecker.cpp | 204 + lib/Checker/Store.cpp | 14 +- lib/Checker/StreamChecker.cpp | 287 + lib/Checker/SymbolManager.cpp | 38 +- lib/Checker/VLASizeChecker.cpp | 49 +- lib/CodeGen/ABIInfo.h | 12 +- lib/CodeGen/BackendUtil.cpp | 339 ++ lib/CodeGen/CGBlocks.cpp | 72 +- lib/CodeGen/CGBlocks.h | 7 +- lib/CodeGen/CGBuilder.h | 8 +- lib/CodeGen/CGBuiltin.cpp | 924 +++- lib/CodeGen/CGCXX.cpp | 77 +- lib/CodeGen/CGCXXABI.h | 1 + lib/CodeGen/CGCall.cpp | 458 +- lib/CodeGen/CGCall.h | 8 +- lib/CodeGen/CGClass.cpp | 156 +- lib/CodeGen/CGDebugInfo.cpp | 43 +- lib/CodeGen/CGDecl.cpp | 148 +- lib/CodeGen/CGDeclCXX.cpp | 195 +- lib/CodeGen/CGException.cpp | 1525 ++++-- lib/CodeGen/CGException.h | 342 ++ lib/CodeGen/CGExpr.cpp | 447 +- lib/CodeGen/CGExprAgg.cpp | 114 +- lib/CodeGen/CGExprCXX.cpp | 111 +- lib/CodeGen/CGExprComplex.cpp | 76 +- lib/CodeGen/CGExprConstant.cpp | 102 +- lib/CodeGen/CGExprScalar.cpp | 496 +- lib/CodeGen/CGObjC.cpp | 29 +- lib/CodeGen/CGObjCGNU.cpp | 378 +- lib/CodeGen/CGObjCMac.cpp | 791 +-- lib/CodeGen/CGObjCRuntime.h | 10 +- lib/CodeGen/CGRTTI.cpp | 22 +- lib/CodeGen/CGStmt.cpp | 275 +- lib/CodeGen/CGTemporaries.cpp | 144 +- lib/CodeGen/CGVTables.cpp | 427 +- lib/CodeGen/CGVTables.h | 17 +- lib/CodeGen/CMakeLists.txt | 6 +- lib/CodeGen/CodeGenAction.cpp | 348 ++ lib/CodeGen/CodeGenFunction.cpp | 640 ++- lib/CodeGen/CodeGenFunction.h | 632 ++- lib/CodeGen/CodeGenModule.cpp | 370 +- lib/CodeGen/CodeGenModule.h | 52 +- lib/CodeGen/CodeGenTypes.cpp | 82 +- lib/CodeGen/CodeGenTypes.h | 34 +- lib/CodeGen/GlobalDecl.h | 10 +- lib/CodeGen/Makefile | 9 +- lib/CodeGen/Mangle.cpp | 197 +- lib/CodeGen/Mangle.h | 12 +- lib/CodeGen/MicrosoftCXXABI.cpp | 1191 ++++ lib/CodeGen/ModuleBuilder.cpp | 2 +- lib/CodeGen/TargetInfo.cpp | 393 +- lib/Driver/Action.cpp | 5 + lib/Driver/Arg.cpp | 189 +- lib/Driver/ArgList.cpp | 92 +- lib/Driver/CMakeLists.txt | 4 +- lib/Driver/Compilation.cpp | 19 +- lib/Driver/Driver.cpp | 130 +- lib/Driver/HostInfo.cpp | 58 + lib/Driver/Makefile | 6 +- lib/Driver/OptTable.cpp | 13 +- lib/Driver/Option.cpp | 106 +- lib/Driver/ToolChains.cpp | 186 +- lib/Driver/ToolChains.h | 18 +- lib/Driver/Tools.cpp | 486 +- lib/Driver/Tools.h | 52 + lib/Driver/Types.cpp | 18 + lib/Frontend/ASTConsumers.cpp | 21 +- lib/Frontend/ASTMerge.cpp | 7 +- lib/Frontend/ASTUnit.cpp | 10 +- lib/Frontend/AnalysisConsumer.cpp | 587 -- lib/Frontend/BoostConAction.cpp | 10 +- lib/Frontend/CMakeLists.txt | 12 +- lib/Frontend/CodeGenAction.cpp | 593 -- lib/Frontend/CompilerInstance.cpp | 32 +- lib/Frontend/CompilerInvocation.cpp | 235 +- lib/Frontend/FixItRewriter.cpp | 167 - lib/Frontend/FrontendAction.cpp | 54 +- lib/Frontend/FrontendActions.cpp | 96 +- lib/Frontend/FrontendOptions.cpp | 4 +- lib/Frontend/GeneratePCH.cpp | 11 +- lib/Frontend/HTMLDiagnostics.cpp | 577 -- lib/Frontend/HTMLPrint.cpp | 94 - lib/Frontend/InitHeaderSearch.cpp | 45 +- lib/Frontend/InitPreprocessor.cpp | 37 +- lib/Frontend/Makefile | 6 +- lib/Frontend/PCHReader.cpp | 443 +- lib/Frontend/PCHReaderDecl.cpp | 609 ++- lib/Frontend/PCHReaderStmt.cpp | 1064 ++-- lib/Frontend/PCHWriter.cpp | 510 +- lib/Frontend/PCHWriterDecl.cpp | 423 +- lib/Frontend/PCHWriterStmt.cpp | 488 +- lib/Frontend/PlistDiagnostics.cpp | 471 -- lib/Frontend/PrintParserCallbacks.cpp | 3 +- lib/Frontend/PrintPreprocessedOutput.cpp | 63 +- lib/Frontend/RewriteMacros.cpp | 217 - lib/Frontend/RewriteObjC.cpp | 5778 ------------------- lib/Frontend/RewriteTest.cpp | 39 - lib/Frontend/TextDiagnosticPrinter.cpp | 63 +- lib/Frontend/Warnings.cpp | 2 + lib/Headers/CMakeLists.txt | 13 +- lib/Headers/Makefile | 21 +- lib/Headers/altivec.h | 5601 +++++++++++++++++-- lib/Headers/arm_neon.td | 341 ++ lib/Headers/emmintrin.h | 7 +- lib/Headers/smmintrin.h | 16 +- lib/Headers/stddef.h | 7 + lib/Headers/stdint.h | 4 +- lib/Headers/xmmintrin.h | 6 +- lib/Index/CallGraph.cpp | 2 +- lib/Index/Entity.cpp | 77 +- lib/Index/EntityImpl.h | 1 + lib/Index/Indexer.cpp | 21 +- lib/Index/Makefile | 12 +- lib/Lex/Lexer.cpp | 56 +- lib/Lex/LiteralSupport.cpp | 17 +- lib/Lex/Makefile | 8 +- lib/Lex/PPCaching.cpp | 12 +- lib/Lex/PPMacroExpansion.cpp | 2 + lib/Lex/Pragma.cpp | 209 +- lib/Lex/Preprocessor.cpp | 10 +- lib/Makefile | 6 +- lib/Parse/AttributeList.cpp | 1 + lib/Parse/CMakeLists.txt | 2 +- lib/Parse/DeclSpec.cpp | 55 +- lib/Parse/Makefile | 6 +- lib/Parse/ParseCXXInlineMethods.cpp | 52 +- lib/Parse/ParseDecl.cpp | 123 +- lib/Parse/ParseDeclCXX.cpp | 186 +- lib/Parse/ParseExpr.cpp | 89 +- lib/Parse/ParseExprCXX.cpp | 144 +- lib/Parse/ParseInit.cpp | 4 +- lib/Parse/ParseObjc.cpp | 144 +- lib/Parse/ParsePragma.cpp | 12 +- lib/Parse/ParsePragma.h | 16 +- lib/Parse/ParseStmt.cpp | 35 +- lib/Parse/ParseTemplate.cpp | 134 +- lib/Parse/Parser.cpp | 114 +- lib/Parse/RAIIObjectsForParser.h | 17 + lib/Rewrite/CMakeLists.txt | 6 + lib/Rewrite/FixItRewriter.cpp | 167 + lib/Rewrite/FrontendActions.cpp | 106 + lib/Rewrite/HTMLPrint.cpp | 94 + lib/Rewrite/Makefile | 6 +- lib/Rewrite/RewriteMacros.cpp | 217 + lib/Rewrite/RewriteObjC.cpp | 5785 ++++++++++++++++++++ lib/Rewrite/RewriteRope.cpp | 2 +- lib/Rewrite/RewriteTest.cpp | 39 + lib/Rewrite/Rewriter.cpp | 12 +- lib/Runtime/Makefile | 101 - lib/Sema/CMakeLists.txt | 3 +- lib/Sema/JumpDiagnostics.cpp | 70 +- lib/Sema/Lookup.h | 5 + lib/Sema/Makefile | 6 +- lib/Sema/Sema.cpp | 45 +- lib/Sema/Sema.h | 239 +- lib/Sema/SemaAccess.cpp | 30 +- lib/Sema/SemaAttr.cpp | 13 +- lib/Sema/SemaCXXCast.cpp | 62 +- lib/Sema/SemaCXXScopeSpec.cpp | 6 +- lib/Sema/SemaChecking.cpp | 458 +- lib/Sema/SemaCodeComplete.cpp | 1026 +++- lib/Sema/SemaDecl.cpp | 298 +- lib/Sema/SemaDeclAttr.cpp | 114 +- lib/Sema/SemaDeclCXX.cpp | 1385 +++-- lib/Sema/SemaDeclObjC.cpp | 52 +- lib/Sema/SemaExceptionSpec.cpp | 9 + lib/Sema/SemaExpr.cpp | 689 ++- lib/Sema/SemaExprCXX.cpp | 255 +- lib/Sema/SemaExprObjC.cpp | 14 +- lib/Sema/SemaInit.cpp | 187 +- lib/Sema/SemaInit.h | 10 +- lib/Sema/SemaLookup.cpp | 446 +- lib/Sema/SemaObjCProperty.cpp | 79 +- lib/Sema/SemaOverload.cpp | 662 ++- lib/Sema/SemaStmt.cpp | 170 +- lib/Sema/SemaTemplate.cpp | 644 ++- lib/Sema/SemaTemplate.h | 31 +- lib/Sema/SemaTemplateDeduction.cpp | 12 + lib/Sema/SemaTemplateInstantiate.cpp | 26 +- lib/Sema/SemaTemplateInstantiateDecl.cpp | 87 +- lib/Sema/SemaType.cpp | 372 +- lib/Sema/TreeTransform.h | 301 +- test/ASTMerge/Inputs/class1.cpp | 8 + test/ASTMerge/Inputs/class2.cpp | 8 + test/ASTMerge/class.cpp | 9 + test/Analysis/PR7218.c | 6 + test/Analysis/additive-folding-range-constraints.c | 99 + test/Analysis/additive-folding.c | 203 + test/Analysis/analyze_display_progress.c | 9 + test/Analysis/bstring.c | 277 + test/Analysis/constant-folding.c | 72 + test/Analysis/dead-stores.c | 4 +- test/Analysis/dead-stores.cpp | 8 + test/Analysis/free.c | 71 + test/Analysis/idempotent-operations.c | 52 + test/Analysis/malloc.c | 44 + test/Analysis/misc-ps-region-store.m | 8 + test/Analysis/misc-ps.m | 51 +- test/Analysis/no-outofbounds.c | 17 + test/Analysis/null-deref-ps.c | 13 +- test/Analysis/outofbound.c | 35 + test/Analysis/ptr-arith.c | 226 + test/Analysis/rdar-6442306-1.m | 2 +- test/Analysis/rdar-7168531.m | 4 +- test/Analysis/reference.cpp | 45 + test/Analysis/retain-release.m | 14 + test/Analysis/stack-addr-ps.c | 6 +- test/Analysis/stackaddrleak.c | 34 + test/Analysis/stream.c | 41 + test/Analysis/undef-buffers.c | 32 + .../basic/basic.lookup/basic.lookup.argdep/p2.cpp | 22 + .../basic.lookup/basic.lookup.classref/p1.cpp | 46 + .../basic/basic.lookup/basic.lookup.qual/p6-0x.cpp | 3 + .../basic/basic.lookup/basic.lookup.qual/p6.cpp | 2 +- .../CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp | 18 + test/CXX/class.access/class.access.base/p1.cpp | 18 +- test/CXX/class.access/class.access.base/p5.cpp | 4 +- test/CXX/class.access/class.access.dcl/p1.cpp | 2 +- test/CXX/class.access/class.friend/p1.cpp | 27 +- test/CXX/class.access/class.protected/p1.cpp | 21 +- test/CXX/class.access/p4.cpp | 11 +- .../basic.namespace/namespace.udecl/p10.cpp | 2 +- .../basic.namespace/namespace.udecl/p12.cpp | 35 +- .../basic.namespace/namespace.udecl/p13.cpp | 13 + test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp | 78 + .../dcl.init.ref/p16-cxx0x-no-extra-copy.cpp | 50 - .../dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp | 32 +- .../dcl.init.ref/p5-cxx0x-no-extra-copy.cpp | 64 + test/CXX/except/except.spec/p14-ir.cpp | 78 + test/CXX/except/except.spec/p14.cpp | 29 + test/CXX/special/class.copy/p20.cpp | 46 + test/CXX/special/class.copy/p9.cpp | 44 + .../temp.variadic/parameter-matching.cpp | 21 + test/CXX/temp/temp.param/p2.cpp | 5 + test/CXX/temp/temp.spec/temp.explicit/p11.cpp | 18 + test/CXX/temp/temp.spec/temp.explicit/p2.cpp | 6 +- .../temp/temp.spec/temp.explicit/p9-linkage.cpp | 2 +- test/CodeCompletion/call.cpp | 2 +- test/CodeCompletion/ordinary-name.cpp | 62 +- test/CodeGen/2008-07-29-override-alias-decl.c | 10 +- test/CodeGen/2008-12-02-logical-or-fold.c | 4 - test/CodeGen/address-space-field2.c | 4 - test/CodeGen/address-space-field3.c | 4 - test/CodeGen/address-space-field4.c | 6 - test/CodeGen/address-space.c | 34 +- test/CodeGen/altivec.c | 4 + test/CodeGen/arm-arguments.c | 64 +- test/CodeGen/arm-cc.c | 18 + test/CodeGen/assign.c | 32 + test/CodeGen/available-externally-suppress.c | 12 + test/CodeGen/blocks-aligned-byref-variable.c | 4 +- test/CodeGen/blocks.c | 6 + test/CodeGen/builtin-attributes.c | 6 +- test/CodeGen/builtins-arm.c | 8 +- test/CodeGen/builtins-ppc-altivec.c | 1174 +++- test/CodeGen/builtins.c | 12 +- test/CodeGen/const-arithmetic.c | 4 +- test/CodeGen/const-unordered-compare.c | 2 +- test/CodeGen/decl.c | 28 + test/CodeGen/exprs.c | 28 +- test/CodeGen/extern-inline.c | 2 +- test/CodeGen/frame-pointer-elim.c | 29 + test/CodeGen/func-in-block.c | 18 + test/CodeGen/init.c | 6 + test/CodeGen/inline.c | 6 +- test/CodeGen/inline2.c | 4 +- test/CodeGen/instrument-functions.c | 18 + test/CodeGen/integer-overflow.c | 45 + test/CodeGen/object-size.c | 18 +- test/CodeGen/pascal-wchar-string.c | 31 + test/CodeGen/pragma-pack-1.c | 2 +- test/CodeGen/regparm.c | 5 + test/CodeGen/statements.c | 2 +- test/CodeGen/struct-init.c | 8 + test/CodeGen/typedef-func.c | 2 +- test/CodeGen/volatile.c | 6 +- test/CodeGen/x86_64-arguments.c | 34 +- test/CodeGenCXX/DynArrayInit.cpp | 15 + test/CodeGenCXX/alloca-align.cpp | 2 +- test/CodeGenCXX/arm-cc.cpp | 20 + test/CodeGenCXX/arm.cpp | 3 +- test/CodeGenCXX/block-in-ctor-dtor.cpp | 48 + test/CodeGenCXX/condition.cpp | 124 +- test/CodeGenCXX/constructor-convert.cpp | 2 +- test/CodeGenCXX/copy-in-cplus-object.cpp | 28 + test/CodeGenCXX/cxx-apple-kext.cpp | 4 +- test/CodeGenCXX/default-arg-temps.cpp | 1 - test/CodeGenCXX/destructors.cpp | 109 +- test/CodeGenCXX/eh.cpp | 116 + test/CodeGenCXX/global-dtor-no-atexit.cpp | 3 + test/CodeGenCXX/global-init-darwin.cpp | 23 + test/CodeGenCXX/global-init.cpp | 8 +- .../incomplete-member-function-pointer.cpp | 10 + test/CodeGenCXX/instantiate-blocks.cpp | 33 + test/CodeGenCXX/internal-linkage.cpp | 37 + test/CodeGenCXX/mangle-address-space.cpp | 6 + test/CodeGenCXX/mangle-exprs.cpp | 2 +- test/CodeGenCXX/mangle-ms.cpp | 96 + test/CodeGenCXX/mangle-subst-std.cpp | 10 + test/CodeGenCXX/mangle-subst.cpp | 13 + test/CodeGenCXX/mangle-unnamed.cpp | 34 +- test/CodeGenCXX/mangle.cpp | 19 + test/CodeGenCXX/member-functions.cpp | 2 +- test/CodeGenCXX/member-init-assignment.cpp | 17 + test/CodeGenCXX/nrvo.cpp | 87 +- test/CodeGenCXX/pointers-to-data-members.cpp | 36 +- test/CodeGenCXX/reference-in-block-args.cpp | 29 + test/CodeGenCXX/references.cpp | 43 +- test/CodeGenCXX/rtti-layout.cpp | 14 + test/CodeGenCXX/rtti-linkage.cpp | 11 + test/CodeGenCXX/sel-address.mm | 14 + test/CodeGenCXX/static-init.cpp | 2 +- test/CodeGenCXX/template-instantiation.cpp | 2 +- test/CodeGenCXX/template-static-var-defer.cpp | 12 + test/CodeGenCXX/temporaries.cpp | 18 + test/CodeGenCXX/threadsafe-statics-exceptions.cpp | 11 +- test/CodeGenCXX/throw-expression-dtor.cpp | 13 + test/CodeGenCXX/thunks.cpp | 12 + test/CodeGenCXX/virtual-base-destructor-call.cpp | 11 +- .../virtual-functions-incomplete-types.cpp | 2 +- .../visibility-hidden-extern-templates.cpp | 26 + test/CodeGenCXX/visibility-inlines-hidden.cpp | 57 + test/CodeGenCXX/visibility.cpp | 20 +- test/CodeGenCXX/x86_64-arguments.cpp | 28 +- test/CodeGenObjC/assign.m | 36 + test/CodeGenObjC/bitfield_encoding.m | 12 + test/CodeGenObjC/blocks-5.m | 37 + test/CodeGenObjC/category-class.m | 17 + test/CodeGenObjC/dot-syntax-2.m | 27 + test/CodeGenObjC/exceptions.m | 29 +- test/CodeGenObjC/metadata_symbols.m | 4 +- test/CodeGenObjC/property-category-impl.m | 20 + test/CodeGenObjCXX/copyable-property-object.mm | 28 + test/CodeGenObjCXX/foreach-statement.mm | 10 + .../CodeGenObjCXX/implicit-copy-assign-operator.mm | 57 + test/CodeGenObjCXX/implicit-copy-constructor.mm | 73 + test/CodeGenObjCXX/method-local-extern-mangle.mm | 14 + .../CodeGenObjCXX/property-derived-to-base-conv.mm | 19 + test/CodeGenObjCXX/references.mm | 25 + test/CodeGenObjCXX/selector-expr-lvalue.mm | 16 + test/Driver/Wp-args.c | 13 + test/Driver/Xlinker-args.c | 9 + test/Driver/arch.c | 3 + test/Driver/cxx-pth.cpp | 4 +- test/Driver/darwin-cc.c | 2 +- test/Driver/darwin-debug-flags.c | 6 +- test/Driver/darwin-dsymutil.c | 38 + test/Driver/darwin-ld.c | 6 +- test/Driver/lto.c | 9 +- test/Driver/option-aliases.c | 11 + test/FixIt/no-typo.c | 6 + test/FixIt/typo.cpp | 10 +- test/FixIt/typo.m | 10 +- test/Frontend/ir-support-codegen.ll | 8 + test/Frontend/ir-support-errors.ll | 8 + test/Frontend/lit.local.cfg | 1 + .../preprocessed-output-macro-first-token.c | 5 + test/Frontend/unknown-pragmas.c | 4 + test/Headers/int64-type.c | 4 + test/Headers/x86-intrinsics-headers.c | 2 +- test/Index/blocks.c | 29 + test/Index/code-complete-errors.c | 2 +- test/Index/code-completion.cpp | 13 + test/Index/complete-at-directives.m | 9 +- test/Index/complete-exprs.c | 36 +- test/Index/complete-macros.c | 15 +- test/Index/complete-method-decls.m | 31 +- test/Index/complete-objc-message.m | 14 +- test/Index/complete-recovery.m | 8 +- test/Index/complete-type-factors.m | 107 + test/Index/print-typekind.c | 2 +- test/Index/print-typekind.m | 10 + test/Index/usrs.m | 14 + test/Lexer/block_cmt_end.c | 2 +- test/Lexer/constants.c | 7 + test/Lexer/has_feature_cxx0x.cpp | 4 +- test/Lexer/has_feature_exceptions.cpp | 4 +- test/Lexer/has_feature_rtti.cpp | 4 +- test/Lexer/hexfloat.cpp | 5 +- test/Makefile | 4 +- test/Misc/macro-backtrace-limit.c | 2 +- test/PCH/attrs.h | 2 +- test/PCH/cxx-friends.cpp | 13 + test/PCH/cxx-friends.h | 6 + test/PCH/cxx-namespaces.cpp | 10 + test/PCH/cxx-namespaces.h | 7 + test/PCH/cxx-templates.cpp | 25 + test/PCH/cxx-templates.h | 102 + test/PCH/cxx-using.cpp | 15 + test/PCH/cxx-using.h | 16 + test/PCH/cxx_exprs.cpp | 8 +- test/PCH/cxx_exprs.h | 4 +- test/PCH/exprs.c | 2 + test/PCH/exprs.h | 2 + test/PCH/types.c | 2 +- test/PCH/types.h | 5 + test/Parser/altivec.c | 34 +- test/Parser/backtrack-crash.cpp | 4 + test/Parser/bracket-crash.cpp | 6 + test/Parser/cxx-altivec.cpp | 25 +- test/Parser/cxx-class.cpp | 2 +- test/Parser/cxx-decl.cpp | 4 + test/Parser/cxx-undeclared-identifier.cpp | 3 + test/Parser/declarators.c | 11 + test/Parser/objc-try-catch-1.m | 6 +- test/Parser/pragma-options.c | 2 +- test/Preprocessor/init.c | 168 +- test/Preprocessor/print_line_track.c | 4 +- test/Preprocessor/stdint.c | 66 +- test/Rewriter/dllimport-typedef.c | 8 +- test/Rewriter/missing-dllimport.c | 8 +- test/Rewriter/rewrite-elaborated-type.mm | 36 + test/Sema/address_spaces.c | 2 +- test/Sema/align-x86-64.c | 11 + test/Sema/attr-deprecated.c | 4 +- test/Sema/attr-regparm.c | 14 +- test/Sema/attr-unknown.c | 4 + test/Sema/bitfield-layout.c | 10 + test/Sema/block-call.c | 6 +- test/Sema/block-return.c | 7 +- test/Sema/builtins.c | 5 +- test/Sema/compare.c | 5 +- test/Sema/const-eval.c | 2 +- test/Sema/conversion-64-32.c | 2 +- test/Sema/conversion.c | 130 +- test/Sema/enum-packed.c | 16 + test/Sema/enum.c | 2 +- test/Sema/expr-comma-c89.c | 6 +- test/Sema/expr-comma.c | 8 +- test/Sema/exprs.c | 8 + test/Sema/ext_vector_casts.c | 7 + test/Sema/ext_vector_comparisons.c | 30 + test/Sema/extern-redecl.c | 9 + test/Sema/format-strings-fixit.c | 44 + test/Sema/format-strings.c | 44 +- test/Sema/function-redecl.c | 2 +- test/Sema/function.c | 4 +- test/Sema/i-c-e.c | 7 +- test/Sema/implicit-decl.c | 1 - test/Sema/init.c | 2 - test/Sema/missing-field-initializers.c | 2 + test/Sema/opencl-init.c | 15 + test/Sema/pragma-align-mac68k-unsupported.c | 4 +- test/Sema/pragma-align-mac68k.c | 2 +- test/Sema/pragma-align-packed.c | 23 + test/Sema/pragma-pack-and-options-align.c | 8 + test/Sema/return.c | 2 +- test/Sema/self-comparison.c | 55 +- test/Sema/struct-cast.c | 3 +- test/Sema/struct-decl.c | 5 + test/Sema/switch.c | 11 + test/Sema/transparent-union.c | 7 + test/Sema/types.c | 2 +- test/Sema/var-redecl.c | 4 +- test/Sema/warn-unused-value.c | 16 +- test/SemaCXX/abstract.cpp | 18 + test/SemaCXX/access-base-class.cpp | 2 +- test/SemaCXX/ambig-user-defined-conversions.cpp | 3 +- test/SemaCXX/attr-regparm.cpp | 14 + test/SemaCXX/blocks-1.cpp | 10 + test/SemaCXX/class-layout.cpp | 31 + test/SemaCXX/class.cpp | 6 + test/SemaCXX/compare.cpp | 8 + test/SemaCXX/conditional-expr.cpp | 31 +- test/SemaCXX/constructor-initializer.cpp | 17 + test/SemaCXX/conversion.cpp | 45 + test/SemaCXX/crash-8124080.cpp | 21 + test/SemaCXX/destructor.cpp | 24 +- test/SemaCXX/empty-class-layout.cpp | 60 + test/SemaCXX/enum.cpp | 8 +- test/SemaCXX/exception-spec-no-exceptions.cpp | 32 + test/SemaCXX/friend.cpp | 17 +- test/SemaCXX/function-type-qual.cpp | 9 +- test/SemaCXX/implicit-member-functions.cpp | 11 + test/SemaCXX/init-priority-attr.cpp | 36 + test/SemaCXX/instantiate-blocks.cpp | 19 + test/SemaCXX/member-expr.cpp | 29 + test/SemaCXX/new-array-size-conv.cpp | 27 + test/SemaCXX/new-delete.cpp | 49 +- test/SemaCXX/overload-call.cpp | 30 + test/SemaCXX/overloaded-builtin-operators.cpp | 16 +- test/SemaCXX/overloaded-operator.cpp | 9 +- test/SemaCXX/pseudo-destructors.cpp | 12 + test/SemaCXX/reinterpret-cast.cpp | 12 + test/SemaCXX/rval-references.cpp | 7 + test/SemaCXX/typedef-redecl.cpp | 6 + test/SemaCXX/using-directive.cpp | 5 + test/SemaCXX/vector.cpp | 30 + test/SemaCXX/warn-self-comparisons.cpp | 5 + test/SemaCXX/warn-unreachable.cpp | 2 +- test/SemaCXX/warn-unused-variables.cpp | 2 +- test/SemaCXX/warn_false_to_pointer.cpp | 9 + test/SemaCXX/wchar_t.cpp | 5 + test/SemaObjC/duplicate-property-class-extension.m | 14 +- test/SemaObjC/format-strings-objc.m | 8 + test/SemaObjC/return.m | 19 + test/SemaObjC/super-class-protocol-conformance.m | 16 + test/SemaObjCXX/instantiate-message.mm | 2 +- test/SemaObjCXX/instantiate-method-return.mm | 26 + test/SemaObjCXX/message.mm | 6 +- test/SemaObjCXX/objc-pointer-conv.mm | 8 + test/SemaObjCXX/overload.mm | 9 + test/SemaTemplate/array-to-pointer-decay.cpp | 25 + test/SemaTemplate/attributes.cpp | 23 +- .../class-template-ctor-initializer.cpp | 22 + test/SemaTemplate/deduction.cpp | 9 +- test/SemaTemplate/dependent-type-identity.cpp | 12 + test/SemaTemplate/destructor-template.cpp | 10 + test/SemaTemplate/example-dynarray.cpp | 2 +- test/SemaTemplate/explicit-instantiation.cpp | 13 + test/SemaTemplate/ext-vector-type.cpp | 4 +- test/SemaTemplate/instantiate-field.cpp | 9 + test/SemaTemplate/instantiate-function-1.cpp | 4 +- test/SemaTemplate/instantiate-function-2.cpp | 11 + test/SemaTemplate/instantiate-member-template.cpp | 33 + test/SemaTemplate/instantiate-objc-1.mm | 1 + test/SemaTemplate/member-function-template.cpp | 16 + test/SemaTemplate/nested-name-spec-template.cpp | 19 +- test/SemaTemplate/self-comparison.cpp | 48 + test/SemaTemplate/typename-specifier-4.cpp | 3 +- test/SemaTemplate/typename-specifier.cpp | 15 +- test/lit.cfg | 6 +- tools/Makefile | 8 +- tools/c-index-test/Makefile | 7 +- tools/c-index-test/c-index-test.c | 47 +- tools/driver/CMakeLists.txt | 1 + tools/driver/Makefile | 13 +- tools/driver/cc1_main.cpp | 20 +- tools/driver/cc1as_main.cpp | 9 +- tools/libclang/CIndex.cpp | 41 +- tools/libclang/CIndexCodeCompletion.cpp | 5 +- tools/libclang/CIndexer.cpp | 1 + tools/libclang/CMakeLists.txt | 3 +- tools/libclang/CXCursor.cpp | 8 +- tools/libclang/CXSourceLocation.h | 7 +- tools/libclang/CXTypes.cpp | 39 +- tools/libclang/Makefile | 11 +- tools/libclang/libclang.darwin.exports | 3 +- tools/libclang/libclang.exports | 4 +- tools/scan-build/ccc-analyzer | 3 + utils/FuzzTest | 340 ++ www/analyzer/installation.html | 4 +- www/analyzer/latest_checker.html.incl | 2 +- www/compatibility.html | 609 +++ www/content.css | 3 + www/cxx_compatibility.html | 282 +- www/hacking.html | 3 + www/index.html | 4 +- www/menu.html.incl | 5 +- 780 files changed, 54482 insertions(+), 23844 deletions(-) delete mode 100644 include/clang/AST/StmtNodes.td create mode 100644 include/clang/Basic/Attr.td create mode 100644 include/clang/Basic/AttrKinds.h create mode 100644 include/clang/Basic/DeclNodes.td create mode 100644 include/clang/Basic/StmtNodes.td create mode 100644 include/clang/Basic/Version.inc.in create mode 100644 include/clang/Basic/arm_neon.td create mode 100644 include/clang/Checker/AnalysisConsumer.h create mode 100644 include/clang/Checker/FrontendActions.h create mode 100644 include/clang/Checker/PathDiagnosticClients.h create mode 100644 include/clang/CodeGen/BackendUtil.h create mode 100644 include/clang/CodeGen/CodeGenAction.h delete mode 100644 include/clang/CodeGen/CodeGenOptions.h delete mode 100644 include/clang/Frontend/AnalysisConsumer.h create mode 100644 include/clang/Frontend/AnalyzerOptions.h delete mode 100644 include/clang/Frontend/CodeGenAction.h create mode 100644 include/clang/Frontend/CodeGenOptions.h delete mode 100644 include/clang/Frontend/FixItRewriter.h delete mode 100644 include/clang/Frontend/PathDiagnosticClients.h create mode 100644 include/clang/Rewrite/ASTConsumers.h create mode 100644 include/clang/Rewrite/FixItRewriter.h create mode 100644 include/clang/Rewrite/FrontendActions.h create mode 100644 include/clang/Rewrite/Rewriters.h create mode 100644 lib/AST/ExprClassification.cpp create mode 100644 lib/Checker/AnalysisConsumer.cpp create mode 100644 lib/Checker/CStringChecker.cpp create mode 100644 lib/Checker/FrontendActions.cpp create mode 100644 lib/Checker/HTMLDiagnostics.cpp create mode 100644 lib/Checker/IdempotentOperationChecker.cpp create mode 100644 lib/Checker/PlistDiagnostics.cpp delete mode 100644 lib/Checker/ReturnStackAddressChecker.cpp create mode 100644 lib/Checker/StackAddrLeakChecker.cpp create mode 100644 lib/Checker/StreamChecker.cpp create mode 100644 lib/CodeGen/BackendUtil.cpp create mode 100644 lib/CodeGen/CGException.h create mode 100644 lib/CodeGen/CodeGenAction.cpp create mode 100644 lib/CodeGen/MicrosoftCXXABI.cpp delete mode 100644 lib/Frontend/AnalysisConsumer.cpp delete mode 100644 lib/Frontend/CodeGenAction.cpp delete mode 100644 lib/Frontend/FixItRewriter.cpp delete mode 100644 lib/Frontend/HTMLDiagnostics.cpp delete mode 100644 lib/Frontend/HTMLPrint.cpp delete mode 100644 lib/Frontend/PlistDiagnostics.cpp delete mode 100644 lib/Frontend/RewriteMacros.cpp delete mode 100644 lib/Frontend/RewriteObjC.cpp delete mode 100644 lib/Frontend/RewriteTest.cpp create mode 100644 lib/Headers/arm_neon.td create mode 100644 lib/Rewrite/FixItRewriter.cpp create mode 100644 lib/Rewrite/FrontendActions.cpp create mode 100644 lib/Rewrite/HTMLPrint.cpp create mode 100644 lib/Rewrite/RewriteMacros.cpp create mode 100644 lib/Rewrite/RewriteObjC.cpp create mode 100644 lib/Rewrite/RewriteTest.cpp delete mode 100644 lib/Runtime/Makefile create mode 100644 test/ASTMerge/Inputs/class1.cpp create mode 100644 test/ASTMerge/Inputs/class2.cpp create mode 100644 test/ASTMerge/class.cpp create mode 100644 test/Analysis/PR7218.c create mode 100644 test/Analysis/additive-folding-range-constraints.c create mode 100644 test/Analysis/additive-folding.c create mode 100644 test/Analysis/analyze_display_progress.c create mode 100644 test/Analysis/bstring.c create mode 100644 test/Analysis/constant-folding.c create mode 100644 test/Analysis/free.c create mode 100644 test/Analysis/idempotent-operations.c create mode 100644 test/Analysis/stackaddrleak.c create mode 100644 test/Analysis/stream.c create mode 100644 test/Analysis/undef-buffers.c create mode 100644 test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp create mode 100644 test/CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp create mode 100644 test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp delete mode 100644 test/CXX/dcl.decl/dcl.init/dcl.init.ref/p16-cxx0x-no-extra-copy.cpp create mode 100644 test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp create mode 100644 test/CXX/except/except.spec/p14-ir.cpp create mode 100644 test/CXX/except/except.spec/p14.cpp create mode 100644 test/CXX/special/class.copy/p20.cpp create mode 100644 test/CXX/special/class.copy/p9.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp create mode 100644 test/CXX/temp/temp.spec/temp.explicit/p11.cpp delete mode 100644 test/CodeGen/2008-12-02-logical-or-fold.c create mode 100644 test/CodeGen/altivec.c create mode 100644 test/CodeGen/arm-cc.c create mode 100644 test/CodeGen/assign.c create mode 100644 test/CodeGen/available-externally-suppress.c create mode 100644 test/CodeGen/frame-pointer-elim.c create mode 100644 test/CodeGen/func-in-block.c create mode 100644 test/CodeGen/instrument-functions.c create mode 100644 test/CodeGen/integer-overflow.c create mode 100644 test/CodeGen/pascal-wchar-string.c create mode 100644 test/CodeGenCXX/DynArrayInit.cpp create mode 100644 test/CodeGenCXX/arm-cc.cpp create mode 100644 test/CodeGenCXX/block-in-ctor-dtor.cpp create mode 100644 test/CodeGenCXX/copy-in-cplus-object.cpp create mode 100644 test/CodeGenCXX/global-init-darwin.cpp create mode 100644 test/CodeGenCXX/incomplete-member-function-pointer.cpp create mode 100644 test/CodeGenCXX/instantiate-blocks.cpp create mode 100644 test/CodeGenCXX/mangle-address-space.cpp create mode 100644 test/CodeGenCXX/mangle-ms.cpp create mode 100644 test/CodeGenCXX/member-init-assignment.cpp create mode 100644 test/CodeGenCXX/reference-in-block-args.cpp create mode 100644 test/CodeGenCXX/sel-address.mm create mode 100644 test/CodeGenCXX/template-static-var-defer.cpp create mode 100644 test/CodeGenCXX/throw-expression-dtor.cpp create mode 100644 test/CodeGenCXX/visibility-hidden-extern-templates.cpp create mode 100644 test/CodeGenCXX/visibility-inlines-hidden.cpp create mode 100644 test/CodeGenObjC/assign.m create mode 100644 test/CodeGenObjC/bitfield_encoding.m create mode 100644 test/CodeGenObjC/blocks-5.m create mode 100644 test/CodeGenObjC/category-class.m create mode 100644 test/CodeGenObjC/dot-syntax-2.m create mode 100644 test/CodeGenObjC/property-category-impl.m create mode 100644 test/CodeGenObjCXX/copyable-property-object.mm create mode 100644 test/CodeGenObjCXX/foreach-statement.mm create mode 100644 test/CodeGenObjCXX/implicit-copy-assign-operator.mm create mode 100644 test/CodeGenObjCXX/implicit-copy-constructor.mm create mode 100644 test/CodeGenObjCXX/method-local-extern-mangle.mm create mode 100644 test/CodeGenObjCXX/property-derived-to-base-conv.mm create mode 100644 test/CodeGenObjCXX/references.mm create mode 100644 test/CodeGenObjCXX/selector-expr-lvalue.mm create mode 100644 test/Driver/Wp-args.c create mode 100644 test/Driver/Xlinker-args.c create mode 100644 test/Driver/arch.c create mode 100644 test/Driver/darwin-dsymutil.c create mode 100644 test/Driver/option-aliases.c create mode 100644 test/FixIt/no-typo.c create mode 100644 test/Frontend/ir-support-codegen.ll create mode 100644 test/Frontend/ir-support-errors.ll create mode 100644 test/Frontend/lit.local.cfg create mode 100644 test/Frontend/preprocessed-output-macro-first-token.c create mode 100644 test/Frontend/unknown-pragmas.c create mode 100644 test/Headers/int64-type.c create mode 100644 test/Index/blocks.c create mode 100644 test/Index/complete-type-factors.m create mode 100644 test/Index/print-typekind.m create mode 100644 test/PCH/cxx-friends.cpp create mode 100644 test/PCH/cxx-friends.h create mode 100644 test/PCH/cxx-namespaces.cpp create mode 100644 test/PCH/cxx-namespaces.h create mode 100644 test/PCH/cxx-templates.cpp create mode 100644 test/PCH/cxx-templates.h create mode 100644 test/PCH/cxx-using.cpp create mode 100644 test/PCH/cxx-using.h create mode 100644 test/Parser/backtrack-crash.cpp create mode 100644 test/Parser/bracket-crash.cpp create mode 100644 test/Rewriter/rewrite-elaborated-type.mm create mode 100644 test/Sema/align-x86-64.c create mode 100644 test/Sema/attr-unknown.c create mode 100644 test/Sema/enum-packed.c create mode 100644 test/Sema/ext_vector_comparisons.c create mode 100644 test/Sema/extern-redecl.c create mode 100644 test/Sema/format-strings-fixit.c create mode 100644 test/Sema/opencl-init.c create mode 100644 test/Sema/pragma-align-packed.c create mode 100644 test/SemaCXX/attr-regparm.cpp create mode 100644 test/SemaCXX/conversion.cpp create mode 100644 test/SemaCXX/crash-8124080.cpp create mode 100644 test/SemaCXX/exception-spec-no-exceptions.cpp create mode 100644 test/SemaCXX/init-priority-attr.cpp create mode 100644 test/SemaCXX/instantiate-blocks.cpp create mode 100644 test/SemaCXX/new-array-size-conv.cpp create mode 100644 test/SemaCXX/warn-self-comparisons.cpp create mode 100644 test/SemaCXX/warn_false_to_pointer.cpp create mode 100644 test/SemaObjCXX/instantiate-method-return.mm create mode 100644 test/SemaTemplate/array-to-pointer-decay.cpp create mode 100644 test/SemaTemplate/self-comparison.cpp create mode 100755 utils/FuzzTest create mode 100644 www/compatibility.html diff --git a/CMakeLists.txt b/CMakeLists.txt index 1be646dfd2e3..1ba2a622d4e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,5 @@ # Clang version information -# Make sure that CMake reconfigures when the version changes. -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/VER - ${CMAKE_CURRENT_BINARY_DIR}/VER) - set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) @@ -28,12 +23,28 @@ if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) endif() endif() -# Compute the Clang version from the contents of VER -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VER CLANG_VERSION_DATA) +# Compute the Clang version from the LLVM version. string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION - ${CLANG_VERSION_DATA}) + ${PACKAGE_VERSION}) message(STATUS "Clang version: ${CLANG_VERSION}") +string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" CLANG_VERSION_MAJOR + ${CLANG_VERSION}) +string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" CLANG_VERSION_MINOR + ${CLANG_VERSION}) +if (${CLANG_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") + set(CLANG_HAS_VERSION_PATCHLEVEL 1) + string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" CLANG_VERSION_PATCHLEVEL + ${CLANG_VERSION}) +else() + set(CLANG_HAS_VERSION_PATCHLEVEL 0) +endif() + +# Configure the Version.inc file. +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/include/clang/Basic/Version.inc.in + ${CMAKE_CURRENT_BINARY_DIR}/include/clang/Basic/Version.inc) + # Add appropriate flags for GCC if (CMAKE_COMPILER_IS_GNUCXX) # FIXME: Turn off exceptions, RTTI: @@ -41,6 +52,10 @@ if (CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings") endif () +if (APPLE) + set(CMAKE_MODULE_LINKER_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress") +endif () + macro(add_clang_library name) set(srcs ${ARGN}) if(MSVC_IDE OR XCODE) @@ -54,7 +69,9 @@ macro(add_clang_library name) ../../include/clang${dir}/*.def) set(srcs ${srcs} ${headers}) endif(MSVC_IDE OR XCODE) - if (SHARED_LIBRARY) + if (MODULE) + set(libkind MODULE) + elseif (SHARED_LIBRARY) set(libkind SHARED) else() set(libkind) diff --git a/Makefile b/Makefile index 39cf9c6f57a1..f871c25274ed 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,63 @@ -LEVEL = ../.. -DIRS := include lib tools docs +##===- Makefile --------------------------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +# If CLANG_LEVEL is not set, then we are the top-level Makefile. Otherwise, we +# are being included from a subdirectory makefile. + +ifndef CLANG_LEVEL + +IS_TOP_LEVEL := 1 +CLANG_LEVEL := . +DIRS := include lib tools runtime docs PARALLEL_DIRS := ifeq ($(BUILD_EXAMPLES),1) PARALLEL_DIRS += examples endif +endif + +ifeq ($(MAKECMDGOALS),libs-only) + DIRS := $(filter-out tools docs, $(DIRS)) + OPTIONAL_DIRS := +endif + +### +# Common Makefile code, shared by all Clang Makefiles. + +# Set LLVM source root level. +LEVEL := $(CLANG_LEVEL)/../.. +# Include LLVM common makefile. include $(LEVEL)/Makefile.common +# Set common Clang build flags. +CPP.Flags += -I$(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include -I$(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include +ifdef CLANG_VENDOR +CPP.Flags += -DCLANG_VENDOR='"$(CLANG_VENDOR) "' +endif + +# Disable -fstrict-aliasing. Darwin disables it by default (and LLVM doesn't +# work with it enabled with GCC), Clang/llvm-gc don't support it yet, and newer +# GCC's have false positive warnings with it on Linux (which prove a pain to +# fix). For example: +# http://gcc.gnu.org/PR41874 +# http://gcc.gnu.org/PR41838 +# +# We can revisit this when LLVM/Clang support it. +CXX.Flags += -fno-strict-aliasing + +### +# Clang Top Level specific stuff. + +ifeq ($(IS_TOP_LEVEL),1) + ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT)) $(RecursiveTargets):: $(Verb) if [ ! -f test/Makefile ]; then \ @@ -26,6 +75,8 @@ report:: clean:: @ $(MAKE) -C test clean +libs-only: all + tags:: $(Verb) etags `find . -type f -name '*.h' -or -name '*.cpp' | \ grep -v /lib/Headers | grep -v /test/` @@ -37,3 +88,5 @@ cscope.files: -or -name '*.h' > cscope.files .PHONY: test report clean cscope.files + +endif diff --git a/NOTES.txt b/NOTES.txt index beceb7d1ccce..f66a96120a81 100644 --- a/NOTES.txt +++ b/NOTES.txt @@ -13,8 +13,7 @@ This is similar to -Eonly. //===---------------------------------------------------------------------===// -Creating and using a PTH file for performance measurement (use a release-asserts -build). +Creating and using a PTH file for performance measurement (use a release build). $ clang -ccc-pch-is-pth -x objective-c-header INPUTS/Cocoa_h.m -o /tmp/tokencache $ clang -cc1 -token-cache /tmp/tokencache INPUTS/Cocoa_h.m diff --git a/README.txt b/README.txt index 924ecc416c3a..44ce723acef8 100644 --- a/README.txt +++ b/README.txt @@ -4,7 +4,7 @@ Welcome to Clang. This is a compiler front-end for the C family of languages (C, C++, Objective-C, and Objective-C++) which is built as part of the LLVM -compiler intrastructure project. +compiler infrastructure project. Unlike many other compiler frontends, Clang is useful for a number of things beyond just compiling code: we intend for Clang to be host to a number of diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index 43733f779378..40c1f5f458cd 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -19,9 +19,6 @@ 1A2A54BD0FD1DD1C00F4CE45 /* HTMLPrint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A54AC0FD1DD1C00F4CE45 /* HTMLPrint.cpp */; }; 1A2A54BE0FD1DD1C00F4CE45 /* PrintParserCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A54AD0FD1DD1C00F4CE45 /* PrintParserCallbacks.cpp */; }; 1A2A54BF0FD1DD1C00F4CE45 /* PrintPreprocessedOutput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A54AE0FD1DD1C00F4CE45 /* PrintPreprocessedOutput.cpp */; }; - 1A2A54C10FD1DD1C00F4CE45 /* RewriteMacros.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A54B00FD1DD1C00F4CE45 /* RewriteMacros.cpp */; }; - 1A2A54C20FD1DD1C00F4CE45 /* RewriteObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A54B10FD1DD1C00F4CE45 /* RewriteObjC.cpp */; }; - 1A2A54C30FD1DD1C00F4CE45 /* RewriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A54B20FD1DD1C00F4CE45 /* RewriteTest.cpp */; }; 1A2A54C40FD1DD1C00F4CE45 /* StmtXML.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A54B30FD1DD1C00F4CE45 /* StmtXML.cpp */; }; 1A2A54C50FD1DD1C00F4CE45 /* Warnings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A54B40FD1DD1C00F4CE45 /* Warnings.cpp */; }; 1A30A9E90B93A4C800201A91 /* ExprCXX.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A30A9E80B93A4C800201A91 /* ExprCXX.h */; }; @@ -171,6 +168,50 @@ BF89C3F911595A01001C2D68 /* SemaType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF89C3F811595A01001C2D68 /* SemaType.cpp */; }; BF89C3FB11595A37001C2D68 /* SemaCodeComplete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF89C3FA11595A37001C2D68 /* SemaCodeComplete.cpp */; }; BF89C3FD11595A5D001C2D68 /* SemaExceptionSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF89C3FC11595A5D001C2D68 /* SemaExceptionSpec.cpp */; }; + BFE2F6AB11DA955A0007EDC0 /* DeltaTree.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F67D11DA95590007EDC0 /* DeltaTree.d */; }; + BFE2F6AC11DA955A0007EDC0 /* DeltaTree.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F67E11DA955A0007EDC0 /* DeltaTree.o */; }; + BFE2F6AD11DA955A0007EDC0 /* FixItRewriter.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F67F11DA955A0007EDC0 /* FixItRewriter.d */; }; + BFE2F6AE11DA955A0007EDC0 /* FixItRewriter.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F68011DA955A0007EDC0 /* FixItRewriter.o */; }; + BFE2F6AF11DA955A0007EDC0 /* FrontendActions.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F68111DA955A0007EDC0 /* FrontendActions.d */; }; + BFE2F6B011DA955A0007EDC0 /* FrontendActions.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F68211DA955A0007EDC0 /* FrontendActions.o */; }; + BFE2F6B111DA955A0007EDC0 /* HTMLPrint.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F68311DA955A0007EDC0 /* HTMLPrint.d */; }; + BFE2F6B211DA955A0007EDC0 /* HTMLPrint.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F68411DA955A0007EDC0 /* HTMLPrint.o */; }; + BFE2F6B311DA955A0007EDC0 /* HTMLRewrite.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F68511DA955A0007EDC0 /* HTMLRewrite.d */; }; + BFE2F6B411DA955A0007EDC0 /* HTMLRewrite.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F68611DA955A0007EDC0 /* HTMLRewrite.o */; }; + BFE2F6B511DA955A0007EDC0 /* RewriteMacros.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F68711DA955A0007EDC0 /* RewriteMacros.d */; }; + BFE2F6B611DA955A0007EDC0 /* RewriteMacros.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F68811DA955A0007EDC0 /* RewriteMacros.o */; }; + BFE2F6B711DA955A0007EDC0 /* RewriteObjC.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F68911DA955A0007EDC0 /* RewriteObjC.d */; }; + BFE2F6B811DA955A0007EDC0 /* RewriteObjC.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F68A11DA955A0007EDC0 /* RewriteObjC.o */; }; + BFE2F6B911DA955A0007EDC0 /* Rewriter.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F68B11DA955A0007EDC0 /* Rewriter.d */; }; + BFE2F6BA11DA955A0007EDC0 /* Rewriter.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F68C11DA955A0007EDC0 /* Rewriter.o */; }; + BFE2F6BB11DA955A0007EDC0 /* RewriteRope.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F68D11DA955A0007EDC0 /* RewriteRope.d */; }; + BFE2F6BC11DA955A0007EDC0 /* RewriteRope.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F68E11DA955A0007EDC0 /* RewriteRope.o */; }; + BFE2F6BD11DA955A0007EDC0 /* RewriteTest.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F68F11DA955A0007EDC0 /* RewriteTest.d */; }; + BFE2F6BE11DA955A0007EDC0 /* RewriteTest.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F69011DA955A0007EDC0 /* RewriteTest.o */; }; + BFE2F6BF11DA955A0007EDC0 /* TokenRewriter.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F69111DA955A0007EDC0 /* TokenRewriter.d */; }; + BFE2F6C011DA955A0007EDC0 /* TokenRewriter.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F69211DA955A0007EDC0 /* TokenRewriter.o */; }; + BFE2F6C111DA955A0007EDC0 /* DeltaTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F69311DA955A0007EDC0 /* DeltaTree.cpp */; }; + BFE2F6C211DA955A0007EDC0 /* FixItRewriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F69411DA955A0007EDC0 /* FixItRewriter.cpp */; }; + BFE2F6C311DA955A0007EDC0 /* FrontendActions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F69511DA955A0007EDC0 /* FrontendActions.cpp */; }; + BFE2F6C411DA955A0007EDC0 /* HTMLPrint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F69611DA955A0007EDC0 /* HTMLPrint.cpp */; }; + BFE2F6C511DA955A0007EDC0 /* HTMLRewrite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F69711DA955A0007EDC0 /* HTMLRewrite.cpp */; }; + BFE2F6C611DA955A0007EDC0 /* Makefile in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F69811DA955A0007EDC0 /* Makefile */; }; + BFE2F6C711DA955A0007EDC0 /* DeltaTree.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F69B11DA955A0007EDC0 /* DeltaTree.d */; }; + BFE2F6C811DA955A0007EDC0 /* DeltaTree.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F69C11DA955A0007EDC0 /* DeltaTree.o */; }; + BFE2F6C911DA955A0007EDC0 /* HTMLRewrite.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F69D11DA955A0007EDC0 /* HTMLRewrite.d */; }; + BFE2F6CA11DA955A0007EDC0 /* HTMLRewrite.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F69E11DA955A0007EDC0 /* HTMLRewrite.o */; }; + BFE2F6CB11DA955A0007EDC0 /* Rewriter.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F69F11DA955A0007EDC0 /* Rewriter.d */; }; + BFE2F6CC11DA955A0007EDC0 /* Rewriter.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F6A011DA955A0007EDC0 /* Rewriter.o */; }; + BFE2F6CD11DA955A0007EDC0 /* RewriteRope.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F6A111DA955A0007EDC0 /* RewriteRope.d */; }; + BFE2F6CE11DA955A0007EDC0 /* RewriteRope.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F6A211DA955A0007EDC0 /* RewriteRope.o */; }; + BFE2F6CF11DA955A0007EDC0 /* TokenRewriter.d in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F6A311DA955A0007EDC0 /* TokenRewriter.d */; }; + BFE2F6D011DA955A0007EDC0 /* TokenRewriter.o in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE2F6A411DA955A0007EDC0 /* TokenRewriter.o */; }; + BFE2F6D111DA955A0007EDC0 /* RewriteMacros.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F6A511DA955A0007EDC0 /* RewriteMacros.cpp */; }; + BFE2F6D211DA955A0007EDC0 /* RewriteObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F6A611DA955A0007EDC0 /* RewriteObjC.cpp */; }; + BFE2F6D311DA955A0007EDC0 /* Rewriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F6A711DA955A0007EDC0 /* Rewriter.cpp */; }; + BFE2F6D411DA955A0007EDC0 /* RewriteRope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F6A811DA955A0007EDC0 /* RewriteRope.cpp */; }; + BFE2F6D511DA955A0007EDC0 /* RewriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F6A911DA955A0007EDC0 /* RewriteTest.cpp */; }; + BFE2F6D611DA955A0007EDC0 /* TokenRewriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BFE2F6AA11DA955A0007EDC0 /* TokenRewriter.cpp */; }; DE01DA490B12ADA300AC22CE /* PPCallbacks.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE01DA480B12ADA300AC22CE /* PPCallbacks.h */; }; DE06756C0C051CFE00EBBFD8 /* ParseExprCXX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */; }; DE06B73E0A8307640050E87E /* LangOptions.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE06B73D0A8307640050E87E /* LangOptions.h */; }; @@ -391,9 +432,6 @@ 1A2A54AC0FD1DD1C00F4CE45 /* HTMLPrint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLPrint.cpp; path = lib/Frontend/HTMLPrint.cpp; sourceTree = ""; }; 1A2A54AD0FD1DD1C00F4CE45 /* PrintParserCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PrintParserCallbacks.cpp; path = lib/Frontend/PrintParserCallbacks.cpp; sourceTree = ""; }; 1A2A54AE0FD1DD1C00F4CE45 /* PrintPreprocessedOutput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PrintPreprocessedOutput.cpp; path = lib/Frontend/PrintPreprocessedOutput.cpp; sourceTree = ""; }; - 1A2A54B00FD1DD1C00F4CE45 /* RewriteMacros.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RewriteMacros.cpp; path = lib/Frontend/RewriteMacros.cpp; sourceTree = ""; }; - 1A2A54B10FD1DD1C00F4CE45 /* RewriteObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = RewriteObjC.cpp; path = lib/Frontend/RewriteObjC.cpp; sourceTree = ""; tabWidth = 2; }; - 1A2A54B20FD1DD1C00F4CE45 /* RewriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RewriteTest.cpp; path = lib/Frontend/RewriteTest.cpp; sourceTree = ""; }; 1A2A54B30FD1DD1C00F4CE45 /* StmtXML.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StmtXML.cpp; path = lib/Frontend/StmtXML.cpp; sourceTree = ""; }; 1A2A54B40FD1DD1C00F4CE45 /* Warnings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Warnings.cpp; path = lib/Frontend/Warnings.cpp; sourceTree = ""; }; 1A30A9E80B93A4C800201A91 /* ExprCXX.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = ExprCXX.h; path = clang/AST/ExprCXX.h; sourceTree = ""; tabWidth = 2; }; @@ -438,6 +476,10 @@ 1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralSupport.cpp; sourceTree = ""; }; 1A97825A1108BA18002B98FC /* CGVTT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = CGVTT.cpp; path = lib/CodeGen/CGVTT.cpp; sourceTree = ""; tabWidth = 2; }; 1A986AB610D0746D00A8EA9E /* CGDeclCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = CGDeclCXX.cpp; path = lib/CodeGen/CGDeclCXX.cpp; sourceTree = ""; tabWidth = 2; }; + 1AA1D35611BECFF70089CC3F /* CC1AsOptions.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CC1AsOptions.td; path = clang/Driver/CC1AsOptions.td; sourceTree = ""; }; + 1AA1D35711BECFF70089CC3F /* CC1Options.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CC1Options.td; path = clang/Driver/CC1Options.td; sourceTree = ""; }; + 1AA1D35811BECFF70089CC3F /* Options.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Options.td; path = clang/Driver/Options.td; sourceTree = ""; }; + 1AA1D35911BECFF70089CC3F /* OptParser.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OptParser.td; path = clang/Driver/OptParser.td; sourceTree = ""; }; 1AA963AB10D8576800786C86 /* FullExpr.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = FullExpr.h; path = clang/AST/FullExpr.h; sourceTree = ""; tabWidth = 2; }; 1AB290021045858B00FE33D8 /* PartialDiagnostic.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = PartialDiagnostic.h; sourceTree = ""; tabWidth = 2; }; 1ABC36930C7A4BDC006DB0AB /* CGBuiltin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = CGBuiltin.cpp; path = lib/CodeGen/CGBuiltin.cpp; sourceTree = ""; tabWidth = 2; }; @@ -661,6 +703,53 @@ BF89C3F811595A01001C2D68 /* SemaType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SemaType.cpp; path = lib/Sema/SemaType.cpp; sourceTree = ""; }; BF89C3FA11595A37001C2D68 /* SemaCodeComplete.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SemaCodeComplete.cpp; path = lib/Sema/SemaCodeComplete.cpp; sourceTree = ""; }; BF89C3FC11595A5D001C2D68 /* SemaExceptionSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SemaExceptionSpec.cpp; path = lib/Sema/SemaExceptionSpec.cpp; sourceTree = ""; }; + BFE2F67A11DA95590007EDC0 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; + BFE2F67C11DA95590007EDC0 /* .dir */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .dir; sourceTree = ""; }; + BFE2F67D11DA95590007EDC0 /* DeltaTree.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = DeltaTree.d; sourceTree = ""; }; + BFE2F67E11DA955A0007EDC0 /* DeltaTree.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = DeltaTree.o; sourceTree = ""; }; + BFE2F67F11DA955A0007EDC0 /* FixItRewriter.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = FixItRewriter.d; sourceTree = ""; }; + BFE2F68011DA955A0007EDC0 /* FixItRewriter.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = FixItRewriter.o; sourceTree = ""; }; + BFE2F68111DA955A0007EDC0 /* FrontendActions.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = FrontendActions.d; sourceTree = ""; }; + BFE2F68211DA955A0007EDC0 /* FrontendActions.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = FrontendActions.o; sourceTree = ""; }; + BFE2F68311DA955A0007EDC0 /* HTMLPrint.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = HTMLPrint.d; sourceTree = ""; }; + BFE2F68411DA955A0007EDC0 /* HTMLPrint.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = HTMLPrint.o; sourceTree = ""; }; + BFE2F68511DA955A0007EDC0 /* HTMLRewrite.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = HTMLRewrite.d; sourceTree = ""; }; + BFE2F68611DA955A0007EDC0 /* HTMLRewrite.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = HTMLRewrite.o; sourceTree = ""; }; + BFE2F68711DA955A0007EDC0 /* RewriteMacros.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = RewriteMacros.d; sourceTree = ""; }; + BFE2F68811DA955A0007EDC0 /* RewriteMacros.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = RewriteMacros.o; sourceTree = ""; }; + BFE2F68911DA955A0007EDC0 /* RewriteObjC.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = RewriteObjC.d; sourceTree = ""; }; + BFE2F68A11DA955A0007EDC0 /* RewriteObjC.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = RewriteObjC.o; sourceTree = ""; }; + BFE2F68B11DA955A0007EDC0 /* Rewriter.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = Rewriter.d; sourceTree = ""; }; + BFE2F68C11DA955A0007EDC0 /* Rewriter.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = Rewriter.o; sourceTree = ""; }; + BFE2F68D11DA955A0007EDC0 /* RewriteRope.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = RewriteRope.d; sourceTree = ""; }; + BFE2F68E11DA955A0007EDC0 /* RewriteRope.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = RewriteRope.o; sourceTree = ""; }; + BFE2F68F11DA955A0007EDC0 /* RewriteTest.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = RewriteTest.d; sourceTree = ""; }; + BFE2F69011DA955A0007EDC0 /* RewriteTest.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = RewriteTest.o; sourceTree = ""; }; + BFE2F69111DA955A0007EDC0 /* TokenRewriter.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = TokenRewriter.d; sourceTree = ""; }; + BFE2F69211DA955A0007EDC0 /* TokenRewriter.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = TokenRewriter.o; sourceTree = ""; }; + BFE2F69311DA955A0007EDC0 /* DeltaTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeltaTree.cpp; sourceTree = ""; }; + BFE2F69411DA955A0007EDC0 /* FixItRewriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FixItRewriter.cpp; sourceTree = ""; }; + BFE2F69511DA955A0007EDC0 /* FrontendActions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrontendActions.cpp; sourceTree = ""; }; + BFE2F69611DA955A0007EDC0 /* HTMLPrint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLPrint.cpp; sourceTree = ""; }; + BFE2F69711DA955A0007EDC0 /* HTMLRewrite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLRewrite.cpp; sourceTree = ""; }; + BFE2F69811DA955A0007EDC0 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; + BFE2F69A11DA955A0007EDC0 /* .dir */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .dir; sourceTree = ""; }; + BFE2F69B11DA955A0007EDC0 /* DeltaTree.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = DeltaTree.d; sourceTree = ""; }; + BFE2F69C11DA955A0007EDC0 /* DeltaTree.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = DeltaTree.o; sourceTree = ""; }; + BFE2F69D11DA955A0007EDC0 /* HTMLRewrite.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = HTMLRewrite.d; sourceTree = ""; }; + BFE2F69E11DA955A0007EDC0 /* HTMLRewrite.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = HTMLRewrite.o; sourceTree = ""; }; + BFE2F69F11DA955A0007EDC0 /* Rewriter.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = Rewriter.d; sourceTree = ""; }; + BFE2F6A011DA955A0007EDC0 /* Rewriter.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = Rewriter.o; sourceTree = ""; }; + BFE2F6A111DA955A0007EDC0 /* RewriteRope.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = RewriteRope.d; sourceTree = ""; }; + BFE2F6A211DA955A0007EDC0 /* RewriteRope.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = RewriteRope.o; sourceTree = ""; }; + BFE2F6A311DA955A0007EDC0 /* TokenRewriter.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = TokenRewriter.d; sourceTree = ""; }; + BFE2F6A411DA955A0007EDC0 /* TokenRewriter.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = TokenRewriter.o; sourceTree = ""; }; + BFE2F6A511DA955A0007EDC0 /* RewriteMacros.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RewriteMacros.cpp; sourceTree = ""; }; + BFE2F6A611DA955A0007EDC0 /* RewriteObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RewriteObjC.cpp; sourceTree = ""; }; + BFE2F6A711DA955A0007EDC0 /* Rewriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Rewriter.cpp; sourceTree = ""; }; + BFE2F6A811DA955A0007EDC0 /* RewriteRope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RewriteRope.cpp; sourceTree = ""; }; + BFE2F6A911DA955A0007EDC0 /* RewriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RewriteTest.cpp; sourceTree = ""; }; + BFE2F6AA11DA955A0007EDC0 /* TokenRewriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenRewriter.cpp; sourceTree = ""; }; DE01DA480B12ADA300AC22CE /* PPCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PPCallbacks.h; sourceTree = ""; }; DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = ParseExprCXX.cpp; path = lib/Parse/ParseExprCXX.cpp; sourceTree = ""; tabWidth = 2; }; DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = ""; tabWidth = 2; }; @@ -807,24 +896,24 @@ DEDFE5270F63A9230035BD10 /* DeclNodes.def */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = text; name = DeclNodes.def; path = clang/AST/DeclNodes.def; sourceTree = ""; tabWidth = 2; }; DEDFE5CB0F7206CC0035BD10 /* NestedNameSpecifier.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = NestedNameSpecifier.h; path = clang/AST/NestedNameSpecifier.h; sourceTree = ""; tabWidth = 2; }; DEDFE6450F7B3B4E0035BD10 /* driver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = driver.cpp; path = tools/driver/driver.cpp; sourceTree = ""; }; - DEDFE6480F7B3B830035BD10 /* Types.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Types.cpp; path = lib/Driver/Types.cpp; sourceTree = ""; }; - DEDFE6490F7B3B830035BD10 /* Tools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Tools.h; path = lib/Driver/Tools.h; sourceTree = ""; }; - DEDFE64A0F7B3B830035BD10 /* Tools.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tools.cpp; path = lib/Driver/Tools.cpp; sourceTree = ""; }; - DEDFE64B0F7B3B830035BD10 /* ToolChains.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ToolChains.h; path = lib/Driver/ToolChains.h; sourceTree = ""; }; - DEDFE64C0F7B3B830035BD10 /* Compilation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Compilation.cpp; path = lib/Driver/Compilation.cpp; sourceTree = ""; }; - DEDFE64D0F7B3B830035BD10 /* ArgList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArgList.cpp; path = lib/Driver/ArgList.cpp; sourceTree = ""; }; - DEDFE64E0F7B3B830035BD10 /* Arg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Arg.cpp; path = lib/Driver/Arg.cpp; sourceTree = ""; }; - DEDFE64F0F7B3B830035BD10 /* Action.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Action.cpp; path = lib/Driver/Action.cpp; sourceTree = ""; }; - DEDFE6500F7B3B830035BD10 /* Phases.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Phases.cpp; path = lib/Driver/Phases.cpp; sourceTree = ""; }; - DEDFE6510F7B3B830035BD10 /* OptTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptTable.cpp; path = lib/Driver/OptTable.cpp; sourceTree = ""; }; - DEDFE6520F7B3B830035BD10 /* Option.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Option.cpp; path = lib/Driver/Option.cpp; sourceTree = ""; }; - DEDFE6530F7B3B830035BD10 /* Job.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Job.cpp; path = lib/Driver/Job.cpp; sourceTree = ""; }; - DEDFE6540F7B3B830035BD10 /* InputInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InputInfo.h; path = lib/Driver/InputInfo.h; sourceTree = ""; }; - DEDFE6550F7B3B830035BD10 /* ToolChains.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ToolChains.cpp; path = lib/Driver/ToolChains.cpp; sourceTree = ""; }; - DEDFE6560F7B3B830035BD10 /* ToolChain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ToolChain.cpp; path = lib/Driver/ToolChain.cpp; sourceTree = ""; }; - DEDFE6570F7B3B830035BD10 /* Tool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tool.cpp; path = lib/Driver/Tool.cpp; sourceTree = ""; }; - DEDFE6580F7B3B830035BD10 /* HostInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HostInfo.cpp; path = lib/Driver/HostInfo.cpp; sourceTree = ""; }; - DEDFE6590F7B3B830035BD10 /* Driver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Driver.cpp; path = lib/Driver/Driver.cpp; sourceTree = ""; }; + DEDFE6480F7B3B830035BD10 /* Types.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Types.cpp; path = lib/Driver/Types.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE6490F7B3B830035BD10 /* Tools.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = Tools.h; path = lib/Driver/Tools.h; sourceTree = ""; tabWidth = 2; }; + DEDFE64A0F7B3B830035BD10 /* Tools.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Tools.cpp; path = lib/Driver/Tools.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE64B0F7B3B830035BD10 /* ToolChains.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = ToolChains.h; path = lib/Driver/ToolChains.h; sourceTree = ""; tabWidth = 2; }; + DEDFE64C0F7B3B830035BD10 /* Compilation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Compilation.cpp; path = lib/Driver/Compilation.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE64D0F7B3B830035BD10 /* ArgList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = ArgList.cpp; path = lib/Driver/ArgList.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE64E0F7B3B830035BD10 /* Arg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Arg.cpp; path = lib/Driver/Arg.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE64F0F7B3B830035BD10 /* Action.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Action.cpp; path = lib/Driver/Action.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE6500F7B3B830035BD10 /* Phases.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Phases.cpp; path = lib/Driver/Phases.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE6510F7B3B830035BD10 /* OptTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = OptTable.cpp; path = lib/Driver/OptTable.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE6520F7B3B830035BD10 /* Option.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Option.cpp; path = lib/Driver/Option.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE6530F7B3B830035BD10 /* Job.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Job.cpp; path = lib/Driver/Job.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE6540F7B3B830035BD10 /* InputInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = InputInfo.h; path = lib/Driver/InputInfo.h; sourceTree = ""; tabWidth = 2; }; + DEDFE6550F7B3B830035BD10 /* ToolChains.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = ToolChains.cpp; path = lib/Driver/ToolChains.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE6560F7B3B830035BD10 /* ToolChain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = ToolChain.cpp; path = lib/Driver/ToolChain.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE6570F7B3B830035BD10 /* Tool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Tool.cpp; path = lib/Driver/Tool.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE6580F7B3B830035BD10 /* HostInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = HostInfo.cpp; path = lib/Driver/HostInfo.cpp; sourceTree = ""; tabWidth = 2; }; + DEDFE6590F7B3B830035BD10 /* Driver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Driver.cpp; path = lib/Driver/Driver.cpp; sourceTree = ""; tabWidth = 2; }; DEDFF87F0F848CE30035BD10 /* TemplateName.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = TemplateName.h; path = clang/AST/TemplateName.h; sourceTree = ""; tabWidth = 2; }; DEDFFF070F959EE60035BD10 /* Diagnostic.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Diagnostic.td; sourceTree = ""; }; DEDFFF530F9704580035BD10 /* DiagnosticGroups.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DiagnosticGroups.td; sourceTree = ""; }; @@ -841,7 +930,6 @@ DEF165150F8D46980098507F /* Types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Types.h; path = clang/Driver/Types.h; sourceTree = ""; }; DEF165160F8D46980098507F /* Action.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Action.h; path = clang/Driver/Action.h; sourceTree = ""; }; DEF165170F8D46980098507F /* Compilation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Compilation.h; path = clang/Driver/Compilation.h; sourceTree = ""; }; - DEF165180F8D46980098507F /* Options.def */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Options.def; path = clang/Driver/Options.def; sourceTree = ""; }; DEF165190F8D46980098507F /* Option.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Option.h; path = clang/Driver/Option.h; sourceTree = ""; }; DEF1651A0F8D46980098507F /* Types.def */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Types.def; path = clang/Driver/Types.def; sourceTree = ""; }; DEF1651B0F8D46980098507F /* ToolChain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ToolChain.h; path = clang/Driver/ToolChain.h; sourceTree = ""; }; @@ -880,6 +968,22 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + BFE2F6AC11DA955A0007EDC0 /* DeltaTree.o in Frameworks */, + BFE2F6AE11DA955A0007EDC0 /* FixItRewriter.o in Frameworks */, + BFE2F6B011DA955A0007EDC0 /* FrontendActions.o in Frameworks */, + BFE2F6B211DA955A0007EDC0 /* HTMLPrint.o in Frameworks */, + BFE2F6B411DA955A0007EDC0 /* HTMLRewrite.o in Frameworks */, + BFE2F6B611DA955A0007EDC0 /* RewriteMacros.o in Frameworks */, + BFE2F6B811DA955A0007EDC0 /* RewriteObjC.o in Frameworks */, + BFE2F6BA11DA955A0007EDC0 /* Rewriter.o in Frameworks */, + BFE2F6BC11DA955A0007EDC0 /* RewriteRope.o in Frameworks */, + BFE2F6BE11DA955A0007EDC0 /* RewriteTest.o in Frameworks */, + BFE2F6C011DA955A0007EDC0 /* TokenRewriter.o in Frameworks */, + BFE2F6C811DA955A0007EDC0 /* DeltaTree.o in Frameworks */, + BFE2F6CA11DA955A0007EDC0 /* HTMLRewrite.o in Frameworks */, + BFE2F6CC11DA955A0007EDC0 /* Rewriter.o in Frameworks */, + BFE2F6CE11DA955A0007EDC0 /* RewriteRope.o in Frameworks */, + BFE2F6D011DA955A0007EDC0 /* TokenRewriter.o in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -901,6 +1005,7 @@ 08FB7795FE84155DC02AAC07 /* Libraries */ = { isa = PBXGroup; children = ( + BFE2F67911DA95590007EDC0 /* Rewrite */, 90FD6D6C103C3D2D005F5B73 /* Index */, DED7D7500A5242C7003AD0FB /* Basic */, DED7D78C0A5242E6003AD0FB /* Lex */, @@ -1012,9 +1117,6 @@ 352246E50F5C6BE000D0D279 /* TextDiagnosticBuffer.cpp */, 352246E60F5C6BE000D0D279 /* TextDiagnosticPrinter.cpp */, 1ACB57E21105820D0047B991 /* TypeXML.cpp */, - 1A2A54B00FD1DD1C00F4CE45 /* RewriteMacros.cpp */, - 1A2A54B10FD1DD1C00F4CE45 /* RewriteObjC.cpp */, - 1A2A54B20FD1DD1C00F4CE45 /* RewriteTest.cpp */, 1A2A54B30FD1DD1C00F4CE45 /* StmtXML.cpp */, 1ACB57E31105820D0047B991 /* VerifyDiagnosticsClient.cpp */, 1A2A54B40FD1DD1C00F4CE45 /* Warnings.cpp */, @@ -1209,6 +1311,77 @@ name = "index-test"; sourceTree = ""; }; + BFE2F67911DA95590007EDC0 /* Rewrite */ = { + isa = PBXGroup; + children = ( + BFE2F67A11DA95590007EDC0 /* CMakeLists.txt */, + BFE2F67B11DA95590007EDC0 /* Debug */, + BFE2F69311DA955A0007EDC0 /* DeltaTree.cpp */, + BFE2F69411DA955A0007EDC0 /* FixItRewriter.cpp */, + BFE2F69511DA955A0007EDC0 /* FrontendActions.cpp */, + BFE2F69611DA955A0007EDC0 /* HTMLPrint.cpp */, + BFE2F69711DA955A0007EDC0 /* HTMLRewrite.cpp */, + BFE2F69811DA955A0007EDC0 /* Makefile */, + BFE2F69911DA955A0007EDC0 /* Release-Asserts */, + BFE2F6A511DA955A0007EDC0 /* RewriteMacros.cpp */, + BFE2F6A611DA955A0007EDC0 /* RewriteObjC.cpp */, + BFE2F6A711DA955A0007EDC0 /* Rewriter.cpp */, + BFE2F6A811DA955A0007EDC0 /* RewriteRope.cpp */, + BFE2F6A911DA955A0007EDC0 /* RewriteTest.cpp */, + BFE2F6AA11DA955A0007EDC0 /* TokenRewriter.cpp */, + ); + name = Rewrite; + path = lib/Rewrite; + sourceTree = ""; + }; + BFE2F67B11DA95590007EDC0 /* Debug */ = { + isa = PBXGroup; + children = ( + BFE2F67C11DA95590007EDC0 /* .dir */, + BFE2F67D11DA95590007EDC0 /* DeltaTree.d */, + BFE2F67E11DA955A0007EDC0 /* DeltaTree.o */, + BFE2F67F11DA955A0007EDC0 /* FixItRewriter.d */, + BFE2F68011DA955A0007EDC0 /* FixItRewriter.o */, + BFE2F68111DA955A0007EDC0 /* FrontendActions.d */, + BFE2F68211DA955A0007EDC0 /* FrontendActions.o */, + BFE2F68311DA955A0007EDC0 /* HTMLPrint.d */, + BFE2F68411DA955A0007EDC0 /* HTMLPrint.o */, + BFE2F68511DA955A0007EDC0 /* HTMLRewrite.d */, + BFE2F68611DA955A0007EDC0 /* HTMLRewrite.o */, + BFE2F68711DA955A0007EDC0 /* RewriteMacros.d */, + BFE2F68811DA955A0007EDC0 /* RewriteMacros.o */, + BFE2F68911DA955A0007EDC0 /* RewriteObjC.d */, + BFE2F68A11DA955A0007EDC0 /* RewriteObjC.o */, + BFE2F68B11DA955A0007EDC0 /* Rewriter.d */, + BFE2F68C11DA955A0007EDC0 /* Rewriter.o */, + BFE2F68D11DA955A0007EDC0 /* RewriteRope.d */, + BFE2F68E11DA955A0007EDC0 /* RewriteRope.o */, + BFE2F68F11DA955A0007EDC0 /* RewriteTest.d */, + BFE2F69011DA955A0007EDC0 /* RewriteTest.o */, + BFE2F69111DA955A0007EDC0 /* TokenRewriter.d */, + BFE2F69211DA955A0007EDC0 /* TokenRewriter.o */, + ); + path = Debug; + sourceTree = ""; + }; + BFE2F69911DA955A0007EDC0 /* Release-Asserts */ = { + isa = PBXGroup; + children = ( + BFE2F69A11DA955A0007EDC0 /* .dir */, + BFE2F69B11DA955A0007EDC0 /* DeltaTree.d */, + BFE2F69C11DA955A0007EDC0 /* DeltaTree.o */, + BFE2F69D11DA955A0007EDC0 /* HTMLRewrite.d */, + BFE2F69E11DA955A0007EDC0 /* HTMLRewrite.o */, + BFE2F69F11DA955A0007EDC0 /* Rewriter.d */, + BFE2F6A011DA955A0007EDC0 /* Rewriter.o */, + BFE2F6A111DA955A0007EDC0 /* RewriteRope.d */, + BFE2F6A211DA955A0007EDC0 /* RewriteRope.o */, + BFE2F6A311DA955A0007EDC0 /* TokenRewriter.d */, + BFE2F6A411DA955A0007EDC0 /* TokenRewriter.o */, + ); + path = "Release-Asserts"; + sourceTree = ""; + }; C6859E8C029090F304C91782 /* Documentation */ = { isa = PBXGroup; children = ( @@ -1722,14 +1895,17 @@ DEF165160F8D46980098507F /* Action.h */, DEF1651D0F8D46980098507F /* ArgList.h */, DEF1651E0F8D46980098507F /* Arg.h */, + 1AA1D35611BECFF70089CC3F /* CC1AsOptions.td */, + 1AA1D35711BECFF70089CC3F /* CC1Options.td */, DEF165170F8D46980098507F /* Compilation.h */, DEF165240F8D46980098507F /* DriverDiagnostic.h */, DEF165200F8D46980098507F /* Driver.h */, DEF1651F0F8D46980098507F /* HostInfo.h */, DEF165210F8D46980098507F /* Job.h */, - DEF165180F8D46980098507F /* Options.def */, DEF165190F8D46980098507F /* Option.h */, + 1AA1D35811BECFF70089CC3F /* Options.td */, DEF1651C0F8D46980098507F /* Options.h */, + 1AA1D35911BECFF70089CC3F /* OptParser.td */, DEF165230F8D46980098507F /* Phases.h */, DEF165140F8D46980098507F /* Tool.h */, DEF165150F8D46980098507F /* Types.h */, @@ -1966,9 +2142,6 @@ 1A2A54BD0FD1DD1C00F4CE45 /* HTMLPrint.cpp in Sources */, 1A2A54BE0FD1DD1C00F4CE45 /* PrintParserCallbacks.cpp in Sources */, 1A2A54BF0FD1DD1C00F4CE45 /* PrintPreprocessedOutput.cpp in Sources */, - 1A2A54C10FD1DD1C00F4CE45 /* RewriteMacros.cpp in Sources */, - 1A2A54C20FD1DD1C00F4CE45 /* RewriteObjC.cpp in Sources */, - 1A2A54C30FD1DD1C00F4CE45 /* RewriteTest.cpp in Sources */, 1A2A54C40FD1DD1C00F4CE45 /* StmtXML.cpp in Sources */, 1A2A54C50FD1DD1C00F4CE45 /* Warnings.cpp in Sources */, 1A6FE7090FD6F85800E00CA9 /* CGTemporaries.cpp in Sources */, @@ -2058,6 +2231,34 @@ 1ABD23F71182449800A48E65 /* Type.cpp in Sources */, 1ABD23F81182449800A48E65 /* TypeLoc.cpp in Sources */, 1ABD23F91182449800A48E65 /* TypePrinter.cpp in Sources */, + BFE2F6AB11DA955A0007EDC0 /* DeltaTree.d in Sources */, + BFE2F6AD11DA955A0007EDC0 /* FixItRewriter.d in Sources */, + BFE2F6AF11DA955A0007EDC0 /* FrontendActions.d in Sources */, + BFE2F6B111DA955A0007EDC0 /* HTMLPrint.d in Sources */, + BFE2F6B311DA955A0007EDC0 /* HTMLRewrite.d in Sources */, + BFE2F6B511DA955A0007EDC0 /* RewriteMacros.d in Sources */, + BFE2F6B711DA955A0007EDC0 /* RewriteObjC.d in Sources */, + BFE2F6B911DA955A0007EDC0 /* Rewriter.d in Sources */, + BFE2F6BB11DA955A0007EDC0 /* RewriteRope.d in Sources */, + BFE2F6BD11DA955A0007EDC0 /* RewriteTest.d in Sources */, + BFE2F6BF11DA955A0007EDC0 /* TokenRewriter.d in Sources */, + BFE2F6C111DA955A0007EDC0 /* DeltaTree.cpp in Sources */, + BFE2F6C211DA955A0007EDC0 /* FixItRewriter.cpp in Sources */, + BFE2F6C311DA955A0007EDC0 /* FrontendActions.cpp in Sources */, + BFE2F6C411DA955A0007EDC0 /* HTMLPrint.cpp in Sources */, + BFE2F6C511DA955A0007EDC0 /* HTMLRewrite.cpp in Sources */, + BFE2F6C611DA955A0007EDC0 /* Makefile in Sources */, + BFE2F6C711DA955A0007EDC0 /* DeltaTree.d in Sources */, + BFE2F6C911DA955A0007EDC0 /* HTMLRewrite.d in Sources */, + BFE2F6CB11DA955A0007EDC0 /* Rewriter.d in Sources */, + BFE2F6CD11DA955A0007EDC0 /* RewriteRope.d in Sources */, + BFE2F6CF11DA955A0007EDC0 /* TokenRewriter.d in Sources */, + BFE2F6D111DA955A0007EDC0 /* RewriteMacros.cpp in Sources */, + BFE2F6D211DA955A0007EDC0 /* RewriteObjC.cpp in Sources */, + BFE2F6D311DA955A0007EDC0 /* Rewriter.cpp in Sources */, + BFE2F6D411DA955A0007EDC0 /* RewriteRope.cpp in Sources */, + BFE2F6D511DA955A0007EDC0 /* RewriteTest.cpp in Sources */, + BFE2F6D611DA955A0007EDC0 /* TokenRewriter.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/docs/InternalsManual.html b/docs/InternalsManual.html index 5ef5dd842a6d..7aa26e00a4f1 100644 --- a/docs/InternalsManual.html +++ b/docs/InternalsManual.html @@ -118,8 +118,8 @@ classes somewhere else, or introduce some other solution.

The Clang Diagnostics subsystem is an important part of how the compiler communicates with the human. Diagnostics are the warnings and errors produced when the code is incorrect or dubious. In Clang, each diagnostic produced has -(at the minimum) a unique ID, a SourceLocation to -"put the caret", an English translation associated with it, and a severity (e.g. +(at the minimum) a unique ID, an English translation associated with it, a SourceLocation to "put the caret", and a severity (e.g. WARNING or ERROR). They can also optionally include a number of arguments to the dianostic (which fill in "%0"'s in the string) as well as a number of source ranges that related to the diagnostic.

@@ -127,7 +127,7 @@ number of source ranges that related to the diagnostic.

In this section, we'll be giving examples produced by the Clang command line driver, but diagnostics can be rendered in many different ways depending on how the DiagnosticClient interface is -implemented. A representative example of a diagonstic is:

+implemented. A representative example of a diagnostic is:

 t.c:38:15: error: invalid operands to binary expression ('int *' and '_Complex float')
@@ -709,7 +709,7 @@ be the location of the "c" identifier.
 
 
  • void* "AnnotationValue" - This contains an opaque object that the parser gets from Sema through an Actions module, it is passed around and Sema -intepretes it, based on the type of annotation token.
  • +interprets it, based on the type of annotation token.
  • TokenKind "Kind" - This indicates the kind of Annotation token this is. See below for the different valid kinds.
  • diff --git a/docs/Makefile b/docs/Makefile index e9bbb28f68c4..053b263d27dc 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -7,7 +7,7 @@ # ##===----------------------------------------------------------------------===## -LEVEL := ../../.. +CLANG_LEVEL := .. DIRS := tools ifdef BUILD_FOR_WEBSITE @@ -22,7 +22,7 @@ $(PROJ_OBJ_DIR)/doxygen.cfg: doxygen.cfg.in -e 's/@abs_top_builddir@/../g' > $@ endif -include $(LEVEL)/Makefile.common +include $(CLANG_LEVEL)/Makefile HTML := $(wildcard $(PROJ_SRC_DIR)/*.html) \ $(wildcard $(PROJ_SRC_DIR)/*.css) diff --git a/docs/PCHInternals.html b/docs/PCHInternals.html index e21ec5e90df3..109d5ed02558 100644 --- a/docs/PCHInternals.html +++ b/docs/PCHInternals.html @@ -144,6 +144,15 @@ deserialized from the precompiled header. These statistics can be useful to determine whether the precompiled header implementation can be improved by making more of the implementation lazy.

    +

    Precompiled headers can be chained. When you create a PCH while +including an existing PCH, Clang can create the new PCH by referencing +the original file and only writing the new data to the new file. For +example, you could create a PCH out of all the headers that are very +commonly used throughout your project, and then create a PCH for every +single source file in the project that includes the code that is +specific to that file, so that recompiling the file itself is very fast, +without duplicating the data from the common headers for every file.

    +

    Precompiled Header Contents

    Precompiled header layout @@ -209,6 +218,27 @@ contents are verified along with the rest of the metadata. +

    A chained PCH file (that is, one that references another PCH) has +a slightly different metadata block, which contains the following +information:

    + +
    +
    Referenced file
    +
    The name of the referenced PCH file. It is looked up like a file +specified using -include-pch.
    + +
    PCH version
    +
    This is the same as in normal PCH files.
    + +
    Original file name
    +
    The full path of the header that was used to generate this +precompiled header.
    + +
    + +

    The language options, target architecture and predefines buffer data +is taken from the end of the chain, since they have to match anyway.

    +

    Source Manager Block

    The source manager block contains the serialized representation of diff --git a/docs/UsersManual.html b/docs/UsersManual.html index 5c5f6f916cf6..51e699fc32cb 100644 --- a/docs/UsersManual.html +++ b/docs/UsersManual.html @@ -36,7 +36,7 @@ td {

    @@ -53,16 +53,6 @@ td {
  • Microsoft extensions
  • -
  • Objective-C Language Features - -
  • -
  • C++ Language Features -
  • -
  • Objective C++ Language Features -
  • Target-Specific Features and Limitations
    • CPU Architectures Features and Limitations @@ -261,11 +251,28 @@ when this is enabled, Clang will print something like:

      When this is disabled, Clang will just print:

      -  test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
      +  test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
      +  #endif bad
      +         ^
      +         //
       
      + +
      -f[no-]color-diagnostics:
      +
      This option, which defaults to on when a color-capable terminal is + detected, controls whether or not Clang prints diagnostics in color. + When this option is enabled, Clang will use colors to highlight + specific parts of the diagnostic, e.g., + +
      +
      +
      '
      -f[no-]diagnostics-show-option: Enable [-Woption] information in diagnostic line.
      @@ -386,6 +393,66 @@ by commenting them out.

      and -Wbaz.

      + +
      -Wambiguous-member-template: +Warn about unqualified uses of a member template whose name resolves +to another template at the location of the use.
      +
      This option, which defaults to on, enables a warning in the +following code:

      + +
      +template<typename T> struct set{};
      +template<typename T> struct trait { typedef const T& type; };
      +struct Value {
      +  template<typename T> void set(typename trait<T>::type value) {}
      +};
      +void foo() {
      +  Value v;
      +  v.set<double>(3.2);
      +}
      +
      + +

      C++ [basic.lookup.classref] requires this to be an error, but, +because it's hard to work around, Clang downgrades it to a warning as +an extension.

      +
      + + +
      -Wbind-to-temporary-copy: Warn about +an unusable copy constructor when binding a reference to a temporary.
      +
      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:

      + +
      +  struct NonCopyable {
      +    NonCopyable();
      +  private:
      +    NonCopyable(const NonCopyable&);
      +  };
      +  void foo(const NonCopyable&);
      +  void bar() {
      +    foo(NonCopyable());  // Disallowed in C++98; allowed in C++0x.
      +  }
      +
      +
      +  struct NonCopyable2 {
      +    NonCopyable2();
      +    NonCopyable2(NonCopyable2&);
      +  };
      +  void foo(const NonCopyable2&);
      +  void bar() {
      +    foo(NonCopyable2());  // Disallowed in C++98; allowed in C++0x.
      +  }
      +
      + +

      Note that if NonCopyable2::NonCopyable2() has a default +argument whose instantiation produces a compile error, that error will +still be a hard error in C++98 mode even if this warning is turned +off.

      + +
      + @@ -717,11 +784,6 @@ extensions are not implemented yet:

      a relatively small feature, so it is likely to be implemented relatively soon.
    • -
    • clang does not support attributes on function pointers -(bug 2461). This is -a relatively important feature, so it is likely to be implemented relatively -soon.
    • -
    • clang does not support #pragma weak (bug 3679). Due to the uses described in the bug, this is likely to be implemented at some @@ -824,45 +886,6 @@ controlling record layout. GCC also contains support for this feature, however where MSVC and GCC are incompatible clang follows the MSVC definition.
    • - -

      Objective-C Language Features

      - - - - -

      Intentional Incompatibilities with GCC

      - - -

      No cast of super, no lvalue casts.

      - - - - -

      C++ Language Features

      - - -

      At this point, Clang C++ is not production-quality and is not recommended for use beyond experimentation. However, Clang C++ support -is under active development and is progressing rapidly. Please see the C++ Status page for details or -ask on the mailing list about how you can help.

      - -

      Note that released Clang compilers will refuse to even try to use clang to compile C++ code unless you pass the -ccc-clang-cxx option to the driver. To turn on Clang's C++ support, please pass that flag. Clang compilers built from the Subversion trunk enable C++ support by default, and do not require the -ccc-clang-cxx flag.

      - -

      Clang strives to strictly conform to the C++ standard. That means -it will reject invalid C++ code that another compiler may accept. If -Clang reports errors in your code, please check -the C++ -Compatibility page to see whether they are C++-conformance bugs -and how you can fix them.

      - - -

      Objective C++ Language Features

      - - -

      At this point, Clang C++ support is not generally useful (and therefore, -neither is Objective-C++). Please see the C++ section for -more information.

      -

      Target-Specific Features and Limitations

      diff --git a/docs/tools/Makefile b/docs/tools/Makefile index 91bc447c083f..5521d6b764c9 100644 --- a/docs/tools/Makefile +++ b/docs/tools/Makefile @@ -37,10 +37,11 @@ clean: else # Otherwise, if not in BUILD_FOR_WEBSITE mode, use the project info. -LEVEL := ../../../.. -include $(LEVEL)/Makefile.common +CLANG_LEVEL := ../.. +include $(CLANG_LEVEL)/Makefile -CLANG_VERSION := $(shell cat $(PROJ_SRC_DIR)/../../VER) +CLANG_VERSION := $(word 3,$(shell grep "CLANG_VERSION " \ + $(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include/clang/Basic/Version.inc)) SRC_DOC_DIR=$(PROJ_SRC_DIR)/ DST_HTML_DIR=$(PROJ_OBJ_DIR)/ diff --git a/examples/Makefile b/examples/Makefile index 869197db35d2..c4af25263398 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -7,8 +7,8 @@ # ##===----------------------------------------------------------------------===## -LEVEL = ../../.. +CLANG_LEVEL := .. PARALLEL_DIRS := clang-interpreter PrintFunctionNames wpa -include $(LEVEL)/Makefile.common +include $(CLANG_LEVEL)/Makefile diff --git a/examples/PrintFunctionNames/CMakeLists.txt b/examples/PrintFunctionNames/CMakeLists.txt index 49dd22ad8d0d..5ea75db42e02 100644 --- a/examples/PrintFunctionNames/CMakeLists.txt +++ b/examples/PrintFunctionNames/CMakeLists.txt @@ -1,26 +1,10 @@ -set(SHARED_LIBRARY TRUE) +set(MODULE TRUE) set(LLVM_NO_RTTI 1) -set(LLVM_USED_LIBS - clangIndex - clangFrontend - clangDriver - clangSema - clangAnalysis - clangAST - clangParse - clangLex - clangBasic) - -set( LLVM_LINK_COMPONENTS - bitreader - mc - core - ) - add_clang_library(PrintFunctionNames PrintFunctionNames.cpp) set_target_properties(PrintFunctionNames PROPERTIES - LINKER_LANGUAGE CXX) + LINKER_LANGUAGE CXX + PREFIX "") diff --git a/examples/PrintFunctionNames/Makefile b/examples/PrintFunctionNames/Makefile index 57d3ba9b0cd9..0ff5189437c7 100644 --- a/examples/PrintFunctionNames/Makefile +++ b/examples/PrintFunctionNames/Makefile @@ -7,21 +7,13 @@ # ##===----------------------------------------------------------------------===## -LEVEL = ../../../.. +CLANG_LEVEL := ../.. LIBRARYNAME = PrintFunctionNames -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include - -# Include this here so we can get the configuration of the targets that have -# been configured for construction. We have to do this early so we can set up -# LINK_COMPONENTS before including Makefile.rules -include $(LEVEL)/Makefile.config - LINK_LIBS_IN_SHARED = 1 SHARED_LIBRARY = 1 -LINK_COMPONENTS := bitreader mc core USEDLIBS = clangIndex.a clangFrontend.a clangDriver.a clangSema.a \ clangAnalysis.a clangAST.a clangParse.a clangLex.a clangBasic.a -include $(LEVEL)/Makefile.common +include $(CLANG_LEVEL)/Makefile diff --git a/examples/PrintFunctionNames/PrintFunctionNames.cpp b/examples/PrintFunctionNames/PrintFunctionNames.cpp index 5b7b66a4f7ff..397cf843fa7f 100644 --- a/examples/PrintFunctionNames/PrintFunctionNames.cpp +++ b/examples/PrintFunctionNames/PrintFunctionNames.cpp @@ -31,11 +31,24 @@ public: } }; -class PrintFunctionNamesAction : public ASTFrontendAction { +class PrintFunctionNamesAction : public PluginASTAction { protected: ASTConsumer *CreateASTConsumer(CompilerInstance &CI, llvm::StringRef) { return new PrintFunctionsConsumer(); } + + bool ParseArgs(const std::vector& args) { + for (unsigned i=0; i InputFilenames(llvm::cl::Positional, llvm::cl::desc("")); +static llvm::cl::opt +ViewCallGraph("view-call-graph", llvm::cl::desc("Display the call graph.")); + +static llvm::cl::opt +AnalyzeFunction("analyze-function", + llvm::cl::desc("Specify the entry function.")); + +namespace { +// A thin wrapper over ASTUnit implementing the TranslationUnit interface. +class ASTUnitTU : public TranslationUnit { + ASTUnit *AST; + DeclReferenceMap DeclRefMap; + SelectorMap SelMap; + +public: + ASTUnitTU(ASTUnit *ast) + : AST(ast), DeclRefMap(AST->getASTContext()), SelMap(AST->getASTContext()) { + } + + virtual ASTContext &getASTContext() { + return AST->getASTContext(); + } + + virtual Preprocessor &getPreprocessor() { + return AST->getPreprocessor(); + } + + virtual DeclReferenceMap &getDeclReferenceMap() { + return DeclRefMap; + } + + virtual SelectorMap &getSelectorMap() { + return SelMap; + } +}; +} + int main(int argc, char **argv) { llvm::cl::ParseCommandLineOptions(argc, argv, "clang-wpa"); - FileManager FileMgr; std::vector ASTUnits; + Program Prog; + Indexer Idxer(Prog); + if (InputFilenames.empty()) return 0; @@ -46,11 +94,52 @@ int main(int argc, char **argv) { ASTUnits.push_back(AST.take()); } - llvm::OwningPtr CG; - CG.reset(new CallGraph()); + if (ViewCallGraph) { + llvm::OwningPtr CG; + CG.reset(new CallGraph(Prog)); + + for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i) + CG->addTU(ASTUnits[i]->getASTContext()); + + CG->ViewCallGraph(); + return 0; + } + + if (AnalyzeFunction.empty()) + return 0; + + // Feed all ASTUnits to the Indexer. + for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i) { + ASTUnitTU *TU = new ASTUnitTU(ASTUnits[i]); + Idxer.IndexAST(TU); + } + + Entity Ent = Entity::get(AnalyzeFunction, Prog); + FunctionDecl *FD; + TranslationUnit *TU; + llvm::tie(FD, TU) = Idxer.getDefinitionFor(Ent); + + if (!FD) + return 0; + + // Create an analysis engine. + Preprocessor &PP = TU->getPreprocessor(); + + // Hard code options for now. + AnalysisManager AMgr(TU->getASTContext(), PP.getDiagnostics(), + PP.getLangOptions(), /* PathDiagnostic */ 0, + CreateRegionStoreManager, + CreateRangeConstraintManager, + /* MaxNodes */ 300000, /* MaxLoop */ 3, + /* VisualizeEG */ false, /* VisualizeEGUbi */ false, + /* PurgeDead */ true, /* EagerlyAssume */ false, + /* TrimGraph */ false, /* InlineCall */ true); - for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i) - CG->addTU(ASTUnits[i]->getASTContext()); + GRTransferFuncs* TF = MakeCFRefCountTF(AMgr.getASTContext(), /*GC*/false, + AMgr.getLangOptions()); + GRExprEngine Eng(AMgr, TF); - CG->ViewCallGraph(); + Eng.ExecuteWorkList(AMgr.getStackFrame(FD), AMgr.getMaxNodes()); + + return 0; } diff --git a/include/Makefile b/include/Makefile index f686d6a64606..79b9adfb7282 100644 --- a/include/Makefile +++ b/include/Makefile @@ -1,4 +1,4 @@ -LEVEL = ../../.. +CLANG_LEVEL := .. DIRS := clang clang-c -include $(LEVEL)/Makefile.common +include $(CLANG_LEVEL)/Makefile diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 86926bd683ba..b377b6d5fe2c 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -342,12 +342,6 @@ CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); */ CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); -/** - * \brief Determine if the source location occurs within the main file - * of the translation unit (as opposed to an included header). - */ -CINDEX_LINKAGE unsigned clang_isFromMainFile(CXSourceLocation loc); - /** * @} */ @@ -1092,7 +1086,9 @@ enum CXTypeKind { CXType_Enum = 106, CXType_Typedef = 107, CXType_ObjCInterface = 108, - CXType_ObjCObjectPointer = 109 + CXType_ObjCObjectPointer = 109, + CXType_FunctionNoProto = 110, + CXType_FunctionProto = 111 }; /** @@ -1144,6 +1140,17 @@ CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T); */ CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K); +/** + * \brief Retrieve the result type associated with a function type. + */ +CINDEX_LINKAGE CXType clang_getResultType(CXType T); + +/** + * \brief Retrieve the result type associated with a given cursor. This only + * returns a valid type of the cursor refers to a function or method. + */ +CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); + /** * @} */ diff --git a/include/clang-c/Makefile b/include/clang-c/Makefile index 5e3522f79137..98ea7190e687 100644 --- a/include/clang-c/Makefile +++ b/include/clang-c/Makefile @@ -1,7 +1,7 @@ -LEVEL = ../../../.. +CLANG_LEVEL := ../.. DIRS := -include $(LEVEL)/Makefile.common +include $(CLANG_LEVEL)/Makefile install-local:: $(Echo) Installing Clang C API include files diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 87a12cde2ad2..3799451360f4 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -62,6 +62,7 @@ namespace clang { class RecordDecl; class StoredDeclsMap; class TagDecl; + class TemplateTemplateParmDecl; class TemplateTypeParmDecl; class TranslationUnitDecl; class TypeDecl; @@ -75,6 +76,8 @@ 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 { + ASTContext &this_() { return *this; } + std::vector Types; llvm::FoldingSet ExtQualNodes; llvm::FoldingSet ComplexTypes; @@ -95,9 +98,12 @@ class ASTContext { llvm::FoldingSet DependentDecltypeTypes; llvm::FoldingSet TemplateTypeParmTypes; llvm::FoldingSet SubstTemplateTypeParmTypes; - llvm::FoldingSet TemplateSpecializationTypes; + llvm::ContextualFoldingSet + TemplateSpecializationTypes; llvm::FoldingSet ElaboratedTypes; llvm::FoldingSet DependentNameTypes; + llvm::ContextualFoldingSet + DependentTemplateSpecializationTypes; llvm::FoldingSet ObjCObjectTypes; llvm::FoldingSet ObjCObjectPointerTypes; @@ -122,6 +128,30 @@ class ASTContext { /// \brief Mapping from ObjCContainers to their ObjCImplementations. llvm::DenseMap ObjCImpls; + /// \brief Representation of a "canonical" template template parameter that + /// is used in canonical template names. + class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode { + TemplateTemplateParmDecl *Parm; + + public: + CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm) + : Parm(Parm) { } + + TemplateTemplateParmDecl *getParam() const { return Parm; } + + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Parm); } + + static void Profile(llvm::FoldingSetNodeID &ID, + TemplateTemplateParmDecl *Parm); + }; + llvm::FoldingSet CanonTemplateTemplateParms; + + TemplateTemplateParmDecl *getCanonicalTemplateTemplateParmDecl( + TemplateTemplateParmDecl *TTP); + + /// \brief Whether __[u]int128_t identifier is installed. + bool IsInt128Installed; + /// BuiltinVaListType - built-in va list type. /// This is initially null and set by Sema::LazilyCreateBuiltin when /// a builtin that takes a valist is encountered. @@ -162,6 +192,8 @@ class ASTContext { /// \brief Type for the Block descriptor for Blocks CodeGen. RecordDecl *BlockDescriptorExtendedType; + TypeSourceInfo NullTypeSourceInfo; + /// \brief Keeps track of all declaration attributes. /// /// Since so few decls have attrs, we keep them in a hash map instead of @@ -302,7 +334,8 @@ public: /// \brief Note that the static data member \p Inst is an instantiation of /// the static data member template \p Tmpl of a class template. void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, - TemplateSpecializationKind TSK); + TemplateSpecializationKind TSK, + SourceLocation PointOfInstantiation = SourceLocation()); /// \brief If the given using decl is an instantiation of a /// (possibly unresolved) using decl from a template instantiation, @@ -329,6 +362,8 @@ public: overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const; + unsigned overridden_methods_size(const CXXMethodDecl *Method) const; + /// \brief Note that the given C++ \p Method overrides the given \p /// Overridden method. void addOverriddenMethod(const CXXMethodDecl *Method, @@ -534,7 +569,7 @@ public: /// getVectorType - Return the unique reference to a vector type of /// the specified element type and size. VectorType must be a built-in type. QualType getVectorType(QualType VectorType, unsigned NumElts, - bool AltiVec, bool IsPixel); + VectorType::AltiVecSpecific AltiVecSpec); /// getExtVectorType - Return the unique reference to an extended vector type /// of the specified element type and size. VectorType must be a built-in @@ -585,7 +620,11 @@ public: /// getTypedefType - Return the unique reference to the type for the /// specified typename decl. - QualType getTypedefType(const TypedefDecl *Decl); + QualType getTypedefType(const TypedefDecl *Decl, QualType Canon = QualType()); + + QualType getRecordType(const RecordDecl *Decl); + + QualType getEnumType(const EnumDecl *Decl); QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST); @@ -599,13 +638,15 @@ public: QualType getTemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, - QualType Canon = QualType(), - bool IsCurrentInstantiation = false); + QualType Canon = QualType()); + + QualType getCanonicalTemplateSpecializationType(TemplateName T, + const TemplateArgument *Args, + unsigned NumArgs); QualType getTemplateSpecializationType(TemplateName T, const TemplateArgumentListInfo &Args, - QualType Canon = QualType(), - bool IsCurrentInstantiation = false); + QualType Canon = QualType()); TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, @@ -619,10 +660,16 @@ public: NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon = QualType()); - QualType getDependentNameType(ElaboratedTypeKeyword Keyword, - NestedNameSpecifier *NNS, - const TemplateSpecializationType *TemplateId, - QualType Canon = QualType()); + + QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, + NestedNameSpecifier *NNS, + const IdentifierInfo *Name, + const TemplateArgumentListInfo &Args); + QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, + NestedNameSpecifier *NNS, + const IdentifierInfo *Name, + unsigned NumArgs, + const TemplateArgument *Args); QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl); @@ -780,6 +827,10 @@ public: /// purpose in characters. CharUnits getObjCEncodingTypeSize(QualType t); + /// \brief Whether __[u]int128_t identifier is installed. + bool isInt128Installed() const { return IsInt128Installed; } + void setInt128Installed() { IsInt128Installed = true; } + /// This setter/getter represents the ObjC 'id' type. It is setup lazily, by /// Sema. id is always a (typedef for a) pointer type, a pointer to a struct. QualType getObjCIdType() const { return ObjCIdTypedefType; } @@ -943,8 +994,9 @@ public: const ASTRecordLayout & getASTObjCImplementationLayout(const ObjCImplementationDecl *D); - /// getKeyFunction - Get the key function for the given record decl. - /// The key function is, according to the Itanium C++ ABI section 5.2.3: + /// getKeyFunction - Get the key function for the given record decl, or NULL + /// if there isn't one. The key function is, according to the Itanium C++ ABI + /// section 5.2.3: /// /// ...the first non-pure virtual function that is not inline at the point /// of class definition. @@ -1013,6 +1065,8 @@ public: return UnqualT1 == UnqualT2; } + bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2); + /// \brief Retrieves the "canonical" declaration of /// \brief Retrieves the "canonical" nested name specifier for a @@ -1272,6 +1326,8 @@ public: TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc = SourceLocation()); + TypeSourceInfo *getNullTypeSourceInfo() { return &NullTypeSourceInfo; } + /// \brief Add a deallocation callback that will be invoked when the /// ASTContext is destroyed. /// @@ -1280,6 +1336,38 @@ public: /// \brief Data Pointer data that will be provided to the callback function /// when it is called. void AddDeallocation(void (*Callback)(void*), void *Data); + + //===--------------------------------------------------------------------===// + // Statistics + //===--------------------------------------------------------------------===// + + /// \brief The number of implicitly-declared default constructors. + static unsigned NumImplicitDefaultConstructors; + + /// \brief The number of implicitly-declared default constructors for + /// which declarations were built. + static unsigned NumImplicitDefaultConstructorsDeclared; + + /// \brief The number of implicitly-declared copy constructors. + static unsigned NumImplicitCopyConstructors; + + /// \brief The number of implicitly-declared copy constructors for + /// which declarations were built. + static unsigned NumImplicitCopyConstructorsDeclared; + + /// \brief The number of implicitly-declared copy assignment operators. + static unsigned NumImplicitCopyAssignmentOperators; + + /// \brief The number of implicitly-declared copy assignment operators for + /// which declarations were built. + static unsigned NumImplicitCopyAssignmentOperatorsDeclared; + + /// \brief The number of implicitly-declared destructors. + static unsigned NumImplicitDestructors; + + /// \brief The number of implicitly-declared destructors for which + /// declarations were built. + static unsigned NumImplicitDestructorsDeclared; private: ASTContext(const ASTContext&); // DO NOT IMPLEMENT @@ -1308,6 +1396,11 @@ private: // by DeclContext objects. This probably should not be in ASTContext, // but we include it here so that ASTContext can quickly deallocate them. llvm::PointerIntPair LastSDM; + + /// \brief A counter used to uniquely identify "blocks". + unsigned int UniqueBlockByRefTypeID; + unsigned int UniqueBlockParmTypeID; + friend class DeclContext; friend class DeclarationNameTable; void ReleaseDeclContextMaps(); diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 3240e50b0787..9faa62eef6f7 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -16,6 +16,7 @@ #include "llvm/Support/Casting.h" #include "llvm/ADT/StringRef.h" +#include "clang/Basic/AttrKinds.h" #include #include #include @@ -25,6 +26,7 @@ namespace clang { class ASTContext; class IdentifierInfo; class ObjCInterfaceDecl; + class Expr; } // Defined in ASTContext.h @@ -41,75 +43,9 @@ namespace clang { /// Attr - This represents one attribute. class Attr { -public: - enum Kind { - Alias, - Aligned, - AlignMac68k, - AlwaysInline, - AnalyzerNoReturn, // Clang-specific. - Annotate, - AsmLabel, // Represent GCC asm label extension. - BaseCheck, - Blocks, - CDecl, - Cleanup, - Const, - Constructor, - Deprecated, - Destructor, - FastCall, - Final, - Format, - FormatArg, - GNUInline, - Hiding, - IBOutletKind, // Clang-specific. Use "Kind" suffix to not conflict w/ macro. - IBOutletCollectionKind, // Clang-specific. - IBActionKind, // Clang-specific. Use "Kind" suffix to not conflict w/ macro. - Malloc, - MaxFieldAlignment, - NoDebug, - NoInline, - NonNull, - NoReturn, - NoThrow, - ObjCException, - ObjCNSObject, - Override, - CFReturnsRetained, // Clang/Checker-specific. - CFReturnsNotRetained, // Clang/Checker-specific. - NSReturnsRetained, // Clang/Checker-specific. - NSReturnsNotRetained, // Clang/Checker-specific. - Overloadable, // Clang-specific - Packed, - Pure, - Regparm, - ReqdWorkGroupSize, // OpenCL-specific - Section, - Sentinel, - StdCall, - ThisCall, - TransparentUnion, - Unavailable, - Unused, - Used, - Visibility, - WarnUnusedResult, - Weak, - WeakImport, - WeakRef, - - FIRST_TARGET_ATTRIBUTE, - DLLExport, - DLLImport, - MSP430Interrupt, - X86ForceAlignArgPointer - }; - private: Attr *Next; - Kind AttrKind; + attr::Kind AttrKind; bool Inherited : 1; protected: @@ -122,7 +58,7 @@ protected: } protected: - Attr(Kind AK) : Next(0), AttrKind(AK), Inherited(false) {} + Attr(attr::Kind AK) : Next(0), AttrKind(AK), Inherited(false) {} virtual ~Attr() { assert(Next == 0 && "Destroy didn't work"); } @@ -133,7 +69,7 @@ public: /// declarations. virtual bool isMerged() const { return true; } - Kind getKind() const { return AttrKind; } + attr::Kind getKind() const { return AttrKind; } Attr *getNext() { return Next; } const Attr *getNext() const { return Next; } @@ -163,13 +99,15 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *) { return true; } }; + +#include "clang/AST/Attrs.inc" class AttrWithString : public Attr { private: const char *Str; unsigned StrLen; protected: - AttrWithString(Attr::Kind AK, ASTContext &C, llvm::StringRef s); + AttrWithString(attr::Kind AK, ASTContext &C, llvm::StringRef s); llvm::StringRef getString() const { return llvm::StringRef(Str, StrLen); } void ReplaceString(ASTContext &C, llvm::StringRef newS); public: @@ -179,9 +117,9 @@ public: #define DEF_SIMPLE_ATTR(ATTR) \ class ATTR##Attr : public Attr { \ public: \ - ATTR##Attr() : Attr(ATTR) {} \ + ATTR##Attr() : Attr(attr::ATTR) {} \ virtual Attr *clone(ASTContext &C) const; \ - static bool classof(const Attr *A) { return A->getKind() == ATTR; } \ + static bool classof(const Attr *A) { return A->getKind() == attr::ATTR; } \ static bool classof(const ATTR##Attr *A) { return true; } \ } @@ -194,7 +132,7 @@ class MaxFieldAlignmentAttr : public Attr { public: MaxFieldAlignmentAttr(unsigned alignment) - : Attr(MaxFieldAlignment), Alignment(alignment) {} + : Attr(attr::MaxFieldAlignment), Alignment(alignment) {} /// getAlignment - The specified alignment in bits. unsigned getAlignment() const { return Alignment; } @@ -203,36 +141,58 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == MaxFieldAlignment; + return A->getKind() == attr::MaxFieldAlignment; } static bool classof(const MaxFieldAlignmentAttr *A) { return true; } }; DEF_SIMPLE_ATTR(AlignMac68k); +/// \brief Atribute for specifying the alignment of a variable or type. +/// +/// This node will either contain the precise Alignment (in bits, not bytes!) +/// or will contain the expression for the alignment attribute in the case of +/// a dependent expression within a class or function template. At template +/// instantiation time these are transformed into concrete attributes. class AlignedAttr : public Attr { unsigned Alignment; + Expr *AlignmentExpr; public: AlignedAttr(unsigned alignment) - : Attr(Aligned), Alignment(alignment) {} + : Attr(attr::Aligned), Alignment(alignment), AlignmentExpr(0) {} + AlignedAttr(Expr *E) + : Attr(attr::Aligned), Alignment(0), AlignmentExpr(E) {} + + /// getAlignmentExpr - Get a dependent alignment expression if one is present. + Expr *getAlignmentExpr() const { + return AlignmentExpr; + } + + /// isDependent - Is the alignment a dependent expression + bool isDependent() const { + return getAlignmentExpr(); + } + + /// getAlignment - The specified alignment in bits. Requires !isDependent(). + unsigned getAlignment() const { + assert(!isDependent() && "Cannot get a value dependent alignment"); + return Alignment; + } - /// getAlignment - The specified alignment in bits. - unsigned getAlignment() const { return Alignment; } - /// getMaxAlignment - Get the maximum alignment of attributes on this list. unsigned getMaxAlignment() const { const AlignedAttr *Next = getNext(); if (Next) - return std::max(Next->getMaxAlignment(), Alignment); + return std::max(Next->getMaxAlignment(), getAlignment()); else - return Alignment; + return getAlignment(); } virtual Attr* clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == Aligned; + return A->getKind() == attr::Aligned; } static bool classof(const AlignedAttr *A) { return true; } }; @@ -240,7 +200,7 @@ public: class AnnotateAttr : public AttrWithString { public: AnnotateAttr(ASTContext &C, llvm::StringRef ann) - : AttrWithString(Annotate, C, ann) {} + : AttrWithString(attr::Annotate, C, ann) {} llvm::StringRef getAnnotation() const { return getString(); } @@ -248,7 +208,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == Annotate; + return A->getKind() == attr::Annotate; } static bool classof(const AnnotateAttr *A) { return true; } }; @@ -256,7 +216,7 @@ public: class AsmLabelAttr : public AttrWithString { public: AsmLabelAttr(ASTContext &C, llvm::StringRef L) - : AttrWithString(AsmLabel, C, L) {} + : AttrWithString(attr::AsmLabel, C, L) {} llvm::StringRef getLabel() const { return getString(); } @@ -264,7 +224,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == AsmLabel; + return A->getKind() == attr::AsmLabel; } static bool classof(const AsmLabelAttr *A) { return true; } }; @@ -274,54 +234,56 @@ DEF_SIMPLE_ATTR(AlwaysInline); class AliasAttr : public AttrWithString { public: AliasAttr(ASTContext &C, llvm::StringRef aliasee) - : AttrWithString(Alias, C, aliasee) {} + : AttrWithString(attr::Alias, C, aliasee) {} llvm::StringRef getAliasee() const { return getString(); } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Alias; } + static bool classof(const Attr *A) { return A->getKind() == attr::Alias; } static bool classof(const AliasAttr *A) { return true; } }; class ConstructorAttr : public Attr { int priority; public: - ConstructorAttr(int p) : Attr(Constructor), priority(p) {} + ConstructorAttr(int p) : Attr(attr::Constructor), priority(p) {} int getPriority() const { return priority; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Constructor; } + static bool classof(const Attr *A) + { return A->getKind() == attr::Constructor; } static bool classof(const ConstructorAttr *A) { return true; } }; class DestructorAttr : public Attr { int priority; public: - DestructorAttr(int p) : Attr(Destructor), priority(p) {} + DestructorAttr(int p) : Attr(attr::Destructor), priority(p) {} int getPriority() const { return priority; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Destructor; } + static bool classof(const Attr *A) + { return A->getKind() == attr::Destructor; } static bool classof(const DestructorAttr *A) { return true; } }; class IBOutletAttr : public Attr { public: - IBOutletAttr() : Attr(IBOutletKind) {} + IBOutletAttr() : Attr(attr::IBOutlet) {} virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == IBOutletKind; + return A->getKind() == attr::IBOutlet; } static bool classof(const IBOutletAttr *A) { return true; } }; @@ -330,7 +292,7 @@ class IBOutletCollectionAttr : public Attr { const ObjCInterfaceDecl *D; public: IBOutletCollectionAttr(const ObjCInterfaceDecl *d = 0) - : Attr(IBOutletCollectionKind), D(d) {} + : Attr(attr::IBOutletCollection), D(d) {} const ObjCInterfaceDecl *getClass() const { return D; } @@ -338,35 +300,35 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == IBOutletCollectionKind; + return A->getKind() == attr::IBOutletCollection; } static bool classof(const IBOutletCollectionAttr *A) { return true; } }; class IBActionAttr : public Attr { public: - IBActionAttr() : Attr(IBActionKind) {} + IBActionAttr() : Attr(attr::IBAction) {} virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == IBActionKind; + return A->getKind() == attr::IBAction; } static bool classof(const IBActionAttr *A) { return true; } }; DEF_SIMPLE_ATTR(AnalyzerNoReturn); DEF_SIMPLE_ATTR(Deprecated); -DEF_SIMPLE_ATTR(Final); DEF_SIMPLE_ATTR(GNUInline); DEF_SIMPLE_ATTR(Malloc); DEF_SIMPLE_ATTR(NoReturn); +DEF_SIMPLE_ATTR(NoInstrumentFunction); class SectionAttr : public AttrWithString { public: SectionAttr(ASTContext &C, llvm::StringRef N) - : AttrWithString(Section, C, N) {} + : AttrWithString(attr::Section, C, N) {} llvm::StringRef getName() const { return getString(); } @@ -374,7 +336,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == Section; + return A->getKind() == attr::Section; } static bool classof(const SectionAttr *A) { return true; } }; @@ -408,7 +370,7 @@ public: virtual Attr *clone(ASTContext &C) const; - static bool classof(const Attr *A) { return A->getKind() == NonNull; } + static bool classof(const Attr *A) { return A->getKind() == attr::NonNull; } static bool classof(const NonNullAttr *A) { return true; } }; @@ -416,7 +378,7 @@ class FormatAttr : public AttrWithString { int formatIdx, firstArg; public: FormatAttr(ASTContext &C, llvm::StringRef type, int idx, int first) - : AttrWithString(Format, C, type), formatIdx(idx), firstArg(first) {} + : AttrWithString(attr::Format, C, type), formatIdx(idx), firstArg(first) {} llvm::StringRef getType() const { return getString(); } void setType(ASTContext &C, llvm::StringRef type); @@ -426,27 +388,27 @@ public: virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Format; } + static bool classof(const Attr *A) { return A->getKind() == attr::Format; } static bool classof(const FormatAttr *A) { return true; } }; class FormatArgAttr : public Attr { int formatIdx; public: - FormatArgAttr(int idx) : Attr(FormatArg), formatIdx(idx) {} + FormatArgAttr(int idx) : Attr(attr::FormatArg), formatIdx(idx) {} int getFormatIdx() const { return formatIdx; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == FormatArg; } + static bool classof(const Attr *A) { return A->getKind() == attr::FormatArg; } static bool classof(const FormatArgAttr *A) { return true; } }; class SentinelAttr : public Attr { int sentinel, NullPos; public: - SentinelAttr(int sentinel_val, int nullPos) : Attr(Sentinel), + SentinelAttr(int sentinel_val, int nullPos) : Attr(attr::Sentinel), sentinel(sentinel_val), NullPos(nullPos) {} int getSentinel() const { return sentinel; } int getNullPos() const { return NullPos; } @@ -454,7 +416,7 @@ public: virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Sentinel; } + static bool classof(const Attr *A) { return A->getKind() == attr::Sentinel; } static bool classof(const SentinelAttr *A) { return true; } }; @@ -469,7 +431,7 @@ public: private: VisibilityTypes VisibilityType; public: - VisibilityAttr(VisibilityTypes v) : Attr(Visibility), + VisibilityAttr(VisibilityTypes v) : Attr(attr::Visibility), VisibilityType(v) {} VisibilityTypes getVisibility() const { return VisibilityType; } @@ -477,7 +439,8 @@ public: virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Visibility; } + static bool classof(const Attr *A) + { return A->getKind() == attr::Visibility; } static bool classof(const VisibilityAttr *A) { return true; } }; @@ -491,13 +454,14 @@ DEF_SIMPLE_ATTR(ObjCException); class OverloadableAttr : public Attr { public: - OverloadableAttr() : Attr(Overloadable) { } + OverloadableAttr() : Attr(attr::Overloadable) { } virtual bool isMerged() const { return false; } virtual Attr *clone(ASTContext &C) const; - static bool classof(const Attr *A) { return A->getKind() == Overloadable; } + static bool classof(const Attr *A) + { return A->getKind() == attr::Overloadable; } static bool classof(const OverloadableAttr *) { return true; } }; @@ -509,14 +473,14 @@ public: private: BlocksAttrTypes BlocksAttrType; public: - BlocksAttr(BlocksAttrTypes t) : Attr(Blocks), BlocksAttrType(t) {} + BlocksAttr(BlocksAttrTypes t) : Attr(attr::Blocks), BlocksAttrType(t) {} BlocksAttrTypes getType() const { return BlocksAttrType; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Blocks; } + static bool classof(const Attr *A) { return A->getKind() == attr::Blocks; } static bool classof(const BlocksAttr *A) { return true; } }; @@ -526,14 +490,14 @@ class CleanupAttr : public Attr { FunctionDecl *FD; public: - CleanupAttr(FunctionDecl *fd) : Attr(Cleanup), FD(fd) {} + CleanupAttr(FunctionDecl *fd) : Attr(attr::Cleanup), FD(fd) {} const FunctionDecl *getFunctionDecl() const { return FD; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Cleanup; } + static bool classof(const Attr *A) { return A->getKind() == attr::Cleanup; } static bool classof(const CleanupAttr *A) { return true; } }; @@ -545,14 +509,14 @@ class RegparmAttr : public Attr { unsigned NumParams; public: - RegparmAttr(unsigned np) : Attr(Regparm), NumParams(np) {} + RegparmAttr(unsigned np) : Attr(attr::Regparm), NumParams(np) {} unsigned getNumParams() const { return NumParams; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Regparm; } + static bool classof(const Attr *A) { return A->getKind() == attr::Regparm; } static bool classof(const RegparmAttr *A) { return true; } }; @@ -560,7 +524,7 @@ class ReqdWorkGroupSizeAttr : public Attr { unsigned X, Y, Z; public: ReqdWorkGroupSizeAttr(unsigned X, unsigned Y, unsigned Z) - : Attr(ReqdWorkGroupSize), X(X), Y(Y), Z(Z) {} + : Attr(attr::ReqdWorkGroupSize), X(X), Y(Y), Z(Z) {} unsigned getXDim() const { return X; } unsigned getYDim() const { return Y; } @@ -570,22 +534,34 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == ReqdWorkGroupSize; + return A->getKind() == attr::ReqdWorkGroupSize; } static bool classof(const ReqdWorkGroupSizeAttr *A) { return true; } }; +class InitPriorityAttr : public Attr { + unsigned Priority; +public: + InitPriorityAttr(unsigned priority) + : Attr(attr::InitPriority), Priority(priority) {} + + virtual void Destroy(ASTContext &C) { Attr::Destroy(C); } + + unsigned getPriority() const { return Priority; } + + virtual Attr *clone(ASTContext &C) const; + + static bool classof(const Attr *A) + { return A->getKind() == attr::InitPriority; } + static bool classof(const InitPriorityAttr *A) { return true; } +}; + // Checker-specific attributes. DEF_SIMPLE_ATTR(CFReturnsNotRetained); DEF_SIMPLE_ATTR(CFReturnsRetained); DEF_SIMPLE_ATTR(NSReturnsNotRetained); DEF_SIMPLE_ATTR(NSReturnsRetained); -// C++0x member checking attributes. -DEF_SIMPLE_ATTR(BaseCheck); -DEF_SIMPLE_ATTR(Hiding); -DEF_SIMPLE_ATTR(Override); - // Target-specific attributes DEF_SIMPLE_ATTR(DLLImport); DEF_SIMPLE_ATTR(DLLExport); @@ -594,14 +570,15 @@ class MSP430InterruptAttr : public Attr { unsigned Number; public: - MSP430InterruptAttr(unsigned n) : Attr(MSP430Interrupt), Number(n) {} + MSP430InterruptAttr(unsigned n) : Attr(attr::MSP430Interrupt), Number(n) {} unsigned getNumber() const { return Number; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == MSP430Interrupt; } + static bool classof(const Attr *A) + { return A->getKind() == attr::MSP430Interrupt; } static bool classof(const MSP430InterruptAttr *A) { return true; } }; diff --git a/include/clang/AST/CMakeLists.txt b/include/clang/AST/CMakeLists.txt index c24ea06aa024..3b090715e083 100644 --- a/include/clang/AST/CMakeLists.txt +++ b/include/clang/AST/CMakeLists.txt @@ -1,5 +1,18 @@ -set(LLVM_TARGET_DEFINITIONS StmtNodes.td) +set(LLVM_TARGET_DEFINITIONS ../Basic/Attr.td) +tablegen(Attrs.inc + -gen-clang-attr-classes + -I ${CMAKE_CURRENT_SOURCE_DIR}/../../) +add_custom_target(ClangAttrClasses + DEPENDS Attrs.inc) + +set(LLVM_TARGET_DEFINITIONS ../Basic/StmtNodes.td) tablegen(StmtNodes.inc -gen-clang-stmt-nodes) add_custom_target(ClangStmtNodes DEPENDS StmtNodes.inc) + +set(LLVM_TARGET_DEFINITIONS ../Basic/DeclNodes.td) +tablegen(DeclNodes.inc + -gen-clang-decl-nodes) +add_custom_target(ClangDeclNodes + DEPENDS DeclNodes.inc) diff --git a/include/clang/AST/CanonicalType.h b/include/clang/AST/CanonicalType.h index 4afb81dd05eb..9f97fd8a7aee 100644 --- a/include/clang/AST/CanonicalType.h +++ b/include/clang/AST/CanonicalType.h @@ -247,6 +247,7 @@ public: LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isCharType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isWideCharType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIntegralType) + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIntegralOrEnumerationType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isRealFloatingType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isComplexType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isAnyComplexType) @@ -269,8 +270,10 @@ public: LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isNullPtrType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isDependentType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isOverloadableType) + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isArrayType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasPointerRepresentation) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasObjCPointerRepresentation) + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasFloatingRepresentation) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isPromotableIntegerType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isSignedIntegerType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isUnsignedIntegerType) diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 7d5b66e02a28..39cd51f606b5 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -28,6 +28,8 @@ class FunctionTemplateDecl; class Stmt; class CompoundStmt; class StringLiteral; +class NestedNameSpecifier; +class TemplateParameterList; class TemplateArgumentList; class MemberSpecializationInfo; class FunctionTemplateSpecializationInfo; @@ -216,7 +218,7 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const NamedDecl *D) { return true; } - static bool classofKind(Kind K) { return K >= NamedFirst && K <= NamedLast; } + static bool classofKind(Kind K) { return K >= firstNamed && K <= lastNamed; } }; inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, @@ -342,6 +344,9 @@ public: static NamespaceDecl *castFromDeclContext(const DeclContext *DC) { return static_cast(const_cast(DC)); } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; /// ValueDecl - Represent the declaration of a variable (in which case it is @@ -361,7 +366,38 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const ValueDecl *D) { return true; } - static bool classofKind(Kind K) { return K >= ValueFirst && K <= ValueLast; } + static bool classofKind(Kind K) { return K >= firstValue && K <= lastValue; } +}; + +/// QualifierInfo - A struct with extended info about a syntactic +/// name qualifier, to be used for the case of out-of-line declarations. +struct QualifierInfo { + /// NNS - The syntactic name qualifier. + NestedNameSpecifier *NNS; + /// NNSRange - The source range for the qualifier. + SourceRange NNSRange; + /// NumTemplParamLists - The number of template parameter lists + /// that were matched against the template-ids occurring into the NNS. + unsigned NumTemplParamLists; + /// TemplParamLists - A new-allocated array of size NumTemplParamLists, + /// containing pointers to the matched template parameter lists. + TemplateParameterList** TemplParamLists; + + /// Default constructor. + QualifierInfo() + : NNS(0), NNSRange(), NumTemplParamLists(0), TemplParamLists(0) {} + /// setTemplateParameterListsInfo - Sets info about matched template + /// parameter lists. + void setTemplateParameterListsInfo(ASTContext &Context, + unsigned NumTPLists, + TemplateParameterList **TPLists); + + void Destroy(ASTContext &Context); + +private: + // Copy constructor and copy assignment are disabled. + QualifierInfo(const QualifierInfo&); + QualifierInfo& operator=(const QualifierInfo&); }; /// \brief Represents a ValueDecl that came out of a declarator. @@ -369,10 +405,8 @@ public: class DeclaratorDecl : public ValueDecl { // A struct representing both a TInfo and a syntactic qualifier, // to be used for the (uncommon) case of out-of-line declarations. - struct ExtInfo { + struct ExtInfo : public QualifierInfo { TypeSourceInfo *TInfo; - NestedNameSpecifier *NNS; - SourceRange NNSRange; }; llvm::PointerUnion DeclInfo; @@ -392,32 +426,55 @@ public: TypeSourceInfo *getTypeSourceInfo() const { return hasExtInfo() - ? DeclInfo.get()->TInfo + ? getExtInfo()->TInfo : DeclInfo.get(); } void setTypeSourceInfo(TypeSourceInfo *TI) { if (hasExtInfo()) - DeclInfo.get()->TInfo = TI; + getExtInfo()->TInfo = TI; else DeclInfo = TI; } + /// getInnerLocStart - Return SourceLocation representing start of source + /// range ignoring outer template declarations. + virtual SourceLocation getInnerLocStart() const { return getLocation(); } + + /// 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()); + } + NestedNameSpecifier *getQualifier() const { - return hasExtInfo() ? DeclInfo.get()->NNS : 0; + return hasExtInfo() ? getExtInfo()->NNS : 0; } SourceRange getQualifierRange() const { - return hasExtInfo() ? DeclInfo.get()->NNSRange : SourceRange(); + return hasExtInfo() ? getExtInfo()->NNSRange : SourceRange(); } void setQualifierInfo(NestedNameSpecifier *Qualifier, SourceRange QualifierRange); + unsigned getNumTemplateParameterLists() const { + return hasExtInfo() ? getExtInfo()->NumTemplParamLists : 0; + } + TemplateParameterList *getTemplateParameterList(unsigned index) const { + assert(index < getNumTemplateParameterLists()); + return getExtInfo()->TemplParamLists[index]; + } + void setTemplateParameterListsInfo(ASTContext &Context, unsigned NumTPLists, + TemplateParameterList **TPLists) { + getExtInfo()->setTemplateParameterListsInfo(Context, NumTPLists, TPLists); + } + SourceLocation getTypeSpecStartLoc() const; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const DeclaratorDecl *D) { return true; } static bool classofKind(Kind K) { - return K >= DeclaratorFirst && K <= DeclaratorLast; + return K >= firstDeclarator && K <= lastDeclarator; } }; @@ -555,6 +612,7 @@ public: virtual void Destroy(ASTContext& C); virtual ~VarDecl(); + virtual SourceLocation getInnerLocStart() const; virtual SourceRange getSourceRange() const; StorageClass getStorageClass() const { return (StorageClass)SClass; } @@ -908,7 +966,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const VarDecl *D) { return true; } - static bool classofKind(Kind K) { return K >= VarFirst && K <= VarLast; } + static bool classofKind(Kind K) { return K >= firstVar && K <= lastVar; } }; class ImplicitParamDecl : public VarDecl { @@ -1063,6 +1121,15 @@ public: None, Extern, Static, PrivateExtern }; + /// \brief The kind of templated function a FunctionDecl can be. + enum TemplatedKind { + TK_NonTemplate, + TK_FunctionTemplate, + TK_MemberSpecialization, + TK_FunctionTemplateSpecialization, + TK_DependentFunctionTemplateSpecialization + }; + private: /// ParamInfo - new[]'d array of pointers to VarDecls for the formal /// parameters of this function. This is null if a prototype or if there are @@ -1154,17 +1221,31 @@ public: bool Qualified) const; virtual SourceRange getSourceRange() const { - return SourceRange(getLocation(), EndRangeLoc); + return SourceRange(getOuterLocStart(), EndRangeLoc); } void setLocEnd(SourceLocation E) { EndRangeLoc = E; } + /// \brief Returns true if the function has a body (definition). The + /// function body might be in any of the (re-)declarations of this + /// function. The variant that accepts a FunctionDecl pointer will + /// set that function declaration to the actual declaration + /// containing the body (if there is one). + bool hasBody(const FunctionDecl *&Definition) const; + + virtual bool hasBody() const { + const FunctionDecl* Definition; + return hasBody(Definition); + } + /// getBody - Retrieve the body (definition) of the function. The /// function body might be in any of the (re-)declarations of this /// function. The variant that accepts a FunctionDecl pointer will /// set that function declaration to the actual declaration /// containing the body (if there is one). + /// NOTE: For checking if there is a body, use hasBody() instead, to avoid + /// unnecessary PCH de-serialization of the body. Stmt *getBody(const FunctionDecl *&Definition) const; virtual Stmt *getBody() const { @@ -1301,6 +1382,12 @@ public: QualType getResultType() const { return getType()->getAs()->getResultType(); } + + /// \brief Determine the type of an expression that calls this function. + QualType getCallResultType() const { + return getType()->getAs()->getCallResultType(getASTContext()); + } + StorageClass getStorageClass() const { return StorageClass(SClass); } void setStorageClass(StorageClass SC) { SClass = SC; } @@ -1355,6 +1442,9 @@ public: /// X::A is required, it will be instantiated from the /// declaration returned by getInstantiatedFromMemberFunction(). FunctionDecl *getInstantiatedFromMemberFunction() const; + + /// \brief What kind of templated function this is. + TemplatedKind getTemplatedKind() const; /// \brief If this function is an instantiation of a member function of a /// class template specialization, retrieves the member specialization @@ -1437,8 +1527,6 @@ public: /// \brief Specify that this function declaration is actually a function /// template specialization. /// - /// \param Context the AST context in which this function resides. - /// /// \param Template the function template that this function template /// specialization specializes. /// @@ -1450,11 +1538,53 @@ public: /// be inserted. /// /// \param TSK the kind of template specialization this is. + /// + /// \param TemplateArgsAsWritten location info of template arguments. + /// + /// \param PointOfInstantiation point at which the function template + /// specialization was first instantiated. void setFunctionTemplateSpecialization(FunctionTemplateDecl *Template, const TemplateArgumentList *TemplateArgs, void *InsertPos, TemplateSpecializationKind TSK = TSK_ImplicitInstantiation, - const TemplateArgumentListInfo *TemplateArgsAsWritten = 0); + const TemplateArgumentListInfo *TemplateArgsAsWritten = 0, + SourceLocation PointOfInstantiation = SourceLocation()); + + /// \brief Specify that this function declaration is actually a function + /// template specialization. + /// + /// \param Template the function template that this function template + /// specialization specializes. + /// + /// \param NumTemplateArgs number of template arguments that produced this + /// function template specialization from the template. + /// + /// \param TemplateArgs array of template arguments that produced this + /// function template specialization from the template. + /// + /// \param TSK the kind of template specialization this is. + /// + /// \param NumTemplateArgsAsWritten number of template arguments that produced + /// this function template specialization from the template. + /// + /// \param TemplateArgsAsWritten array of location info for the template + /// arguments. + /// + /// \param LAngleLoc location of left angle token. + /// + /// \param RAngleLoc location of right angle token. + /// + /// \param PointOfInstantiation point at which the function template + /// specialization was first instantiated. + void setFunctionTemplateSpecialization(FunctionTemplateDecl *Template, + unsigned NumTemplateArgs, + const TemplateArgument *TemplateArgs, + TemplateSpecializationKind TSK, + unsigned NumTemplateArgsAsWritten, + TemplateArgumentLoc *TemplateArgsAsWritten, + SourceLocation LAngleLoc, + SourceLocation RAngleLoc, + SourceLocation PointOfInstantiation); /// \brief Specifies that this function declaration is actually a /// dependent function template specialization. @@ -1493,7 +1623,7 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const FunctionDecl *D) { return true; } static bool classofKind(Kind K) { - return K >= FunctionFirst && K <= FunctionLast; + return K >= firstFunction && K <= lastFunction; } static DeclContext *castToDeclContext(const FunctionDecl *D) { return static_cast(const_cast(D)); @@ -1501,6 +1631,9 @@ public: static FunctionDecl *castFromDeclContext(const DeclContext *DC) { return static_cast(const_cast(DC)); } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; @@ -1556,7 +1689,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const FieldDecl *D) { return true; } - static bool classofKind(Kind K) { return K >= FieldFirst && K <= FieldLast; } + static bool classofKind(Kind K) { return K >= firstField && K <= lastField; } }; /// EnumConstantDecl - An instance of this object exists for each enum constant @@ -1625,7 +1758,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const TypeDecl *D) { return true; } - static bool classofKind(Kind K) { return K >= TypeFirst && K <= TypeLast; } + static bool classofKind(Kind K) { return K >= firstType && K <= lastType; } }; @@ -1715,10 +1848,7 @@ private: // A struct representing syntactic qualifier info, // to be used for the (uncommon) case of out-of-line declarations. - struct ExtInfo { - NestedNameSpecifier *NNS; - SourceRange NNSRange; - }; + typedef QualifierInfo ExtInfo; /// TypedefDeclOrQualifier - If the (out-of-line) tag declaration name /// is qualified, it points to the qualifier info (nns and range); @@ -1767,6 +1897,13 @@ public: 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; } + + /// getOuterLocStart - Return SourceLocation representing start of source + /// range taking into account any outer template declarations. + SourceLocation getOuterLocStart() const; virtual SourceRange getSourceRange() const; virtual TagDecl* getCanonicalDecl(); @@ -1830,24 +1967,34 @@ public: TypedefDecl *getTypedefForAnonDecl() const { return hasExtInfo() ? 0 : TypedefDeclOrQualifier.get(); } - + void setTypedefForAnonDecl(TypedefDecl *TDD); - + NestedNameSpecifier *getQualifier() const { - return hasExtInfo() ? TypedefDeclOrQualifier.get()->NNS : 0; + return hasExtInfo() ? getExtInfo()->NNS : 0; } SourceRange getQualifierRange() const { - return hasExtInfo() - ? TypedefDeclOrQualifier.get()->NNSRange - : SourceRange(); + return hasExtInfo() ? getExtInfo()->NNSRange : SourceRange(); } void setQualifierInfo(NestedNameSpecifier *Qualifier, SourceRange QualifierRange); + unsigned getNumTemplateParameterLists() const { + return hasExtInfo() ? getExtInfo()->NumTemplParamLists : 0; + } + TemplateParameterList *getTemplateParameterList(unsigned i) const { + assert(i < getNumTemplateParameterLists()); + return getExtInfo()->TemplParamLists[i]; + } + void setTemplateParameterListsInfo(ASTContext &Context, unsigned NumTPLists, + TemplateParameterList **TPLists) { + getExtInfo()->setTemplateParameterListsInfo(Context, NumTPLists, TPLists); + } + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const TagDecl *D) { return true; } - static bool classofKind(Kind K) { return K >= TagFirst && K <= TagLast; } + static bool classofKind(Kind K) { return K >= firstTag && K <= lastTag; } static DeclContext *castToDeclContext(const TagDecl *D) { return static_cast(const_cast(D)); @@ -1855,6 +2002,9 @@ public: static TagDecl *castFromDeclContext(const DeclContext *DC) { return static_cast(const_cast(DC)); } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; /// EnumDecl - Represents an enum. As an extension, we allow forward-declared @@ -1896,9 +2046,17 @@ public: return cast(TagDecl::getCanonicalDecl()); } + const EnumDecl *getPreviousDeclaration() const { + return cast_or_null(TagDecl::getPreviousDeclaration()); + } + EnumDecl *getPreviousDeclaration() { + return cast_or_null(TagDecl::getPreviousDeclaration()); + } + static EnumDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation TKL, EnumDecl *PrevDecl); + static EnumDecl *Create(ASTContext &C, EmptyShell Empty); virtual void Destroy(ASTContext& C); @@ -1917,11 +2075,17 @@ public: typedef specific_decl_iterator enumerator_iterator; enumerator_iterator enumerator_begin() const { - return enumerator_iterator(this->decls_begin()); + const EnumDecl *E = cast_or_null(getDefinition()); + if (!E) + E = this; + return enumerator_iterator(E->decls_begin()); } enumerator_iterator enumerator_end() const { - return enumerator_iterator(this->decls_end()); + const EnumDecl *E = cast_or_null(getDefinition()); + if (!E) + E = this; + return enumerator_iterator(E->decls_end()); } /// getPromotionType - Return the integer type that enumerators @@ -2010,6 +2174,14 @@ public: SourceLocation L, IdentifierInfo *Id, SourceLocation TKL = SourceLocation(), RecordDecl* PrevDecl = 0); + static RecordDecl *Create(ASTContext &C, EmptyShell Empty); + + const RecordDecl *getPreviousDeclaration() const { + return cast_or_null(TagDecl::getPreviousDeclaration()); + } + RecordDecl *getPreviousDeclaration() { + return cast_or_null(TagDecl::getPreviousDeclaration()); + } virtual void Destroy(ASTContext& C); @@ -2092,7 +2264,7 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const RecordDecl *D) { return true; } static bool classofKind(Kind K) { - return K >= RecordFirst && K <= RecordLast; + return K >= firstRecord && K <= lastRecord; } }; @@ -2127,11 +2299,13 @@ class BlockDecl : public Decl, public DeclContext { unsigned NumParams; Stmt *Body; + TypeSourceInfo *SignatureAsWritten; protected: BlockDecl(DeclContext *DC, SourceLocation CaretLoc) : Decl(Block, DC, CaretLoc), DeclContext(Block), - IsVariadic(false), ParamInfo(0), NumParams(0), Body(0) {} + IsVariadic(false), ParamInfo(0), NumParams(0), Body(0), + SignatureAsWritten(0) {} virtual ~BlockDecl(); virtual void Destroy(ASTContext& C); @@ -2148,6 +2322,9 @@ public: Stmt *getBody() const { return (Stmt*) Body; } void setBody(CompoundStmt *B) { Body = (Stmt*) B; } + void setSignatureAsWritten(TypeSourceInfo *Sig) { SignatureAsWritten = Sig; } + TypeSourceInfo *getSignatureAsWritten() const { return SignatureAsWritten; } + // Iterator access to formal parameters. unsigned param_size() const { return getNumParams(); } typedef ParmVarDecl **param_iterator; diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index c15aeef14ba6..2d2407ffb18d 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -68,12 +68,13 @@ class Decl { public: /// \brief Lists the kind of concrete classes of Decl. enum Kind { -#define DECL(Derived, Base) Derived, -#define DECL_RANGE(CommonBase, Start, End) \ - CommonBase##First = Start, CommonBase##Last = End, -#define LAST_DECL_RANGE(CommonBase, Start, End) \ - CommonBase##First = Start, CommonBase##Last = End -#include "clang/AST/DeclNodes.def" +#define DECL(DERIVED, BASE) DERIVED, +#define ABSTRACT_DECL(DECL) +#define DECL_RANGE(BASE, START, END) \ + first##BASE = START, last##BASE = END, +#define LAST_DECL_RANGE(BASE, START, END) \ + first##BASE = START, last##BASE = END +#include "clang/AST/DeclNodes.inc" }; /// \brief A placeholder type used to construct an empty shell of a @@ -244,7 +245,15 @@ protected: HasAttrs(false), Implicit(false), Used(false), Access(AS_none), PCHLevel(0), IdentifierNamespace(getIdentifierNamespaceForKind(DK)) { - if (Decl::CollectingStats()) addDeclKind(DK); + if (Decl::CollectingStats()) add(DK); + } + + Decl(Kind DK, EmptyShell Empty) + : NextDeclInContext(0), DeclKind(DK), InvalidDecl(0), + HasAttrs(false), Implicit(false), Used(false), + Access(AS_none), PCHLevel(0), + IdentifierNamespace(getIdentifierNamespaceForKind(DK)) { + if (Decl::CollectingStats()) add(DK); } virtual ~Decl(); @@ -296,6 +305,7 @@ public: } bool hasAttrs() const { return HasAttrs; } + void initAttrs(Attr *attrs); void addAttr(Attr *attr); const Attr *getAttrs() const { if (!HasAttrs) return 0; // common case, no attributes. @@ -328,7 +338,11 @@ public: /// \brief Whether this declaration was used, meaning that a definition /// is required. - bool isUsed() const; + /// + /// \param CheckUsedAttr When true, also consider the "used" attribute + /// (in addition to the "used" bit set by \c setUsed()) when determining + /// whether the function is used. + bool isUsed(bool CheckUsedAttr = true) const; void setUsed(bool U = true) { Used = U; } @@ -474,15 +488,16 @@ public: /// top-level Stmt* of that body. Otherwise this method returns null. virtual Stmt* getBody() const { return 0; } - /// getCompoundBody - Returns getBody(), dyn_casted to a CompoundStmt. - CompoundStmt* getCompoundBody() const; + /// \brief Returns true if this Decl represents a declaration for a body of + /// code, such as a function or method definition. + virtual bool hasBody() const { return getBody() != 0; } /// getBodyRBrace - Gets the right brace of the body, if a body exists. /// This works whether the body is a CompoundStmt or a CXXTryStmt. SourceLocation getBodyRBrace() const; // global temp stats (until we have a per-module visitor) - static void addDeclKind(Kind k); + static void add(Kind k); static bool CollectingStats(bool Enable = false); static void PrintStats(); @@ -631,6 +646,8 @@ class DeclContext { /// another pointer. mutable Decl *LastDecl; + friend class ExternalASTSource; + protected: DeclContext(Decl::Kind K) : DeclKind(K), ExternalLexicalStorage(false), @@ -687,7 +704,7 @@ public: case Decl::ObjCMethod: return true; default: - return DeclKind >= Decl::FunctionFirst && DeclKind <= Decl::FunctionLast; + return DeclKind >= Decl::firstFunction && DeclKind <= Decl::lastFunction; } } @@ -700,7 +717,7 @@ public: } bool isRecord() const { - return DeclKind >= Decl::RecordFirst && DeclKind <= Decl::RecordLast; + return DeclKind >= Decl::firstRecord && DeclKind <= Decl::lastRecord; } bool isNamespace() const { @@ -1083,9 +1100,10 @@ public: static bool classof(const Decl *D); static bool classof(const DeclContext *D) { return true; } -#define DECL_CONTEXT(Name) \ - static bool classof(const Name##Decl *D) { return true; } -#include "clang/AST/DeclNodes.def" +#define DECL(NAME, BASE) +#define DECL_CONTEXT(NAME) \ + static bool classof(const NAME##Decl *D) { return true; } +#include "clang/AST/DeclNodes.inc" void dumpDeclContext() const; diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index c19c200f265d..41474ab21e32 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -92,6 +92,53 @@ namespace llvm { namespace clang { +/// AccessSpecDecl - An access specifier followed by colon ':'. +/// +/// An objects of this class represents sugar for the syntactic occurrence +/// of an access specifier followed by a colon in the list of member +/// specifiers of a C++ class definition. +/// +/// Note that they do not represent other uses of access specifiers, +/// such as those occurring in a list of base specifiers. +/// Also note that this class has nothing to do with so-called +/// "access declarations" (C++98 11.3 [class.access.dcl]). +class AccessSpecDecl : public Decl { + /// ColonLoc - The location of the ':'. + SourceLocation ColonLoc; + + AccessSpecDecl(AccessSpecifier AS, DeclContext *DC, + SourceLocation ASLoc, SourceLocation ColonLoc) + : Decl(AccessSpec, DC, ASLoc), ColonLoc(ColonLoc) { + setAccess(AS); + } +public: + /// getAccessSpecifierLoc - The location of the access specifier. + SourceLocation getAccessSpecifierLoc() const { return getLocation(); } + /// setAccessSpecifierLoc - Sets the location of the access specifier. + void setAccessSpecifierLoc(SourceLocation ASLoc) { setLocation(ASLoc); } + + /// getColonLoc - The location of the colon following the access specifier. + SourceLocation getColonLoc() const { return ColonLoc; } + /// setColonLoc - Sets the location of the colon. + void setColonLoc(SourceLocation CLoc) { ColonLoc = CLoc; } + + SourceRange getSourceRange() const { + return SourceRange(getAccessSpecifierLoc(), getColonLoc()); + } + + static AccessSpecDecl *Create(ASTContext &C, AccessSpecifier AS, + DeclContext *DC, SourceLocation ASLoc, + SourceLocation ColonLoc) { + return new (C) AccessSpecDecl(AS, DC, ASLoc, ColonLoc); + } + + // Implement isa/cast/dyncast/etc. + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classof(const AccessSpecDecl *D) { return true; } + static bool classofKind(Kind K) { return K == AccessSpec; } +}; + + /// CXXBaseSpecifier - A base class of a C++ class. /// /// Each CXXBaseSpecifier represents a single, direct base class (or @@ -271,7 +318,20 @@ class CXXRecordDecl : public RecordDecl { /// ComputedVisibleConversions - True when visible conversion functions are /// already computed and are available. bool ComputedVisibleConversions : 1; - + + /// \brief Whether we have already declared the default constructor or + /// do not need to have one declared. + bool DeclaredDefaultConstructor : 1; + + /// \brief Whether we have already declared the copy constructor. + bool DeclaredCopyConstructor : 1; + + /// \brief Whether we have already declared the copy-assignment operator. + bool DeclaredCopyAssignment : 1; + + /// \brief Whether we have already declared a destructor within the class. + bool DeclaredDestructor : 1; + /// Bases - Base classes of this class. /// FIXME: This is wasted space for a union. CXXBaseSpecifier *Bases; @@ -367,6 +427,13 @@ public: virtual const CXXRecordDecl *getCanonicalDecl() const { return cast(RecordDecl::getCanonicalDecl()); } + + const CXXRecordDecl *getPreviousDeclaration() const { + return cast_or_null(RecordDecl::getPreviousDeclaration()); + } + CXXRecordDecl *getPreviousDeclaration() { + return cast_or_null(RecordDecl::getPreviousDeclaration()); + } CXXRecordDecl *getDefinition() const { if (!DefinitionData) return 0; @@ -380,6 +447,7 @@ public: SourceLocation TKL = SourceLocation(), CXXRecordDecl* PrevDecl=0, bool DelayTypeCreation = false); + static CXXRecordDecl *Create(ASTContext &C, EmptyShell Empty); virtual void Destroy(ASTContext& C); @@ -476,6 +544,20 @@ public: return data().FirstFriend != 0; } + /// \brief Determine whether this class has had its default constructor + /// declared implicitly or does not need one declared implicitly. + /// + /// This value is used for lazy creation of default constructors. + bool hasDeclaredDefaultConstructor() const { + return data().DeclaredDefaultConstructor; + } + + /// \brief Note whether this class has already had its default constructor + /// implicitly declared or doesn't need one. + void setDeclaredDefaultConstructor(bool DDC) { + data().DeclaredDefaultConstructor = DDC; + } + /// hasConstCopyConstructor - Determines whether this class has a /// copy constructor that accepts a const-qualified argument. bool hasConstCopyConstructor(ASTContext &Context) const; @@ -484,12 +566,18 @@ public: CXXConstructorDecl *getCopyConstructor(ASTContext &Context, unsigned TypeQuals) const; - /// hasConstCopyAssignment - Determines whether this class has a - /// copy assignment operator that accepts a const-qualified argument. - /// It returns its decl in MD if found. - bool hasConstCopyAssignment(ASTContext &Context, - const CXXMethodDecl *&MD) const; - + /// \brief Retrieve the copy-assignment operator for this class, if available. + /// + /// This routine attempts to find the copy-assignment operator for this + /// class, using a simplistic form of overload resolution. + /// + /// \param ArgIsConst Whether the argument to the copy-assignment operator + /// is const-qualified. + /// + /// \returns The copy-assignment operator that can be invoked, or NULL if + /// a unique copy-assignment operator could not be found. + CXXMethodDecl *getCopyAssignmentOperator(bool ArgIsConst) const; + /// addedConstructor - Notify the class that another constructor has /// been added. This routine helps maintain information about the /// class based on which constructors have been added. @@ -509,9 +597,23 @@ public: return data().UserDeclaredCopyConstructor; } + /// \brief Determine whether this class has had its copy constructor + /// declared, either via the user or via an implicit declaration. + /// + /// This value is used for lazy creation of copy constructors. + bool hasDeclaredCopyConstructor() const { + return data().DeclaredCopyConstructor; + } + + /// \brief Note whether this class has already had its copy constructor + /// declared. + void setDeclaredCopyConstructor(bool DCC) { + data().DeclaredCopyConstructor = DCC; + } + /// addedAssignmentOperator - Notify the class that another assignment /// operator has been added. This routine helps maintain information about the - /// class based on which operators have been added. + /// class based on which operators have been added. void addedAssignmentOperator(ASTContext &Context, CXXMethodDecl *OpDecl); /// hasUserDeclaredCopyAssignment - Whether this class has a @@ -521,6 +623,20 @@ public: return data().UserDeclaredCopyAssignment; } + /// \brief Determine whether this class has had its copy assignment operator + /// declared, either via the user or via an implicit declaration. + /// + /// This value is used for lazy creation of copy assignment operators. + bool hasDeclaredCopyAssignment() const { + return data().DeclaredCopyAssignment; + } + + /// \brief Note whether this class has already had its copy assignment + /// operator declared. + void setDeclaredCopyAssignment(bool DCA) { + data().DeclaredCopyAssignment = DCA; + } + /// hasUserDeclaredDestructor - Whether this class has a /// user-declared destructor. When false, a destructor will be /// implicitly declared. @@ -533,8 +649,21 @@ public: /// fully defined, a destructor will be implicitly declared. void setUserDeclaredDestructor(bool UCD) { data().UserDeclaredDestructor = UCD; + if (UCD) + data().DeclaredDestructor = true; } + /// \brief Determine whether this class has had its destructor declared, + /// either via the user or via an implicit declaration. + /// + /// This value is used for lazy creation of destructors. + bool hasDeclaredDestructor() const { return data().DeclaredDestructor; } + + /// \brief Note whether this class has already had its destructor declared. + void setDeclaredDestructor(bool DD) { + data().DeclaredDestructor = DD; + } + /// getConversions - Retrieve the overload set containing all of the /// conversion functions in this class. UnresolvedSetImpl *getConversionFunctions() { @@ -726,10 +855,10 @@ public: void setTemplateSpecializationKind(TemplateSpecializationKind TSK); /// getDefaultConstructor - Returns the default constructor for this class - CXXConstructorDecl *getDefaultConstructor(ASTContext &Context); + CXXConstructorDecl *getDefaultConstructor(); /// getDestructor - Returns the destructor decl for this class. - CXXDestructorDecl *getDestructor(ASTContext &Context) const; + CXXDestructorDecl *getDestructor() const; /// isLocalClass - If the class is a local class [class.local], returns /// the enclosing function declaration. @@ -920,14 +1049,15 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { - return K == CXXRecord || - K == ClassTemplateSpecialization || - K == ClassTemplatePartialSpecialization; + return K >= firstCXXRecord && K <= lastCXXRecord; } static bool classof(const CXXRecordDecl *D) { return true; } static bool classof(const ClassTemplateSpecializationDecl *D) { return true; } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; /// CXXMethodDecl - Represents a static or instance method of a @@ -984,6 +1114,7 @@ public: method_iterator begin_overridden_methods() const; method_iterator end_overridden_methods() const; + unsigned size_overridden_methods() const; /// getParent - Returns the parent of this method declaration, which /// is the class in which this method is defined. @@ -1012,7 +1143,7 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const CXXMethodDecl *D) { return true; } static bool classofKind(Kind K) { - return K >= CXXMethod && K <= CXXConversion; + return K >= firstCXXMethod && K <= lastCXXMethod; } }; @@ -1387,6 +1518,9 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const CXXConstructorDecl *D) { return true; } static bool classofKind(Kind K) { return K == CXXConstructor; } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; /// CXXDestructorDecl - Represents a C++ destructor within a @@ -1450,6 +1584,9 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const CXXDestructorDecl *D) { return true; } static bool classofKind(Kind K) { return K == CXXDestructor; } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; /// CXXConversionDecl - Represents a C++ conversion function within a @@ -1504,6 +1641,9 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const CXXConversionDecl *D) { return true; } static bool classofKind(Kind K) { return K == CXXConversion; } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; /// LinkageSpecDecl - This represents a linkage specification. For example: @@ -1607,7 +1747,7 @@ class UsingDirectiveDecl : public NamedDecl { SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor) - : NamedDecl(Decl::UsingDirective, DC, L, getName()), + : NamedDecl(UsingDirective, DC, L, getName()), NamespaceLoc(NamespcLoc), QualifierRange(QualifierRange), Qualifier(Qualifier), IdentLoc(IdentLoc), NominatedNamespace(Nominated), @@ -1680,7 +1820,7 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const UsingDirectiveDecl *D) { return true; } - static bool classofKind(Kind K) { return K == Decl::UsingDirective; } + static bool classofKind(Kind K) { return K == UsingDirective; } // Friend for getUsingDirectiveName. friend class DeclContext; @@ -1714,7 +1854,7 @@ class NamespaceAliasDecl : public NamedDecl { SourceRange QualifierRange, NestedNameSpecifier *Qualifier, SourceLocation IdentLoc, NamedDecl *Namespace) - : NamedDecl(Decl::NamespaceAlias, DC, L, Alias), AliasLoc(AliasLoc), + : NamedDecl(NamespaceAlias, DC, L, Alias), AliasLoc(AliasLoc), QualifierRange(QualifierRange), Qualifier(Qualifier), IdentLoc(IdentLoc), Namespace(Namespace) { } @@ -1786,7 +1926,7 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const NamespaceAliasDecl *D) { return true; } - static bool classofKind(Kind K) { return K == Decl::NamespaceAlias; } + static bool classofKind(Kind K) { return K == NamespaceAlias; } }; /// UsingShadowDecl - Represents a shadow declaration introduced into @@ -1809,9 +1949,12 @@ class UsingShadowDecl : public NamedDecl { UsingShadowDecl(DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target) - : NamedDecl(UsingShadow, DC, Loc, Target->getDeclName()), + : NamedDecl(UsingShadow, DC, Loc, DeclarationName()), Underlying(Target), Using(Using) { - IdentifierNamespace = Target->getIdentifierNamespace(); + if (Target) { + setDeclName(Target->getDeclName()); + IdentifierNamespace = Target->getIdentifierNamespace(); + } setImplicit(); } @@ -1828,7 +1971,11 @@ public: /// \brief Sets the underlying declaration which has been brought into the /// local scope. - void setTargetDecl(NamedDecl* ND) { Underlying = ND; } + void setTargetDecl(NamedDecl* ND) { + assert(ND && "Target decl is null!"); + Underlying = ND; + IdentifierNamespace = ND->getIdentifierNamespace(); + } /// \brief Gets the using declaration to which this declaration is tied. UsingDecl *getUsingDecl() const { return Using; } @@ -1866,7 +2013,7 @@ class UsingDecl : public NamedDecl { UsingDecl(DeclContext *DC, SourceLocation L, SourceRange NNR, SourceLocation UL, NestedNameSpecifier* TargetNNS, DeclarationName Name, bool IsTypeNameArg) - : NamedDecl(Decl::Using, DC, L, Name), + : NamedDecl(Using, DC, L, Name), NestedNameRange(NNR), UsingLocation(UL), TargetNestedName(TargetNNS), IsTypeName(IsTypeNameArg) { } @@ -1934,7 +2081,10 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const UsingDecl *D) { return true; } - static bool classofKind(Kind K) { return K == Decl::Using; } + static bool classofKind(Kind K) { return K == Using; } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; /// UnresolvedUsingValueDecl - Represents a dependent using @@ -1960,7 +2110,7 @@ class UnresolvedUsingValueDecl : public ValueDecl { NestedNameSpecifier *TargetNNS, SourceLocation TargetNameLoc, DeclarationName TargetName) - : ValueDecl(Decl::UnresolvedUsingValue, DC, TargetNameLoc, TargetName, Ty), + : ValueDecl(UnresolvedUsingValue, DC, TargetNameLoc, TargetName, Ty), TargetNestedNameRange(TargetNNR), UsingLocation(UsingLoc), TargetNestedNameSpecifier(TargetNNS) { } @@ -1997,7 +2147,7 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const UnresolvedUsingValueDecl *D) { return true; } - static bool classofKind(Kind K) { return K == Decl::UnresolvedUsingValue; } + static bool classofKind(Kind K) { return K == UnresolvedUsingValue; } }; /// UnresolvedUsingTypenameDecl - Represents a dependent using @@ -2026,7 +2176,7 @@ class UnresolvedUsingTypenameDecl : public TypeDecl { SourceLocation TypenameLoc, SourceRange TargetNNR, NestedNameSpecifier *TargetNNS, SourceLocation TargetNameLoc, IdentifierInfo *TargetName) - : TypeDecl(Decl::UnresolvedUsingTypename, DC, TargetNameLoc, TargetName), + : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName), TargetNestedNameRange(TargetNNR), UsingLocation(UsingLoc), TypenameLocation(TypenameLoc), TargetNestedNameSpecifier(TargetNNS) { } @@ -2070,7 +2220,7 @@ public: 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 == Decl::UnresolvedUsingTypename; } + static bool classofKind(Kind K) { return K == UnresolvedUsingTypename; } }; /// StaticAssertDecl - Represents a C++0x static_assert declaration. @@ -2098,7 +2248,7 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(StaticAssertDecl *D) { return true; } - static bool classofKind(Kind K) { return K == Decl::StaticAssert; } + static bool classofKind(Kind K) { return K == StaticAssert; } }; /// Insertion operator for diagnostics. This allows sending AccessSpecifier's diff --git a/include/clang/AST/DeclFriend.h b/include/clang/AST/DeclFriend.h index a20625da56b7..2807d16379ae 100644 --- a/include/clang/AST/DeclFriend.h +++ b/include/clang/AST/DeclFriend.h @@ -59,10 +59,14 @@ private: FriendLoc(FriendL) { } + explicit FriendDecl(EmptyShell Empty) + : Decl(Decl::Friend, Empty), NextFriend(0) { } + public: static FriendDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL); + static FriendDecl *Create(ASTContext &C, EmptyShell Empty); /// If this friend declaration names an (untemplated but /// possibly dependent) type, return the type; otherwise @@ -87,6 +91,9 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const FriendDecl *D) { return true; } static bool classofKind(Kind K) { return K == Decl::Friend; } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; /// An iterator over the friend declarations of a class. diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 97d165696aad..fb8596f50a0b 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -239,6 +239,12 @@ public: QualType getResultType() const { return MethodDeclType; } void setResultType(QualType T) { MethodDeclType = T; } + /// \brief Determine the type of an expression that sends a message to this + /// function. + QualType getSendResultType() const { + return getResultType().getCallResultType(getASTContext()); + } + TypeSourceInfo *getResultTypeSourceInfo() const { return ResultTInfo; } void setResultTypeSourceInfo(TypeSourceInfo *TInfo) { ResultTInfo = TInfo; } @@ -417,8 +423,8 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const ObjCContainerDecl *D) { return true; } static bool classofKind(Kind K) { - return K >= ObjCContainerFirst && - K <= ObjCContainerLast; + return K >= firstObjCContainer && + K <= lastObjCContainer; } static DeclContext *castToDeclContext(const ObjCContainerDecl *D) { @@ -550,8 +556,8 @@ public: void setCategoryList(ObjCCategoryDecl *category) { CategoryList = category; } - - ObjCCategoryDecl* getClassExtension() const; + + ObjCCategoryDecl* getFirstClassExtension() const; ObjCPropertyDecl *FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId) const; @@ -983,6 +989,7 @@ public: } bool IsClassExtension() const { return getIdentifier() == 0; } + const ObjCCategoryDecl *getNextClassExtension() const; typedef specific_decl_iterator ivar_iterator; ivar_iterator ivar_begin() const { @@ -1059,7 +1066,7 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const ObjCImplDecl *D) { return true; } static bool classofKind(Kind K) { - return K >= ObjCImplFirst && K <= ObjCImplLast; + return K >= firstObjCImpl && K <= lastObjCImpl; } }; @@ -1306,9 +1313,9 @@ public: enum PropertyControl { None, Required, Optional }; private: SourceLocation AtLoc; // location of @property - QualType DeclType; + TypeSourceInfo *DeclType; unsigned PropertyAttributes : 8; - + unsigned PropertyAttributesAsWritten : 8; // @required/@optional unsigned PropertyImplementation : 2; @@ -1320,9 +1327,11 @@ private: ObjCIvarDecl *PropertyIvarDecl; // Synthesize ivar for this property ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - SourceLocation AtLocation, QualType T) + SourceLocation AtLocation, TypeSourceInfo *T) : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation), DeclType(T), - PropertyAttributes(OBJC_PR_noattr), PropertyImplementation(None), + PropertyAttributes(OBJC_PR_noattr), + PropertyAttributesAsWritten(OBJC_PR_noattr), + PropertyImplementation(None), GetterName(Selector()), SetterName(Selector()), GetterMethodDecl(0), SetterMethodDecl(0) , PropertyIvarDecl(0) {} @@ -1330,13 +1339,14 @@ public: static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation AtLocation, - QualType T, + TypeSourceInfo *T, PropertyControl propControl = None); SourceLocation getAtLoc() const { return AtLoc; } void setAtLoc(SourceLocation L) { AtLoc = L; } - QualType getType() const { return DeclType; } - void setType(QualType T) { DeclType = T; } + TypeSourceInfo *getTypeSourceInfo() const { return DeclType; } + QualType getType() const { return DeclType->getType(); } + void setType(TypeSourceInfo *T) { DeclType = T; } PropertyAttributeKind getPropertyAttributes() const { return PropertyAttributeKind(PropertyAttributes); @@ -1345,6 +1355,14 @@ public: PropertyAttributes |= PRVal; } + PropertyAttributeKind getPropertyAttributesAsWritten() const { + return PropertyAttributeKind(PropertyAttributesAsWritten); + } + + void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) { + PropertyAttributesAsWritten = PRVal; + } + void makeitReadWriteAttribute(void) { PropertyAttributes &= ~OBJC_PR_readonly; PropertyAttributes |= OBJC_PR_readwrite; diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index b7b90b14adfd..135dd3ae78d3 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -180,18 +180,29 @@ public: TemplateArgumentListBuilder &Builder, bool TakeArgs); + /// TemplateArgumentList - It copies the template arguments into a locally + /// new[]'d array. + TemplateArgumentList(ASTContext &Context, + const TemplateArgument *Args, unsigned NumArgs); + /// Produces a shallow copy of the given template argument list. This /// assumes that the input argument list outlives it. This takes the list as /// a pointer to avoid looking like a copy constructor, since this really /// really isn't safe to use that way. explicit TemplateArgumentList(const TemplateArgumentList *Other); - + + TemplateArgumentList() : NumFlatArguments(0), NumStructuredArguments(0) { } + /// Used to release the memory associated with a TemplateArgumentList /// object. FIXME: This is currently not called anywhere, but the /// memory will still be freed when using a BumpPtrAllocator. void Destroy(ASTContext &C); ~TemplateArgumentList(); + + /// \brief Copies the template arguments into a locally new[]'d array. + void init(ASTContext &Context, + const TemplateArgument *Args, unsigned NumArgs); /// \brief Retrieve the template argument at a given index. const TemplateArgument &get(unsigned Idx) const { @@ -261,12 +272,27 @@ public: static bool classof(const ClassTemplateDecl *D) { return true; } static bool classof(const TemplateTemplateParmDecl *D) { return true; } static bool classofKind(Kind K) { - return K >= TemplateFirst && K <= TemplateLast; + return K >= firstTemplate && K <= lastTemplate; + } + + SourceRange getSourceRange() const { + return SourceRange(TemplateParams->getTemplateLoc(), + TemplatedDecl->getSourceRange().getEnd()); } protected: NamedDecl *TemplatedDecl; TemplateParameterList* TemplateParams; + +public: + /// \brief Initialize the underlying templated declaration and + /// template parameters. + void init(NamedDecl *templatedDecl, TemplateParameterList* templateParams) { + assert(TemplatedDecl == 0 && "TemplatedDecl already set!"); + assert(TemplateParams == 0 && "TemplateParams already set!"); + TemplatedDecl = templatedDecl; + TemplateParams = templateParams; + } }; /// \brief Provides information about a function template specialization, @@ -353,8 +379,9 @@ class MemberSpecializationInfo { public: explicit - MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK) - : MemberAndTSK(IF, TSK - 1), PointOfInstantiation() { + MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK, + SourceLocation POI = SourceLocation()) + : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) { assert(TSK != TSK_Undeclared && "Cannot encode undeclared template specializations for members"); } @@ -602,6 +629,9 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const FunctionTemplateDecl *D) { return true; } static bool classofKind(Kind K) { return K == FunctionTemplate; } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; //===----------------------------------------------------------------------===// @@ -634,9 +664,11 @@ protected: public: /// Get the nesting depth of the template parameter. unsigned getDepth() const { return Depth; } + void setDepth(unsigned D) { Depth = D; } /// Get the position of the template parameter within its parameter list. unsigned getPosition() const { return Position; } + void setPosition(unsigned P) { Position = P; } /// Get the index of the template parameter within its parameter list. unsigned getIndex() const { return Position; } @@ -675,6 +707,7 @@ public: SourceLocation L, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack); + static TemplateTypeParmDecl *Create(ASTContext &C, EmptyShell Empty); /// \brief Whether this template type parameter was declared with /// the 'typename' keyword. If not, it was declared with the 'class' @@ -711,6 +744,13 @@ public: DefaultArgument = 0; InheritedDefault = false; } + + /// \brief Set whether this template type parameter was declared with + /// 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; @@ -734,15 +774,16 @@ public: /// @endcode class NonTypeTemplateParmDecl : public VarDecl, protected TemplateParmPosition { - /// \brief The default template argument, if any. - Expr *DefaultArgument; + /// \brief The default template argument, if any, and whether or not + /// it was inherited. + llvm::PointerIntPair DefaultArgumentAndInherited; NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo) : VarDecl(NonTypeTemplateParm, DC, L, Id, T, TInfo, VarDecl::None, VarDecl::None), - TemplateParmPosition(D, P), DefaultArgument(0) + TemplateParmPosition(D, P), DefaultArgumentAndInherited(0, false) { } public: @@ -751,22 +792,43 @@ public: unsigned P, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo); using TemplateParmPosition::getDepth; + using TemplateParmPosition::setDepth; using TemplateParmPosition::getPosition; + using TemplateParmPosition::setPosition; using TemplateParmPosition::getIndex; /// \brief Determine whether this template parameter has a default /// argument. - bool hasDefaultArgument() const { return DefaultArgument; } + bool hasDefaultArgument() const { + return DefaultArgumentAndInherited.getPointer() != 0; + } /// \brief Retrieve the default argument, if any. - Expr *getDefaultArgument() const { return DefaultArgument; } + Expr *getDefaultArgument() const { + return DefaultArgumentAndInherited.getPointer(); + } /// \brief Retrieve the location of the default argument, if any. SourceLocation getDefaultArgumentLoc() const; - /// \brief Set the default argument for this template parameter. - void setDefaultArgument(Expr *DefArg) { - DefaultArgument = DefArg; + /// \brief Determines whether the default argument was inherited + /// from a previous declaration of this template. + bool defaultArgumentWasInherited() const { + return DefaultArgumentAndInherited.getInt(); + } + + /// \brief Set the default argument for this template parameter, and + /// whether that default argument was inherited from another + /// declaration. + void setDefaultArgument(Expr *DefArg, bool Inherited) { + DefaultArgumentAndInherited.setPointer(DefArg); + DefaultArgumentAndInherited.setInt(Inherited); + } + + /// \brief Removes the default argument of this template parameter. + void removeDefaultArgument() { + DefaultArgumentAndInherited.setPointer(0); + DefaultArgumentAndInherited.setInt(false); } // Implement isa/cast/dyncast/etc. @@ -785,14 +847,17 @@ public: class TemplateTemplateParmDecl : public TemplateDecl, protected TemplateParmPosition { - /// \brief The default template argument, if any. + /// DefaultArgument - The default template argument, if any. TemplateArgumentLoc DefaultArgument; + /// Whether or not the default argument was inherited. + bool DefaultArgumentWasInherited; TemplateTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D, unsigned P, IdentifierInfo *Id, TemplateParameterList *Params) : TemplateDecl(TemplateTemplateParm, DC, L, Id, Params), - TemplateParmPosition(D, P), DefaultArgument() + TemplateParmPosition(D, P), DefaultArgument(), + DefaultArgumentWasInherited(false) { } public: @@ -807,24 +872,45 @@ public: /// \brief Determine whether this template parameter has a default /// argument. - bool hasDefaultArgument() const { - return !DefaultArgument.getArgument().isNull(); + bool hasDefaultArgument() const { + return !DefaultArgument.getArgument().isNull(); } /// \brief Retrieve the default argument, if any. - const TemplateArgumentLoc &getDefaultArgument() const { - return DefaultArgument; + const TemplateArgumentLoc &getDefaultArgument() const { + return DefaultArgument; + } + + /// \brief Retrieve the location of the default argument, if any. + SourceLocation getDefaultArgumentLoc() const; + + /// \brief Determines whether the default argument was inherited + /// from a previous declaration of this template. + bool defaultArgumentWasInherited() const { + return DefaultArgumentWasInherited; } - /// \brief Set the default argument for this template parameter. - void setDefaultArgument(const TemplateArgumentLoc &DefArg) { + /// \brief Set the default argument for this template parameter, and + /// whether that default argument was inherited from another + /// declaration. + void setDefaultArgument(const TemplateArgumentLoc &DefArg, bool Inherited) { DefaultArgument = DefArg; + DefaultArgumentWasInherited = Inherited; + } + + /// \brief Removes the default argument of this template parameter. + void removeDefaultArgument() { + DefaultArgument = TemplateArgumentLoc(); + DefaultArgumentWasInherited = false; } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const TemplateTemplateParmDecl *D) { return true; } static bool classofKind(Kind K) { return K == TemplateTemplateParm; } + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; /// \brief Represents a class template specialization, which refers to @@ -860,9 +946,22 @@ class ClassTemplateSpecializationDecl llvm::PointerUnion SpecializedTemplate; - /// \brief The type-as-written of an explicit template specialization. + /// \brief Further info for explicit template specialization/instantiation. + struct ExplicitSpecializationInfo { + /// \brief The type-as-written. + TypeSourceInfo *TypeAsWritten; + /// \brief The location of the extern keyword. + SourceLocation ExternLoc; + /// \brief The location of the template keyword. + SourceLocation TemplateKeywordLoc; + + ExplicitSpecializationInfo() + : TypeAsWritten(0), ExternLoc(), TemplateKeywordLoc() {} + }; + + /// \brief Further info for explicit template specialization/instantiation. /// Does not apply to implicit specializations. - TypeSourceInfo *TypeAsWritten; + ExplicitSpecializationInfo *ExplicitInfo; /// \brief The template arguments used to describe this specialization. TemplateArgumentList TemplateArgs; @@ -881,12 +980,16 @@ protected: TemplateArgumentListBuilder &Builder, ClassTemplateSpecializationDecl *PrevDecl); + explicit ClassTemplateSpecializationDecl(Kind DK); + public: static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation L, ClassTemplateDecl *SpecializedTemplate, TemplateArgumentListBuilder &Builder, ClassTemplateSpecializationDecl *PrevDecl); + static ClassTemplateSpecializationDecl * + Create(ASTContext &Context, EmptyShell Empty); virtual void Destroy(ASTContext& C); @@ -903,6 +1006,14 @@ public: return TemplateArgs; } + /// \brief Initialize the template arguments of the class template + /// specialization. + void initTemplateArgs(TemplateArgument *Args, unsigned NumArgs) { + assert(TemplateArgs.flat_size() == 0 && + "Template arguments already initialized!"); + TemplateArgs.init(getASTContext(), Args, NumArgs); + } + /// \brief Determine the kind of specialization that this /// declaration represents. TemplateSpecializationKind getSpecializationKind() const { @@ -943,6 +1054,19 @@ public: SpecializedTemplate.get()); } + /// \brief Retrieve the class template or class template partial + /// specialization which was specialized by this. + llvm::PointerUnion + getSpecializedTemplateOrPartial() const { + if (SpecializedPartialSpecialization *PartialSpec + = SpecializedTemplate.dyn_cast()) + return PartialSpec->PartialSpecialization; + + return const_cast( + SpecializedTemplate.get()); + } + /// \brief Retrieve the set of template arguments that should be used /// to instantiate members of the class template or class template partial /// specialization from which this class template specialization was @@ -967,6 +1091,8 @@ public: /// template arguments have been deduced. void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, TemplateArgumentList *TemplateArgs) { + assert(!SpecializedTemplate.is() && + "Already set to a class template partial specialization!"); SpecializedPartialSpecialization *PS = new (getASTContext()) SpecializedPartialSpecialization(); PS->PartialSpecialization = PartialSpec; @@ -974,17 +1100,59 @@ public: SpecializedTemplate = PS; } + /// \brief Note that this class template specialization is actually an + /// instantiation of the given class template partial specialization whose + /// template arguments have been deduced. + void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, + TemplateArgument *TemplateArgs, + unsigned NumTemplateArgs) { + ASTContext &Ctx = getASTContext(); + setInstantiationOf(PartialSpec, + new (Ctx) TemplateArgumentList(Ctx, TemplateArgs, + NumTemplateArgs)); + } + + /// \brief Note that this class template specialization is an instantiation + /// of the given class template. + void setInstantiationOf(ClassTemplateDecl *TemplDecl) { + assert(!SpecializedTemplate.is() && + "Previously set to a class template partial specialization!"); + SpecializedTemplate = TemplDecl; + } + /// \brief Sets the type of this specialization as it was written by /// the user. This will be a class template specialization type. void setTypeAsWritten(TypeSourceInfo *T) { - TypeAsWritten = T; + if (!ExplicitInfo) ExplicitInfo = new ExplicitSpecializationInfo; + ExplicitInfo->TypeAsWritten = T; } - /// \brief Gets the type of this specialization as it was written by /// the user, if it was so written. TypeSourceInfo *getTypeAsWritten() const { - return TypeAsWritten; + return ExplicitInfo ? ExplicitInfo->TypeAsWritten : 0; + } + + /// \brief Gets the location of the extern keyword, if present. + SourceLocation getExternLoc() const { + return ExplicitInfo ? ExplicitInfo->ExternLoc : SourceLocation(); + } + /// \brief Sets the location of the extern keyword. + void setExternLoc(SourceLocation Loc) { + if (!ExplicitInfo) ExplicitInfo = new ExplicitSpecializationInfo; + ExplicitInfo->ExternLoc = Loc; + } + + /// \brief Sets the location of the template keyword. + void setTemplateKeywordLoc(SourceLocation Loc) { + if (!ExplicitInfo) ExplicitInfo = new ExplicitSpecializationInfo; + ExplicitInfo->TemplateKeywordLoc = Loc; } + /// \brief Gets the location of the template keyword, if present. + SourceLocation getTemplateKeywordLoc() const { + return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation(); + } + + SourceLocation getInnerLocStart() const { return getTemplateKeywordLoc(); } void Profile(llvm::FoldingSetNodeID &ID) const { Profile(ID, TemplateArgs.getFlatArgumentList(), TemplateArgs.flat_size(), @@ -1001,8 +1169,8 @@ public: static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { - return K == ClassTemplateSpecialization || - K == ClassTemplatePartialSpecialization; + return K >= firstClassTemplateSpecialization && + K <= lastClassTemplateSpecialization; } static bool classof(const ClassTemplateSpecializationDecl *) { @@ -1053,6 +1221,12 @@ class ClassTemplatePartialSpecializationDecl TemplateParams(Params), ArgsAsWritten(ArgInfos), NumArgsAsWritten(NumArgInfos), SequenceNumber(SequenceNumber), InstantiatedFromMember(0, false) { } + + ClassTemplatePartialSpecializationDecl() + : ClassTemplateSpecializationDecl(ClassTemplatePartialSpecialization), + TemplateParams(0), ArgsAsWritten(0), + NumArgsAsWritten(0), SequenceNumber(0), + InstantiatedFromMember(0, false) { } public: static ClassTemplatePartialSpecializationDecl * @@ -1065,16 +1239,26 @@ public: ClassTemplatePartialSpecializationDecl *PrevDecl, unsigned SequenceNumber); + static ClassTemplatePartialSpecializationDecl * + Create(ASTContext &Context, EmptyShell Empty); + /// Get the list of template parameters TemplateParameterList *getTemplateParameters() const { return TemplateParams; } + void initTemplateParameters(TemplateParameterList *Params) { + assert(TemplateParams == 0 && "TemplateParams already set"); + TemplateParams = Params; + } + /// Get the template arguments as written. TemplateArgumentLoc *getTemplateArgsAsWritten() const { return ArgsAsWritten; } + void initTemplateArgsAsWritten(const TemplateArgumentListInfo &ArgInfos); + /// Get the number of template arguments as written. unsigned getNumTemplateArgsAsWritten() const { return NumArgsAsWritten; @@ -1083,6 +1267,7 @@ public: /// \brief Get the sequence number for this class template partial /// specialization. unsigned getSequenceNumber() const { return SequenceNumber; } + void setSequenceNumber(unsigned N) { SequenceNumber = N; } /// \brief Retrieve the member class template partial specialization from /// which this particular class template partial specialization was @@ -1199,26 +1384,19 @@ protected: llvm::PointerIntPair InstantiatedFromMember; }; - // FIXME: Combine PreviousDeclaration with CommonPtr, as in - // FunctionTemplateDecl. - - /// \brief Previous declaration of this class template. - ClassTemplateDecl *PreviousDeclaration; + /// \brief A pointer to the previous declaration (if this is a redeclaration) + /// or to the data that is common to all declarations of this class template. + llvm::PointerUnion CommonOrPrev; - /// \brief Pointer to the data that is common to all of the - /// declarations of this class template. - /// - /// The first declaration of a class template (e.g., the declaration - /// with no "previous declaration") owns this pointer. - Common *CommonPtr; + /// \brief Retrieves the "common" pointer shared by all + /// (re-)declarations of the same class template. Calling this routine + /// may implicitly allocate memory for the common pointer. + Common *getCommonPtr(); ClassTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name, - TemplateParameterList *Params, NamedDecl *Decl, - ClassTemplateDecl *PrevDecl, Common *CommonPtr) + TemplateParameterList *Params, NamedDecl *Decl) : TemplateDecl(ClassTemplate, DC, L, Name, Params, Decl), - PreviousDeclaration(PrevDecl), CommonPtr(CommonPtr) { } - - ~ClassTemplateDecl(); + CommonOrPrev((Common*)0) { } public: /// Get the underlying class declarations of the template. @@ -1226,13 +1404,30 @@ public: return static_cast(TemplatedDecl); } - /// \brief Retrieve the previous declaration of this template. - ClassTemplateDecl *getPreviousDeclaration() const { - return PreviousDeclaration; + /// \brief Retrieve the previous declaration of this class template, or + /// NULL if no such declaration exists. + const ClassTemplateDecl *getPreviousDeclaration() const { + return CommonOrPrev.dyn_cast(); + } + + /// \brief Retrieve the previous declaration of this function template, or + /// NULL if no such declaration exists. + ClassTemplateDecl *getPreviousDeclaration() { + return CommonOrPrev.dyn_cast(); + } + + /// \brief Set the previous declaration of this class template. + void setPreviousDeclaration(ClassTemplateDecl *Prev) { + if (Prev) + CommonOrPrev = Prev; } virtual ClassTemplateDecl *getCanonicalDecl(); + const ClassTemplateDecl *getCanonicalDecl() const { + return const_cast(this)->getCanonicalDecl(); + } + /// Create a class template node. static ClassTemplateDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, @@ -1243,14 +1438,14 @@ public: /// \brief Retrieve the set of specializations of this class template. llvm::FoldingSet &getSpecializations() { - return CommonPtr->Specializations; + return getCommonPtr()->Specializations; } /// \brief Retrieve the set of partial specializations of this class /// template. llvm::FoldingSet & getPartialSpecializations() { - return CommonPtr->PartialSpecializations; + return getCommonPtr()->PartialSpecializations; } /// \brief Retrieve the partial specializations as an ordered list. @@ -1281,7 +1476,7 @@ public: /// typedef array this_type; // "array" is equivalent to "array" /// }; /// \endcode - QualType getInjectedClassNameSpecialization(ASTContext &Context); + QualType getInjectedClassNameSpecialization(); /// \brief Retrieve the member class template that this class template was /// derived from. @@ -1303,13 +1498,13 @@ public: /// X::A, a TemplateClassDecl (whose parent is X, also a TCD). /// /// \returns null if this is not an instantiation of a member class template. - ClassTemplateDecl *getInstantiatedFromMemberTemplate() const { - return CommonPtr->InstantiatedFromMember.getPointer(); + ClassTemplateDecl *getInstantiatedFromMemberTemplate() { + return getCommonPtr()->InstantiatedFromMember.getPointer(); } void setInstantiatedFromMemberTemplate(ClassTemplateDecl *CTD) { - assert(!CommonPtr->InstantiatedFromMember.getPointer()); - CommonPtr->InstantiatedFromMember.setPointer(CTD); + assert(!getCommonPtr()->InstantiatedFromMember.getPointer()); + getCommonPtr()->InstantiatedFromMember.setPointer(CTD); } /// \brief Determines whether this template was a specialization of a @@ -1328,14 +1523,14 @@ public: /// struct X::Inner { /* ... */ }; /// \endcode bool isMemberSpecialization() { - return CommonPtr->InstantiatedFromMember.getInt(); + return getCommonPtr()->InstantiatedFromMember.getInt(); } /// \brief Note that this member template is a specialization. void setMemberSpecialization() { - assert(CommonPtr->InstantiatedFromMember.getPointer() && + assert(getCommonPtr()->InstantiatedFromMember.getPointer() && "Only member templates can be member template specializations"); - CommonPtr->InstantiatedFromMember.setInt(true); + getCommonPtr()->InstantiatedFromMember.setInt(true); } // Implement isa/cast/dyncast support @@ -1344,6 +1539,9 @@ public: static bool classofKind(Kind K) { return K == ClassTemplate; } virtual void Destroy(ASTContext& C); + + friend class PCHDeclReader; + friend class PCHDeclWriter; }; /// Declaration of a friend template. For example: diff --git a/include/clang/AST/DeclVisitor.h b/include/clang/AST/DeclVisitor.h index 140e5c0a2a99..aee1998028eb 100644 --- a/include/clang/AST/DeclVisitor.h +++ b/include/clang/AST/DeclVisitor.h @@ -30,20 +30,19 @@ class DeclVisitor { public: RetTy Visit(Decl *D) { switch (D->getKind()) { - default: assert(false && "Decl that isn't part of DeclNodes.def!"); -#define DECL(Derived, Base) \ - case Decl::Derived: DISPATCH(Derived##Decl, Derived##Decl); -#define ABSTRACT_DECL(Derived, Base) -#include "clang/AST/DeclNodes.def" + default: assert(false && "Decl that isn't part of DeclNodes.inc!"); +#define DECL(DERIVED, BASE) \ + case Decl::DERIVED: DISPATCH(DERIVED##Decl, DERIVED##Decl); +#define ABSTRACT_DECL(DECL) +#include "clang/AST/DeclNodes.inc" } } // If the implementation chooses not to implement a certain visit // method, fall back to the parent. -#define DECL(Derived, Base) \ - RetTy Visit##Derived##Decl(Derived##Decl *D) { DISPATCH(Base, Base); } -#define ABSTRACT_DECL(Derived, Base) DECL(Derived, Base) -#include "clang/AST/DeclNodes.def" +#define DECL(DERIVED, BASE) \ + RetTy Visit##DERIVED##Decl(DERIVED##Decl *D) { DISPATCH(BASE, BASE); } +#include "clang/AST/DeclNodes.inc" RetTy VisitDecl(Decl *D) { return RetTy(); } }; diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 66639e2ef733..807644349e56 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -162,9 +162,6 @@ public: }; isLvalueResult isLvalue(ASTContext &Ctx) const; - // Same as above, but excluding checks for non-object and void types in C - isLvalueResult isLvalueInternal(ASTContext &Ctx) const; - /// isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, /// does not have an incomplete type, does not have a const-qualified type, /// and if it is a structure or union, does not have any member (including, @@ -194,6 +191,95 @@ public: isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc = 0) const; + /// \brief The return type of classify(). Represents the C++0x expression + /// taxonomy. + class Classification { + public: + /// \brief The various classification results. Most of these mean prvalue. + enum Kinds { + CL_LValue, + CL_XValue, + CL_Function, // Functions cannot be lvalues in C. + CL_Void, // Void cannot be an lvalue 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_PRValue // A prvalue for any other reason, of any other type + }; + /// \brief The results of modification testing. + enum ModifiableType { + CM_Untested, // testModifiable was false. + CM_Modifiable, + CM_RValue, // Not modifiable because it's an rvalue + CM_Function, // Not modifiable because it's a function; C++ only + CM_LValueCast, // Same as CM_RValue, but indicates GCC cast-as-lvalue ext + CM_NotBlockQualified, // Not captured in the closure + CM_NoSetterProperty,// Implicit assignment to ObjC property without setter + CM_ConstQualified, + CM_ArrayType, + CM_IncompleteType + }; + + private: + friend class Expr; + + unsigned short Kind; + unsigned short Modifiable; + + explicit Classification(Kinds k, ModifiableType m) + : Kind(k), Modifiable(m) + {} + + public: + Classification() {} + + Kinds getKind() const { return static_cast(Kind); } + ModifiableType getModifiable() const { + assert(Modifiable != CM_Untested && "Did not test for modifiability."); + return static_cast(Modifiable); + } + bool isLValue() const { return Kind == CL_LValue; } + bool isXValue() const { return Kind == CL_XValue; } + bool isGLValue() const { return Kind <= CL_XValue; } + bool isPRValue() const { return Kind >= CL_Function; } + bool isRValue() const { return Kind >= CL_XValue; } + bool isModifiable() const { return getModifiable() == CM_Modifiable; } + }; + /// \brief classify - Classify this expression according to the C++0x + /// expression taxonomy. + /// + /// C++0x defines ([basic.lval]) a new taxonomy of expressions to replace the + /// old lvalue vs rvalue. This function determines the type of expression this + /// is. There are three expression types: + /// - lvalues are classical lvalues as in C++03. + /// - prvalues are equivalent to rvalues in C++03. + /// - xvalues are expressions yielding unnamed rvalue references, e.g. a + /// function returning an rvalue reference. + /// lvalues and xvalues are collectively referred to as glvalues, while + /// prvalues and xvalues together form rvalues. + /// If a + Classification Classify(ASTContext &Ctx) const { + return ClassifyImpl(Ctx, 0); + } + + /// \brief classifyModifiable - Classify this expression according to the + /// C++0x expression taxonomy, and see if it is valid on the left side + /// of an assignment. + /// + /// This function extends classify in that it also tests whether the + /// expression is modifiable (C99 6.3.2.1p1). + /// \param Loc A source location that might be filled with a relevant location + /// if the expression is not modifiable. + Classification ClassifyModifiable(ASTContext &Ctx, SourceLocation &Loc) const{ + return ClassifyImpl(Ctx, &Loc); + } + +private: + Classification ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const; + +public: + /// \brief If this expression refers to a bit-field, retrieve the /// declaration of that bit-field. FieldDecl *getBitField(); @@ -414,6 +500,7 @@ struct ExplicitTemplateArgumentList { void initializeFrom(const TemplateArgumentListInfo &List); void copyInto(TemplateArgumentListInfo &List) const; + static std::size_t sizeFor(unsigned NumTemplateArgs); static std::size_t sizeFor(const TemplateArgumentListInfo &List); }; @@ -474,27 +561,21 @@ class DeclRefExpr : public Expr { ValueDecl *D, SourceLocation NameLoc, const TemplateArgumentListInfo *TemplateArgs, QualType T); + + /// \brief Construct an empty declaration reference expression. + explicit DeclRefExpr(EmptyShell Empty) + : Expr(DeclRefExprClass, Empty) { } -protected: /// \brief Computes the type- and value-dependence flags for this /// declaration reference expression. void computeDependence(); - DeclRefExpr(StmtClass SC, ValueDecl *d, QualType t, SourceLocation l) : - Expr(SC, t, false, false), DecoratedD(d, 0), Loc(l) { - computeDependence(); - } - public: DeclRefExpr(ValueDecl *d, QualType t, SourceLocation l) : Expr(DeclRefExprClass, t, false, false), DecoratedD(d, 0), Loc(l) { computeDependence(); } - /// \brief Construct an empty declaration reference expression. - explicit DeclRefExpr(EmptyShell Empty) - : Expr(DeclRefExprClass, Empty) { } - static DeclRefExpr *Create(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange QualifierRange, @@ -502,6 +583,10 @@ public: SourceLocation NameLoc, QualType T, const TemplateArgumentListInfo *TemplateArgs = 0); + + /// \brief Construct an empty declaration reference expression. + static DeclRefExpr *CreateEmpty(ASTContext &Context, + bool HasQualifier, unsigned NumTemplateArgs); ValueDecl *getDecl() { return DecoratedD.getPointer(); } const ValueDecl *getDecl() const { return DecoratedD.getPointer(); } @@ -591,6 +676,9 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + friend class PCHStmtReader; + friend class PCHStmtWriter; }; /// PredefinedExpr - [C99 6.4.2.2] - A predefined identifier such as __func__. @@ -1560,11 +1648,6 @@ public: Base(base), MemberDecl(memberdecl), MemberLoc(l), IsArrow(isarrow), HasQualifierOrFoundDecl(false), HasExplicitTemplateArgumentList(false) {} - /// \brief Build an empty member reference expression. - explicit MemberExpr(EmptyShell Empty) - : Expr(MemberExprClass, Empty), HasQualifierOrFoundDecl(false), - HasExplicitTemplateArgumentList(false) { } - static MemberExpr *Create(ASTContext &C, Expr *base, bool isarrow, NestedNameSpecifier *qual, SourceRange qualrange, ValueDecl *memberdecl, DeclAccessPair founddecl, @@ -1937,6 +2020,7 @@ public: } const CXXBaseSpecifierArray& getBasePath() const { return BasePath; } + CXXBaseSpecifierArray& getBasePath() { return BasePath; } static bool classof(const Stmt *T) { return T->getStmtClass() >= firstCastExprConstant && @@ -2169,7 +2253,8 @@ public: /// predicates to categorize the respective opcodes. bool isMultiplicativeOp() const { return Opc >= Mul && Opc <= Rem; } - bool isAdditiveOp() const { return Opc == Add || Opc == Sub; } + static bool isAdditiveOp(Opcode Opc) { return Opc == Add || Opc == Sub; } + bool isAdditiveOp() const { return isAdditiveOp(Opc); } static bool isShiftOp(Opcode Opc) { return Opc == Shl || Opc == Shr; } bool isShiftOp() const { return isShiftOp(Opc); } @@ -3153,7 +3238,7 @@ public: ~ParenListExpr() {} /// \brief Build an empty paren list. - //explicit ParenListExpr(EmptyShell Empty) : Expr(ParenListExprClass, Empty) { } + explicit ParenListExpr(EmptyShell Empty) : Expr(ParenListExprClass, Empty) { } unsigned getNumExprs() const { return NumExprs; } @@ -3183,6 +3268,9 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + friend class PCHStmtReader; + friend class PCHStmtWriter; }; @@ -3305,12 +3393,15 @@ class BlockDeclRefExpr : public Expr { SourceLocation Loc; bool IsByRef : 1; bool ConstQualAdded : 1; + Stmt *CopyConstructorVal; public: // FIXME: Fix type/value dependence! BlockDeclRefExpr(ValueDecl *d, QualType t, SourceLocation l, bool ByRef, - bool constAdded = false) - : Expr(BlockDeclRefExprClass, t, false, false), D(d), Loc(l), IsByRef(ByRef), - ConstQualAdded(constAdded) {} + bool constAdded = false, + Stmt *copyConstructorVal = 0) + : Expr(BlockDeclRefExprClass, t, (!t.isNull() && t->isDependentType()),false), + D(d), Loc(l), IsByRef(ByRef), + ConstQualAdded(constAdded), CopyConstructorVal(copyConstructorVal) {} // \brief Build an empty reference to a declared variable in a // block. @@ -3331,6 +3422,12 @@ public: bool isConstQualAdded() const { return ConstQualAdded; } void setConstQualAdded(bool C) { ConstQualAdded = C; } + + const Expr *getCopyConstructorExpr() const + { return cast_or_null(CopyConstructorVal); } + Expr *getCopyConstructorExpr() + { return cast_or_null(CopyConstructorVal); } + void setCopyConstructorExpr(Expr *E) { CopyConstructorVal = E; } static bool classof(const Stmt *T) { return T->getStmtClass() == BlockDeclRefExprClass; diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 0c493f36df09..b9553815d8eb 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -465,7 +465,6 @@ class CXXDefaultArgExpr : public Expr { /// \brief The location where the default argument expression was used. SourceLocation Loc; -protected: CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param) : Expr(SC, param->hasUnparsedDefaultArg() @@ -504,9 +503,6 @@ public: // Retrieve the parameter that the argument was created from. const ParmVarDecl *getParam() const { return Param.getPointer(); } ParmVarDecl *getParam() { return Param.getPointer(); } - - /// isExprStored - Return true if this expression owns the expression. - bool isExprStored() const { return Param.getInt(); } // Retrieve the actual argument to the function call. const Expr *getExpr() const { @@ -519,16 +515,10 @@ public: return *reinterpret_cast (this + 1); return getParam()->getDefaultArg(); } - - void setExpr(Expr *E) { - Param.setInt(true); - Param.setPointer((ParmVarDecl*)E); - } /// \brief Retrieve the location where this default argument was actually /// used. SourceLocation getUsedLocation() const { return Loc; } - void setUsedLocation(SourceLocation L) { Loc = L; } virtual SourceRange getSourceRange() const { // Default argument expressions have no representation in the @@ -544,6 +534,9 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + friend class PCHStmtReader; + friend class PCHStmtWriter; }; /// CXXTemporary - Represents a C++ temporary. @@ -655,6 +648,9 @@ public: static CXXBindReferenceExpr *Create(ASTContext &C, Expr *SubExpr, bool ExtendsLifetime, bool RequiresTemporaryCopy); + + explicit CXXBindReferenceExpr(EmptyShell Empty) + : Expr(CXXBindReferenceExprClass, Empty) { } const Expr *getSubExpr() const { return cast(SubExpr); } Expr *getSubExpr() { return cast(SubExpr); } @@ -670,7 +666,7 @@ public: // extendsLifetime - Whether binding this reference extends the lifetime of // the expression being bound. FIXME: Add C++ reference. - bool extendsLifetime() { return ExtendsLifetime; } + bool extendsLifetime() const { return ExtendsLifetime; } // Implement isa/cast/dyncast/etc. static bool classof(const Stmt *T) { @@ -681,6 +677,8 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + friend class PCHStmtReader; }; /// CXXConstructExpr - Represents a call to a C++ constructor. @@ -711,13 +709,20 @@ protected: ConstructionKind ConstructKind = CK_Complete); ~CXXConstructExpr() { } + /// \brief Construct an empty C++ construction expression. + CXXConstructExpr(StmtClass SC, EmptyShell Empty) + : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0), + ConstructKind(0), Args(0), NumArgs(0) { } + virtual void DoDestroy(ASTContext &C); public: - /// \brief Construct an empty C++ construction expression that will store - /// \p numargs arguments. - CXXConstructExpr(EmptyShell Empty, ASTContext &C, unsigned numargs); - + /// \brief Construct an empty C++ construction expression. + explicit CXXConstructExpr(EmptyShell Empty) + : Expr(CXXConstructExprClass, Empty), Constructor(0), + Elidable(0), ZeroInitialization(0), + ConstructKind(0), Args(0), NumArgs(0) { } + static CXXConstructExpr *Create(ASTContext &C, QualType T, SourceLocation Loc, CXXConstructorDecl *D, bool Elidable, @@ -790,6 +795,8 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + friend class PCHStmtReader; }; /// CXXFunctionalCastExpr - Represents an explicit C++ type conversion @@ -829,12 +836,8 @@ public: /// /// This expression type represents a C++ "functional" cast /// (C++[expr.type.conv]) with N != 1 arguments that invokes a -/// constructor to build a temporary object. If N == 0 but no -/// constructor will be called (because the functional cast is -/// performing a value-initialized an object whose class type has no -/// user-declared constructors), CXXZeroInitValueExpr will represent -/// the functional cast. Finally, with N == 1 arguments the functional -/// cast expression will be represented by CXXFunctionalCastExpr. +/// constructor to build a temporary object. With N == 1 arguments the +/// functional cast expression will be represented by CXXFunctionalCastExpr. /// Example: /// @code /// struct X { X(int, float); } @@ -853,6 +856,8 @@ public: Expr **Args,unsigned NumArgs, SourceLocation rParenLoc, bool ZeroInitialization = false); + explicit CXXTemporaryObjectExpr(EmptyShell Empty) + : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty) { } ~CXXTemporaryObjectExpr() { } @@ -866,24 +871,25 @@ public: return T->getStmtClass() == CXXTemporaryObjectExprClass; } static bool classof(const CXXTemporaryObjectExpr *) { return true; } + + friend class PCHStmtReader; }; -/// CXXZeroInitValueExpr - [C++ 5.2.3p2] +/// CXXScalarValueInitExpr - [C++ 5.2.3p2] /// Expression "T()" which creates a value-initialized rvalue of type -/// T, which is either a non-class type or a class type without any -/// user-defined constructors. +/// T, which is a non-class type. /// -class CXXZeroInitValueExpr : public Expr { +class CXXScalarValueInitExpr : public Expr { SourceLocation TyBeginLoc; SourceLocation RParenLoc; public: - CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, + CXXScalarValueInitExpr(QualType ty, SourceLocation tyBeginLoc, SourceLocation rParenLoc ) : - Expr(CXXZeroInitValueExprClass, ty, false, false), + Expr(CXXScalarValueInitExprClass, ty, false, false), TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} - explicit CXXZeroInitValueExpr(EmptyShell Shell) - : Expr(CXXZeroInitValueExprClass, Shell) { } + explicit CXXScalarValueInitExpr(EmptyShell Shell) + : Expr(CXXScalarValueInitExprClass, Shell) { } SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } @@ -902,9 +908,9 @@ public: } static bool classof(const Stmt *T) { - return T->getStmtClass() == CXXZeroInitValueExprClass; + return T->getStmtClass() == CXXScalarValueInitExprClass; } - static bool classof(const CXXZeroInitValueExpr *) { return true; } + static bool classof(const CXXScalarValueInitExpr *) { return true; } // Iterators virtual child_iterator child_begin(); @@ -916,15 +922,13 @@ public: class CXXNewExpr : public Expr { // Was the usage ::new, i.e. is the global new to be used? bool GlobalNew : 1; - // Was the form (type-id) used? Otherwise, it was new-type-id. - bool ParenTypeId : 1; // Is there an initializer? If not, built-ins are uninitialized, else they're // value-initialized. bool Initializer : 1; // Do we allocate an array? If so, the first SubExpr is the size expression. bool Array : 1; // The number of placement new arguments. - unsigned NumPlacementArgs : 14; + unsigned NumPlacementArgs : 15; // The number of constructor arguments. This may be 1 even for non-class // types; use the pseudo copy constructor. unsigned NumConstructorArgs : 14; @@ -941,12 +945,18 @@ class CXXNewExpr : public Expr { // Must be null for all other types. CXXConstructorDecl *Constructor; + /// \brief If the allocated type was expressed as a parenthesized type-id, + /// the source range covering the parenthesized type-id. + SourceRange TypeIdParens; + SourceLocation StartLoc; SourceLocation EndLoc; + friend class PCHStmtReader; public: CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew, - Expr **placementArgs, unsigned numPlaceArgs, bool ParenTypeId, + Expr **placementArgs, unsigned numPlaceArgs, + SourceRange TypeIdParens, Expr *arraySize, CXXConstructorDecl *constructor, bool initializer, Expr **constructorArgs, unsigned numConsArgs, FunctionDecl *operatorDelete, QualType ty, @@ -989,10 +999,11 @@ public: return cast(SubExprs[Array + i]); } + bool isParenTypeId() const { return TypeIdParens.isValid(); } + SourceRange getTypeIdParens() const { return TypeIdParens; } + bool isGlobalNew() const { return GlobalNew; } void setGlobalNew(bool V) { GlobalNew = V; } - bool isParenTypeId() const { return ParenTypeId; } - void setParenTypeId(bool V) { ParenTypeId = V; } bool hasInitializer() const { return Initializer; } void setHasInitializer(bool V) { Initializer = V; } @@ -1082,18 +1093,26 @@ public: : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete), ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), Loc(loc) { } + explicit CXXDeleteExpr(EmptyShell Shell) + : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { } bool isGlobalDelete() const { return GlobalDelete; } bool isArrayForm() const { return ArrayForm; } + + void setGlobalDelete(bool V) { GlobalDelete = V; } + void setArrayForm(bool V) { ArrayForm = V; } FunctionDecl *getOperatorDelete() const { return OperatorDelete; } + void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } Expr *getArgument() { return cast(Argument); } const Expr *getArgument() const { return cast(Argument); } + void setArgument(Expr *E) { Argument = E; } virtual SourceRange getSourceRange() const { return SourceRange(Loc, Argument->getLocEnd()); } + void setStartLoc(SourceLocation L) { Loc = L; } static bool classof(const Stmt *T) { return T->getStmtClass() == CXXDeleteExprClass; @@ -1215,6 +1234,10 @@ public: ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), DestroyedType(DestroyedType) { } + explicit CXXPseudoDestructorExpr(EmptyShell Shell) + : Expr(CXXPseudoDestructorExprClass, Shell), + Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { } + void setBase(Expr *E) { Base = E; } Expr *getBase() const { return cast(Base); } @@ -1227,11 +1250,13 @@ public: /// the nested-name-specifier that precedes the member name. Otherwise, /// returns an empty source range. SourceRange getQualifierRange() const { return QualifierRange; } + void setQualifierRange(SourceRange R) { QualifierRange = R; } /// \brief If the member name was qualified, retrieves the /// nested-name-specifier that precedes the member name. Otherwise, returns /// NULL. NestedNameSpecifier *getQualifier() const { return Qualifier; } + void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } /// \brief Determine whether this pseudo-destructor expression was written /// using an '->' (otherwise, it used a '.'). @@ -1240,6 +1265,7 @@ public: /// \brief Retrieve the location of the '.' or '->' operator. SourceLocation getOperatorLoc() const { return OperatorLoc; } + void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } /// \brief Retrieve the scope type in a qualified pseudo-destructor /// expression. @@ -1251,13 +1277,16 @@ public: /// nested-name-specifier. It is stored as the "scope type" of the pseudo- /// destructor expression. TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; } + void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; } /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor /// expression. SourceLocation getColonColonLoc() const { return ColonColonLoc; } + void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; } /// \brief Retrieve the location of the '~'. SourceLocation getTildeLoc() const { return TildeLoc; } + void setTildeLoc(SourceLocation L) { TildeLoc = L; } /// \brief Retrieve the source location information for the type /// being destroyed. @@ -1285,6 +1314,17 @@ public: return DestroyedType.getLocation(); } + /// \brief Set the name of destroyed type for a dependent pseudo-destructor + /// expression. + void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) { + DestroyedType = PseudoDestructorTypeStorage(II, Loc); + } + + /// \brief Set the destroyed type. + void setDestroyedType(TypeSourceInfo *Info) { + DestroyedType = PseudoDestructorTypeStorage(Info); + } + virtual SourceRange getSourceRange() const; static bool classof(const Stmt *T) { @@ -1321,6 +1361,9 @@ public: : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()), UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { } + explicit UnaryTypeTraitExpr(EmptyShell Empty) + : Expr(UnaryTypeTraitExprClass, Empty), UTT((UnaryTypeTrait)0) { } + virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} UnaryTypeTrait getTrait() const { return UTT; } @@ -1337,6 +1380,8 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + friend class PCHStmtReader; }; /// \brief A reference to an overloaded function set, either an @@ -1361,16 +1406,20 @@ class OverloadExpr : public Expr { /// The location of the name. SourceLocation NameLoc; +protected: /// True if the name was a template-id. bool HasExplicitTemplateArgs; -protected: OverloadExpr(StmtClass K, ASTContext &C, QualType T, bool Dependent, NestedNameSpecifier *Qualifier, SourceRange QRange, DeclarationName Name, SourceLocation NameLoc, bool HasTemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End); + OverloadExpr(StmtClass K, EmptyShell Empty) + : Expr(K, Empty), Results(0), NumResults(0), + Qualifier(0), HasExplicitTemplateArgs(false) { } + public: /// Computes whether an unresolved lookup on the given declarations /// and optional template arguments is type- and value-dependent. @@ -1401,6 +1450,9 @@ public: decls_iterator decls_end() const { return UnresolvedSetIterator(Results + NumResults); } + + void initializeResults(ASTContext &C, + UnresolvedSetIterator Begin,UnresolvedSetIterator End); /// Gets the number of declarations in the unresolved set. unsigned getNumDecls() const { return NumResults; } @@ -1415,9 +1467,11 @@ public: /// Fetches the nested-name qualifier, if one was given. NestedNameSpecifier *getQualifier() const { return Qualifier; } + void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } /// Fetches the range of the nested-name qualifier. SourceRange getQualifierRange() const { return QualifierRange; } + void setQualifierRange(SourceRange R) { QualifierRange = R; } /// \brief Determines whether this expression had an explicit /// template argument list, e.g. f. @@ -1480,6 +1534,11 @@ class UnresolvedLookupExpr : public OverloadExpr { RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass) {} + UnresolvedLookupExpr(EmptyShell Empty) + : OverloadExpr(UnresolvedLookupExprClass, Empty), + RequiresADL(false), Overloaded(false), NamingClass(0) + {} + public: static UnresolvedLookupExpr *Create(ASTContext &C, bool Dependent, @@ -1511,17 +1570,23 @@ public: UnresolvedSetIterator Begin, UnresolvedSetIterator End); + static UnresolvedLookupExpr *CreateEmpty(ASTContext &C, + unsigned NumTemplateArgs); + /// True if this declaration should be extended by /// argument-dependent lookup. bool requiresADL() const { return RequiresADL; } + void setRequiresADL(bool V) { RequiresADL = V; } /// 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 @@ -1628,18 +1693,25 @@ public: SourceLocation NameLoc, const TemplateArgumentListInfo *TemplateArgs = 0); + static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C, + unsigned NumTemplateArgs); + /// \brief Retrieve the name that this expression refers to. DeclarationName getDeclName() const { return Name; } + void setDeclName(DeclarationName N) { Name = N; } /// \brief Retrieve the location of the name within the expression. SourceLocation getLocation() const { return Loc; } + void setLocation(SourceLocation L) { Loc = L; } /// \brief Retrieve the source range of the nested-name-specifier. SourceRange getQualifierRange() const { return QualifierRange; } + void setQualifierRange(SourceRange R) { QualifierRange = R; } /// \brief Retrieve the nested-name-specifier that qualifies this /// declaration. NestedNameSpecifier *getQualifier() const { return Qualifier; } + void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } /// Determines whether this lookup had explicit template arguments. bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } @@ -1648,6 +1720,11 @@ public: // nodes, users are *forbidden* from calling these methods on objects // without explicit template arguments. + ExplicitTemplateArgumentList &getExplicitTemplateArgs() { + assert(hasExplicitTemplateArgs()); + return *reinterpret_cast(this + 1); + } + /// Gets a reference to the explicit template argument list. const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { assert(hasExplicitTemplateArgs()); @@ -1792,6 +1869,9 @@ class CXXUnresolvedConstructExpr : public Expr { unsigned NumArgs, SourceLocation RParenLoc); + CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs) + : Expr(CXXUnresolvedConstructExprClass, Empty), NumArgs(NumArgs) { } + public: static CXXUnresolvedConstructExpr *Create(ASTContext &C, SourceLocation TyBegin, @@ -1801,6 +1881,9 @@ public: unsigned NumArgs, SourceLocation RParenLoc); + static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C, + unsigned NumArgs); + /// \brief Retrieve the source location where the type begins. SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } @@ -1845,6 +1928,11 @@ public: return *(arg_begin() + I); } + void setArg(unsigned I, Expr *E) { + assert(I < NumArgs && "Argument index out-of-range"); + *(arg_begin() + I) = E; + } + virtual SourceRange getSourceRange() const { return SourceRange(TyBeginLoc, RParenLoc); } @@ -1908,20 +1996,6 @@ class CXXDependentScopeMemberExpr : public Expr { /// \brief The location of the member name. SourceLocation MemberLoc; - /// \brief Retrieve the explicit template argument list that followed the - /// member template name, if any. - ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() { - assert(HasExplicitTemplateArgs); - return reinterpret_cast(this + 1); - } - - /// \brief Retrieve the explicit template argument list that followed the - /// member template name, if any. - const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const { - return const_cast(this) - ->getExplicitTemplateArgumentList(); - } - CXXDependentScopeMemberExpr(ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, @@ -1960,6 +2034,9 @@ public: SourceLocation MemberLoc, const TemplateArgumentListInfo *TemplateArgs); + static CXXDependentScopeMemberExpr * + CreateEmpty(ASTContext &C, unsigned NumTemplateArgs); + /// \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. @@ -1974,6 +2051,7 @@ public: 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. @@ -1987,10 +2065,12 @@ public: /// \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; } /// \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 @@ -2006,6 +2086,9 @@ public: NamedDecl *getFirstQualifierFoundInScope() const { return FirstQualifierFoundInScope; } + void setFirstQualifierFoundInScope(NamedDecl *D) { + FirstQualifierFoundInScope = D; + } /// \brief Retrieve the name of the member that this expression /// refers to. @@ -2023,6 +2106,20 @@ public: return HasExplicitTemplateArgs; } + /// \brief Retrieve the explicit template argument list that followed the + /// member template name, if any. + ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() { + assert(HasExplicitTemplateArgs); + return reinterpret_cast(this + 1); + } + + /// \brief Retrieve the explicit template argument list that followed the + /// member template name, if any. + const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const { + return const_cast(this) + ->getExplicitTemplateArgumentList(); + } + /// \brief Copies the template arguments (if present) into the given /// structure. void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { @@ -2030,6 +2127,12 @@ public: getExplicitTemplateArgumentList()->copyInto(List); } + /// \brief Initializes the template arguments using the given structure. + void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) { + assert(HasExplicitTemplateArgs); + getExplicitTemplateArgumentList()->initializeFrom(List); + } + /// \brief Retrieve the location of the left angle bracket following the /// member name ('<'), if any. SourceLocation getLAngleLoc() const { @@ -2127,6 +2230,10 @@ class UnresolvedMemberExpr : public OverloadExpr { SourceLocation MemberLoc, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End); + + UnresolvedMemberExpr(EmptyShell Empty) + : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false), + HasUnresolvedUsing(false), Base(0) { } public: static UnresolvedMemberExpr * @@ -2140,6 +2247,9 @@ public: const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End); + static UnresolvedMemberExpr * + CreateEmpty(ASTContext &C, unsigned NumTemplateArgs); + /// \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. @@ -2158,6 +2268,12 @@ public: 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. diff --git a/include/clang/AST/ExternalASTSource.h b/include/clang/AST/ExternalASTSource.h index 79e44511d32d..def9ced94c29 100644 --- a/include/clang/AST/ExternalASTSource.h +++ b/include/clang/AST/ExternalASTSource.h @@ -58,67 +58,85 @@ public: virtual ~ExternalASTSource(); - /// \brief Resolve a type ID into a type, potentially building a new - /// type. - virtual QualType GetType(uint32_t ID) = 0; - /// \brief Resolve a declaration ID into a declaration, potentially /// building a new declaration. - virtual Decl *GetDecl(uint32_t ID) = 0; + /// + /// 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; /// \brief Resolve a selector ID into a selector. - virtual Selector GetSelector(uint32_t ID) = 0; + /// + /// This operation only needs to be implemented if the AST source + /// returns non-zero for GetNumKnownSelectors(). + virtual Selector GetExternalSelector(uint32_t ID) = 0; /// \brief Returns the number of selectors known to the external AST /// source. - virtual uint32_t GetNumKnownSelectors() = 0; + virtual uint32_t GetNumExternalSelectors() = 0; - /// \brief Resolve the offset of a statement in the decl stream into a - /// statement. + /// \brief Resolve the offset of a statement in the decl stream into + /// a statement. /// - /// This operation will read a new statement from the external - /// source each time it is called, and is meant to be used via a - /// LazyOffsetPtr. - virtual Stmt *GetDeclStmt(uint64_t Offset) = 0; + /// 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; - /// \brief Read all of the declarations lexically stored in a - /// declaration context. + /// \brief Finds all declarations with the given name in the + /// given context. /// - /// \param DC The declaration context whose declarations will be - /// read. + /// Generally the final step of this method is either to call + /// SetExternalVisibleDeclsForName or to recursively call lookup on + /// the DeclContext after calling SetExternalVisibleDecls. + virtual DeclContext::lookup_result + FindExternalVisibleDeclsByName(const DeclContext *DC, + DeclarationName Name) = 0; + + /// \brief Finds all declarations lexically contained within the given + /// DeclContext. /// - /// \param Decls Vector that will contain the declarations loaded - /// from the external source. The caller is responsible for merging - /// these declarations with any declarations already stored in the - /// declaration context. - /// - /// \returns true if there was an error while reading the - /// declarations for this declaration context. - virtual bool ReadDeclsLexicallyInContext(DeclContext *DC, - llvm::SmallVectorImpl &Decls) = 0; - - /// \brief Read all of the declarations visible from a declaration - /// context. - /// - /// \param DC The declaration context whose visible declarations - /// will be read. - /// - /// \param Decls A vector of visible declaration structures, - /// providing the mapping from each name visible in the declaration - /// context to the declaration IDs of declarations with that name. - /// - /// \returns true if there was an error while reading the - /// declarations for this declaration context. - virtual bool ReadDeclsVisibleInContext(DeclContext *DC, - llvm::SmallVectorImpl & Decls) = 0; + /// \return true if an error occurred + virtual bool FindExternalLexicalDecls(const DeclContext *DC, + llvm::SmallVectorImpl &Result) = 0; /// \brief Function that will be invoked when we begin parsing a new /// translation unit involving this external AST source. + /// + /// The default implementation of this method is a no-op. virtual void StartTranslationUnit(ASTConsumer *Consumer) { } /// \brief Print any statistics that have been gathered regarding /// the external AST source. + /// + /// The default implementation of this method is a no-op. virtual void PrintStats(); + +protected: + /// \brief Initialize the context's lookup map with the given decls. + /// It is assumed that none of the declarations are redeclarations of + /// each other. + static void SetExternalVisibleDecls(const DeclContext *DC, + const llvm::SmallVectorImpl &Decls); + + /// \brief Initialize the context's lookup map with the given decls. + /// It is assumed that none of the declarations are redeclarations of + /// each other. + static void SetExternalVisibleDecls(const DeclContext *DC, + const llvm::SmallVectorImpl &Decls); + + static DeclContext::lookup_result + SetExternalVisibleDeclsForName(const DeclContext *DC, + const VisibleDeclaration &VD); + + static DeclContext::lookup_result + SetExternalVisibleDeclsForName(const DeclContext *DC, + DeclarationName Name, + llvm::SmallVectorImpl &Decls); + + static DeclContext::lookup_result + SetNoExternalVisibleDeclsForName(const DeclContext *DC, + DeclarationName Name); }; /// \brief A lazy pointer to an AST node (of base type T) that resides @@ -185,7 +203,8 @@ public: }; /// \brief A lazy pointer to a statement. -typedef LazyOffsetPtr LazyDeclStmtPtr; +typedef LazyOffsetPtr + LazyDeclStmtPtr; } // end namespace clang diff --git a/include/clang/AST/Makefile b/include/clang/AST/Makefile index a25977cad621..00a1e1bf7977 100644 --- a/include/clang/AST/Makefile +++ b/include/clang/AST/Makefile @@ -1,13 +1,23 @@ -LEVEL = ../../../../.. -BUILT_SOURCES = StmtNodes.inc +CLANG_LEVEL := ../../.. +TD_SRC_DIR = $(PROJ_SRC_DIR)/../Basic +BUILT_SOURCES = Attrs.inc StmtNodes.inc DeclNodes.inc TABLEGEN_INC_FILES_COMMON = 1 -include $(LEVEL)/Makefile.common +include $(CLANG_LEVEL)/Makefile -INPUT_TDS = $(PROJ_SRC_DIR)/StmtNodes.td +$(ObjDir)/Attrs.inc.tmp : $(TD_SRC_DIR)/Attr.td $(TBLGEN) \ + $(ObjDir)/.dir + $(Echo) "Building Clang attribute classes with tblgen" + $(Verb) $(TableGen) -gen-clang-attr-classes -o $(call SYSPATH, $@) \ + -I $(PROJ_SRC_DIR)/../../ $< -$(ObjDir)/StmtNodes.inc.tmp : StmtNodes.td $(TBLGEN) $(ObjDir)/.dir +$(ObjDir)/StmtNodes.inc.tmp : $(TD_SRC_DIR)/StmtNodes.td $(TBLGEN) \ + $(ObjDir)/.dir $(Echo) "Building Clang statement node tables with tblgen" $(Verb) $(TableGen) -gen-clang-stmt-nodes -o $(call SYSPATH, $@) $< +$(ObjDir)/DeclNodes.inc.tmp : $(TD_SRC_DIR)/DeclNodes.td $(TBLGEN) \ + $(ObjDir)/.dir + $(Echo) "Building Clang declaration node tables with tblgen" + $(Verb) $(TableGen) -gen-clang-decl-nodes -o $(call SYSPATH, $@) $< diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index 07865e0eb3f1..0853dddbe9e5 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -29,739 +29,1634 @@ #include "clang/AST/TemplateBase.h" #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" +#include "clang/AST/TypeLoc.h" + +// The following three macros are used for meta programming. The code +// using them is responsible for defining macro OPERATOR(). + +// All unary operators. +#define UNARYOP_LIST() \ + OPERATOR(PostInc) OPERATOR(PostDec) \ + OPERATOR(PreInc) OPERATOR(PreDec) \ + OPERATOR(AddrOf) OPERATOR(Deref) \ + OPERATOR(Plus) OPERATOR(Minus) \ + OPERATOR(Not) OPERATOR(LNot) \ + OPERATOR(Real) OPERATOR(Imag) \ + OPERATOR(Extension) OPERATOR(OffsetOf) + +// All binary operators (excluding compound assign operators). +#define BINOP_LIST() \ + OPERATOR(PtrMemD) OPERATOR(PtrMemI) \ + OPERATOR(Mul) OPERATOR(Div) OPERATOR(Rem) \ + OPERATOR(Add) OPERATOR(Sub) OPERATOR(Shl) \ + OPERATOR(Shr) \ + \ + OPERATOR(LT) OPERATOR(GT) OPERATOR(LE) \ + OPERATOR(GE) OPERATOR(EQ) OPERATOR(NE) \ + OPERATOR(And) OPERATOR(Xor) OPERATOR(Or) \ + OPERATOR(LAnd) OPERATOR(LOr) \ + \ + OPERATOR(Assign) \ + OPERATOR(Comma) + +// All compound assign operators. +#define CAO_LIST() \ + OPERATOR(Mul) OPERATOR(Div) OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) \ + OPERATOR(Shl) OPERATOR(Shr) OPERATOR(And) OPERATOR(Or) OPERATOR(Xor) namespace clang { -#define DISPATCH(NAME, CLASS, Var) \ -return getDerived().Visit ## NAME(static_cast(Var)) - -// We use preprocessor meta-programming to generate the Visit*() -// methods for all subclasses of Stmt, Decl, and Type. Some of the -// generated definitions, however, need to be customized. The -// meta-programming technique we use doesn't let us select which -// methods to generate. Therefore we have to generate ALL of them in -// a helper class RecursiveASTVisitorImpl, and override the ones we -// don't like in a child class RecursiveASTVisitor (C++ doesn't allow -// overriding a method in the same class). -// -// Do not use this class directly - use RecursiveASTVisitor instead. +// A helper macro to implement short-circuiting when recursing. It +// invokes CALL_EXPR, which must be a method call, on the derived +// object (s.t. a user of RecursiveASTVisitor can override the method +// in CALL_EXPR). +#define TRY_TO(CALL_EXPR) \ + do { if (!getDerived().CALL_EXPR) return false; } while (0) + +/// \brief A class that does preorder depth-first traversal on the +/// entire Clang AST and visits each node. +/// +/// This class performs three distinct tasks: +/// 1. traverse the AST (i.e. go to each node); +/// 2. at a given node, walk up the class hierarchy, starting from +/// the node's dynamic type, until the top-most class (e.g. Stmt, +/// Decl, or Type) is reached. +/// 3. given a (node, class) combination, where 'class' is some base +/// class of the dynamic type of 'node', call a user-overridable +/// function to actually visit the node. +/// +/// These tasks are done by three groups of methods, respectively: +/// 1. TraverseDecl(Decl *x) does task #1. It is the entry point +/// for traversing an AST rooted at x. This method simply +/// dispatches (i.e. forwards) to TraverseFoo(Foo *x) where Foo +/// is the dynamic type of *x, which calls WalkUpFromFoo(x) and +/// then recursively visits the child nodes of x. +/// TraverseStmt(Stmt *x) and TraverseType(QualType x) work +/// similarly. +/// 2. WalkUpFromFoo(Foo *x) does task #2. It does not try to visit +/// any child node of x. Instead, it first calls WalkUpFromBar(x) +/// where Bar is the direct parent class of Foo (unless Foo has +/// no parent), and then calls VisitFoo(x) (see the next list item). +/// 3. VisitFoo(Foo *x) does task #3. +/// +/// These three method groups are tiered (Traverse* > WalkUpFrom* > +/// Visit*). A method (e.g. Traverse*) may call methods from the same +/// tier (e.g. other Traverse*) or one tier lower (e.g. WalkUpFrom*). +/// It may not call methods from a higher tier. +/// +/// Note that since WalkUpFromFoo() calls WalkUpFromBar() (where Bar +/// is Foo's super class) before calling VisitFoo(), the result is +/// that the Visit*() methods for a given node are called in the +/// top-down order (e.g. for a node of type NamedDecl, the order will +/// be VisitDecl(), VisitNamedDecl(), and then VisitNamespaceDecl()). +/// +/// This scheme guarantees that all Visit*() calls for the same AST +/// node are grouped together. In other words, Visit*() methods for +/// different nodes are never interleaved. +/// +/// Clients of this visitor should subclass the visitor (providing +/// themselves as the template argument, using the curiously recurring +/// template pattern) and override any of the Traverse*, WalkUpFrom*, +/// and Visit* methods for declarations, types, statements, +/// expressions, or other AST nodes where the visitor should customize +/// behavior. Most users only need to override Visit*. Advanced +/// users may override Traverse* and WalkUpFrom* to implement custom +/// traversal strategies. Returning false from one of these overridden +/// functions will abort the entire traversal. template -class RecursiveASTVisitorImpl { +class RecursiveASTVisitor { public: /// \brief Return a reference to the derived class. Derived &getDerived() { return *static_cast(this); } /// \brief Recursively visit a statement or expression, by - /// dispatching to Visit*() based on the argument's dynamic type. - /// This is NOT meant to be overridden by a subclass. + /// dispatching to Traverse*() based on the argument's dynamic type. /// - /// \returns true if the visitation was terminated early, false + /// \returns false if the visitation was terminated early, true /// otherwise (including when the argument is NULL). - bool Visit(Stmt *S); + bool TraverseStmt(Stmt *S); /// \brief Recursively visit a type, by dispatching to - /// Visit*Type() based on the argument's getTypeClass() property. - /// This is NOT meant to be overridden by a subclass. + /// Traverse*Type() based on the argument's getTypeClass() property. /// - /// \returns true if the visitation was terminated early, false + /// \returns false if the visitation was terminated early, true /// otherwise (including when the argument is a Null type). - bool Visit(QualType T); + bool TraverseType(QualType T); + + /// \brief Recursively visit a type with location, by dispatching to + /// Traverse*TypeLoc() based on the argument type's getTypeClass() property. + /// + /// \returns false if the visitation was terminated early, true + /// otherwise (including when the argument is a Null type location). + bool TraverseTypeLoc(TypeLoc TL); /// \brief Recursively visit a declaration, by dispatching to - /// Visit*Decl() based on the argument's dynamic type. This is - /// NOT meant to be overridden by a subclass. + /// Traverse*Decl() based on the argument's dynamic type. /// - /// \returns true if the visitation was terminated early, false + /// \returns false if the visitation was terminated early, true /// otherwise (including when the argument is NULL). - bool Visit(Decl *D); + bool TraverseDecl(Decl *D); /// \brief Recursively visit a C++ nested-name-specifier. /// - /// \returns true if the visitation was terminated early, false otherwise. - bool VisitNestedNameSpecifier(NestedNameSpecifier *NNS); + /// \returns false if the visitation was terminated early, true otherwise. + bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS); - /// \brief Recursively visit a template name. + /// \brief Recursively visit a template name and dispatch to the + /// appropriate method. /// - /// \returns true if the visitation was terminated early, false otherwise. - bool VisitTemplateName(TemplateName Template); + /// \returns false if the visitation was terminated early, true otherwise. + bool TraverseTemplateName(TemplateName Template); - /// \brief Recursively visit a template argument. + /// \brief Recursively visit a template argument and dispatch to the + /// appropriate method for the argument type. /// - /// \returns true if the visitation was terminated early, false otherwise. - bool VisitTemplateArgument(const TemplateArgument &Arg); + /// \returns false if the visitation was terminated early, true otherwise. + // FIXME: migrate callers to TemplateArgumentLoc instead. + bool TraverseTemplateArgument(const TemplateArgument &Arg); - /// \brief Recursively visit a set of template arguments. + /// \brief Recursively visit a template argument location and dispatch to the + /// appropriate method for the argument type. /// - /// \returns true if the visitation was terminated early, false otherwise. - bool VisitTemplateArguments(const TemplateArgument *Args, unsigned NumArgs); - - // If the implementation chooses not to implement a certain visit method, fall - // back on VisitExpr or whatever else is the superclass. -#define STMT(CLASS, PARENT) \ -bool Visit ## CLASS(CLASS *S) { DISPATCH(PARENT, PARENT, S); } -#include "clang/AST/StmtNodes.inc" + /// \returns false if the visitation was terminated early, true otherwise. + bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc); - // If the implementation doesn't implement binary operator methods, fall back - // on VisitBinaryOperator. -#define BINOP_FALLBACK(NAME) \ -bool VisitBin ## NAME(BinaryOperator *S) { \ -DISPATCH(BinaryOperator, BinaryOperator, S); \ -} - BINOP_FALLBACK(PtrMemD) BINOP_FALLBACK(PtrMemI) - BINOP_FALLBACK(Mul) BINOP_FALLBACK(Div) BINOP_FALLBACK(Rem) - BINOP_FALLBACK(Add) BINOP_FALLBACK(Sub) BINOP_FALLBACK(Shl) - BINOP_FALLBACK(Shr) - - BINOP_FALLBACK(LT) BINOP_FALLBACK(GT) BINOP_FALLBACK(LE) - BINOP_FALLBACK(GE) BINOP_FALLBACK(EQ) BINOP_FALLBACK(NE) - BINOP_FALLBACK(And) BINOP_FALLBACK(Xor) BINOP_FALLBACK(Or) - BINOP_FALLBACK(LAnd) BINOP_FALLBACK(LOr) - - BINOP_FALLBACK(Assign) - BINOP_FALLBACK(Comma) -#undef BINOP_FALLBACK - - // If the implementation doesn't implement compound assignment operator - // methods, fall back on VisitCompoundAssignOperator. -#define CAO_FALLBACK(NAME) \ -bool VisitBin ## NAME(CompoundAssignOperator *S) { \ -DISPATCH(CompoundAssignOperator, CompoundAssignOperator, S); \ -} - CAO_FALLBACK(MulAssign) CAO_FALLBACK(DivAssign) CAO_FALLBACK(RemAssign) - CAO_FALLBACK(AddAssign) CAO_FALLBACK(SubAssign) CAO_FALLBACK(ShlAssign) - CAO_FALLBACK(ShrAssign) CAO_FALLBACK(AndAssign) CAO_FALLBACK(OrAssign) - CAO_FALLBACK(XorAssign) -#undef CAO_FALLBACK - - // If the implementation doesn't implement unary operator methods, fall back - // on VisitUnaryOperator. -#define UNARYOP_FALLBACK(NAME) \ -bool VisitUnary ## NAME(UnaryOperator *S) { \ -DISPATCH(UnaryOperator, UnaryOperator, S); \ -} - UNARYOP_FALLBACK(PostInc) UNARYOP_FALLBACK(PostDec) - UNARYOP_FALLBACK(PreInc) UNARYOP_FALLBACK(PreDec) - UNARYOP_FALLBACK(AddrOf) UNARYOP_FALLBACK(Deref) - - UNARYOP_FALLBACK(Plus) UNARYOP_FALLBACK(Minus) - UNARYOP_FALLBACK(Not) UNARYOP_FALLBACK(LNot) - UNARYOP_FALLBACK(Real) UNARYOP_FALLBACK(Imag) - UNARYOP_FALLBACK(Extension) UNARYOP_FALLBACK(OffsetOf) -#undef UNARYOP_FALLBACK - - /// \brief Basis for statement and expression visitation, which - /// visits all of the substatements and subexpressions. + /// \brief Recursively visit a set of template arguments. + /// This can be overridden by a subclass, but it's not expected that + /// will be needed -- this visitor always dispatches to another. /// - /// The relation between Visit(Stmt *S) and this method is that - /// the former dispatches to Visit*() based on S's dynamic type, - /// which forwards the call up the inheritance chain until - /// reaching VisitStmt(), which then calls Visit() on each - /// substatement/subexpression. - bool VisitStmt(Stmt *S); - - /// \brief Basis for type visitation, which by default does nothing. + /// \returns false if the visitation was terminated early, true otherwise. + // FIXME: take a TemplateArgumentLoc* (or TemplateArgumentListInfo) instead. + bool TraverseTemplateArguments(const TemplateArgument *Args, + unsigned NumArgs); + + /// \brief Recursively visit a constructor initializer. This + /// automatically dispatches to another visitor for the initializer + /// expression, but not for the name of the initializer, so may + /// be overridden for clients that need access to the name. /// - /// The relation between Visit(QualType T) and this method is - /// that the former dispatches to Visit*Type(), which forwards the - /// call up the inheritance chain until reaching VisitType(). - bool VisitType(Type *T); + /// \returns false if the visitation was terminated early, true otherwise. + bool TraverseConstructorInitializer(CXXBaseOrMemberInitializer *Init); + + // ---- Methods on Stmts ---- -#define TYPE(Class, Base) \ - bool Visit##Class##Type(Class##Type *T); + // Declare Traverse*() for all concrete Stmt classes. +#define ABSTRACT_STMT(STMT) +#define STMT(CLASS, PARENT) \ + bool Traverse##CLASS(CLASS *S); +#include "clang/AST/StmtNodes.inc" + // The above header #undefs ABSTRACT_STMT and STMT upon exit. + + // Define WalkUpFrom*() and empty Visit*() for all Stmt classes. + bool WalkUpFromStmt(Stmt *S) { return getDerived().VisitStmt(S); } + bool VisitStmt(Stmt *S) { return true; } +#define STMT(CLASS, PARENT) \ + bool WalkUpFrom##CLASS(CLASS *S) { \ + TRY_TO(WalkUpFrom##PARENT(S)); \ + TRY_TO(Visit##CLASS(S)); \ + return true; \ + } \ + bool Visit##CLASS(CLASS *S) { return true; } +#include "clang/AST/StmtNodes.inc" + + // Define Traverse*(), WalkUpFrom*(), and Visit*() for unary + // operator methods. Unary operators are not classes in themselves + // (they're all opcodes in UnaryOperator) but do have visitors. +#define OPERATOR(NAME) \ + bool TraverseUnary##NAME(UnaryOperator *S) { \ + TRY_TO(WalkUpFromUnary##NAME(S)); \ + TRY_TO(TraverseStmt(S->getSubExpr())); \ + return true; \ + } \ + bool WalkUpFromUnary##NAME(UnaryOperator *S) { \ + TRY_TO(WalkUpFromUnaryOperator(S)); \ + TRY_TO(VisitUnary##NAME(S)); \ + return true; \ + } \ + bool VisitUnary##NAME(UnaryOperator *S) { return true; } + + UNARYOP_LIST() +#undef OPERATOR + + // Define Traverse*(), WalkUpFrom*(), and Visit*() for binary + // operator methods. Binary operators are not classes in themselves + // (they're all opcodes in BinaryOperator) but do have visitors. +#define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE) \ + bool TraverseBin##NAME(BINOP_TYPE *S) { \ + TRY_TO(WalkUpFromBin##NAME(S)); \ + TRY_TO(TraverseStmt(S->getLHS())); \ + TRY_TO(TraverseStmt(S->getRHS())); \ + return true; \ + } \ + bool WalkUpFromBin##NAME(BINOP_TYPE *S) { \ + TRY_TO(WalkUpFrom##BINOP_TYPE(S)); \ + TRY_TO(VisitBin##NAME(S)); \ + return true; \ + } \ + bool VisitBin##NAME(BINOP_TYPE *S) { return true; } + +#define OPERATOR(NAME) GENERAL_BINOP_FALLBACK(NAME, BinaryOperator) + BINOP_LIST() +#undef OPERATOR + + // Define Traverse*(), WalkUpFrom*(), and Visit*() for compound + // assignment methods. Compound assignment operators are not + // classes in themselves (they're all opcodes in + // CompoundAssignOperator) but do have visitors. +#define OPERATOR(NAME) \ + GENERAL_BINOP_FALLBACK(NAME##Assign, CompoundAssignOperator) + + CAO_LIST() +#undef OPERATOR +#undef GENERAL_BINOP_FALLBACK + + // ---- Methods on Types ---- + // FIXME: revamp to take TypeLoc's rather than Types. + + // Declare Traverse*() for all concrete Type classes. +#define ABSTRACT_TYPE(CLASS, BASE) +#define TYPE(CLASS, BASE) \ + bool Traverse##CLASS##Type(CLASS##Type *T); +#include "clang/AST/TypeNodes.def" + // The above header #undefs ABSTRACT_TYPE and TYPE upon exit. + + // Define WalkUpFrom*() and empty Visit*() for all Type classes. + bool WalkUpFromType(Type *T) { return getDerived().VisitType(T); } + bool VisitType(Type *T) { return true; } +#define TYPE(CLASS, BASE) \ + bool WalkUpFrom##CLASS##Type(CLASS##Type *T) { \ + TRY_TO(WalkUpFrom##BASE(T)); \ + TRY_TO(Visit##CLASS##Type(T)); \ + return true; \ + } \ + bool Visit##CLASS##Type(CLASS##Type *T) { return true; } #include "clang/AST/TypeNodes.def" - /// \brief Basis for declaration and definition visitation, which - /// visits all of the subnodes. - /// - /// The relation between Visit(Decl *) and this method is that the - /// former dispatches to Visit*Decl(), which forwards the call up - /// the inheritance chain until reaching VisitDecl(). - bool VisitDecl(Decl *D); - -#define DECL(Class, Base) \ - bool Visit##Class##Decl(Class##Decl *D) { \ - return getDerived().Visit##Base(D); \ + // ---- Methods on TypeLocs ---- + // FIXME: this currently just calls the matching Type methods + + // Declare Traverse*() for all concrete Type classes. +#define ABSTRACT_TYPELOC(CLASS, BASE) +#define TYPELOC(CLASS, BASE) \ + bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL); +#include "clang/AST/TypeLocNodes.def" + // The above header #undefs ABSTRACT_TYPELOC and TYPELOC upon exit. + + // Define WalkUpFrom*() and empty Visit*() for all TypeLoc classes. + bool WalkUpFromTypeLoc(TypeLoc TL) { return getDerived().VisitTypeLoc(TL); } + bool VisitTypeLoc(TypeLoc TL) { return true; } + + // QualifiedTypeLoc and UnqualTypeLoc are not declared in + // TypeNodes.def and thus need to be handled specially. + bool WalkUpFromQualifiedTypeLoc(QualifiedTypeLoc TL) { + return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc()); } -#define ABSTRACT_DECL(Class, Base) DECL(Class, Base) -#include "clang/AST/DeclNodes.def" + bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { return true; } + bool WalkUpFromUnqualTypeLoc(UnqualTypeLoc TL) { + return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc()); + } + bool VisitUnqualTypeLoc(UnqualTypeLoc TL) { return true; } + + // Note that BASE includes trailing 'Type' which CLASS doesn't. +#define TYPE(CLASS, BASE) \ + bool WalkUpFrom##CLASS##TypeLoc(CLASS##TypeLoc TL) { \ + TRY_TO(WalkUpFrom##BASE##Loc(TL)); \ + TRY_TO(Visit##CLASS##TypeLoc(TL)); \ + return true; \ + } \ + bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; } +#include "clang/AST/TypeNodes.def" + + // ---- Methods on Decls ---- + + // Declare Traverse*() for all concrete Decl classes. +#define ABSTRACT_DECL(DECL) +#define DECL(CLASS, BASE) \ + bool Traverse##CLASS##Decl(CLASS##Decl *D); +#include "clang/AST/DeclNodes.inc" + // The above header #undefs ABSTRACT_DECL and DECL upon exit. + + // Define WalkUpFrom*() and empty Visit*() for all Decl classes. + bool WalkUpFromDecl(Decl *D) { return getDerived().VisitDecl(D); } + bool VisitDecl(Decl *D) { return true; } +#define DECL(CLASS, BASE) \ + bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \ + TRY_TO(WalkUpFrom##BASE(D)); \ + TRY_TO(Visit##CLASS##Decl(D)); \ + return true; \ + } \ + bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; } +#include "clang/AST/DeclNodes.inc" + +private: + // These are helper methods used by more than one Traverse* method. + bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL); + bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL, + unsigned Count); + bool TraverseRecordHelper(RecordDecl *D); + bool TraverseCXXRecordHelper(CXXRecordDecl *D); + bool TraverseDeclaratorHelper(DeclaratorDecl *D); + bool TraverseDeclContextHelper(DeclContext *DC); + bool TraverseFunctionHelper(FunctionDecl *D); + bool TraverseVarHelper(VarDecl *D); }; +#define DISPATCH(NAME, CLASS, VAR) \ + return getDerived().Traverse##NAME(static_cast(VAR)) + template -bool RecursiveASTVisitorImpl::Visit(Stmt *S) { +bool RecursiveASTVisitor::TraverseStmt(Stmt *S) { if (!S) - return false; + return true; // If we have a binary expr, dispatch to the subcode of the binop. A smart // optimizer (e.g. LLVM) will fold this comparison into the switch stmt // below. if (BinaryOperator *BinOp = dyn_cast(S)) { switch (BinOp->getOpcode()) { - case BinaryOperator::PtrMemD: DISPATCH(BinPtrMemD, BinaryOperator, S); - case BinaryOperator::PtrMemI: DISPATCH(BinPtrMemI, BinaryOperator, S); - case BinaryOperator::Mul: DISPATCH(BinMul, BinaryOperator, S); - case BinaryOperator::Div: DISPATCH(BinDiv, BinaryOperator, S); - case BinaryOperator::Rem: DISPATCH(BinRem, BinaryOperator, S); - case BinaryOperator::Add: DISPATCH(BinAdd, BinaryOperator, S); - case BinaryOperator::Sub: DISPATCH(BinSub, BinaryOperator, S); - case BinaryOperator::Shl: DISPATCH(BinShl, BinaryOperator, S); - case BinaryOperator::Shr: DISPATCH(BinShr, BinaryOperator, S); - - case BinaryOperator::LT: DISPATCH(BinLT, BinaryOperator, S); - case BinaryOperator::GT: DISPATCH(BinGT, BinaryOperator, S); - case BinaryOperator::LE: DISPATCH(BinLE, BinaryOperator, S); - case BinaryOperator::GE: DISPATCH(BinGE, BinaryOperator, S); - case BinaryOperator::EQ: DISPATCH(BinEQ, BinaryOperator, S); - case BinaryOperator::NE: DISPATCH(BinNE, BinaryOperator, S); - - case BinaryOperator::And: DISPATCH(BinAnd, BinaryOperator, S); - case BinaryOperator::Xor: DISPATCH(BinXor, BinaryOperator, S); - case BinaryOperator::Or : DISPATCH(BinOr, BinaryOperator, S); - case BinaryOperator::LAnd: DISPATCH(BinLAnd, BinaryOperator, S); - case BinaryOperator::LOr : DISPATCH(BinLOr, BinaryOperator, S); - case BinaryOperator::Assign: DISPATCH(BinAssign, BinaryOperator, S); - case BinaryOperator::MulAssign: - DISPATCH(BinMulAssign, CompoundAssignOperator, S); - case BinaryOperator::DivAssign: - DISPATCH(BinDivAssign, CompoundAssignOperator, S); - case BinaryOperator::RemAssign: - DISPATCH(BinRemAssign, CompoundAssignOperator, S); - case BinaryOperator::AddAssign: - DISPATCH(BinAddAssign, CompoundAssignOperator, S); - case BinaryOperator::SubAssign: - DISPATCH(BinSubAssign, CompoundAssignOperator, S); - case BinaryOperator::ShlAssign: - DISPATCH(BinShlAssign, CompoundAssignOperator, S); - case BinaryOperator::ShrAssign: - DISPATCH(BinShrAssign, CompoundAssignOperator, S); - case BinaryOperator::AndAssign: - DISPATCH(BinAndAssign, CompoundAssignOperator, S); - case BinaryOperator::OrAssign: - DISPATCH(BinOrAssign, CompoundAssignOperator, S); - case BinaryOperator::XorAssign: - DISPATCH(BinXorAssign, CompoundAssignOperator, S); - case BinaryOperator::Comma: DISPATCH(BinComma, BinaryOperator, S); +#define OPERATOR(NAME) \ + case BinaryOperator::NAME: DISPATCH(Bin##PtrMemD, BinaryOperator, S); + + BINOP_LIST() +#undef OPERATOR +#undef BINOP_LIST + +#define OPERATOR(NAME) \ + case BinaryOperator::NAME##Assign: \ + DISPATCH(Bin##NAME##Assign, CompoundAssignOperator, S); + + CAO_LIST() +#undef OPERATOR +#undef CAO_LIST } } else if (UnaryOperator *UnOp = dyn_cast(S)) { switch (UnOp->getOpcode()) { - case UnaryOperator::PostInc: DISPATCH(UnaryPostInc, UnaryOperator, S); - case UnaryOperator::PostDec: DISPATCH(UnaryPostDec, UnaryOperator, S); - case UnaryOperator::PreInc: DISPATCH(UnaryPreInc, UnaryOperator, S); - case UnaryOperator::PreDec: DISPATCH(UnaryPreDec, UnaryOperator, S); - case UnaryOperator::AddrOf: DISPATCH(UnaryAddrOf, UnaryOperator, S); - case UnaryOperator::Deref: DISPATCH(UnaryDeref, UnaryOperator, S); - case UnaryOperator::Plus: DISPATCH(UnaryPlus, UnaryOperator, S); - case UnaryOperator::Minus: DISPATCH(UnaryMinus, UnaryOperator, S); - case UnaryOperator::Not: DISPATCH(UnaryNot, UnaryOperator, S); - case UnaryOperator::LNot: DISPATCH(UnaryLNot, UnaryOperator, S); - case UnaryOperator::Real: DISPATCH(UnaryReal, UnaryOperator, S); - case UnaryOperator::Imag: DISPATCH(UnaryImag, UnaryOperator, S); - case UnaryOperator::Extension: DISPATCH(UnaryExtension, UnaryOperator, S); - case UnaryOperator::OffsetOf: DISPATCH(UnaryOffsetOf, UnaryOperator, S); +#define OPERATOR(NAME) \ + case UnaryOperator::NAME: DISPATCH(Unary##NAME, UnaryOperator, S); + + UNARYOP_LIST() +#undef OPERATOR +#undef UNARYOP_LIST } } - // Top switch stmt: dispatch to VisitFooStmt for each FooStmt. + // Top switch stmt: dispatch to TraverseFooStmt for each concrete FooStmt. switch (S->getStmtClass()) { case Stmt::NoStmtClass: break; #define ABSTRACT_STMT(STMT) -#define STMT(CLASS, PARENT) \ -case Stmt::CLASS ## Class: DISPATCH(CLASS, CLASS, S); +#define STMT(CLASS, PARENT) \ + case Stmt::CLASS##Class: DISPATCH(CLASS, CLASS, S); #include "clang/AST/StmtNodes.inc" } - return false; + return true; } template -bool RecursiveASTVisitorImpl::Visit(QualType T) { +bool RecursiveASTVisitor::TraverseType(QualType T) { if (T.isNull()) - return false; + return true; switch (T->getTypeClass()) { -#define ABSTRACT_TYPE(Class, Base) -#define TYPE(Class, Base) \ - case Type::Class: DISPATCH(Class##Type, Class##Type, T.getTypePtr()); +#define ABSTRACT_TYPE(CLASS, BASE) +#define TYPE(CLASS, BASE) \ + case Type::CLASS: DISPATCH(CLASS##Type, CLASS##Type, T.getTypePtr()); #include "clang/AST/TypeNodes.def" } - return false; + return true; } template -bool RecursiveASTVisitorImpl::Visit(Decl *D) { +bool RecursiveASTVisitor::TraverseTypeLoc(TypeLoc TL) { + if (TL.isNull()) + return true; + + switch (TL.getTypeLocClass()) { +#define ABSTRACT_TYPELOC(CLASS, BASE) +#define TYPELOC(CLASS, BASE) \ + case TypeLoc::CLASS: \ + return getDerived().Traverse##CLASS##TypeLoc(*cast(&TL)); +#include "clang/AST/TypeLocNodes.def" + } + + return true; +} + + +template +bool RecursiveASTVisitor::TraverseDecl(Decl *D) { if (!D) - return false; + return true; + + // As a syntax visitor, we want to ignore declarations for + // implicitly-defined declarations (ones not typed explicitly by the + // user). + if (D->isImplicit()) + return true; switch (D->getKind()) { -#define ABSTRACT_DECL(Class, Base) -#define DECL(Class, Base) \ - case Decl::Class: DISPATCH(Class##Decl, Class##Decl, D); -#include "clang/AST/DeclNodes.def" - } +#define ABSTRACT_DECL(DECL) +#define DECL(CLASS, BASE) \ + case Decl::CLASS: DISPATCH(CLASS##Decl, CLASS##Decl, D); +#include "clang/AST/DeclNodes.inc" + } - return false; + return true; } +#undef DISPATCH + template -bool RecursiveASTVisitorImpl::VisitNestedNameSpecifier( +bool RecursiveASTVisitor::TraverseNestedNameSpecifier( NestedNameSpecifier *NNS) { - if (NNS->getPrefix() && - getDerived().VisitNestedNameSpecifier(NNS->getPrefix())) + if (!NNS) return true; + if (NNS->getPrefix()) + TRY_TO(TraverseNestedNameSpecifier(NNS->getPrefix())); + switch (NNS->getKind()) { case NestedNameSpecifier::Identifier: case NestedNameSpecifier::Namespace: case NestedNameSpecifier::Global: - return false; + return true; case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpecWithTemplate: - return Visit(QualType(NNS->getAsType(), 0)); + TRY_TO(TraverseType(QualType(NNS->getAsType(), 0))); } - return false; + return true; } template -bool RecursiveASTVisitorImpl::VisitTemplateName(TemplateName Template) { +bool RecursiveASTVisitor::TraverseTemplateName(TemplateName Template) { if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) - return DTN->getQualifier() && - getDerived().VisitNestedNameSpecifier(DTN->getQualifier()); - - if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName()) - return getDerived().VisitNestedNameSpecifier(QTN->getQualifier()); + TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier())); + else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName()) + TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier())); - return false; + return true; } template -bool RecursiveASTVisitorImpl::VisitTemplateArgument( +bool RecursiveASTVisitor::TraverseTemplateArgument( const TemplateArgument &Arg) { switch (Arg.getKind()) { case TemplateArgument::Null: case TemplateArgument::Declaration: case TemplateArgument::Integral: - return false; + return true; case TemplateArgument::Type: - return Visit(Arg.getAsType()); + return getDerived().TraverseType(Arg.getAsType()); case TemplateArgument::Template: - return getDerived().VisitTemplateName(Arg.getAsTemplate()); + return getDerived().TraverseTemplateName(Arg.getAsTemplate()); case TemplateArgument::Expression: - return getDerived().Visit(Arg.getAsExpr()); + return getDerived().TraverseStmt(Arg.getAsExpr()); case TemplateArgument::Pack: - return getDerived().VisitTemplateArguments(Arg.pack_begin(), - Arg.pack_size()); + return getDerived().TraverseTemplateArguments(Arg.pack_begin(), + Arg.pack_size()); } - return false; + return true; } +// FIXME: no template name location? +// FIXME: no source locations for a template argument pack? template -bool RecursiveASTVisitorImpl::VisitTemplateArguments( - const TemplateArgument *Args, - unsigned NumArgs) { - for (unsigned I = 0; I != NumArgs; ++I) - if (getDerived().VisitTemplateArgument(Args[I])) - return true; +bool RecursiveASTVisitor::TraverseTemplateArgumentLoc( + const TemplateArgumentLoc &ArgLoc) { + const TemplateArgument &Arg = ArgLoc.getArgument(); - return false; -} + switch (Arg.getKind()) { + case TemplateArgument::Null: + case TemplateArgument::Declaration: + case TemplateArgument::Integral: + return true; -template -bool RecursiveASTVisitorImpl::VisitStmt(Stmt *Node) { - for (Stmt::child_iterator C = Node->child_begin(), CEnd = Node->child_end(); - C != CEnd; ++C) { - if (Visit(*C)) - return true; + case TemplateArgument::Type: { + TypeSourceInfo *TSI = ArgLoc.getTypeSourceInfo(); + return getDerived().TraverseTypeLoc(TSI->getTypeLoc()); } - return false; + case TemplateArgument::Template: + return getDerived().TraverseTemplateName(Arg.getAsTemplate()); + + case TemplateArgument::Expression: + return getDerived().TraverseStmt(ArgLoc.getSourceExpression()); + + case TemplateArgument::Pack: + return getDerived().TraverseTemplateArguments(Arg.pack_begin(), + Arg.pack_size()); + } + + return true; } template -bool RecursiveASTVisitorImpl::VisitType(Type *T) { - return false; +bool RecursiveASTVisitor::TraverseTemplateArguments( + const TemplateArgument *Args, + unsigned NumArgs) { + for (unsigned I = 0; I != NumArgs; ++I) { + TRY_TO(TraverseTemplateArgument(Args[I])); + } + + return true; } template -bool RecursiveASTVisitorImpl::VisitBuiltinType(BuiltinType *T) { - return getDerived().VisitType(T); +bool RecursiveASTVisitor::TraverseConstructorInitializer( + CXXBaseOrMemberInitializer *Init) { + // FIXME: recurse on TypeLoc of the base initializer if isBaseInitializer()? + if (Init->isWritten()) + TRY_TO(TraverseStmt(Init->getInit())); + return true; } -template -bool RecursiveASTVisitorImpl::VisitComplexType(ComplexType *T) { - if (Visit(T->getElementType())) - return true; - return getDerived().VisitType(T); -} +// ----------------- Type traversal ----------------- -template -bool RecursiveASTVisitorImpl::VisitPointerType(PointerType *T) { - if (Visit(T->getPointeeType())) - return true; +// This macro makes available a variable T, the passed-in type. +#define DEF_TRAVERSE_TYPE(TYPE, CODE) \ + template \ + bool RecursiveASTVisitor::Traverse##TYPE (TYPE *T) { \ + TRY_TO(WalkUpFrom##TYPE (T)); \ + { CODE; } \ + return true; \ + } - return getDerived().VisitType(T); -} +DEF_TRAVERSE_TYPE(BuiltinType, { }) -template -bool RecursiveASTVisitorImpl::VisitBlockPointerType( - BlockPointerType *T) { - if (Visit(T->getPointeeType())) - return true; +DEF_TRAVERSE_TYPE(ComplexType, { + TRY_TO(TraverseType(T->getElementType())); + }) - return getDerived().VisitType(T); -} +DEF_TRAVERSE_TYPE(PointerType, { + TRY_TO(TraverseType(T->getPointeeType())); + }) -template -bool RecursiveASTVisitorImpl::VisitReferenceType(ReferenceType *T) { - if (Visit(T->getPointeeType())) - return true; +DEF_TRAVERSE_TYPE(BlockPointerType, { + TRY_TO(TraverseType(T->getPointeeType())); + }) - return getDerived().VisitType(T); -} +DEF_TRAVERSE_TYPE(LValueReferenceType, { + TRY_TO(TraverseType(T->getPointeeType())); + }) -template -bool RecursiveASTVisitorImpl::VisitLValueReferenceType( - LValueReferenceType *T) { - return getDerived().VisitReferenceType(T); -} +DEF_TRAVERSE_TYPE(RValueReferenceType, { + TRY_TO(TraverseType(T->getPointeeType())); + }) -template -bool RecursiveASTVisitorImpl::VisitRValueReferenceType( - RValueReferenceType *T) { - return getDerived().VisitReferenceType(T); -} +DEF_TRAVERSE_TYPE(MemberPointerType, { + TRY_TO(TraverseType(QualType(T->getClass(), 0))); + TRY_TO(TraverseType(T->getPointeeType())); + }) -template -bool RecursiveASTVisitorImpl::VisitMemberPointerType( - MemberPointerType *T) { - if (Visit(QualType(T->getClass(), 0)) || Visit(T->getPointeeType())) - return true; +DEF_TRAVERSE_TYPE(ConstantArrayType, { + TRY_TO(TraverseType(T->getElementType())); + }) - return getDerived().VisitType(T); -} +DEF_TRAVERSE_TYPE(IncompleteArrayType, { + TRY_TO(TraverseType(T->getElementType())); + }) -template -bool RecursiveASTVisitorImpl::VisitArrayType(ArrayType *T) { - if (Visit(T->getElementType())) - return true; +DEF_TRAVERSE_TYPE(VariableArrayType, { + TRY_TO(TraverseType(T->getElementType())); + TRY_TO(TraverseStmt(T->getSizeExpr())); + }) - return getDerived().VisitType(T); -} +DEF_TRAVERSE_TYPE(DependentSizedArrayType, { + TRY_TO(TraverseType(T->getElementType())); + if (T->getSizeExpr()) + TRY_TO(TraverseStmt(T->getSizeExpr())); + }) -template -bool RecursiveASTVisitorImpl::VisitConstantArrayType( - ConstantArrayType *T) { - return getDerived().VisitArrayType(T); -} +DEF_TRAVERSE_TYPE(DependentSizedExtVectorType, { + if (T->getSizeExpr()) + TRY_TO(TraverseStmt(T->getSizeExpr())); + TRY_TO(TraverseType(T->getElementType())); + }) -template -bool RecursiveASTVisitorImpl::VisitIncompleteArrayType( - IncompleteArrayType *T) { - return getDerived().VisitArrayType(T); -} +DEF_TRAVERSE_TYPE(VectorType, { + TRY_TO(TraverseType(T->getElementType())); + }) -template -bool RecursiveASTVisitorImpl::VisitVariableArrayType( - VariableArrayType *T) { - if (Visit(T->getSizeExpr())) - return true; +DEF_TRAVERSE_TYPE(ExtVectorType, { + TRY_TO(TraverseType(T->getElementType())); + }) - return getDerived().VisitArrayType(T); -} +DEF_TRAVERSE_TYPE(FunctionNoProtoType, { + TRY_TO(TraverseType(T->getResultType())); + }) -template -bool RecursiveASTVisitorImpl::VisitDependentSizedArrayType( - DependentSizedArrayType *T) { - if (T->getSizeExpr() && Visit(T->getSizeExpr())) - return true; +DEF_TRAVERSE_TYPE(FunctionProtoType, { + TRY_TO(TraverseType(T->getResultType())); - return getDerived().VisitArrayType(T); -} + for (FunctionProtoType::arg_type_iterator A = T->arg_type_begin(), + AEnd = T->arg_type_end(); + A != AEnd; ++A) { + TRY_TO(TraverseType(*A)); + } -template -bool RecursiveASTVisitorImpl::VisitDependentSizedExtVectorType( - DependentSizedExtVectorType *T) { - if ((T->getSizeExpr() && Visit(T->getSizeExpr())) || - Visit(T->getElementType())) - return true; + for (FunctionProtoType::exception_iterator E = T->exception_begin(), + EEnd = T->exception_end(); + E != EEnd; ++E) { + TRY_TO(TraverseType(*E)); + } + }) - return getDerived().VisitType(T); -} +DEF_TRAVERSE_TYPE(UnresolvedUsingType, { }) +DEF_TRAVERSE_TYPE(TypedefType, { }) -template -bool RecursiveASTVisitorImpl::VisitVectorType(VectorType *T) { - if (Visit(T->getElementType())) - return true; +DEF_TRAVERSE_TYPE(TypeOfExprType, { + TRY_TO(TraverseStmt(T->getUnderlyingExpr())); + }) - return getDerived().VisitType(T); -} +DEF_TRAVERSE_TYPE(TypeOfType, { + TRY_TO(TraverseType(T->getUnderlyingType())); + }) -template -bool RecursiveASTVisitorImpl::VisitExtVectorType(ExtVectorType *T) { - return getDerived().VisitVectorType(T); -} +DEF_TRAVERSE_TYPE(DecltypeType, { + TRY_TO(TraverseStmt(T->getUnderlyingExpr())); + }) -template -bool RecursiveASTVisitorImpl::VisitFunctionType(FunctionType *T) { - if (Visit(T->getResultType())) - return true; +DEF_TRAVERSE_TYPE(RecordType, { }) +DEF_TRAVERSE_TYPE(EnumType, { }) +DEF_TRAVERSE_TYPE(TemplateTypeParmType, { }) +DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, { }) - return getDerived().VisitType(T); -} +DEF_TRAVERSE_TYPE(TemplateSpecializationType, { + TRY_TO(TraverseTemplateName(T->getTemplateName())); + TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs())); + }) + +DEF_TRAVERSE_TYPE(InjectedClassNameType, { }) + +DEF_TRAVERSE_TYPE(ElaboratedType, { + if (T->getQualifier()) { + TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); + } + TRY_TO(TraverseType(T->getNamedType())); + }) + +DEF_TRAVERSE_TYPE(DependentNameType, { + TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); + }) + +DEF_TRAVERSE_TYPE(DependentTemplateSpecializationType, { + TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); + TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs())); + }) + +DEF_TRAVERSE_TYPE(ObjCInterfaceType, { }) + +DEF_TRAVERSE_TYPE(ObjCObjectType, { + // We have to watch out here because an ObjCInterfaceType's base + // type is itself. + if (T->getBaseType().getTypePtr() != T) + TRY_TO(TraverseType(T->getBaseType())); + }) + +DEF_TRAVERSE_TYPE(ObjCObjectPointerType, { + TRY_TO(TraverseType(T->getPointeeType())); + }) + +#undef DEF_TRAVERSE_TYPE + +// ----------------- TypeLoc traversal ----------------- + +// This macro makes available a variable TL, the passed-in TypeLoc. +// It calls WalkUpFrom* for the Type in the given TypeLoc, in addition +// to WalkUpFrom* for the TypeLoc itself, such that existing clients +// that override the WalkUpFrom*Type() and/or Visit*Type() methods +// continue to work. +#define DEF_TRAVERSE_TYPELOC(TYPE, CODE) \ + template \ + bool RecursiveASTVisitor::Traverse##TYPE##Loc(TYPE##Loc TL) { \ + TRY_TO(WalkUpFrom##TYPE(TL.getTypePtr())); \ + TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \ + { CODE; } \ + return true; \ + } template -bool RecursiveASTVisitorImpl::VisitFunctionNoProtoType( - FunctionNoProtoType *T) { - return getDerived().VisitFunctionType(T); +bool RecursiveASTVisitor::TraverseQualifiedTypeLoc( + QualifiedTypeLoc TL) { + // Move this over to the 'main' typeloc tree. Note that this is a + // move -- we pretend that we were really looking at the unqualified + // typeloc all along -- rather than a recursion, so we don't follow + // the normal CRTP plan of going through + // getDerived().TraverseTypeLoc. If we did, we'd be traversing + // twice for the same type (once as a QualifiedTypeLoc version of + // the type, once as an UnqualifiedTypeLoc version of the type), + // which in effect means we'd call VisitTypeLoc twice with the + // 'same' type. This solves that problem, at the cost of never + // seeing the qualified version of the type (unless the client + // subclasses TraverseQualifiedTypeLoc themselves). It's not a + // perfect solution. A perfect solution probably requires making + // QualifiedTypeLoc a wrapper around TypeLoc -- like QualType is a + // wrapper around Type* -- rather than being its own class in the + // type hierarchy. + return TraverseTypeLoc(TL.getUnqualifiedLoc()); } +DEF_TRAVERSE_TYPELOC(BuiltinType, { }) + +// FIXME: ComplexTypeLoc is unfinished +DEF_TRAVERSE_TYPELOC(ComplexType, { + TRY_TO(TraverseType(TL.getTypePtr()->getElementType())); + }) + +DEF_TRAVERSE_TYPELOC(PointerType, { + TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); + }) + +DEF_TRAVERSE_TYPELOC(BlockPointerType, { + TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); + }) + +DEF_TRAVERSE_TYPELOC(LValueReferenceType, { + TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); + }) + +DEF_TRAVERSE_TYPELOC(RValueReferenceType, { + TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); + }) + +// FIXME: location of base class? +// We traverse this in the type case as well, but how is it not reached through +// the pointee type? +DEF_TRAVERSE_TYPELOC(MemberPointerType, { + TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0))); + TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); + }) + +DEF_TRAVERSE_TYPELOC(ConstantArrayType, { + TRY_TO(TraverseTypeLoc(TL.getElementLoc())); + }) + +DEF_TRAVERSE_TYPELOC(IncompleteArrayType, { + TRY_TO(TraverseTypeLoc(TL.getElementLoc())); + }) + +DEF_TRAVERSE_TYPELOC(VariableArrayType, { + TRY_TO(TraverseTypeLoc(TL.getElementLoc())); + TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr())); + }) + +DEF_TRAVERSE_TYPELOC(DependentSizedArrayType, { + TRY_TO(TraverseTypeLoc(TL.getElementLoc())); + if (TL.getTypePtr()->getSizeExpr()) + TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr())); + }) + +// FIXME: order? why not size expr first? +// FIXME: base VectorTypeLoc is unfinished +DEF_TRAVERSE_TYPELOC(DependentSizedExtVectorType, { + if (TL.getTypePtr()->getSizeExpr()) + TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr())); + TRY_TO(TraverseType(TL.getTypePtr()->getElementType())); + }) + +// FIXME: VectorTypeLoc is unfinished +DEF_TRAVERSE_TYPELOC(VectorType, { + TRY_TO(TraverseType(TL.getTypePtr()->getElementType())); + }) + +// FIXME: size and attributes +// FIXME: base VectorTypeLoc is unfinished +DEF_TRAVERSE_TYPELOC(ExtVectorType, { + TRY_TO(TraverseType(TL.getTypePtr()->getElementType())); + }) + +DEF_TRAVERSE_TYPELOC(FunctionNoProtoType, { + TRY_TO(TraverseTypeLoc(TL.getResultLoc())); + }) + +// FIXME: location of arguments, exception specifications (attributes?) +// Note that we have the ParmVarDecl's here. Do we want to use them? +DEF_TRAVERSE_TYPELOC(FunctionProtoType, { + TRY_TO(TraverseTypeLoc(TL.getResultLoc())); + + FunctionProtoType *T = TL.getTypePtr(); +/* + for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) { + TRY_TO(TraverseDecl(TL.getArg(I))); + } +*/ + for (FunctionProtoType::arg_type_iterator A = T->arg_type_begin(), + AEnd = T->arg_type_end(); + A != AEnd; ++A) { + TRY_TO(TraverseType(*A)); + } + for (FunctionProtoType::exception_iterator E = T->exception_begin(), + EEnd = T->exception_end(); + E != EEnd; ++E) { + TRY_TO(TraverseType(*E)); + } + }) + +DEF_TRAVERSE_TYPELOC(UnresolvedUsingType, { }) +DEF_TRAVERSE_TYPELOC(TypedefType, { }) + +DEF_TRAVERSE_TYPELOC(TypeOfExprType, { + TRY_TO(TraverseStmt(TL.getUnderlyingExpr())); + }) + +DEF_TRAVERSE_TYPELOC(TypeOfType, { + TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc())); + }) + +// FIXME: location of underlying expr +DEF_TRAVERSE_TYPELOC(DecltypeType, { + TRY_TO(TraverseStmt(TL.getTypePtr()->getUnderlyingExpr())); + }) + +DEF_TRAVERSE_TYPELOC(RecordType, { }) +DEF_TRAVERSE_TYPELOC(EnumType, { }) +DEF_TRAVERSE_TYPELOC(TemplateTypeParmType, { }) +DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, { }) + +// FIXME: use the loc for the template name? +DEF_TRAVERSE_TYPELOC(TemplateSpecializationType, { + TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName())); + for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) { + TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I))); + } + }) + +DEF_TRAVERSE_TYPELOC(InjectedClassNameType, { }) + +// FIXME: use the sourceloc on qualifier? +DEF_TRAVERSE_TYPELOC(ElaboratedType, { + if (TL.getTypePtr()->getQualifier()) { + TRY_TO(TraverseNestedNameSpecifier(TL.getTypePtr()->getQualifier())); + } + TRY_TO(TraverseTypeLoc(TL.getNamedTypeLoc())); + }) + +// FIXME: use the sourceloc on qualifier? +DEF_TRAVERSE_TYPELOC(DependentNameType, { + TRY_TO(TraverseNestedNameSpecifier(TL.getTypePtr()->getQualifier())); + }) + +DEF_TRAVERSE_TYPELOC(DependentTemplateSpecializationType, { + TRY_TO(TraverseNestedNameSpecifier(TL.getTypePtr()->getQualifier())); + for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) { + TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I))); + } + }) + +DEF_TRAVERSE_TYPELOC(ObjCInterfaceType, { }) + +DEF_TRAVERSE_TYPELOC(ObjCObjectType, { + // We have to watch out here because an ObjCInterfaceType's base + // type is itself. + if (TL.getTypePtr()->getBaseType().getTypePtr() != TL.getTypePtr()) + TRY_TO(TraverseTypeLoc(TL.getBaseLoc())); + }) + +DEF_TRAVERSE_TYPELOC(ObjCObjectPointerType, { + TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); + }) + +#undef DEF_TRAVERSE_TYPELOC + +// ----------------- Decl traversal ----------------- +// +// For a Decl, we automate (in the DEF_TRAVERSE_DECL macro) traversing +// the children that come from the DeclContext associated with it. +// Therefore each Traverse* only needs to worry about children other +// than those. + template -bool RecursiveASTVisitorImpl::VisitFunctionProtoType( - FunctionProtoType *T) { - for (FunctionProtoType::arg_type_iterator A = T->arg_type_begin(), - AEnd = T->arg_type_end(); - A != AEnd; ++A) { - if (Visit(*A)) - return true; - } +bool RecursiveASTVisitor::TraverseDeclContextHelper(DeclContext *DC) { + if (!DC) + return true; - for (FunctionProtoType::exception_iterator E = T->exception_begin(), - EEnd = T->exception_end(); - E != EEnd; ++E) { - if (Visit(*E)) - return true; + for (DeclContext::decl_iterator Child = DC->decls_begin(), + ChildEnd = DC->decls_end(); + Child != ChildEnd; ++Child) { + TRY_TO(TraverseDecl(*Child)); } - return getDerived().VisitFunctionType(T); + return true; } -template -bool RecursiveASTVisitorImpl::VisitUnresolvedUsingType( - UnresolvedUsingType *T) { - return getDerived().VisitType(T); +// This macro makes available a variable D, the passed-in decl. +#define DEF_TRAVERSE_DECL(DECL, CODE) \ +template \ +bool RecursiveASTVisitor::Traverse##DECL (DECL *D) { \ + TRY_TO(WalkUpFrom##DECL (D)); \ + { CODE; } \ + TRY_TO(TraverseDeclContextHelper(dyn_cast(D))); \ + return true; \ } -template -bool RecursiveASTVisitorImpl::VisitTypedefType(TypedefType *T) { - return getDerived().VisitType(T); -} +DEF_TRAVERSE_DECL(AccessSpecDecl, { }) -template -bool RecursiveASTVisitorImpl::VisitTypeOfExprType(TypeOfExprType *T) { - if (Visit(T->getUnderlyingExpr())) - return true; +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(TraverseStmt(D->getBody())); + }) - return getDerived().VisitType(T); -} +DEF_TRAVERSE_DECL(FileScopeAsmDecl, { + TRY_TO(TraverseStmt(D->getAsmString())); + }) -template -bool RecursiveASTVisitorImpl::VisitTypeOfType(TypeOfType *T) { - if (Visit(T->getUnderlyingType())) - return true; +DEF_TRAVERSE_DECL(FriendDecl, { + TRY_TO(TraverseDecl(D->getFriendDecl())); + }) - return getDerived().VisitType(T); -} +DEF_TRAVERSE_DECL(FriendTemplateDecl, { + TRY_TO(TraverseDecl(D->getFriendDecl())); + for (unsigned I = 0, E = D->getNumTemplateParameters(); I < E; ++I) { + TemplateParameterList *TPL = D->getTemplateParameterList(I); + for (TemplateParameterList::iterator ITPL = TPL->begin(), + ETPL = TPL->end(); + ITPL != ETPL; ++ITPL) { + TRY_TO(TraverseDecl(*ITPL)); + } + } + }) -template -bool RecursiveASTVisitorImpl::VisitDecltypeType(DecltypeType *T) { - if (Visit(T->getUnderlyingExpr())) +DEF_TRAVERSE_DECL(LinkageSpecDecl, { }) + +DEF_TRAVERSE_DECL(ObjCClassDecl, { + // FIXME: implement this + }) + +DEF_TRAVERSE_DECL(ObjCForwardProtocolDecl, { + // FIXME: implement this + }) + +DEF_TRAVERSE_DECL(ObjCPropertyImplDecl, { + // FIXME: implement this + }) + +DEF_TRAVERSE_DECL(StaticAssertDecl, { + TRY_TO(TraverseStmt(D->getAssertExpr())); + TRY_TO(TraverseStmt(D->getMessage())); + }) + +DEF_TRAVERSE_DECL(TranslationUnitDecl, { + // Code in an unnamed namespace shows up automatically in + // decls_begin()/decls_end(). Thus we don't need to recurse on + // D->getAnonymousNamespace(). + }) + +DEF_TRAVERSE_DECL(NamespaceAliasDecl, { + // We shouldn't traverse an aliased namespace, since it will be + // defined (and, therefore, traversed) somewhere else. + // + // 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; + }) - return getDerived().VisitType(T); -} +DEF_TRAVERSE_DECL(NamespaceDecl, { + // Code in an unnamed namespace shows up automatically in + // decls_begin()/decls_end(). Thus we don't need to recurse on + // D->getAnonymousNamespace(). + }) -template -bool RecursiveASTVisitorImpl::VisitTagType(TagType *T) { - return getDerived().VisitType(T); -} +DEF_TRAVERSE_DECL(ObjCCompatibleAliasDecl, { + // FIXME: implement + }) -template -bool RecursiveASTVisitorImpl::VisitRecordType(RecordType *T) { - return getDerived().VisitTagType(T); -} +DEF_TRAVERSE_DECL(ObjCCategoryDecl, { + // FIXME: implement + }) + +DEF_TRAVERSE_DECL(ObjCCategoryImplDecl, { + // FIXME: implement + }) + +DEF_TRAVERSE_DECL(ObjCImplementationDecl, { + // FIXME: implement + }) + +DEF_TRAVERSE_DECL(ObjCInterfaceDecl, { + // FIXME: implement + }) + +DEF_TRAVERSE_DECL(ObjCProtocolDecl, { + // FIXME: implement + }) + +DEF_TRAVERSE_DECL(ObjCMethodDecl, { + // FIXME: implement + }) + +DEF_TRAVERSE_DECL(ObjCPropertyDecl, { + // FIXME: implement + }) +DEF_TRAVERSE_DECL(UsingDecl, { + TRY_TO(TraverseNestedNameSpecifier(D->getTargetNestedNameDecl())); + }) + +DEF_TRAVERSE_DECL(UsingDirectiveDecl, { + TRY_TO(TraverseNestedNameSpecifier(D->getQualifier())); + }) + +DEF_TRAVERSE_DECL(UsingShadowDecl, { }) + +// A helper method for TemplateDecl's children. template -bool RecursiveASTVisitorImpl::VisitEnumType(EnumType *T) { - return getDerived().VisitType(T); +bool RecursiveASTVisitor::TraverseTemplateParameterListHelper( + TemplateParameterList *TPL) { + if (TPL) { + for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end(); + I != E; ++I) { + TRY_TO(TraverseDecl(*I)); + } + } + return true; } +DEF_TRAVERSE_DECL(ClassTemplateDecl, { + TRY_TO(TraverseDecl(D->getTemplatedDecl())); + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); + // We should not traverse the specializations/partial + // specializations. Those will show up in other contexts. + // getInstantiatedFromMemberTemplate() is just a link from a + // template instantiation back to the template from which it was + // instantiated, and thus should not be traversed either. + }) + +DEF_TRAVERSE_DECL(FunctionTemplateDecl, { + TRY_TO(TraverseDecl(D->getTemplatedDecl())); + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); + }) + +DEF_TRAVERSE_DECL(TemplateTemplateParmDecl, { + // D is the "T" in something like + // template